2010-07-21 14:17:33 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
#ifndef mozilla_layers_ShadowLayers_h
|
|
|
|
#define mozilla_layers_ShadowLayers_h 1
|
|
|
|
|
|
|
|
#include "gfxASurface.h"
|
2012-07-23 16:58:37 -07:00
|
|
|
#include "GLDefs.h"
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
#include "ImageLayers.h"
|
2012-07-18 09:31:40 -07:00
|
|
|
#include "LayersBackend.h"
|
2012-07-13 12:38:09 -07:00
|
|
|
#include "mozilla/ipc/SharedMemory.h"
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
class gfxSharedImageSurface;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2012-07-23 16:58:37 -07:00
|
|
|
|
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
class TextureImage;
|
|
|
|
}
|
|
|
|
using namespace gl;
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
namespace layers {
|
|
|
|
|
2011-01-20 19:49:09 -08:00
|
|
|
class Edit;
|
|
|
|
class EditReply;
|
2010-11-05 00:17:07 -07:00
|
|
|
class OptionalThebesBuffer;
|
2010-07-21 14:17:33 -07:00
|
|
|
class PLayerChild;
|
|
|
|
class PLayersChild;
|
|
|
|
class PLayersParent;
|
|
|
|
class ShadowableLayer;
|
|
|
|
class ShadowThebesLayer;
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowContainerLayer;
|
2010-07-21 14:17:33 -07:00
|
|
|
class ShadowImageLayer;
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowColorLayer;
|
2010-07-21 14:17:33 -07:00
|
|
|
class ShadowCanvasLayer;
|
2012-07-17 16:59:45 -07:00
|
|
|
class ShadowRefLayer;
|
2010-09-13 22:23:08 -07:00
|
|
|
class SurfaceDescriptor;
|
2010-09-13 22:23:08 -07:00
|
|
|
class ThebesBuffer;
|
2012-04-13 08:17:39 -07:00
|
|
|
class TiledLayerComposer;
|
2010-07-21 14:17:33 -07:00
|
|
|
class Transaction;
|
2011-04-20 16:21:56 -07:00
|
|
|
class SharedImage;
|
2011-09-27 15:19:28 -07:00
|
|
|
class CanvasSurface;
|
2012-04-13 08:17:39 -07:00
|
|
|
class BasicTiledLayerBuffer;
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2012-07-12 05:51:57 -07:00
|
|
|
enum BufferCapabilities {
|
|
|
|
DEFAULT_BUFFER_CAPS = 0,
|
|
|
|
/**
|
|
|
|
* The allocated buffer must be efficiently mappable as a
|
|
|
|
* gfxImageSurface.
|
|
|
|
*/
|
|
|
|
MAP_AS_IMAGE_SURFACE = 1 << 0
|
|
|
|
};
|
|
|
|
|
2012-07-12 05:51:58 -07:00
|
|
|
enum OpenMode {
|
|
|
|
OPEN_READ_ONLY,
|
|
|
|
OPEN_READ_WRITE
|
|
|
|
};
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
/**
|
|
|
|
* We want to share layer trees across thread contexts and address
|
|
|
|
* spaces for several reasons; chief among them
|
|
|
|
*
|
|
|
|
* - a parent process can paint a child process's layer tree while
|
|
|
|
* the child process is blocked, say on content script. This is
|
|
|
|
* important on mobile devices where UI responsiveness is key.
|
|
|
|
*
|
|
|
|
* - a dedicated "compositor" process can asynchronously (wrt the
|
|
|
|
* browser process) composite and animate layer trees, allowing a
|
|
|
|
* form of pipeline parallelism between compositor/browser/content
|
|
|
|
*
|
|
|
|
* - a dedicated "compositor" process can take all responsibility for
|
|
|
|
* accessing the GPU, which is desirable on systems with
|
|
|
|
* buggy/leaky drivers because the compositor process can die while
|
|
|
|
* browser and content live on (and failover mechanisms can be
|
|
|
|
* installed to quickly bring up a replacement compositor)
|
|
|
|
*
|
|
|
|
* The Layers model has a crisply defined API, which makes it easy to
|
|
|
|
* safely "share" layer trees. The ShadowLayers API extends Layers to
|
|
|
|
* allow a remote, parent process to access a child process's layer
|
|
|
|
* tree.
|
|
|
|
*
|
|
|
|
* ShadowLayerForwarder publishes a child context's layer tree to a
|
|
|
|
* parent context. This comprises recording layer-tree modifications
|
|
|
|
* into atomic transactions and pushing them over IPC.
|
|
|
|
*
|
|
|
|
* ShadowLayerManager grafts layer subtrees published by child-context
|
|
|
|
* ShadowLayerForwarder(s) into a parent-context layer tree.
|
|
|
|
*
|
|
|
|
* (Advanced note: because our process tree may have a height >2, a
|
|
|
|
* non-leaf subprocess may both receive updates from child processes
|
|
|
|
* and publish them to parent processes. Put another way,
|
|
|
|
* LayerManagers may be both ShadowLayerManagers and
|
|
|
|
* ShadowLayerForwarders.)
|
|
|
|
*
|
|
|
|
* There are only shadow types for layers that have different shadow
|
|
|
|
* vs. not-shadow behavior. ColorLayers and ContainerLayers behave
|
|
|
|
* the same way in both regimes (so far).
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ShadowLayerForwarder
|
|
|
|
{
|
2012-07-12 05:51:58 -07:00
|
|
|
friend class AutoOpenSurface;
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
public:
|
2012-07-12 05:51:58 -07:00
|
|
|
typedef gfxASurface::gfxContentType gfxContentType;
|
2010-12-30 23:40:19 -08:00
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
virtual ~ShadowLayerForwarder();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Begin recording a transaction to be forwarded atomically to a
|
|
|
|
* ShadowLayerManager.
|
|
|
|
*/
|
|
|
|
void BeginTransaction();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The following methods may only be called after BeginTransaction()
|
|
|
|
* but before EndTransaction(). They mirror the LayerManager
|
|
|
|
* interface in Layers.h.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify the shadow manager that a new, "real" layer has been
|
|
|
|
* created, and a corresponding shadow layer should be created in
|
|
|
|
* the compositing process.
|
|
|
|
*/
|
|
|
|
void CreatedThebesLayer(ShadowableLayer* aThebes);
|
|
|
|
void CreatedContainerLayer(ShadowableLayer* aContainer);
|
|
|
|
void CreatedImageLayer(ShadowableLayer* aImage);
|
|
|
|
void CreatedColorLayer(ShadowableLayer* aColor);
|
|
|
|
void CreatedCanvasLayer(ShadowableLayer* aCanvas);
|
2012-07-17 16:59:45 -07:00
|
|
|
void CreatedRefLayer(ShadowableLayer* aRef);
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2011-10-10 16:43:56 -07:00
|
|
|
/**
|
|
|
|
* The specified layer is destroying its buffers.
|
|
|
|
* |aBackBufferToDestroy| is deallocated when this transaction is
|
|
|
|
* posted to the parent. During the parent-side transaction, the
|
|
|
|
* shadow is told to destroy its front buffer. This can happen when
|
|
|
|
* a new front/back buffer pair have been created because of a layer
|
|
|
|
* resize, e.g.
|
|
|
|
*/
|
|
|
|
void DestroyedThebesBuffer(ShadowableLayer* aThebes,
|
|
|
|
const SurfaceDescriptor& aBackBufferToDestroy);
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
/**
|
|
|
|
* At least one attribute of |aMutant| has changed, and |aMutant|
|
|
|
|
* needs to sync to its shadow layer. This initial implementation
|
|
|
|
* forwards all attributes when any is mutated.
|
|
|
|
*/
|
|
|
|
void Mutated(ShadowableLayer* aMutant);
|
|
|
|
|
|
|
|
void SetRoot(ShadowableLayer* aRoot);
|
|
|
|
/**
|
|
|
|
* Insert |aChild| after |aAfter| in |aContainer|. |aAfter| can be
|
|
|
|
* NULL to indicated that |aChild| should be appended to the end of
|
|
|
|
* |aContainer|'s child list.
|
|
|
|
*/
|
|
|
|
void InsertAfter(ShadowableLayer* aContainer,
|
|
|
|
ShadowableLayer* aChild,
|
|
|
|
ShadowableLayer* aAfter=NULL);
|
|
|
|
void RemoveChild(ShadowableLayer* aContainer,
|
|
|
|
ShadowableLayer* aChild);
|
|
|
|
|
2012-03-18 16:02:38 -07:00
|
|
|
/**
|
|
|
|
* Set aMaskLayer as the mask on aLayer.
|
|
|
|
* Note that only image layers are properly supported
|
|
|
|
* ShadowLayersParent::UpdateMask and accompanying ipdl
|
|
|
|
* will need changing to update properties for other kinds
|
|
|
|
* of mask layer.
|
|
|
|
*/
|
|
|
|
void SetMask(ShadowableLayer* aLayer,
|
|
|
|
ShadowableLayer* aMaskLayer);
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
/**
|
|
|
|
* Notify the shadow manager that the specified layer's back buffer
|
|
|
|
* has new pixels and should become the new front buffer, and be
|
|
|
|
* re-rendered, in the compositing process. The former front buffer
|
|
|
|
* is swapped for |aNewFrontBuffer| and becomes the new back buffer
|
|
|
|
* for the "real" layer.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* |aBufferRect| is the screen rect covered as a whole by the
|
|
|
|
* possibly-toroidally-rotated |aNewFrontBuffer|. |aBufferRotation|
|
|
|
|
* is buffer's rotation, if any.
|
|
|
|
*/
|
|
|
|
void PaintedThebesBuffer(ShadowableLayer* aThebes,
|
2010-09-13 22:23:08 -07:00
|
|
|
const nsIntRegion& aUpdatedRegion,
|
|
|
|
const nsIntRect& aBufferRect,
|
|
|
|
const nsIntPoint& aBufferRotation,
|
2010-09-13 22:23:08 -07:00
|
|
|
const SurfaceDescriptor& aNewFrontBuffer);
|
2012-04-13 08:17:39 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify the compositor that a tiled layer buffer has changed
|
|
|
|
* that needs to be synced to the shadow retained copy. The tiled
|
|
|
|
* layer buffer will operate directly on the shadow retained buffer
|
|
|
|
* and is free to choose it's own internal representation (double buffering,
|
|
|
|
* copy on write, tiling).
|
|
|
|
*/
|
|
|
|
void PaintedTiledLayerBuffer(ShadowableLayer* aThebes,
|
|
|
|
BasicTiledLayerBuffer* aTiledLayerBuffer);
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
/**
|
|
|
|
* NB: this initial implementation only forwards RGBA data for
|
|
|
|
* ImageLayers. This is slow, and will be optimized.
|
|
|
|
*/
|
|
|
|
void PaintedImage(ShadowableLayer* aImage,
|
2011-04-20 21:38:39 -07:00
|
|
|
const SharedImage& aNewFrontImage);
|
2010-07-21 14:17:33 -07:00
|
|
|
void PaintedCanvas(ShadowableLayer* aCanvas,
|
2011-09-27 15:19:28 -07:00
|
|
|
bool aNeedYFlip,
|
2011-04-20 14:45:57 -07:00
|
|
|
const SurfaceDescriptor& aNewFrontSurface);
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* End the current transaction and forward it to ShadowLayerManager.
|
|
|
|
* |aReplies| are directions from the ShadowLayerManager to the
|
|
|
|
* caller of EndTransaction().
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool EndTransaction(InfallibleTArray<EditReply>* aReplies);
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2012-06-01 05:42:36 -07:00
|
|
|
/**
|
|
|
|
* Composite ShadowLayerManager's layer tree into aTarget.
|
|
|
|
*/
|
|
|
|
bool ShadowDrawToTarget(gfxContext* aTarget);
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
/**
|
|
|
|
* Set an actor through which layer updates will be pushed.
|
|
|
|
*/
|
|
|
|
void SetShadowManager(PLayersChild* aShadowManager)
|
|
|
|
{
|
|
|
|
mShadowManager = aShadowManager;
|
|
|
|
}
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
void SetParentBackendType(LayersBackend aBackendType)
|
|
|
|
{
|
|
|
|
mParentBackend = aBackendType;
|
|
|
|
}
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
/**
|
|
|
|
* True if this is forwarding to a ShadowLayerManager.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasShadowManager() const { return !!mShadowManager; }
|
2011-08-09 12:38:26 -07:00
|
|
|
PLayersChild* GetShadowManager() const { return mShadowManager; }
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2010-09-13 22:23:08 -07:00
|
|
|
/**
|
|
|
|
* The following Alloc/Open/Destroy interfaces abstract over the
|
|
|
|
* details of working with surfaces that are shared across
|
|
|
|
* processes. They provide the glue between C++ Layers and the
|
|
|
|
* ShadowLayer IPC system.
|
|
|
|
*
|
|
|
|
* The basic lifecycle is
|
|
|
|
*
|
|
|
|
* - a Layer needs a buffer. Its ShadowableLayer subclass calls
|
2012-07-12 05:51:57 -07:00
|
|
|
* AllocBuffer(), then calls one of the Created*Buffer() methods
|
|
|
|
* above to transfer the (temporary) front buffer to its
|
2010-09-13 22:23:08 -07:00
|
|
|
* ShadowLayer in the other process. The Layer needs a
|
|
|
|
* gfxASurface to paint, so the ShadowableLayer uses
|
|
|
|
* OpenDescriptor(backBuffer) to get that surface, and hands it
|
|
|
|
* out to the Layer.
|
|
|
|
*
|
|
|
|
* - a Layer has painted new pixels. Its ShadowableLayer calls one
|
|
|
|
* of the Painted*Buffer() methods above with the back buffer
|
|
|
|
* descriptor. This notification is forwarded to the ShadowLayer,
|
|
|
|
* which uses OpenDescriptor() to access the newly-painted pixels.
|
|
|
|
* The ShadowLayer then updates its front buffer in a Layer- and
|
|
|
|
* platform-dependent way, and sends a surface descriptor back to
|
|
|
|
* the ShadowableLayer that becomes its new back back buffer.
|
|
|
|
*
|
|
|
|
* - a Layer wants to destroy its buffers. Its ShadowableLayer
|
|
|
|
* calls Destroyed*Buffer(), which gives up control of the back
|
|
|
|
* buffer descriptor. The actual back buffer surface is then
|
|
|
|
* destroyed using DestroySharedSurface() just before notifying
|
|
|
|
* the parent process. When the parent process is notified, the
|
|
|
|
* ShadowLayer also calls DestroySharedSurface() on its front
|
|
|
|
* buffer, and the double-buffer pair is gone.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shmem (gfxSharedImageSurface) buffers are available on all
|
|
|
|
* platforms, but they may not be optimal.
|
|
|
|
*
|
|
|
|
* In the absence of platform-specific buffers these fall back to
|
|
|
|
* Shmem/gfxSharedImageSurface.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AllocBuffer(const gfxIntSize& aSize,
|
2012-07-12 05:51:57 -07:00
|
|
|
gfxASurface::gfxContentType aContent,
|
|
|
|
SurfaceDescriptor* aBuffer);
|
2010-12-30 23:40:31 -08:00
|
|
|
|
2012-07-12 05:51:57 -07:00
|
|
|
bool AllocBufferWithCaps(const gfxIntSize& aSize,
|
|
|
|
gfxASurface::gfxContentType aContent,
|
|
|
|
uint32_t aCaps,
|
|
|
|
SurfaceDescriptor* aBuffer);
|
|
|
|
|
2010-09-13 22:23:08 -07:00
|
|
|
void DestroySharedSurface(SurfaceDescriptor* aSurface);
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
/**
|
|
|
|
* Construct a shadow of |aLayer| on the "other side", at the
|
|
|
|
* ShadowLayerManager.
|
|
|
|
*/
|
|
|
|
PLayerChild* ConstructShadowFor(ShadowableLayer* aLayer);
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
LayersBackend GetParentBackendType()
|
|
|
|
{
|
|
|
|
return mParentBackend;
|
|
|
|
}
|
2010-12-30 23:40:19 -08:00
|
|
|
|
2012-03-12 08:50:15 -07:00
|
|
|
/**
|
|
|
|
* Flag the next paint as the first for a document.
|
|
|
|
*/
|
|
|
|
void SetIsFirstPaint() { mIsFirstPaint = true; }
|
|
|
|
|
2012-05-22 16:15:16 -07:00
|
|
|
virtual PRInt32 GetMaxTextureSize() const { return mMaxTextureSize; }
|
|
|
|
void SetMaxTextureSize(PRInt32 aMaxTextureSize) { mMaxTextureSize = aMaxTextureSize; }
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
protected:
|
|
|
|
ShadowLayerForwarder();
|
|
|
|
|
|
|
|
PLayersChild* mShadowManager;
|
|
|
|
|
|
|
|
private:
|
2012-07-12 05:51:57 -07:00
|
|
|
bool AllocBuffer(const gfxIntSize& aSize,
|
|
|
|
gfxASurface::gfxContentType aContent,
|
|
|
|
gfxSharedImageSurface** aBuffer);
|
2010-09-13 22:23:08 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool PlatformAllocBuffer(const gfxIntSize& aSize,
|
2012-07-12 05:51:57 -07:00
|
|
|
gfxASurface::gfxContentType aContent,
|
|
|
|
uint32_t aCaps,
|
|
|
|
SurfaceDescriptor* aBuffer);
|
2010-12-30 23:40:31 -08:00
|
|
|
|
2012-07-12 05:51:58 -07:00
|
|
|
/**
|
|
|
|
* Try to query the content type efficiently, but at worst map the
|
|
|
|
* surface and return it in *aSurface.
|
|
|
|
*/
|
|
|
|
static gfxContentType
|
|
|
|
GetDescriptorSurfaceContentType(const SurfaceDescriptor& aDescriptor,
|
|
|
|
OpenMode aMode,
|
|
|
|
gfxASurface** aSurface);
|
|
|
|
/**
|
|
|
|
* It can be expensive to open a descriptor just to query its
|
|
|
|
* content type. If the platform impl can do this cheaply, it will
|
|
|
|
* set *aContent and return true.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
PlatformGetDescriptorSurfaceContentType(const SurfaceDescriptor& aDescriptor,
|
|
|
|
OpenMode aMode,
|
|
|
|
gfxContentType* aContent,
|
|
|
|
gfxASurface** aSurface);
|
|
|
|
// (Same as above, but for surface size.)
|
|
|
|
static gfxIntSize
|
|
|
|
GetDescriptorSurfaceSize(const SurfaceDescriptor& aDescriptor,
|
|
|
|
OpenMode aMode,
|
|
|
|
gfxASurface** aSurface);
|
|
|
|
static bool
|
|
|
|
PlatformGetDescriptorSurfaceSize(const SurfaceDescriptor& aDescriptor,
|
|
|
|
OpenMode aMode,
|
|
|
|
gfxIntSize* aSize,
|
|
|
|
gfxASurface** aSurface);
|
|
|
|
|
|
|
|
static already_AddRefed<gfxASurface>
|
|
|
|
OpenDescriptor(OpenMode aMode, const SurfaceDescriptor& aSurface);
|
|
|
|
|
2010-09-13 22:23:08 -07:00
|
|
|
static already_AddRefed<gfxASurface>
|
2012-07-12 05:51:58 -07:00
|
|
|
PlatformOpenDescriptor(OpenMode aMode, const SurfaceDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
/** Make this descriptor unusable for gfxASurface clients. A
|
|
|
|
* private interface with AutoOpenSurface. */
|
|
|
|
static void
|
|
|
|
CloseDescriptor(const SurfaceDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
static bool
|
|
|
|
PlatformCloseDescriptor(const SurfaceDescriptor& aDescriptor);
|
2010-09-13 22:23:08 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
|
2010-09-13 22:23:08 -07:00
|
|
|
|
|
|
|
static void PlatformSyncBeforeUpdate();
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
Transaction* mTxn;
|
2012-05-22 16:15:16 -07:00
|
|
|
PRInt32 mMaxTextureSize;
|
2010-12-30 23:40:19 -08:00
|
|
|
LayersBackend mParentBackend;
|
2012-03-12 08:50:15 -07:00
|
|
|
|
|
|
|
bool mIsFirstPaint;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShadowLayerManager : public LayerManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~ShadowLayerManager() {}
|
|
|
|
|
2010-09-03 11:01:05 -07:00
|
|
|
virtual void GetBackendName(nsAString& name) { name.AssignLiteral("Shadow"); }
|
|
|
|
|
2010-09-24 15:41:31 -07:00
|
|
|
void DestroySharedSurface(gfxSharedImageSurface* aSurface,
|
|
|
|
PLayersParent* aDeallocator);
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2010-09-24 15:41:31 -07:00
|
|
|
void DestroySharedSurface(SurfaceDescriptor* aSurface,
|
|
|
|
PLayersParent* aDeallocator);
|
2010-09-13 22:23:08 -07:00
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
/** CONSTRUCTION PHASE ONLY */
|
|
|
|
virtual already_AddRefed<ShadowThebesLayer> CreateShadowThebesLayer() = 0;
|
|
|
|
/** CONSTRUCTION PHASE ONLY */
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual already_AddRefed<ShadowContainerLayer> CreateShadowContainerLayer() = 0;
|
|
|
|
/** CONSTRUCTION PHASE ONLY */
|
2010-07-21 14:17:33 -07:00
|
|
|
virtual already_AddRefed<ShadowImageLayer> CreateShadowImageLayer() = 0;
|
|
|
|
/** CONSTRUCTION PHASE ONLY */
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual already_AddRefed<ShadowColorLayer> CreateShadowColorLayer() = 0;
|
|
|
|
/** CONSTRUCTION PHASE ONLY */
|
2010-07-21 14:17:33 -07:00
|
|
|
virtual already_AddRefed<ShadowCanvasLayer> CreateShadowCanvasLayer() = 0;
|
2012-07-17 16:59:45 -07:00
|
|
|
/** CONSTRUCTION PHASE ONLY */
|
|
|
|
virtual already_AddRefed<ShadowRefLayer> CreateShadowRefLayer() { return nsnull; }
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2012-07-23 16:58:37 -07:00
|
|
|
/**
|
|
|
|
* Try to open |aDescriptor| for direct texturing. If the
|
|
|
|
* underlying surface supports direct texturing, a non-null
|
|
|
|
* TextureImage is returned. Otherwise null is returned.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<TextureImage>
|
|
|
|
OpenDescriptorForDirectTexturing(GLContext* aContext,
|
|
|
|
const SurfaceDescriptor& aDescriptor,
|
|
|
|
GLenum aWrapMode);
|
|
|
|
|
2010-09-13 22:23:08 -07:00
|
|
|
static void PlatformSyncBeforeReplyUpdate();
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
void SetCompositorID(PRUint32 aID)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mCompositorID==0, "The compositor ID must be set only once.");
|
|
|
|
mCompositorID = aID;
|
|
|
|
}
|
|
|
|
PRUint32 GetCompositorID() const
|
|
|
|
{
|
|
|
|
return mCompositorID;
|
|
|
|
}
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
protected:
|
2012-07-13 12:38:09 -07:00
|
|
|
ShadowLayerManager()
|
|
|
|
: mCompositorID(0) {}
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
|
2012-07-13 12:38:09 -07:00
|
|
|
PRUint32 mCompositorID;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A ShadowableLayer is a Layer can be shared with a parent context
|
|
|
|
* through a ShadowLayerForwarder. A ShadowableLayer maps to a
|
|
|
|
* Shadow*Layer in a parent context.
|
|
|
|
*
|
|
|
|
* Note that ShadowLayers can themselves be ShadowableLayers.
|
|
|
|
*/
|
|
|
|
class ShadowableLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~ShadowableLayer() {}
|
|
|
|
|
|
|
|
virtual Layer* AsLayer() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if this layer has a shadow in a parent process.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasShadow() { return !!mShadow; }
|
2010-07-21 14:17:33 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the IPC handle to a Shadow*Layer referring to this if one
|
|
|
|
* exists, NULL if not.
|
|
|
|
*/
|
|
|
|
PLayerChild* GetShadow() { return mShadow; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ShadowableLayer() : mShadow(NULL) {}
|
|
|
|
|
|
|
|
PLayerChild* mShadow;
|
|
|
|
};
|
|
|
|
|
2011-09-27 15:19:26 -07:00
|
|
|
/**
|
|
|
|
* SurfaceDeallocator interface
|
|
|
|
*/
|
|
|
|
class ISurfaceDeAllocator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void DestroySharedSurface(gfxSharedImageSurface* aSurface) = 0;
|
|
|
|
virtual void DestroySharedSurface(SurfaceDescriptor* aSurface) = 0;
|
|
|
|
protected:
|
2012-07-18 09:15:47 -07:00
|
|
|
~ISurfaceDeAllocator() {}
|
2011-09-27 15:19:26 -07:00
|
|
|
};
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
/**
|
|
|
|
* A ShadowLayer is the representation of a child-context's Layer in a
|
|
|
|
* parent context. They can be transformed, clipped,
|
|
|
|
* etc. independently of their origin Layers.
|
|
|
|
*
|
|
|
|
* Note that ShadowLayers can themselves have a shadow in a parent
|
|
|
|
* context.
|
|
|
|
*/
|
|
|
|
class ShadowLayer
|
2010-07-21 14:17:33 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual ~ShadowLayer() {}
|
|
|
|
|
2010-09-24 15:41:31 -07:00
|
|
|
/**
|
2011-09-27 15:19:26 -07:00
|
|
|
* Set deallocator for data recieved from IPC protocol
|
|
|
|
* We should be able to set allocator right before swap call
|
|
|
|
* that is why allowed multiple call with the same Allocator
|
2010-09-24 15:41:31 -07:00
|
|
|
*/
|
2011-09-27 15:19:26 -07:00
|
|
|
virtual void SetAllocator(ISurfaceDeAllocator* aAllocator)
|
2010-09-24 15:41:31 -07:00
|
|
|
{
|
2011-09-27 15:19:26 -07:00
|
|
|
NS_ASSERTION(!mAllocator || mAllocator == aAllocator, "Stomping allocator?");
|
2010-10-13 15:55:45 -07:00
|
|
|
mAllocator = aAllocator;
|
2010-09-24 15:41:31 -07:00
|
|
|
}
|
|
|
|
|
2012-07-18 09:15:47 -07:00
|
|
|
virtual void DestroyFrontBuffer() { }
|
2011-09-27 15:19:26 -07:00
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
/**
|
|
|
|
* The following methods are
|
|
|
|
*
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
*
|
|
|
|
* They are analogous to the Layer interface.
|
|
|
|
*/
|
|
|
|
void SetShadowVisibleRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
mShadowVisibleRegion = aRegion;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetShadowClipRect(const nsIntRect* aRect)
|
|
|
|
{
|
|
|
|
mUseShadowClipRect = aRect != nsnull;
|
|
|
|
if (aRect) {
|
|
|
|
mShadowClipRect = *aRect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetShadowTransform(const gfx3DMatrix& aMatrix)
|
|
|
|
{
|
|
|
|
mShadowTransform = aMatrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
// These getters can be used anytime.
|
|
|
|
const nsIntRect* GetShadowClipRect() { return mUseShadowClipRect ? &mShadowClipRect : nsnull; }
|
|
|
|
const nsIntRegion& GetShadowVisibleRegion() { return mShadowVisibleRegion; }
|
|
|
|
const gfx3DMatrix& GetShadowTransform() { return mShadowTransform; }
|
|
|
|
|
2012-04-13 08:17:39 -07:00
|
|
|
virtual TiledLayerComposer* AsTiledLayerComposer() { return NULL; }
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
protected:
|
|
|
|
ShadowLayer()
|
|
|
|
: mAllocator(nsnull)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mUseShadowClipRect(false)
|
2010-10-13 15:55:45 -07:00
|
|
|
{}
|
|
|
|
|
2011-09-27 15:19:26 -07:00
|
|
|
ISurfaceDeAllocator* mAllocator;
|
2010-10-13 15:55:45 -07:00
|
|
|
nsIntRegion mShadowVisibleRegion;
|
|
|
|
gfx3DMatrix mShadowTransform;
|
|
|
|
nsIntRect mShadowClipRect;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mUseShadowClipRect;
|
2010-10-13 15:55:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ShadowThebesLayer : public ShadowLayer,
|
|
|
|
public ThebesLayer
|
|
|
|
{
|
|
|
|
public:
|
2010-07-21 14:17:33 -07:00
|
|
|
virtual void InvalidateRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("ShadowThebesLayers can't fill invalidated regions");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
*/
|
2010-09-13 22:23:08 -07:00
|
|
|
virtual void SetValidRegion(const nsIntRegion& aRegion)
|
2010-07-21 14:17:33 -07:00
|
|
|
{
|
|
|
|
mValidRegion = aRegion;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2010-09-03 13:10:46 -07:00
|
|
|
/**
|
2010-07-21 14:17:33 -07:00
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
*
|
|
|
|
* Publish the remote layer's back ThebesLayerBuffer to this shadow,
|
|
|
|
* swapping out the old front ThebesLayerBuffer (the new back buffer
|
|
|
|
* for the remote layer).
|
|
|
|
*/
|
2010-09-13 22:23:08 -07:00
|
|
|
virtual void
|
|
|
|
Swap(const ThebesBuffer& aNewFront, const nsIntRegion& aUpdatedRegion,
|
2011-10-10 09:47:27 -07:00
|
|
|
OptionalThebesBuffer* aNewBack, nsIntRegion* aNewBackValidRegion,
|
2010-11-05 00:17:07 -07:00
|
|
|
OptionalThebesBuffer* aReadOnlyFront, nsIntRegion* aFrontUpdatedRegion) = 0;
|
2010-07-21 14:17:33 -07:00
|
|
|
|
2010-09-02 20:05:01 -07:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
*
|
|
|
|
* Destroy the current front buffer.
|
|
|
|
*/
|
|
|
|
virtual void DestroyFrontBuffer() = 0;
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual ShadowLayer* AsShadowLayer() { return this; }
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
MOZ_LAYER_DECL_NAME("ShadowThebesLayer", TYPE_SHADOW)
|
|
|
|
|
|
|
|
protected:
|
2010-09-24 15:41:31 -07:00
|
|
|
ShadowThebesLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: ThebesLayer(aManager, aImplData)
|
|
|
|
{}
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowContainerLayer : public ShadowLayer,
|
|
|
|
public ContainerLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ShadowLayer* AsShadowLayer() { return this; }
|
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("ShadowContainerLayer", TYPE_SHADOW)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ShadowContainerLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: ContainerLayer(aManager, aImplData)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowCanvasLayer : public ShadowLayer,
|
|
|
|
public CanvasLayer
|
2010-07-21 14:17:33 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
*
|
|
|
|
* Publish the remote layer's back surface to this shadow, swapping
|
|
|
|
* out the old front surface (the new back surface for the remote
|
|
|
|
* layer).
|
|
|
|
*/
|
2011-09-27 15:19:28 -07:00
|
|
|
virtual void Swap(const CanvasSurface& aNewFront, bool needYFlip,
|
|
|
|
CanvasSurface* aNewBack) = 0;
|
2010-09-02 20:05:01 -07:00
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual ShadowLayer* AsShadowLayer() { return this; }
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
MOZ_LAYER_DECL_NAME("ShadowCanvasLayer", TYPE_SHADOW)
|
|
|
|
|
|
|
|
protected:
|
2010-09-24 15:41:31 -07:00
|
|
|
ShadowCanvasLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: CanvasLayer(aManager, aImplData)
|
|
|
|
{}
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowImageLayer : public ShadowLayer,
|
|
|
|
public ImageLayer
|
2010-07-21 14:17:33 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* @see ShadowCanvasLayer::Swap
|
|
|
|
*/
|
2011-09-27 15:19:26 -07:00
|
|
|
virtual void Swap(const SharedImage& aFront,
|
|
|
|
SharedImage* aNewBack) = 0;
|
2010-09-02 20:05:01 -07:00
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual ShadowLayer* AsShadowLayer() { return this; }
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
MOZ_LAYER_DECL_NAME("ShadowImageLayer", TYPE_SHADOW)
|
|
|
|
|
|
|
|
protected:
|
2010-09-24 15:41:31 -07:00
|
|
|
ShadowImageLayer(LayerManager* aManager, void* aImplData)
|
2012-07-13 12:38:09 -07:00
|
|
|
: ImageLayer(aManager, aImplData),
|
|
|
|
mImageContainerID(0),
|
|
|
|
mImageVersion(0)
|
2010-09-24 15:41:31 -07:00
|
|
|
{}
|
2012-07-13 12:38:09 -07:00
|
|
|
|
|
|
|
// ImageBridge protocol:
|
|
|
|
PRUint32 mImageContainerID;
|
|
|
|
PRUint32 mImageVersion;
|
2010-07-21 14:17:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowColorLayer : public ShadowLayer,
|
|
|
|
public ColorLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ShadowLayer* AsShadowLayer() { return this; }
|
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("ShadowColorLayer", TYPE_SHADOW)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ShadowColorLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: ColorLayer(aManager, aImplData)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
class ShadowRefLayer : public ShadowLayer,
|
|
|
|
public RefLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ShadowLayer* AsShadowLayer() { return this; }
|
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("ShadowRefLayer", TYPE_SHADOW)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ShadowRefLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: RefLayer(aManager, aImplData)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface);
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
ipc::SharedMemory::SharedMemoryType OptimalShmemType();
|
|
|
|
|
|
|
|
|
2010-07-21 14:17:33 -07:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // ifndef mozilla_layers_ShadowLayers_h
|