/usr/include/thunderbird/CompositableHost.h is in thunderbird-dev 1:24.4.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_GFX_BUFFERHOST_H
#define MOZILLA_GFX_BUFFERHOST_H
#include "mozilla/layers/Compositor.h"
#include "mozilla/layers/PCompositableParent.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "ThebesLayerBuffer.h"
#include "ClientTiledThebesLayer.h" // for BasicTiledLayerBuffer
#include "mozilla/RefPtr.h"
namespace mozilla {
namespace layers {
// Some properties of a Layer required for tiling
struct TiledLayerProperties
{
nsIntRegion mVisibleRegion;
nsIntRegion mValidRegion;
gfxRect mDisplayPort;
gfxSize mEffectiveResolution;
gfxRect mCompositionBounds;
bool mRetainTiles;
};
class Layer;
class TextureHost;
class SurfaceDescriptor;
/**
* The compositor-side counterpart to CompositableClient. Responsible for
* updating textures and data about textures from IPC and how textures are
* composited (tiling, double buffering, etc.).
*
* Update (for images/canvases) and UpdateThebes (for Thebes) are called during
* the layers transaction to update the Compositbale's textures from the
* content side. The actual update (and any syncronous upload) is done by the
* TextureHost, but it is coordinated by the CompositableHost.
*
* Composite is called by the owning layer when it is composited. CompositableHost
* will use its TextureHost(s) and call Compositor::DrawQuad to do the actual
* rendering.
*/
class CompositableHost : public RefCounted<CompositableHost>
{
public:
CompositableHost(const TextureInfo& aTextureInfo)
: mTextureInfo(aTextureInfo)
, mCompositor(nullptr)
, mLayer(nullptr)
{
MOZ_COUNT_CTOR(CompositableHost);
}
virtual ~CompositableHost()
{
MOZ_COUNT_DTOR(CompositableHost);
}
static TemporaryRef<CompositableHost> Create(const TextureInfo& aTextureInfo);
virtual CompositableType GetType() = 0;
virtual void SetCompositor(Compositor* aCompositor)
{
mCompositor = aCompositor;
}
// composite the contents of this buffer host to the compositor's surface
virtual void Composite(EffectChain& aEffectChain,
float aOpacity,
const gfx::Matrix4x4& aTransform,
const gfx::Point& aOffset,
const gfx::Filter& aFilter,
const gfx::Rect& aClipRect,
const nsIntRegion* aVisibleRegion = nullptr,
TiledLayerProperties* aLayerProperties = nullptr) = 0;
/**
* @return true if we should schedule a composition.
*/
virtual bool Update(const SurfaceDescriptor& aImage,
SurfaceDescriptor* aResult = nullptr);
/**
* Update the content host.
* aUpdated is the region which should be updated
* aUpdatedRegionBack is the region in aNewBackResult which has been updated
*/
virtual void UpdateThebes(const ThebesBufferData& aData,
const nsIntRegion& aUpdated,
const nsIntRegion& aOldValidRegionBack,
nsIntRegion* aUpdatedRegionBack)
{
MOZ_ASSERT(false, "should be implemented or not used");
}
/**
* Update the content host using a surface that only contains the updated
* region.
*
* Takes ownership of aSurface, and is responsible for freeing it.
*
* @param aTextureId Texture to update.
* @param aSurface Surface containing the update area. Its contents are relative
* to aUpdated.TopLeft()
* @param aUpdated Area of the content host to update.
* @param aBufferRect New area covered by the content host.
* @param aBufferRotation New buffer rotation.
*/
virtual void UpdateIncremental(TextureIdentifier aTextureId,
SurfaceDescriptor& aSurface,
const nsIntRegion& aUpdated,
const nsIntRect& aBufferRect,
const nsIntPoint& aBufferRotation)
{
MOZ_ASSERT(false, "should be implemented or not used");
}
/**
* Ensure that a suitable texture host exists in this compositable. The
* compositable host may or may not create a new texture host. If a texture
* host is replaced, then the compositable is responsible for enusring it is
* destroyed correctly (without leaking resources).
* aTextureId - identifies the texture within the compositable, how the
* compositable chooses to use this is between the compositable client and
* host and will vary between types of compositable.
* aSurface - the new or existing texture host should support surface
* descriptors of the same type and, if necessary, this specific surface
* descriptor. Whether it is necessary or not depends on the protocol between
* the compositable client and host.
* aAllocator - the allocator used to allocate and de-allocate resources.
* aTextureInfo - contains flags for the texture.
*/
virtual void EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo) = 0;
/**
* Ensure that a suitable texture host exists in this compsitable.
*
* Only used with ContentHostIncremental.
*
* No SurfaceDescriptor or TextureIdentifier is provider as we
* don't have a single surface for the texture contents, and we
* need to allocate our own one to be updated later.
*/
virtual void EnsureTextureHostIncremental(ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo,
const nsIntRect& aBufferRect)
{
MOZ_ASSERT(false, "should be implemented or not used");
}
virtual TextureHost* GetTextureHost() { return nullptr; }
virtual LayerRenderState GetRenderState() = 0;
virtual void SetPictureRect(const nsIntRect& aPictureRect)
{
MOZ_ASSERT(false, "Should have been overridden");
}
/**
* Adds a mask effect using this texture as the mask, if possible.
* @return true if the effect was added, false otherwise.
*/
bool AddMaskEffect(EffectChain& aEffects,
const gfx::Matrix4x4& aTransform,
bool aIs3D = false);
Compositor* GetCompositor() const
{
return mCompositor;
}
Layer* GetLayer() const { return mLayer; }
void SetLayer(Layer* aLayer) { mLayer = aLayer; }
virtual TiledLayerComposer* AsTiledLayerComposer() { return nullptr; }
virtual void Attach(Layer* aLayer, Compositor* aCompositor)
{
MOZ_ASSERT(aCompositor, "Compositor is required");
SetCompositor(aCompositor);
SetLayer(aLayer);
}
void Detach() {
SetLayer(nullptr);
SetCompositor(nullptr);
}
virtual void Dump(FILE* aFile=NULL,
const char* aPrefix="",
bool aDumpHtml=false) { }
static void DumpTextureHost(FILE* aFile, TextureHost* aTexture);
#ifdef MOZ_DUMP_PAINTING
virtual already_AddRefed<gfxImageSurface> GetAsSurface() { return nullptr; }
#endif
#ifdef MOZ_LAYERS_HAVE_LOG
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) { }
#endif
protected:
TextureInfo mTextureInfo;
Compositor* mCompositor;
Layer* mLayer;
};
class CompositableParentManager;
class CompositableParent : public PCompositableParent
{
public:
CompositableParent(CompositableParentManager* aMgr,
const TextureInfo& aTextureInfo,
uint64_t aID = 0);
~CompositableParent();
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
CompositableHost* GetCompositableHost() const
{
return mHost;
}
void SetCompositableHost(CompositableHost* aHost)
{
mHost = aHost;
}
CompositableType GetType() const
{
return mType;
}
CompositableParentManager* GetCompositableManager() const
{
return mManager;
}
void SetCompositorID(uint64_t aCompositorID)
{
mCompositorID = aCompositorID;
}
uint64_t GetCompositorID() const
{
return mCompositorID;
}
private:
RefPtr<CompositableHost> mHost;
CompositableParentManager* mManager;
CompositableType mType;
uint64_t mID;
uint64_t mCompositorID;
};
/**
* Global CompositableMap, to use in the compositor thread only.
*
* PCompositable and PLayer can, in the case of async textures, be managed by
* different top level protocols. In this case they don't share the same
* communication channel and we can't send an OpAttachCompositable (PCompositable,
* PLayer) message.
*
* In order to attach a layer and the right compositable if the the compositable
* is async, we store references to the async compositables in a CompositableMap
* that is accessed only on the compositor thread. During a layer transaction we
* send the message OpAttachAsyncCompositable(ID, PLayer), and on the compositor
* side we lookup the ID in the map and attach the correspondig compositable to
* the layer.
*
* CompositableMap must be global because the image bridge doesn't have any
* reference to whatever we have created with PLayerTransaction. So, the only way to
* actually connect these two worlds is to have something global that they can
* both query (in the same thread). The map is not allocated the map on the
* stack to avoid the badness of static initialization.
*
* Also, we have a compositor/PLayerTransaction protocol/etc. per layer manager, and the
* ImageBridge is used by all the existing compositors that have a video, so
* there isn't an instance or "something" that lives outside the boudaries of a
* given layer manager on the compositor thread except the image bridge and the
* thread itself.
*/
namespace CompositableMap {
void Create();
void Destroy();
CompositableParent* Get(uint64_t aID);
void Set(uint64_t aID, CompositableParent* aParent);
void Erase(uint64_t aID);
void Clear();
} // CompositableMap
} // namespace
} // namespace
#endif
|