2011-02-04 21:11:24 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04: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-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
#ifndef GFX_LAYERS_H
|
|
|
|
#define GFX_LAYERS_H
|
|
|
|
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2010-03-01 10:56:18 +03:00
|
|
|
#include "gfxTypes.h"
|
2010-05-18 08:04:22 +04:00
|
|
|
#include "gfxASurface.h"
|
2010-03-01 10:56:18 +03:00
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsRect.h"
|
2010-04-01 22:05:40 +04:00
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2010-03-02 02:08:28 +03:00
|
|
|
#include "gfx3DMatrix.h"
|
2010-05-13 04:56:11 +04:00
|
|
|
#include "gfxColor.h"
|
2010-05-18 08:04:22 +04:00
|
|
|
#include "gfxPattern.h"
|
2011-10-07 01:23:18 +04:00
|
|
|
#include "nsTArray.h"
|
2012-02-01 06:18:30 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2012-07-31 21:28:20 +04:00
|
|
|
#include "nsStyleAnimation.h"
|
2012-07-31 04:42:26 +04:00
|
|
|
#include "FrameMetrics.h"
|
2011-06-24 21:41:18 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2012-01-06 02:40:35 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2011-06-24 21:41:18 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
class gfxContext;
|
|
|
|
class nsPaintEvent;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
extern uint8_t gLayerManagerLayerBuilder;
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
namespace mozilla {
|
2012-08-21 08:06:46 +04:00
|
|
|
|
|
|
|
class FrameLayerBuilder;
|
2013-02-14 03:26:24 +04:00
|
|
|
class WebGLContext;
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
}
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
namespace css {
|
|
|
|
class ComputedTimingFunction;
|
|
|
|
}
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
namespace layers {
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
class Animation;
|
2012-08-20 17:35:42 +04:00
|
|
|
class AnimationData;
|
2013-04-18 01:39:13 +04:00
|
|
|
class AsyncPanZoomController;
|
2012-07-31 21:28:20 +04:00
|
|
|
class CommonLayerAttributes;
|
2010-03-01 10:56:18 +03:00
|
|
|
class Layer;
|
|
|
|
class ThebesLayer;
|
|
|
|
class ContainerLayer;
|
2010-03-02 02:09:35 +03:00
|
|
|
class ImageLayer;
|
2010-05-13 04:56:11 +04:00
|
|
|
class ColorLayer;
|
2010-03-02 02:09:35 +03:00
|
|
|
class ImageContainer;
|
2010-05-18 08:04:22 +04:00
|
|
|
class CanvasLayer;
|
2011-02-17 01:43:30 +03:00
|
|
|
class ReadbackLayer;
|
|
|
|
class ReadbackProcessor;
|
2012-07-18 03:59:45 +04:00
|
|
|
class RefLayer;
|
2013-04-26 02:25:33 +04:00
|
|
|
class LayerComposite;
|
2012-03-19 03:02:38 +04:00
|
|
|
class ShadowableLayer;
|
2011-08-09 23:38:26 +04:00
|
|
|
class ShadowLayerForwarder;
|
2013-04-26 02:25:33 +04:00
|
|
|
class LayerManagerComposite;
|
2010-07-22 01:17:33 +04:00
|
|
|
class SpecificLayerAttributes;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
class SurfaceDescriptor;
|
|
|
|
class Compositor;
|
|
|
|
class LayerComposite;
|
|
|
|
struct TextureFactoryIdentifier;
|
|
|
|
struct EffectMask;
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
#define MOZ_LAYER_DECL_NAME(n, e) \
|
|
|
|
virtual const char* Name() const { return n; } \
|
|
|
|
virtual LayerType GetType() const { return e; }
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* Base class for userdata objects attached to layers and layer managers.
|
|
|
|
*/
|
|
|
|
class THEBES_API LayerUserData {
|
|
|
|
public:
|
|
|
|
virtual ~LayerUserData() {}
|
|
|
|
};
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/*
|
|
|
|
* Motivation: For truly smooth animation and video playback, we need to
|
|
|
|
* be able to compose frames and render them on a dedicated thread (i.e.
|
|
|
|
* off the main thread where DOM manipulation, script execution and layout
|
|
|
|
* induce difficult-to-bound latency). This requires Gecko to construct
|
|
|
|
* some kind of persistent scene structure (graph or tree) that can be
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* safely transmitted across threads. We have other scenarios (e.g. mobile
|
2010-03-01 10:56:18 +03:00
|
|
|
* browsing) where retaining some rendered data between paints is desired
|
|
|
|
* for performance, so again we need a retained scene structure.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* Our retained scene structure is a layer tree. Each layer represents
|
|
|
|
* content which can be composited onto a destination surface; the root
|
|
|
|
* layer is usually composited into a window, and non-root layers are
|
|
|
|
* composited into their parent layers. Layers have attributes (e.g.
|
|
|
|
* opacity and clipping) that influence their compositing.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* We want to support a variety of layer implementations, including
|
|
|
|
* a simple "immediate mode" implementation that doesn't retain any
|
|
|
|
* rendered data between paints (i.e. uses cairo in just the way that
|
|
|
|
* Gecko used it before layers were introduced). But we also don't want
|
|
|
|
* to have bifurcated "layers"/"non-layers" rendering paths in Gecko.
|
|
|
|
* Therefore the layers API is carefully designed to permit maximally
|
|
|
|
* efficient implementation in an "immediate mode" style. See the
|
|
|
|
* BasicLayerManager for such an implementation.
|
|
|
|
*/
|
|
|
|
|
2012-07-17 21:03:50 +04:00
|
|
|
static void LayerManagerUserDataDestroy(void *data)
|
|
|
|
{
|
|
|
|
delete static_cast<LayerUserData*>(data);
|
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* A LayerManager controls a tree of layers. All layers in the tree
|
|
|
|
* must use the same LayerManager.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* All modifications to a layer tree must happen inside a transaction.
|
|
|
|
* Only the state of the layer tree at the end of a transaction is
|
|
|
|
* rendered. Transactions cannot be nested
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* Each transaction has two phases:
|
|
|
|
* 1) Construction: layers are created, inserted, removed and have
|
|
|
|
* properties set on them in this phase.
|
|
|
|
* BeginTransaction and BeginTransactionWithTarget start a transaction in
|
|
|
|
* the Construction phase. When the client has finished constructing the layer
|
|
|
|
* tree, it should call EndConstruction() to enter the drawing phase.
|
|
|
|
* 2) Drawing: ThebesLayers are rendered into in this phase, in tree
|
|
|
|
* order. When the client has finished drawing into the ThebesLayers, it should
|
|
|
|
* call EndTransaction to complete the transaction.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* All layer API calls happen on the main thread.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* Layers are refcounted. The layer manager holds a reference to the
|
|
|
|
* root layer, and each container layer holds a reference to its children.
|
|
|
|
*/
|
|
|
|
class THEBES_API LayerManager {
|
2010-04-01 22:05:40 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(LayerManager)
|
2010-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
public:
|
2012-08-16 01:55:38 +04:00
|
|
|
LayerManager()
|
|
|
|
: mDestroyed(false)
|
|
|
|
, mSnapEffectiveTransforms(true)
|
|
|
|
, mId(0)
|
|
|
|
, mInTransaction(false)
|
2010-07-21 22:06:33 +04:00
|
|
|
{
|
|
|
|
InitLog();
|
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
virtual ~LayerManager() {}
|
|
|
|
|
2010-08-07 09:09:17 +04:00
|
|
|
/**
|
|
|
|
* Release layers and resources held by this layer manager, and mark
|
|
|
|
* it as destroyed. Should do any cleanup necessary in preparation
|
|
|
|
* for its widget going away. After this call, only user data calls
|
|
|
|
* are valid on the layer manager.
|
|
|
|
*/
|
2013-04-12 11:28:55 +04:00
|
|
|
virtual void Destroy()
|
|
|
|
{
|
|
|
|
mDestroyed = true;
|
|
|
|
mUserData.Destroy();
|
|
|
|
mRoot = nullptr;
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsDestroyed() { return mDestroyed; }
|
2010-08-07 09:09:17 +04:00
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
virtual ShadowLayerForwarder* AsShadowForwarder()
|
2012-07-30 18:20:58 +04:00
|
|
|
{ return nullptr; }
|
2011-08-09 23:38:26 +04:00
|
|
|
|
2013-04-26 02:25:33 +04:00
|
|
|
virtual LayerManagerComposite* AsLayerManagerComposite()
|
2012-07-30 18:20:58 +04:00
|
|
|
{ return nullptr; }
|
2011-08-09 23:38:26 +04:00
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
/**
|
|
|
|
* Returns true if this LayerManager is owned by an nsIWidget,
|
|
|
|
* and is used for drawing into the widget.
|
|
|
|
*/
|
|
|
|
virtual bool IsWidgetLayerManager() { return true; }
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* Start a new transaction. Nested transactions are not allowed so
|
|
|
|
* there must be no transaction currently in progress.
|
|
|
|
* This transaction will update the state of the window from which
|
|
|
|
* this LayerManager was obtained.
|
|
|
|
*/
|
|
|
|
virtual void BeginTransaction() = 0;
|
|
|
|
/**
|
|
|
|
* Start a new transaction. Nested transactions are not allowed so
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* there must be no transaction currently in progress.
|
2010-03-01 10:56:18 +03:00
|
|
|
* This transaction will render the contents of the layer tree to
|
|
|
|
* the given target context. The rendering will be complete when
|
|
|
|
* EndTransaction returns.
|
|
|
|
*/
|
|
|
|
virtual void BeginTransactionWithTarget(gfxContext* aTarget) = 0;
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2012-08-13 14:10:10 +04:00
|
|
|
enum EndTransactionFlags {
|
|
|
|
END_DEFAULT = 0,
|
|
|
|
END_NO_IMMEDIATE_REDRAW = 1 << 0, // Do not perform the drawing phase
|
|
|
|
END_NO_COMPOSITE = 1 << 1 // Do not composite after drawing thebes layer contents.
|
|
|
|
};
|
|
|
|
|
2012-08-21 08:06:46 +04:00
|
|
|
FrameLayerBuilder* GetLayerBuilder() {
|
2012-08-29 09:48:15 +04:00
|
|
|
return reinterpret_cast<FrameLayerBuilder*>(GetUserData(&gLayerManagerLayerBuilder));
|
2012-08-21 08:06:46 +04:00
|
|
|
}
|
|
|
|
|
2011-01-19 11:27:54 +03:00
|
|
|
/**
|
|
|
|
* Attempts to end an "empty transaction". There must have been no
|
|
|
|
* changes to the layer tree since the BeginTransaction().
|
|
|
|
* It's possible for this to fail; ThebesLayers may need to be updated
|
|
|
|
* due to VRAM data being lost, for example. In such cases this method
|
|
|
|
* returns false, and the caller must proceed with a normal layer tree
|
|
|
|
* update and EndTransaction.
|
|
|
|
*/
|
2012-08-13 14:10:10 +04:00
|
|
|
virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
2011-01-25 11:45:17 +03:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
2010-05-21 07:20:48 +04:00
|
|
|
* Function called to draw the contents of each ThebesLayer.
|
|
|
|
* aRegionToDraw contains the region that needs to be drawn.
|
2010-03-04 00:37:04 +03:00
|
|
|
* This would normally be a subregion of the visible region.
|
|
|
|
* The callee must draw all of aRegionToDraw. Drawing outside
|
|
|
|
* aRegionToDraw will be clipped out or ignored.
|
2010-05-21 07:20:48 +04:00
|
|
|
* The callee must draw all of aRegionToDraw.
|
2010-07-16 01:07:51 +04:00
|
|
|
* This region is relative to 0,0 in the ThebesLayer.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-04 00:37:04 +03:00
|
|
|
* aRegionToInvalidate contains a region whose contents have been
|
|
|
|
* changed by the layer manager and which must therefore be invalidated.
|
2010-07-16 01:07:51 +04:00
|
|
|
* For example, this could be non-empty if a retained layer internally
|
|
|
|
* switches from RGBA to RGB or back ... we might want to repaint it to
|
2010-03-04 00:37:04 +03:00
|
|
|
* consistently use subpixel-AA or not.
|
2010-07-16 01:07:51 +04:00
|
|
|
* This region is relative to 0,0 in the ThebesLayer.
|
|
|
|
* aRegionToInvalidate may contain areas that are outside
|
|
|
|
* aRegionToDraw; the callee must ensure that these areas are repainted
|
|
|
|
* in the current layer manager transaction or in a later layer
|
|
|
|
* manager transaction.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-05-21 07:20:48 +04:00
|
|
|
* aContext must not be used after the call has returned.
|
|
|
|
* We guarantee that buffered contents in the visible
|
|
|
|
* region are valid once drawing is complete.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-07-16 01:07:51 +04:00
|
|
|
* The origin of aContext is 0,0 in the ThebesLayer.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2010-05-21 07:20:48 +04:00
|
|
|
typedef void (* DrawThebesLayerCallback)(ThebesLayer* aLayer,
|
|
|
|
gfxContext* aContext,
|
|
|
|
const nsIntRegion& aRegionToDraw,
|
2010-03-04 00:37:04 +03:00
|
|
|
const nsIntRegion& aRegionToInvalidate,
|
2010-05-21 07:20:48 +04:00
|
|
|
void* aCallbackData);
|
2011-09-26 17:20:42 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
2010-05-21 07:20:48 +04:00
|
|
|
* Finish the construction phase of the transaction, perform the
|
|
|
|
* drawing phase, and end the transaction.
|
|
|
|
* During the drawing phase, all ThebesLayers in the tree are
|
|
|
|
* drawn in tree order, exactly once each, except for those layers
|
|
|
|
* where it is known that the visible region is empty.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2010-12-14 03:14:07 +03:00
|
|
|
virtual void EndTransaction(DrawThebesLayerCallback aCallback,
|
2011-09-26 17:20:42 +04:00
|
|
|
void* aCallbackData,
|
|
|
|
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2012-08-13 14:10:10 +04:00
|
|
|
virtual bool HasShadowManagerInternal() const { return false; }
|
|
|
|
bool HasShadowManager() const { return HasShadowManagerInternal(); }
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
bool IsSnappingEffectiveTransforms() { return mSnapEffectiveTransforms; }
|
2010-11-08 12:06:15 +03:00
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
/**
|
2012-07-23 07:00:36 +04:00
|
|
|
* Returns true if this LayerManager can properly support layers with
|
|
|
|
* SURFACE_COMPONENT_ALPHA. This can include disabling component
|
|
|
|
* alpha if required.
|
|
|
|
*/
|
|
|
|
virtual bool AreComponentAlphaLayersEnabled() { return true; }
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2011-02-10 11:58:11 +03:00
|
|
|
* Set the root layer. The root layer is initially null. If there is
|
|
|
|
* no root layer, EndTransaction won't draw anything.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
|
|
|
virtual void SetRoot(Layer* aLayer) = 0;
|
2010-06-01 03:29:37 +04:00
|
|
|
/**
|
|
|
|
* Can be called anytime
|
|
|
|
*/
|
|
|
|
Layer* GetRoot() { return mRoot; }
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2012-09-27 00:41:56 +04:00
|
|
|
/**
|
|
|
|
* Does a breadth-first search from the root layer to find the first
|
|
|
|
* scrollable layer.
|
|
|
|
* Can be called any time.
|
|
|
|
*/
|
|
|
|
Layer* GetPrimaryScrollableLayer();
|
|
|
|
|
2013-01-10 13:10:20 +04:00
|
|
|
/**
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* Returns a list of all descendant layers for which
|
2013-01-10 13:10:20 +04:00
|
|
|
* GetFrameMetrics().IsScrollable() is true.
|
|
|
|
*/
|
|
|
|
void GetScrollableLayers(nsTArray<Layer*>& aArray);
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Called when a managee has mutated.
|
2011-01-26 09:26:37 +03:00
|
|
|
* Subclasses overriding this method must first call their
|
|
|
|
* superclass's impl
|
2010-07-22 01:17:33 +04:00
|
|
|
*/
|
2011-01-26 09:26:37 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// In debug builds, we check some properties of |aLayer|.
|
|
|
|
virtual void Mutated(Layer* aLayer);
|
|
|
|
#else
|
2010-07-22 01:17:33 +04:00
|
|
|
virtual void Mutated(Layer* aLayer) { }
|
2011-01-26 09:26:37 +03:00
|
|
|
#endif
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ThebesLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ThebesLayer> CreateThebesLayer() = 0;
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ContainerLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
|
2010-03-02 02:09:35 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create an ImageLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ImageLayer> CreateImageLayer() = 0;
|
2010-05-13 04:56:11 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ColorLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ColorLayer> CreateColorLayer() = 0;
|
2010-05-18 08:04:22 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a CanvasLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() = 0;
|
2011-02-17 01:43:30 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ReadbackLayer for this manager's layer tree.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer() { return nullptr; }
|
2012-07-18 03:59:45 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a RefLayer for this manager's layer tree.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual already_AddRefed<RefLayer> CreateRefLayer() { return nullptr; }
|
2012-07-18 03:59:45 +04:00
|
|
|
|
2010-03-02 02:09:35 +03:00
|
|
|
|
|
|
|
/**
|
2012-02-01 06:18:30 +04:00
|
|
|
* Can be called anytime, from any thread.
|
2012-07-13 23:38:09 +04:00
|
|
|
*
|
|
|
|
* Creates an Image container which forwards its images to the compositor within
|
|
|
|
* layer transactions on the main thread.
|
2010-03-02 02:09:35 +03:00
|
|
|
*/
|
2012-02-01 06:18:30 +04:00
|
|
|
static already_AddRefed<ImageContainer> CreateImageContainer();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2012-07-13 23:38:09 +04:00
|
|
|
/**
|
|
|
|
* Can be called anytime, from any thread.
|
|
|
|
*
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* Tries to create an Image container which forwards its images to the compositor
|
2012-07-13 23:38:09 +04:00
|
|
|
* asynchronously using the ImageBridge IPDL protocol. If the protocol is not
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* available, the returned ImageContainer will forward images within layer
|
2012-07-13 23:38:09 +04:00
|
|
|
* transactions, just like if it was created with CreateImageContainer().
|
|
|
|
*/
|
|
|
|
static already_AddRefed<ImageContainer> CreateAsynchronousImageContainer();
|
2010-03-30 22:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Type of layer manager his is. This is to be used sparsely in order to
|
|
|
|
* avoid a lot of Layers backend specific code. It should be used only when
|
|
|
|
* Layers backend specific functionality is necessary.
|
|
|
|
*/
|
|
|
|
virtual LayersBackend GetBackendType() = 0;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2010-09-08 07:27:29 +04:00
|
|
|
/**
|
2012-06-26 06:43:31 +04:00
|
|
|
* Creates a surface which is optimized for inter-operating with this layer
|
2010-09-08 07:27:29 +04:00
|
|
|
* manager.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<gfxASurface>
|
|
|
|
CreateOptimalSurface(const gfxIntSize &aSize,
|
|
|
|
gfxASurface::gfxImageFormat imageFormat);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2012-06-26 06:43:31 +04:00
|
|
|
/**
|
|
|
|
* Creates a surface for alpha masks which is optimized for inter-operating
|
|
|
|
* with this layer manager. In contrast to CreateOptimalSurface, this surface
|
|
|
|
* is optimised for drawing alpha only and we assume that drawing the mask
|
|
|
|
* is fairly simple.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<gfxASurface>
|
|
|
|
CreateOptimalMaskSurface(const gfxIntSize &aSize);
|
2012-06-26 02:54:05 +04:00
|
|
|
|
2011-06-24 21:41:18 +04:00
|
|
|
/**
|
|
|
|
* Creates a DrawTarget which is optimized for inter-operating with this
|
|
|
|
* layermanager.
|
|
|
|
*/
|
|
|
|
virtual TemporaryRef<mozilla::gfx::DrawTarget>
|
|
|
|
CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
|
|
|
|
mozilla::gfx::SurfaceFormat aFormat);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) { return true; }
|
2011-06-24 21:41:18 +04:00
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
/**
|
|
|
|
* Returns a TextureFactoryIdentifier which describes properties of the backend
|
|
|
|
* used to decide what kind of texture and buffer clients to create
|
|
|
|
*/
|
|
|
|
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier();
|
|
|
|
|
2012-05-23 03:15:16 +04:00
|
|
|
/**
|
2012-09-28 10:57:33 +04:00
|
|
|
* returns the maximum texture size on this layer backend, or INT32_MAX
|
2012-05-23 03:15:16 +04:00
|
|
|
* if there is no maximum
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual int32_t GetMaxTextureSize() const = 0;
|
2012-05-23 03:15:16 +04:00
|
|
|
|
2010-09-03 22:01:05 +04:00
|
|
|
/**
|
|
|
|
* Return the name of the layer manager's backend.
|
|
|
|
*/
|
|
|
|
virtual void GetBackendName(nsAString& aName) = 0;
|
|
|
|
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This setter can be used anytime. The user data for all keys is
|
|
|
|
* initially null. Ownership pases to the layer manager.
|
|
|
|
*/
|
|
|
|
void SetUserData(void* aKey, LayerUserData* aData)
|
2012-07-17 21:03:50 +04:00
|
|
|
{
|
|
|
|
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManagerUserDataDestroy);
|
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This can be used anytime. Ownership passes to the caller!
|
|
|
|
*/
|
|
|
|
nsAutoPtr<LayerUserData> RemoveUserData(void* aKey)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
|
|
|
nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
2012-07-17 21:03:50 +04:00
|
|
|
return d;
|
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasUserData(void* aKey)
|
2012-07-17 21:03:50 +04:00
|
|
|
{
|
2012-08-04 04:38:44 +04:00
|
|
|
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
2012-07-17 21:03:50 +04:00
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime. Ownership is retained by the layer
|
|
|
|
* manager.
|
|
|
|
*/
|
|
|
|
LayerUserData* GetUserData(void* aKey)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2012-07-17 21:03:50 +04:00
|
|
|
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
|
|
|
}
|
2010-06-01 03:29:37 +04:00
|
|
|
|
2012-11-08 07:51:55 +04:00
|
|
|
/**
|
|
|
|
* Must be called outside of a layers transaction.
|
|
|
|
*
|
|
|
|
* For the subtree rooted at |aSubtree|, this attempts to free up
|
|
|
|
* any free-able resources like retained buffers, but may do nothing
|
|
|
|
* at all. After this call, the layer tree is left in an undefined
|
|
|
|
* state; the layers in |aSubtree|'s subtree may no longer have
|
|
|
|
* buffers with valid content and may no longer be able to draw
|
|
|
|
* their visible and valid regions.
|
|
|
|
*
|
|
|
|
* In general, a painting or forwarding transaction on |this| must
|
|
|
|
* complete on the tree before it returns to a valid state.
|
|
|
|
*
|
|
|
|
* Resource freeing begins from |aSubtree| or |mRoot| if |aSubtree|
|
|
|
|
* is null. |aSubtree|'s manager must be this.
|
|
|
|
*/
|
|
|
|
virtual void ClearCachedResources(Layer* aSubtree = nullptr) {}
|
|
|
|
|
2012-03-12 19:50:15 +04:00
|
|
|
/**
|
|
|
|
* Flag the next paint as the first for a document.
|
|
|
|
*/
|
|
|
|
virtual void SetIsFirstPaint() {}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
// We always declare the following logging symbols, because it's
|
|
|
|
// extremely tricky to conditionally declare them. However, for
|
|
|
|
// ifndef MOZ_LAYERS_HAVE_LOG builds, they only have trivial
|
|
|
|
// definitions in Layers.cpp.
|
2010-07-21 22:06:33 +04:00
|
|
|
virtual const char* Name() const { return "???"; }
|
2010-07-21 22:06:33 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
|
|
|
* aFile, which defaults to stderr.
|
|
|
|
*/
|
2012-08-07 21:57:26 +04:00
|
|
|
void Dump(FILE* aFile=NULL, const char* aPrefix="", bool aDumpHtml=false);
|
2010-07-21 22:06:33 +04:00
|
|
|
/**
|
|
|
|
* Dump information about just this layer manager itself to aFile,
|
|
|
|
* which defaults to stderr.
|
|
|
|
*/
|
|
|
|
void DumpSelf(FILE* aFile=NULL, const char* aPrefix="");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log information about this layer manager and its managed tree to
|
|
|
|
* the NSPR log (if enabled for "Layers").
|
|
|
|
*/
|
|
|
|
void Log(const char* aPrefix="");
|
|
|
|
/**
|
|
|
|
* Log information about just this layer manager itself to the NSPR
|
|
|
|
* log (if enabled for "Layers").
|
|
|
|
*/
|
|
|
|
void LogSelf(const char* aPrefix="");
|
|
|
|
|
2013-01-23 22:47:44 +04:00
|
|
|
/**
|
|
|
|
* Record (and return) frame-intervals and paint-times for frames which were presented
|
|
|
|
* between calling StartFrameTimeRecording and StopFrameTimeRecording.
|
|
|
|
*
|
|
|
|
* - Uses a cyclic buffer and serves concurrent consumers, so if Stop is called too late
|
|
|
|
* (elements were overwritten since Start), result is considered invalid and hence empty.
|
|
|
|
* - Buffer is capable of holding 10 seconds @ 60fps (or more if frames were less frequent).
|
|
|
|
* Can be changed (up to 1 hour) via pref: toolkit.framesRecording.bufferSize.
|
|
|
|
* - Note: the first frame-interval may be longer than expected because last frame
|
|
|
|
* might have been presented some time before calling StartFrameTimeRecording.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a handle which represents current recording start position.
|
|
|
|
*/
|
|
|
|
uint32_t StartFrameTimeRecording();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears, then populates 2 arraye with the recorded frames timing data.
|
|
|
|
* The arrays will be empty if data was overwritten since aStartIndex was obtained.
|
|
|
|
*/
|
|
|
|
void StopFrameTimeRecording(uint32_t aStartIndex,
|
|
|
|
nsTArray<float>& aFrameIntervals,
|
|
|
|
nsTArray<float>& aPaintTimes);
|
|
|
|
|
2013-01-04 06:53:15 +04:00
|
|
|
void SetPaintStartTime(TimeStamp& aTime);
|
2012-01-06 02:40:35 +04:00
|
|
|
|
|
|
|
void PostPresent();
|
|
|
|
|
2012-10-11 21:54:27 +04:00
|
|
|
void BeginTabSwitch();
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
static bool IsLogEnabled();
|
|
|
|
static PRLogModuleInfo* GetLog() { return sLog; }
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2012-07-18 20:31:40 +04:00
|
|
|
bool IsCompositingCheap(LayersBackend aBackend)
|
2013-01-10 14:02:21 +04:00
|
|
|
{
|
|
|
|
// LAYERS_NONE is an error state, but in that case we should try to
|
|
|
|
// avoid loading the compositor!
|
|
|
|
return LAYERS_BASIC != aBackend && LAYERS_NONE != aBackend;
|
|
|
|
}
|
2011-02-04 21:11:24 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsCompositingCheap() { return true; }
|
2011-02-04 21:11:24 +03:00
|
|
|
|
2012-08-16 01:55:38 +04:00
|
|
|
bool IsInTransaction() const { return mInTransaction; }
|
|
|
|
|
2010-06-01 03:29:37 +04:00
|
|
|
protected:
|
|
|
|
nsRefPtr<Layer> mRoot;
|
2012-07-17 21:03:50 +04:00
|
|
|
gfx::UserData mUserData;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDestroyed;
|
|
|
|
bool mSnapEffectiveTransforms;
|
2010-07-21 22:06:33 +04:00
|
|
|
|
|
|
|
// Print interesting information about this into aTo. Internally
|
|
|
|
// used to implement Dump*() and Log*().
|
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
|
|
|
static void InitLog();
|
|
|
|
static PRLogModuleInfo* sLog;
|
2012-07-18 03:59:45 +04:00
|
|
|
uint64_t mId;
|
2012-08-16 01:55:38 +04:00
|
|
|
bool mInTransaction;
|
2012-01-06 02:40:35 +04:00
|
|
|
private:
|
2013-01-23 22:47:44 +04:00
|
|
|
struct FramesTimingRecording
|
|
|
|
{
|
|
|
|
// Stores state and data for frame intervals and paint times recording.
|
|
|
|
// see LayerManager::StartFrameTimeRecording() at Layers.cpp for more details.
|
|
|
|
FramesTimingRecording()
|
|
|
|
: mIsPaused(true)
|
|
|
|
, mNextIndex(0)
|
|
|
|
{}
|
|
|
|
bool mIsPaused;
|
|
|
|
uint32_t mNextIndex;
|
|
|
|
TimeStamp mLastFrameTime;
|
|
|
|
TimeStamp mPaintStartTime;
|
|
|
|
nsTArray<float> mIntervals;
|
|
|
|
nsTArray<float> mPaints;
|
|
|
|
uint32_t mLatestStartIndex;
|
|
|
|
uint32_t mCurrentRunStartIndex;
|
|
|
|
};
|
|
|
|
FramesTimingRecording mRecording;
|
|
|
|
|
2012-10-11 21:54:27 +04:00
|
|
|
TimeStamp mTabSwitchStart;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
2010-05-21 07:20:48 +04:00
|
|
|
class ThebesLayer;
|
2012-07-31 21:28:20 +04:00
|
|
|
typedef InfallibleTArray<Animation> AnimationArray;
|
|
|
|
|
|
|
|
struct AnimData {
|
|
|
|
InfallibleTArray<nsStyleAnimation::Value> mStartValues;
|
|
|
|
InfallibleTArray<nsStyleAnimation::Value> mEndValues;
|
2013-04-08 22:31:10 +04:00
|
|
|
InfallibleTArray<nsAutoPtr<mozilla::css::ComputedTimingFunction> > mFunctions;
|
2012-07-31 21:28:20 +04:00
|
|
|
};
|
2010-05-21 07:20:48 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* A Layer represents anything that can be rendered onto a destination
|
|
|
|
* surface.
|
|
|
|
*/
|
|
|
|
class THEBES_API Layer {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(Layer)
|
2010-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
public:
|
2011-02-17 01:43:30 +03:00
|
|
|
// Keep these in alphabetical order
|
2010-07-02 05:01:09 +04:00
|
|
|
enum LayerType {
|
2011-02-17 01:43:30 +03:00
|
|
|
TYPE_CANVAS,
|
|
|
|
TYPE_COLOR,
|
2010-07-02 05:01:09 +04:00
|
|
|
TYPE_CONTAINER,
|
|
|
|
TYPE_IMAGE,
|
2011-02-17 01:43:30 +03:00
|
|
|
TYPE_READBACK,
|
2012-07-18 03:59:45 +04:00
|
|
|
TYPE_REF,
|
2011-02-17 01:43:30 +03:00
|
|
|
TYPE_SHADOW,
|
|
|
|
TYPE_THEBES
|
2010-07-02 05:01:09 +04:00
|
|
|
};
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
virtual ~Layer();
|
2010-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
/**
|
2010-08-07 09:09:17 +04:00
|
|
|
* Returns the LayerManager this Layer belongs to. Note that the layer
|
|
|
|
* manager might be in a destroyed state, at which point it's only
|
|
|
|
* valid to set/get user data from it.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
|
|
|
LayerManager* Manager() { return mManager; }
|
|
|
|
|
2010-09-02 13:18:40 +04:00
|
|
|
enum {
|
|
|
|
/**
|
|
|
|
* If this is set, the caller is promising that by the end of this
|
|
|
|
* transaction the entire visible region (as specified by
|
|
|
|
* SetVisibleRegion) will be filled with opaque content.
|
|
|
|
*/
|
|
|
|
CONTENT_OPAQUE = 0x01,
|
|
|
|
/**
|
2010-12-20 04:26:14 +03:00
|
|
|
* If this is set, the caller is notifying that the contents of this layer
|
|
|
|
* require per-component alpha for optimal fidelity. However, there is no
|
|
|
|
* guarantee that component alpha will be supported for this layer at
|
|
|
|
* paint time.
|
|
|
|
* This should never be set at the same time as CONTENT_OPAQUE.
|
2010-09-02 13:18:40 +04:00
|
|
|
*/
|
2011-10-07 01:23:18 +04:00
|
|
|
CONTENT_COMPONENT_ALPHA = 0x02,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If this is set then this layer is part of a preserve-3d group, and should
|
|
|
|
* be sorted with sibling layers that are also part of the same group.
|
|
|
|
*/
|
2012-12-12 09:21:23 +04:00
|
|
|
CONTENT_PRESERVE_3D = 0x04,
|
|
|
|
/**
|
|
|
|
* This indicates that the transform may be changed on during an empty
|
|
|
|
* transaction where there is no possibility of redrawing the content, so the
|
|
|
|
* implementation should be ready for that.
|
|
|
|
*/
|
2013-04-15 16:30:28 +04:00
|
|
|
CONTENT_MAY_CHANGE_TRANSFORM = 0x08,
|
|
|
|
/**
|
|
|
|
* This indicates that the content does not want to be snapped to pixel
|
|
|
|
* boundaries, so the layers code should not do transform snapping.
|
|
|
|
*/
|
|
|
|
CONTENT_DISABLE_TRANSFORM_SNAPPING = 0x10
|
2010-09-02 13:18:40 +04:00
|
|
|
};
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2010-09-02 13:18:40 +04:00
|
|
|
* This lets layout make some promises about what will be drawn into the
|
|
|
|
* visible region of the ThebesLayer. This enables internal quality
|
|
|
|
* and performance optimizations.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetContentFlags(uint32_t aFlags)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2010-12-20 04:26:14 +03:00
|
|
|
NS_ASSERTION((aFlags & (CONTENT_OPAQUE | CONTENT_COMPONENT_ALPHA)) !=
|
|
|
|
(CONTENT_OPAQUE | CONTENT_COMPONENT_ALPHA),
|
|
|
|
"Can't be opaque and require component alpha");
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mContentFlags != aFlags) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ContentFlags", this));
|
2012-08-07 07:00:41 +04:00
|
|
|
mContentFlags = aFlags;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2010-09-17 23:29:52 +04:00
|
|
|
* Tell this layer which region will be visible. The visible region
|
|
|
|
* is a region which contains all the contents of the layer that can
|
|
|
|
* actually affect the rendering of the window. It can exclude areas
|
|
|
|
* that are covered by opaque contents of other layers, and it can
|
|
|
|
* exclude areas where this layer simply contains no content at all.
|
|
|
|
* (This can be an overapproximation to the "true" visible region.)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-09-17 23:29:52 +04:00
|
|
|
* There is no general guarantee that drawing outside the bounds of the
|
|
|
|
* visible region will be ignored. So if a layer draws outside the bounds
|
|
|
|
* of its visible region, it needs to ensure that what it draws is valid.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2010-07-22 01:17:33 +04:00
|
|
|
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
2012-08-07 07:00:41 +04:00
|
|
|
if (!mVisibleRegion.IsEqual(aRegion)) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) VisibleRegion was %s is %s", this,
|
|
|
|
mVisibleRegion.ToString().get(), aRegion.ToString().get()));
|
2012-08-07 07:00:41 +04:00
|
|
|
mVisibleRegion = aRegion;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the opacity which will be applied to this layer as it
|
|
|
|
* is composited to the destination.
|
|
|
|
*/
|
2010-07-22 01:17:33 +04:00
|
|
|
void SetOpacity(float aOpacity)
|
|
|
|
{
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mOpacity != aOpacity) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Opacity", this));
|
2012-08-07 07:00:41 +04:00
|
|
|
mOpacity = aOpacity;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set a clip rect which will be applied to this layer as it is
|
|
|
|
* composited to the destination. The coordinates are relative to
|
|
|
|
* the parent layer (i.e. the contents of this layer
|
|
|
|
* are transformed before this clip rect is applied).
|
|
|
|
* For the root layer, the coordinates are relative to the widget,
|
|
|
|
* in device pixels.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* If aRect is null no clipping will be performed.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
|
|
|
void SetClipRect(const nsIntRect* aRect)
|
|
|
|
{
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mUseClipRect) {
|
|
|
|
if (!aRect) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is <none>", this,
|
|
|
|
mClipRect.x, mClipRect.y, mClipRect.width, mClipRect.height));
|
2012-08-07 07:00:41 +04:00
|
|
|
mUseClipRect = false;
|
|
|
|
Mutated();
|
|
|
|
} else {
|
|
|
|
if (!aRect->IsEqualEdges(mClipRect)) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is %d,%d,%d,%d", this,
|
|
|
|
mClipRect.x, mClipRect.y, mClipRect.width, mClipRect.height,
|
|
|
|
aRect->x, aRect->y, aRect->width, aRect->height));
|
2012-08-07 07:00:41 +04:00
|
|
|
mClipRect = *aRect;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aRect) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was <none> is %d,%d,%d,%d", this,
|
|
|
|
aRect->x, aRect->y, aRect->width, aRect->height));
|
2012-08-07 07:00:41 +04:00
|
|
|
mUseClipRect = true;
|
2013-03-22 06:17:28 +04:00
|
|
|
mClipRect = *aRect;
|
|
|
|
Mutated();
|
2012-08-07 07:00:41 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
}
|
|
|
|
}
|
2010-08-07 09:09:17 +04:00
|
|
|
|
2012-01-18 05:35:49 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set a layer to mask this layer.
|
|
|
|
*
|
|
|
|
* The mask layer should be applied using its effective transform (after it
|
|
|
|
* is calculated by ComputeEffectiveTransformForMaskLayer), this should use
|
|
|
|
* this layer's parent's transform and the mask layer's transform, but not
|
|
|
|
* this layer's. That is, the mask layer is specified relative to this layer's
|
|
|
|
* position in it's parent layer's coord space.
|
|
|
|
* Currently, only 2D translations are supported for the mask layer transform.
|
|
|
|
*
|
|
|
|
* Ownership of aMaskLayer passes to this.
|
|
|
|
* Typical use would be an ImageLayer with an alpha image used for masking.
|
|
|
|
* See also ContainerState::BuildMaskLayer in FrameLayerBuilder.cpp.
|
|
|
|
*/
|
|
|
|
void SetMaskLayer(Layer* aMaskLayer)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (aMaskLayer) {
|
|
|
|
gfxMatrix maskTransform;
|
|
|
|
bool maskIs2D = aMaskLayer->GetTransform().CanDraw2D(&maskTransform);
|
2012-06-26 06:43:31 +04:00
|
|
|
NS_ASSERTION(maskIs2D, "Mask layer has invalid transform.");
|
2012-01-18 05:35:49 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mMaskLayer != aMaskLayer) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) MaskLayer", this));
|
2012-08-07 07:00:41 +04:00
|
|
|
mMaskLayer = aMaskLayer;
|
|
|
|
Mutated();
|
|
|
|
}
|
2012-01-18 05:35:49 +04:00
|
|
|
}
|
|
|
|
|
2010-03-02 02:08:28 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Tell this layer what its transform should be. The transformation
|
|
|
|
* is applied when compositing the layer into its parent container.
|
|
|
|
* XXX Currently only transformations corresponding to 2D affine transforms
|
|
|
|
* are supported.
|
|
|
|
*/
|
2012-07-31 06:20:00 +04:00
|
|
|
void SetBaseTransform(const gfx3DMatrix& aMatrix)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
NS_ASSERTION(!aMatrix.IsSingular(),
|
2012-11-30 02:11:04 +04:00
|
|
|
"Shouldn't be trying to draw with a singular matrix!");
|
2012-10-03 09:55:50 +04:00
|
|
|
mPendingTransform = nullptr;
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mTransform == aMatrix) {
|
|
|
|
return;
|
|
|
|
}
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) BaseTransform", this));
|
2010-07-22 01:17:33 +04:00
|
|
|
mTransform = aMatrix;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-03-02 02:08:28 +03:00
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
/**
|
|
|
|
* Can be called at any time.
|
|
|
|
*
|
|
|
|
* Like SetBaseTransform(), but can be called before the next
|
|
|
|
* transform (i.e. outside an open transaction). Semantically, this
|
|
|
|
* method enqueues a new transform value to be set immediately after
|
|
|
|
* the next transaction is opened.
|
|
|
|
*/
|
|
|
|
void SetBaseTransformForNextTransaction(const gfx3DMatrix& aMatrix)
|
|
|
|
{
|
|
|
|
mPendingTransform = new gfx3DMatrix(aMatrix);
|
|
|
|
}
|
|
|
|
|
2012-08-04 01:29:22 +04:00
|
|
|
void SetPostScale(float aXScale, float aYScale)
|
2012-07-31 06:20:00 +04:00
|
|
|
{
|
2012-11-02 11:13:08 +04:00
|
|
|
if (mPostXScale == aXScale && mPostYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PostScale", this));
|
2012-08-04 01:29:22 +04:00
|
|
|
mPostXScale = aXScale;
|
|
|
|
mPostYScale = aYScale;
|
2012-07-31 06:20:00 +04:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2012-05-04 09:00:57 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* A layer is "fixed position" when it draws content from a content
|
|
|
|
* (not chrome) document, the topmost content document has a root scrollframe
|
|
|
|
* with a displayport, but the layer does not move when that displayport scrolls.
|
|
|
|
*/
|
2013-03-28 14:58:45 +04:00
|
|
|
void SetIsFixedPosition(bool aFixedPosition)
|
|
|
|
{
|
|
|
|
if (mIsFixedPosition != aFixedPosition) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) IsFixedPosition", this));
|
|
|
|
mIsFixedPosition = aFixedPosition;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2011-04-06 09:00:25 +04:00
|
|
|
|
2012-08-20 17:35:42 +04:00
|
|
|
// Call AddAnimation to add a new animation to this layer from layout code.
|
|
|
|
// Caller must add segments to the returned animation.
|
2013-01-11 09:14:51 +04:00
|
|
|
// aStart represents the time at the *end* of the delay.
|
2012-08-20 17:35:42 +04:00
|
|
|
Animation* AddAnimation(mozilla::TimeStamp aStart, mozilla::TimeDuration aDuration,
|
|
|
|
float aIterations, int aDirection,
|
|
|
|
nsCSSProperty aProperty, const AnimationData& aData);
|
2012-07-31 21:28:20 +04:00
|
|
|
// ClearAnimations clears animations on this layer.
|
|
|
|
void ClearAnimations();
|
|
|
|
// This is only called when the layer tree is updated. Do not call this from
|
|
|
|
// layout code. To add an animation to this layer, use AddAnimation.
|
|
|
|
void SetAnimations(const AnimationArray& aAnimations);
|
|
|
|
|
2012-06-27 19:43:57 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* If a layer is "fixed position", this determines which point on the layer
|
|
|
|
* is considered the "anchor" point, that is, the point which remains in the
|
|
|
|
* same position when compositing the layer tree with a transformation
|
|
|
|
* (such as when asynchronously scrolling and zooming).
|
|
|
|
*/
|
2013-03-28 14:58:45 +04:00
|
|
|
void SetFixedPositionAnchor(const gfxPoint& aAnchor)
|
|
|
|
{
|
|
|
|
if (mAnchor != aAnchor) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FixedPositionAnchor", this));
|
|
|
|
mAnchor = aAnchor;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2012-06-27 19:43:57 +04:00
|
|
|
|
2013-03-07 14:17:33 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* If a layer represents a fixed position element or elements that are on
|
|
|
|
* a document that has had fixed position element margins set on it, these
|
|
|
|
* will be mirrored here. This allows for asynchronous animation of the
|
|
|
|
* margins by reconciling the difference between this value and a value that
|
|
|
|
* is updated more frequently.
|
2013-04-15 12:31:48 +04:00
|
|
|
* If the left or top margins are negative, it means that the elements this
|
|
|
|
* layer represents are auto-positioned, and so fixed position margins should
|
|
|
|
* not have an effect on the corresponding axis.
|
2013-03-07 14:17:33 +04:00
|
|
|
*/
|
2013-03-28 14:58:45 +04:00
|
|
|
void SetFixedPositionMargins(const gfx::Margin& aMargins)
|
|
|
|
{
|
|
|
|
if (mMargins != aMargins) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FixedPositionMargins", this));
|
|
|
|
mMargins = aMargins;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2013-03-07 14:17:33 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
// These getters can be used anytime.
|
|
|
|
float GetOpacity() { return mOpacity; }
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsIntRect* GetClipRect() { return mUseClipRect ? &mClipRect : nullptr; }
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t GetContentFlags() { return mContentFlags; }
|
2010-06-01 03:29:37 +04:00
|
|
|
const nsIntRegion& GetVisibleRegion() { return mVisibleRegion; }
|
2010-03-01 10:56:18 +03:00
|
|
|
ContainerLayer* GetParent() { return mParent; }
|
|
|
|
Layer* GetNextSibling() { return mNextSibling; }
|
|
|
|
Layer* GetPrevSibling() { return mPrevSibling; }
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual Layer* GetFirstChild() { return nullptr; }
|
|
|
|
virtual Layer* GetLastChild() { return nullptr; }
|
2012-07-31 06:20:00 +04:00
|
|
|
const gfx3DMatrix GetTransform();
|
|
|
|
const gfx3DMatrix& GetBaseTransform() { return mTransform; }
|
2012-08-04 01:29:22 +04:00
|
|
|
float GetPostXScale() { return mPostXScale; }
|
|
|
|
float GetPostYScale() { return mPostYScale; }
|
2011-04-06 09:00:25 +04:00
|
|
|
bool GetIsFixedPosition() { return mIsFixedPosition; }
|
2012-06-27 19:43:57 +04:00
|
|
|
gfxPoint GetFixedPositionAnchor() { return mAnchor; }
|
2013-03-07 14:17:33 +04:00
|
|
|
const gfx::Margin& GetFixedPositionMargins() { return mMargins; }
|
2012-01-18 05:35:49 +04:00
|
|
|
Layer* GetMaskLayer() { return mMaskLayer; }
|
2012-07-30 22:36:12 +04:00
|
|
|
|
2013-04-18 01:39:13 +04:00
|
|
|
// These functions allow attaching an AsyncPanZoomController to this layer,
|
|
|
|
// and can be used anytime.
|
|
|
|
void SetAsyncPanZoomController(AsyncPanZoomController *controller);
|
|
|
|
AsyncPanZoomController* GetAsyncPanZoomController();
|
|
|
|
|
2013-02-13 01:00:54 +04:00
|
|
|
// Note that all lengths in animation data are either in CSS pixels or app
|
|
|
|
// units and must be converted to device pixels by the compositor.
|
2012-07-31 21:28:20 +04:00
|
|
|
AnimationArray& GetAnimations() { return mAnimations; }
|
|
|
|
InfallibleTArray<AnimData>& GetAnimationData() { return mAnimationData; }
|
2012-10-03 09:55:50 +04:00
|
|
|
|
2012-12-12 01:12:43 +04:00
|
|
|
uint64_t GetAnimationGeneration() { return mAnimationGeneration; }
|
|
|
|
void SetAnimationGeneration(uint64_t aCount) { mAnimationGeneration = aCount; }
|
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
*
|
|
|
|
* Apply pending changes to layers before drawing them, if those
|
|
|
|
* pending changes haven't been overridden by later changes.
|
|
|
|
*/
|
|
|
|
void ApplyPendingUpdatesToSubtree();
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
*
|
|
|
|
* Write layer-subtype-specific attributes into aAttrs. Used to
|
|
|
|
* synchronize layer attributes to their shadows'.
|
|
|
|
*/
|
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) { }
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
// Returns true if it's OK to save the contents of aLayer in an
|
|
|
|
// opaque surface (a surface without an alpha channel).
|
|
|
|
// If we can use a surface without an alpha channel, we should, because
|
|
|
|
// it will often make painting of antialiased text faster and higher
|
|
|
|
// quality.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool CanUseOpaqueSurface();
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2011-01-03 04:48:09 +03:00
|
|
|
enum SurfaceMode {
|
|
|
|
SURFACE_OPAQUE,
|
|
|
|
SURFACE_SINGLE_CHANNEL_ALPHA,
|
|
|
|
SURFACE_COMPONENT_ALPHA
|
|
|
|
};
|
|
|
|
SurfaceMode GetSurfaceMode()
|
|
|
|
{
|
|
|
|
if (CanUseOpaqueSurface())
|
|
|
|
return SURFACE_OPAQUE;
|
|
|
|
if (mContentFlags & CONTENT_COMPONENT_ALPHA)
|
|
|
|
return SURFACE_COMPONENT_ALPHA;
|
|
|
|
return SURFACE_SINGLE_CHANNEL_ALPHA;
|
|
|
|
}
|
|
|
|
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This setter can be used anytime. The user data for all keys is
|
|
|
|
* initially null. Ownership pases to the layer manager.
|
|
|
|
*/
|
|
|
|
void SetUserData(void* aKey, LayerUserData* aData)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2012-07-17 21:03:50 +04:00
|
|
|
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManagerUserDataDestroy);
|
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This can be used anytime. Ownership passes to the caller!
|
|
|
|
*/
|
|
|
|
nsAutoPtr<LayerUserData> RemoveUserData(void* aKey)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
|
|
|
nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
2012-07-17 21:03:50 +04:00
|
|
|
return d;
|
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasUserData(void* aKey)
|
2012-07-17 21:03:50 +04:00
|
|
|
{
|
2012-08-04 04:38:44 +04:00
|
|
|
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
2012-07-17 21:03:50 +04:00
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime. Ownership is retained by the layer
|
|
|
|
* manager.
|
|
|
|
*/
|
|
|
|
LayerUserData* GetUserData(void* aKey)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2012-07-17 21:03:50 +04:00
|
|
|
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
|
|
|
}
|
2010-05-21 07:20:48 +04:00
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
/**
|
|
|
|
* |Disconnect()| is used by layers hooked up over IPC. It may be
|
|
|
|
* called at any time, and may not be called at all. Using an
|
|
|
|
* IPC-enabled layer after Destroy() (drawing etc.) results in a
|
|
|
|
* safe no-op; no crashy or uaf etc.
|
|
|
|
*
|
|
|
|
* XXX: this interface is essentially LayerManager::Destroy, but at
|
|
|
|
* Layer granularity. It might be beneficial to unify them.
|
|
|
|
*/
|
|
|
|
virtual void Disconnect() {}
|
|
|
|
|
2010-05-21 07:20:48 +04:00
|
|
|
/**
|
|
|
|
* Dynamic downcast to a Thebes layer. Returns null if this is not
|
|
|
|
* a ThebesLayer.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual ThebesLayer* AsThebesLayer() { return nullptr; }
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2011-04-12 00:53:01 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a ContainerLayer. Returns null if this is not
|
|
|
|
* a ContainerLayer.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual ContainerLayer* AsContainerLayer() { return nullptr; }
|
2011-04-12 00:53:01 +04:00
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a RefLayer. Returns null if this is not a
|
|
|
|
* RefLayer.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual RefLayer* AsRefLayer() { return nullptr; }
|
2012-07-18 03:59:45 +04:00
|
|
|
|
2012-11-19 21:58:38 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a Color. Returns null if this is not a
|
|
|
|
* ColorLayer.
|
|
|
|
*/
|
|
|
|
virtual ColorLayer* AsColorLayer() { return nullptr; }
|
|
|
|
|
2010-10-14 02:55:45 +04:00
|
|
|
/**
|
2013-04-26 02:25:33 +04:00
|
|
|
* Dynamic cast to a LayerComposite. Return null if this is not a
|
|
|
|
* LayerComposite. Can be used anytime.
|
2010-10-14 02:55:45 +04:00
|
|
|
*/
|
2013-04-26 02:25:33 +04:00
|
|
|
virtual LayerComposite* AsLayerComposite() { return nullptr; }
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2012-03-19 03:02:38 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a ShadowableLayer. Return null if this is not a
|
|
|
|
* ShadowableLayer. Can be used anytime.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual ShadowableLayer* AsShadowableLayer() { return nullptr; }
|
2012-03-19 03:02:38 +04:00
|
|
|
|
2010-10-14 02:55:45 +04:00
|
|
|
// These getters can be used anytime. They return the effective
|
|
|
|
// values that should be used when drawing this layer to screen,
|
|
|
|
// accounting for this layer possibly being a shadow.
|
|
|
|
const nsIntRect* GetEffectiveClipRect();
|
|
|
|
const nsIntRegion& GetEffectiveVisibleRegion();
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* Returns the product of the opacities of this layer and all ancestors up
|
|
|
|
* to and excluding the nearest ancestor that has UseIntermediateSurface() set.
|
|
|
|
*/
|
|
|
|
float GetEffectiveOpacity();
|
|
|
|
/**
|
|
|
|
* This returns the effective transform computed by
|
|
|
|
* ComputeEffectiveTransforms. Typically this is a transform that transforms
|
|
|
|
* this layer all the way to some intermediate surface or destination
|
|
|
|
* surface. For non-BasicLayers this will be a transform to the nearest
|
|
|
|
* ancestor with UseIntermediateSurface() (or to the root, if there is no
|
|
|
|
* such ancestor), but for BasicLayers it's different.
|
|
|
|
*/
|
|
|
|
const gfx3DMatrix& GetEffectiveTransform() const { return mEffectiveTransform; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aTransformToSurface the composition of the transforms
|
|
|
|
* from the parent layer (if any) to the destination pixel grid.
|
|
|
|
*
|
|
|
|
* Computes mEffectiveTransform for this layer and all its descendants.
|
|
|
|
* mEffectiveTransform transforms this layer up to the destination
|
|
|
|
* pixel grid (whatever aTransformToSurface is relative to).
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-11-08 12:06:15 +03:00
|
|
|
* We promise that when this is called on a layer, all ancestor layers
|
|
|
|
* have already had ComputeEffectiveTransforms called.
|
|
|
|
*/
|
|
|
|
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) = 0;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2012-02-08 02:27:44 +04:00
|
|
|
/**
|
|
|
|
* computes the effective transform for a mask layer, if this layer has one
|
|
|
|
*/
|
|
|
|
void ComputeEffectiveTransformForMaskLayer(const gfx3DMatrix& aTransformToSurface);
|
|
|
|
|
2011-02-25 10:44:22 +03:00
|
|
|
/**
|
|
|
|
* Calculate the scissor rect required when rendering this layer.
|
2011-05-23 04:27:03 +04:00
|
|
|
* Returns a rectangle relative to the intermediate surface belonging to the
|
|
|
|
* nearest ancestor that has an intermediate surface, or relative to the root
|
|
|
|
* viewport if no ancestor has an intermediate surface, corresponding to the
|
|
|
|
* clip rect for this layer intersected with aCurrentScissorRect.
|
|
|
|
* If no ancestor has an intermediate surface, the clip rect is transformed
|
|
|
|
* by aWorldTransform before being combined with aCurrentScissorRect, if
|
|
|
|
* aWorldTransform is non-null.
|
2011-02-25 10:44:22 +03:00
|
|
|
*/
|
2011-05-23 04:27:03 +04:00
|
|
|
nsIntRect CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
|
|
|
|
const gfxMatrix* aWorldTransform);
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
virtual const char* Name() const =0;
|
|
|
|
virtual LayerType GetType() const =0;
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* Only the implementation should call this. This is per-implementation
|
|
|
|
* private data. Normally, all layers with a given layer manager
|
|
|
|
* use the same type of ImplData.
|
|
|
|
*/
|
|
|
|
void* ImplData() { return mImplData; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Only the implementation should use these methods.
|
|
|
|
*/
|
|
|
|
void SetParent(ContainerLayer* aParent) { mParent = aParent; }
|
|
|
|
void SetNextSibling(Layer* aSibling) { mNextSibling = aSibling; }
|
|
|
|
void SetPrevSibling(Layer* aSibling) { mPrevSibling = aSibling; }
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
|
|
|
* aFile, which defaults to stderr.
|
|
|
|
*/
|
2012-08-07 21:57:26 +04:00
|
|
|
void Dump(FILE* aFile=NULL, const char* aPrefix="", bool aDumpHtml=false);
|
2010-07-21 22:06:33 +04:00
|
|
|
/**
|
|
|
|
* Dump information about just this layer manager itself to aFile,
|
|
|
|
* which defaults to stderr.
|
|
|
|
*/
|
|
|
|
void DumpSelf(FILE* aFile=NULL, const char* aPrefix="");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log information about this layer manager and its managed tree to
|
|
|
|
* the NSPR log (if enabled for "Layers").
|
|
|
|
*/
|
|
|
|
void Log(const char* aPrefix="");
|
|
|
|
/**
|
|
|
|
* Log information about just this layer manager itself to the NSPR
|
|
|
|
* log (if enabled for "Layers").
|
|
|
|
*/
|
|
|
|
void LogSelf(const char* aPrefix="");
|
|
|
|
|
|
|
|
static bool IsLogEnabled() { return LayerManager::IsLogEnabled(); }
|
|
|
|
|
2012-08-29 09:47:18 +04:00
|
|
|
/**
|
|
|
|
* Returns the current area of the layer (in layer-space coordinates)
|
|
|
|
* marked as needed to be recomposited.
|
|
|
|
*/
|
2012-08-29 09:48:43 +04:00
|
|
|
const nsIntRegion& GetInvalidRegion() { return mInvalidRegion; }
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark the entirety of the layer's visible region as being invalid.
|
|
|
|
*/
|
2012-08-29 09:48:43 +04:00
|
|
|
void SetInvalidRectToVisibleRegion() { mInvalidRegion = GetVisibleRegion(); }
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds to the current invalid rect.
|
|
|
|
*/
|
2012-08-29 09:48:43 +04:00
|
|
|
void AddInvalidRect(const nsIntRect& aRect) { mInvalidRegion.Or(mInvalidRegion, aRect); }
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the invalid rect, marking the layer as being identical to what is currently
|
|
|
|
* composited.
|
|
|
|
*/
|
2012-08-29 09:48:43 +04:00
|
|
|
void ClearInvalidRect() { mInvalidRegion.SetEmpty(); }
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
void ApplyPendingUpdatesForThisTransaction();
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2012-04-27 04:24:53 +04:00
|
|
|
#ifdef DEBUG
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetDebugColorIndex(uint32_t aIndex) { mDebugColorIndex = aIndex; }
|
|
|
|
uint32_t GetDebugColorIndex() { return mDebugColorIndex; }
|
2012-04-27 04:24:53 +04:00
|
|
|
#endif
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
virtual LayerRenderState GetRenderState() { return LayerRenderState(); }
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
protected:
|
2012-07-31 21:28:20 +04:00
|
|
|
Layer(LayerManager* aManager, void* aImplData);
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
void Mutated()
|
|
|
|
{
|
|
|
|
mManager->Mutated(this);
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
// Print interesting information about this into aTo. Internally
|
|
|
|
// used to implement Dump*() and Log*(). If subclasses have
|
|
|
|
// additional interesting properties, they should override this with
|
|
|
|
// an implementation that first calls the base implementation then
|
|
|
|
// appends additional info to aTo.
|
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* Returns the local transform for this layer: either mTransform or,
|
|
|
|
* for shadow layers, GetShadowTransform()
|
|
|
|
*/
|
2012-07-31 06:20:00 +04:00
|
|
|
const gfx3DMatrix GetLocalTransform();
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
/**
|
|
|
|
* Returns the local opacity for this layer: either mOpacity or,
|
|
|
|
* for shadow layers, GetShadowOpacity()
|
|
|
|
*/
|
|
|
|
const float GetLocalOpacity();
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
2012-12-07 03:58:13 +04:00
|
|
|
* We can snap layer transforms for two reasons:
|
|
|
|
* 1) To avoid unnecessary resampling when a transform is a translation
|
|
|
|
* by a non-integer number of pixels.
|
|
|
|
* Snapping the translation to an integer number of pixels avoids
|
|
|
|
* blurring the layer and can be faster to composite.
|
|
|
|
* 2) When a layer is used to render a rectangular object, we need to
|
|
|
|
* emulate the rendering of rectangular inactive content and snap the
|
|
|
|
* edges of the rectangle to pixel boundaries. This is both to ensure
|
|
|
|
* layer rendering is consistent with inactive content rendering, and to
|
|
|
|
* avoid seams.
|
|
|
|
* This function implements type 1 snapping. If aTransform is a 2D
|
|
|
|
* translation, and this layer's layer manager has enabled snapping
|
|
|
|
* (which is the default), return aTransform with the translation snapped
|
|
|
|
* to nearest pixels. Otherwise just return aTransform. Call this when the
|
|
|
|
* layer does not correspond to a single rectangular content object.
|
|
|
|
* This function does not try to snap if aTransform has a scale, because in
|
|
|
|
* that case resampling is inevitable and there's no point in trying to
|
|
|
|
* avoid it. In fact snapping can cause problems because pixel edges in the
|
|
|
|
* layer's content can be rendered unpredictably (jiggling) as the scale
|
|
|
|
* interacts with the snapping of the translation, especially with animated
|
|
|
|
* transforms.
|
|
|
|
* @param aResidualTransform a transform to apply before the result transform
|
|
|
|
* in order to get the results to completely match aTransform.
|
|
|
|
*/
|
|
|
|
gfx3DMatrix SnapTransformTranslation(const gfx3DMatrix& aTransform,
|
|
|
|
gfxMatrix* aResidualTransform);
|
|
|
|
/**
|
|
|
|
* See comment for SnapTransformTranslation.
|
|
|
|
* This function implements type 2 snapping. If aTransform is a translation
|
|
|
|
* and/or scale, transform aSnapRect by aTransform, snap to pixel boundaries,
|
|
|
|
* and return the transform that maps aSnapRect to that rect. Otherwise
|
|
|
|
* just return aTransform.
|
2010-11-08 12:06:15 +03:00
|
|
|
* @param aSnapRect a rectangle whose edges should be snapped to pixel
|
2012-12-07 03:58:13 +04:00
|
|
|
* boundaries in the destination surface.
|
|
|
|
* @param aResidualTransform a transform to apply before the result transform
|
|
|
|
* in order to get the results to completely match aTransform.
|
2010-11-08 12:06:15 +03:00
|
|
|
*/
|
|
|
|
gfx3DMatrix SnapTransform(const gfx3DMatrix& aTransform,
|
|
|
|
const gfxRect& aSnapRect,
|
|
|
|
gfxMatrix* aResidualTransform);
|
|
|
|
|
2012-12-12 09:21:23 +04:00
|
|
|
/**
|
|
|
|
* Returns true if this layer's effective transform is not just
|
|
|
|
* a translation by integers, or if this layer or some ancestor layer
|
|
|
|
* is marked as having a transform that may change without a full layer
|
|
|
|
* transaction.
|
|
|
|
*/
|
|
|
|
bool MayResample();
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
LayerManager* mManager;
|
|
|
|
ContainerLayer* mParent;
|
|
|
|
Layer* mNextSibling;
|
|
|
|
Layer* mPrevSibling;
|
|
|
|
void* mImplData;
|
2012-01-18 05:35:49 +04:00
|
|
|
nsRefPtr<Layer> mMaskLayer;
|
2012-07-17 21:03:50 +04:00
|
|
|
gfx::UserData mUserData;
|
2010-06-01 03:29:37 +04:00
|
|
|
nsIntRegion mVisibleRegion;
|
2010-03-02 02:08:28 +03:00
|
|
|
gfx3DMatrix mTransform;
|
2012-10-03 09:55:50 +04:00
|
|
|
// A mutation of |mTransform| that we've queued to be applied at the
|
|
|
|
// end of the next transaction (if nothing else overrides it in the
|
|
|
|
// meantime).
|
|
|
|
nsAutoPtr<gfx3DMatrix> mPendingTransform;
|
2012-08-04 01:29:22 +04:00
|
|
|
float mPostXScale;
|
|
|
|
float mPostYScale;
|
2010-11-08 12:06:15 +03:00
|
|
|
gfx3DMatrix mEffectiveTransform;
|
2012-07-31 21:28:20 +04:00
|
|
|
AnimationArray mAnimations;
|
|
|
|
InfallibleTArray<AnimData> mAnimationData;
|
2010-03-01 10:56:18 +03:00
|
|
|
float mOpacity;
|
|
|
|
nsIntRect mClipRect;
|
2011-01-26 09:26:37 +03:00
|
|
|
nsIntRect mTileSourceRect;
|
2012-08-29 09:48:43 +04:00
|
|
|
nsIntRegion mInvalidRegion;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mContentFlags;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUseClipRect;
|
|
|
|
bool mUseTileSourceRect;
|
|
|
|
bool mIsFixedPosition;
|
2012-06-27 19:43:57 +04:00
|
|
|
gfxPoint mAnchor;
|
2013-03-07 14:17:33 +04:00
|
|
|
gfx::Margin mMargins;
|
2012-08-22 19:56:38 +04:00
|
|
|
DebugOnly<uint32_t> mDebugColorIndex;
|
2012-12-12 01:12:43 +04:00
|
|
|
// If this layer is used for OMTA, then this counter is used to ensure we
|
|
|
|
// stay in sync with the animation manager
|
|
|
|
uint64_t mAnimationGeneration;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A Layer which we can draw into using Thebes. It is a conceptually
|
|
|
|
* infinite surface, but each ThebesLayer has an associated "valid region"
|
|
|
|
* of contents that it is currently storing, which is finite. ThebesLayer
|
|
|
|
* implementations can store content between paints.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* ThebesLayers are rendered into during the drawing phase of a transaction.
|
|
|
|
*
|
|
|
|
* Currently the contents of a ThebesLayer are in the device output color
|
|
|
|
* space.
|
|
|
|
*/
|
|
|
|
class THEBES_API ThebesLayer : public Layer {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Tell this layer that the content in some region has changed and
|
|
|
|
* will need to be repainted. This area is removed from the valid
|
|
|
|
* region.
|
|
|
|
*/
|
|
|
|
virtual void InvalidateRegion(const nsIntRegion& aRegion) = 0;
|
2011-06-22 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set whether ComputeEffectiveTransforms should compute the
|
|
|
|
* "residual translation" --- the translation that should be applied *before*
|
|
|
|
* mEffectiveTransform to get the ideal transform for this ThebesLayer.
|
|
|
|
* When this is true, ComputeEffectiveTransforms will compute the residual
|
|
|
|
* and ensure that the layer is invalidated whenever the residual changes.
|
|
|
|
* When it's false, a change in the residual will not trigger invalidation
|
|
|
|
* and GetResidualTranslation will return 0,0.
|
|
|
|
* So when the residual is to be ignored, set this to false for better
|
|
|
|
* performance.
|
|
|
|
*/
|
|
|
|
void SetAllowResidualTranslation(bool aAllow) { mAllowResidualTranslation = aAllow; }
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-06-01 03:29:37 +04:00
|
|
|
/**
|
|
|
|
* Can be used anytime
|
|
|
|
*/
|
2010-09-04 00:10:46 +04:00
|
|
|
const nsIntRegion& GetValidRegion() const { return mValidRegion; }
|
2010-06-01 03:29:37 +04:00
|
|
|
|
2010-05-21 07:20:48 +04:00
|
|
|
virtual ThebesLayer* AsThebesLayer() { return this; }
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("ThebesLayer", TYPE_THEBES)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
|
|
|
|
{
|
|
|
|
gfx3DMatrix idealTransform = GetLocalTransform()*aTransformToSurface;
|
2011-06-22 16:11:28 +04:00
|
|
|
gfxMatrix residual;
|
2012-12-07 03:58:13 +04:00
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform,
|
2012-07-30 18:20:58 +04:00
|
|
|
mAllowResidualTranslation ? &residual : nullptr);
|
2012-12-07 03:58:13 +04:00
|
|
|
// The residual can only be a translation because SnapTransformTranslation
|
|
|
|
// only changes the transform if it's a translation
|
2011-06-22 16:11:28 +04:00
|
|
|
NS_ASSERTION(!residual.HasNonTranslation(),
|
|
|
|
"Residual transform can only be a translation");
|
2012-08-17 03:38:59 +04:00
|
|
|
if (!residual.GetTranslation().WithinEpsilonOf(mResidualTranslation, 1e-3f)) {
|
2011-06-22 16:11:28 +04:00
|
|
|
mResidualTranslation = residual.GetTranslation();
|
|
|
|
NS_ASSERTION(-0.5 <= mResidualTranslation.x && mResidualTranslation.x < 0.5 &&
|
|
|
|
-0.5 <= mResidualTranslation.y && mResidualTranslation.y < 0.5,
|
|
|
|
"Residual translation out of range");
|
|
|
|
mValidRegion.SetEmpty();
|
|
|
|
}
|
2012-02-08 02:27:44 +04:00
|
|
|
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
2011-02-17 01:43:30 +03:00
|
|
|
bool UsedForReadback() { return mUsedForReadback; }
|
|
|
|
void SetUsedForReadback(bool aUsed) { mUsedForReadback = aUsed; }
|
2011-06-22 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* Returns the residual translation. Apply this translation when drawing
|
|
|
|
* into the ThebesLayer so that when mEffectiveTransform is applied afterwards
|
|
|
|
* by layer compositing, the results exactly match the "ideal transform"
|
|
|
|
* (the product of the transform of this layer and its ancestors).
|
|
|
|
* Returns 0,0 unless SetAllowResidualTranslation(true) has been called.
|
|
|
|
* The residual translation components are always in the range [-0.5, 0.5).
|
|
|
|
*/
|
|
|
|
gfxPoint GetResidualTranslation() const { return mResidualTranslation; }
|
2011-02-17 01:43:30 +03:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
protected:
|
|
|
|
ThebesLayer(LayerManager* aManager, void* aImplData)
|
2010-09-04 00:10:46 +04:00
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mValidRegion()
|
2011-02-17 01:43:30 +03:00
|
|
|
, mUsedForReadback(false)
|
2011-06-22 16:11:28 +04:00
|
|
|
, mAllowResidualTranslation(false)
|
2010-12-20 04:26:14 +03:00
|
|
|
{
|
|
|
|
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
|
|
|
|
}
|
2010-06-01 03:29:37 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
2011-06-22 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* ComputeEffectiveTransforms snaps the ideal transform to get mEffectiveTransform.
|
|
|
|
* mResidualTranslation is the translation that should be applied *before*
|
|
|
|
* mEffectiveTransform to get the ideal transform.
|
|
|
|
*/
|
|
|
|
gfxPoint mResidualTranslation;
|
2010-06-01 03:29:37 +04:00
|
|
|
nsIntRegion mValidRegion;
|
2011-02-17 01:43:30 +03:00
|
|
|
/**
|
|
|
|
* Set when this ThebesLayer is participating in readback, i.e. some
|
|
|
|
* ReadbackLayer (may) be getting its background from this layer.
|
|
|
|
*/
|
|
|
|
bool mUsedForReadback;
|
2011-06-22 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* True when
|
|
|
|
*/
|
|
|
|
bool mAllowResidualTranslation;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A Layer which other layers render into. It holds references to its
|
|
|
|
* children.
|
|
|
|
*/
|
|
|
|
class THEBES_API ContainerLayer : public Layer {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Insert aChild into the child list of this container. aChild must
|
|
|
|
* not be currently in any child list or the root for the layer manager.
|
|
|
|
* If aAfter is non-null, it must be a child of this container and
|
|
|
|
* we insert after that layer. If it's null we insert at the start.
|
|
|
|
*/
|
|
|
|
virtual void InsertAfter(Layer* aChild, Layer* aAfter) = 0;
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Remove aChild from the child list of this container. aChild must
|
|
|
|
* be a child of this container.
|
|
|
|
*/
|
|
|
|
virtual void RemoveChild(Layer* aChild) = 0;
|
2012-08-29 14:52:55 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Reposition aChild from the child list of this container. aChild must
|
|
|
|
* be a child of this container.
|
|
|
|
* If aAfter is non-null, it must be a child of this container and we
|
|
|
|
* reposition after that layer. If it's null, we reposition at the start.
|
|
|
|
*/
|
|
|
|
virtual void RepositionChild(Layer* aChild, Layer* aAfter) = 0;
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-09-04 00:10:45 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the (sub)document metrics used to render the Layer subtree
|
|
|
|
* rooted at this.
|
|
|
|
*/
|
|
|
|
void SetFrameMetrics(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mFrameMetrics != aFrameMetrics) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FrameMetrics", this));
|
2012-08-07 07:00:41 +04:00
|
|
|
mFrameMetrics = aFrameMetrics;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-09-04 00:10:45 +04:00
|
|
|
}
|
|
|
|
|
2012-08-04 01:29:22 +04:00
|
|
|
void SetPreScale(float aXScale, float aYScale)
|
|
|
|
{
|
2012-11-02 11:13:08 +04:00
|
|
|
if (mPreXScale == aXScale && mPreYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
2013-01-08 13:39:12 +04:00
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PreScale", this));
|
2012-08-04 01:29:22 +04:00
|
|
|
mPreXScale = aXScale;
|
|
|
|
mPreYScale = aYScale;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2013-01-08 13:39:12 +04:00
|
|
|
void SetInheritedScale(float aXScale, float aYScale)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-01-08 13:39:12 +04:00
|
|
|
if (mInheritedXScale == aXScale && mInheritedYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) InheritedScale", this));
|
2013-01-08 13:39:12 +04:00
|
|
|
mInheritedXScale = aXScale;
|
|
|
|
mInheritedYScale = aYScale;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs);
|
|
|
|
|
2011-10-07 01:23:18 +04:00
|
|
|
void SortChildrenBy3DZOrder(nsTArray<Layer*>& aArray);
|
|
|
|
|
2010-09-04 00:10:45 +04:00
|
|
|
// These getters can be used anytime.
|
|
|
|
|
2011-04-12 00:53:01 +04:00
|
|
|
virtual ContainerLayer* AsContainerLayer() { return this; }
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
virtual Layer* GetFirstChild() { return mFirstChild; }
|
2010-11-17 02:33:56 +03:00
|
|
|
virtual Layer* GetLastChild() { return mLastChild; }
|
2010-09-04 00:10:45 +04:00
|
|
|
const FrameMetrics& GetFrameMetrics() { return mFrameMetrics; }
|
2012-08-04 01:29:22 +04:00
|
|
|
float GetPreXScale() { return mPreXScale; }
|
|
|
|
float GetPreYScale() { return mPreYScale; }
|
2013-01-08 13:39:12 +04:00
|
|
|
float GetInheritedXScale() { return mInheritedXScale; }
|
|
|
|
float GetInheritedYScale() { return mInheritedYScale; }
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("ContainerLayer", TYPE_CONTAINER)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* ContainerLayer backends need to override ComputeEffectiveTransforms
|
|
|
|
* since the decision about whether to use a temporary surface for the
|
|
|
|
* container is backend-specific. ComputeEffectiveTransforms must also set
|
|
|
|
* mUseIntermediateSurface.
|
|
|
|
*/
|
|
|
|
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Call this only after ComputeEffectiveTransforms has been invoked
|
|
|
|
* on this layer.
|
|
|
|
* Returns true if this will use an intermediate surface. This is largely
|
|
|
|
* backend-dependent, but it affects the operation of GetEffectiveOpacity().
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool UseIntermediateSurface() { return mUseIntermediateSurface; }
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2011-05-23 04:27:03 +04:00
|
|
|
/**
|
|
|
|
* Returns the rectangle covered by the intermediate surface,
|
|
|
|
* in this layer's coordinate system
|
|
|
|
*/
|
|
|
|
nsIntRect GetIntermediateSurfaceRect()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mUseIntermediateSurface, "Must have intermediate surface");
|
|
|
|
return mVisibleRegion.GetBounds();
|
|
|
|
}
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this container has more than one non-empty child
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasMultipleChildren();
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2011-01-03 04:48:09 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this container supports children with component alpha.
|
|
|
|
* Should only be called while painting a child of this layer.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SupportsComponentAlphaChildren() { return mSupportsComponentAlphaChildren; }
|
2011-01-03 04:48:09 +03:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
protected:
|
2011-02-17 01:43:30 +03:00
|
|
|
friend class ReadbackProcessor;
|
|
|
|
|
|
|
|
void DidInsertChild(Layer* aLayer);
|
|
|
|
void DidRemoveChild(Layer* aLayer);
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
ContainerLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData),
|
2012-07-30 18:20:58 +04:00
|
|
|
mFirstChild(nullptr),
|
|
|
|
mLastChild(nullptr),
|
2012-08-04 01:29:22 +04:00
|
|
|
mPreXScale(1.0f),
|
|
|
|
mPreYScale(1.0f),
|
2013-01-08 13:39:12 +04:00
|
|
|
mInheritedXScale(1.0f),
|
|
|
|
mInheritedYScale(1.0f),
|
2011-10-17 18:59:28 +04:00
|
|
|
mUseIntermediateSurface(false),
|
|
|
|
mSupportsComponentAlphaChildren(false),
|
|
|
|
mMayHaveReadbackChild(false)
|
2010-12-20 04:26:14 +03:00
|
|
|
{
|
|
|
|
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
|
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* A default implementation of ComputeEffectiveTransforms for use by OpenGL
|
|
|
|
* and D3D.
|
|
|
|
*/
|
|
|
|
void DefaultComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loops over the children calling ComputeEffectiveTransforms on them.
|
|
|
|
*/
|
|
|
|
void ComputeEffectiveTransformsForChildren(const gfx3DMatrix& aTransformToSurface);
|
|
|
|
|
2010-09-04 00:10:45 +04:00
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
Layer* mFirstChild;
|
2010-11-17 02:33:56 +03:00
|
|
|
Layer* mLastChild;
|
2010-09-04 00:10:45 +04:00
|
|
|
FrameMetrics mFrameMetrics;
|
2012-08-04 01:29:22 +04:00
|
|
|
float mPreXScale;
|
|
|
|
float mPreYScale;
|
2013-01-08 13:39:12 +04:00
|
|
|
// The resolution scale inherited from the parent layer. This will already
|
|
|
|
// be part of mTransform.
|
|
|
|
float mInheritedXScale;
|
|
|
|
float mInheritedYScale;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUseIntermediateSurface;
|
|
|
|
bool mSupportsComponentAlphaChildren;
|
|
|
|
bool mMayHaveReadbackChild;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
/**
|
2010-05-13 04:56:11 +04:00
|
|
|
* A Layer which just renders a solid color in its visible region. It actually
|
|
|
|
* can fill any area that contains the visible region, so if you need to
|
|
|
|
* restrict the area filled, set a clip region on this layer.
|
2010-05-13 04:56:11 +04:00
|
|
|
*/
|
|
|
|
class THEBES_API ColorLayer : public Layer {
|
|
|
|
public:
|
2012-11-19 21:58:38 +04:00
|
|
|
virtual ColorLayer* AsColorLayer() { return this; }
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the color of the layer.
|
|
|
|
*/
|
|
|
|
virtual void SetColor(const gfxRGBA& aColor)
|
|
|
|
{
|
2013-03-28 14:58:45 +04:00
|
|
|
if (mColor != aColor) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Color", this));
|
|
|
|
mColor = aColor;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-05-13 04:56:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This getter can be used anytime.
|
|
|
|
virtual const gfxRGBA& GetColor() { return mColor; }
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("ColorLayer", TYPE_COLOR)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
|
|
|
|
{
|
|
|
|
gfx3DMatrix idealTransform = GetLocalTransform()*aTransformToSurface;
|
2012-12-07 03:58:13 +04:00
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, nullptr);
|
2012-02-08 02:27:44 +04:00
|
|
|
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
protected:
|
|
|
|
ColorLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData),
|
|
|
|
mColor(0.0, 0.0, 0.0, 0.0)
|
|
|
|
{}
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
gfxRGBA mColor;
|
|
|
|
};
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
/**
|
|
|
|
* A Layer for HTML Canvas elements. It's backed by either a
|
|
|
|
* gfxASurface or a GLContext (for WebGL layers), and has some control
|
|
|
|
* for intelligent updating from the source if necessary (for example,
|
|
|
|
* if hardware compositing is not available, for reading from the GL
|
|
|
|
* buffer into an image surface that we can layer composite.)
|
|
|
|
*
|
|
|
|
* After Initialize is called, the underlying canvas Surface/GLContext
|
|
|
|
* must not be modified during a layer transaction.
|
|
|
|
*/
|
|
|
|
class THEBES_API CanvasLayer : public Layer {
|
|
|
|
public:
|
|
|
|
struct Data {
|
|
|
|
Data()
|
2013-02-14 03:26:24 +04:00
|
|
|
: mSurface(nullptr)
|
|
|
|
, mDrawTarget(nullptr)
|
|
|
|
, mGLContext(nullptr)
|
|
|
|
, mSize(0,0)
|
|
|
|
, mIsGLAlphaPremult(false)
|
2010-05-18 08:04:22 +04:00
|
|
|
{ }
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
// One of these two must be specified for Canvas2D, but never both
|
2010-05-18 08:04:22 +04:00
|
|
|
gfxASurface* mSurface; // a gfx Surface for the canvas contents
|
2011-06-24 21:41:18 +04:00
|
|
|
mozilla::gfx::DrawTarget *mDrawTarget; // a DrawTarget for the canvas contents
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
// Or this, for GL.
|
|
|
|
mozilla::gl::GLContext* mGLContext;
|
|
|
|
|
|
|
|
// The size of the canvas content
|
2010-05-18 08:04:22 +04:00
|
|
|
nsIntSize mSize;
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
// Whether mGLContext contains data that is alpha-premultiplied.
|
|
|
|
bool mIsGLAlphaPremult;
|
2010-05-18 08:04:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Initialize this CanvasLayer with the given data. The data must
|
|
|
|
* have either mSurface or mGLContext initialized (but not both), as
|
|
|
|
* well as mSize.
|
|
|
|
*
|
|
|
|
* This must only be called once.
|
|
|
|
*/
|
|
|
|
virtual void Initialize(const Data& aData) = 0;
|
|
|
|
|
|
|
|
/**
|
2011-03-28 03:59:46 +04:00
|
|
|
* Notify this CanvasLayer that the canvas surface contents have
|
|
|
|
* changed (or will change) before the next transaction.
|
2010-05-18 08:04:22 +04:00
|
|
|
*/
|
2012-08-29 09:47:18 +04:00
|
|
|
void Updated() { mDirty = true; SetInvalidRectToVisibleRegion(); }
|
2011-03-28 03:59:46 +04:00
|
|
|
|
2012-09-30 10:20:25 +04:00
|
|
|
/**
|
|
|
|
* Notify this CanvasLayer that the canvas surface contents have
|
|
|
|
* been painted since the last change.
|
|
|
|
*/
|
|
|
|
void Painted() { mDirty = false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the canvas surface contents have changed since the
|
|
|
|
* last paint.
|
|
|
|
*/
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
bool IsDirty()
|
|
|
|
{
|
2012-09-30 10:20:25 +04:00
|
|
|
// We can only tell if we are dirty if we're part of the
|
|
|
|
// widget's retained layer tree.
|
|
|
|
if (!mManager || !mManager->IsWidgetLayerManager()) {
|
|
|
|
return true;
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
return mDirty;
|
2012-09-30 10:20:25 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
/**
|
|
|
|
* Register a callback to be called at the start of each transaction.
|
|
|
|
*/
|
|
|
|
typedef void PreTransactionCallback(void* closureData);
|
|
|
|
void SetPreTransactionCallback(PreTransactionCallback* callback, void* closureData)
|
|
|
|
{
|
|
|
|
mPreTransCallback = callback;
|
|
|
|
mPreTransCallbackData = closureData;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void FirePreTransactionCallback()
|
|
|
|
{
|
|
|
|
if (mPreTransCallback) {
|
|
|
|
mPreTransCallback(mPreTransCallbackData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2011-03-28 03:59:46 +04:00
|
|
|
/**
|
|
|
|
* Register a callback to be called at the end of each transaction.
|
|
|
|
*/
|
|
|
|
typedef void (* DidTransactionCallback)(void* aClosureData);
|
|
|
|
void SetDidTransactionCallback(DidTransactionCallback aCallback, void* aClosureData)
|
|
|
|
{
|
2013-02-14 03:26:24 +04:00
|
|
|
mPostTransCallback = aCallback;
|
|
|
|
mPostTransCallbackData = aClosureData;
|
2011-03-28 03:59:46 +04:00
|
|
|
}
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the filter used to resample this image (if necessary).
|
|
|
|
*/
|
2013-03-28 14:58:45 +04:00
|
|
|
void SetFilter(gfxPattern::GraphicsFilter aFilter)
|
|
|
|
{
|
|
|
|
if (mFilter != aFilter) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
|
|
|
|
mFilter = aFilter;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 08:04:22 +04:00
|
|
|
gfxPattern::GraphicsFilter GetFilter() const { return mFilter; }
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("CanvasLayer", TYPE_CANVAS)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
|
|
|
|
{
|
|
|
|
// Snap our local transform first, and snap the inherited transform as well.
|
|
|
|
// This makes our snapping equivalent to what would happen if our content
|
|
|
|
// was drawn into a ThebesLayer (gfxContext would snap using the local
|
|
|
|
// transform, then we'd snap again when compositing the ThebesLayer).
|
|
|
|
mEffectiveTransform =
|
|
|
|
SnapTransform(GetLocalTransform(), gfxRect(0, 0, mBounds.width, mBounds.height),
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr)*
|
2012-12-07 03:58:13 +04:00
|
|
|
SnapTransformTranslation(aTransformToSurface, nullptr);
|
2012-02-08 02:27:44 +04:00
|
|
|
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
protected:
|
|
|
|
CanvasLayer(LayerManager* aManager, void* aImplData)
|
2013-02-14 03:26:24 +04:00
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mPreTransCallback(nullptr)
|
|
|
|
, mPreTransCallbackData(nullptr)
|
|
|
|
, mPostTransCallback(nullptr)
|
|
|
|
, mPostTransCallbackData(nullptr)
|
|
|
|
, mFilter(gfxPattern::FILTER_GOOD)
|
|
|
|
, mDirty(false)
|
|
|
|
{}
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
2011-03-28 03:59:46 +04:00
|
|
|
void FireDidTransactionCallback()
|
|
|
|
{
|
2013-02-14 03:26:24 +04:00
|
|
|
if (mPostTransCallback) {
|
|
|
|
mPostTransCallback(mPostTransCallbackData);
|
2011-03-28 03:59:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* 0, 0, canvaswidth, canvasheight
|
|
|
|
*/
|
|
|
|
nsIntRect mBounds;
|
2013-02-14 03:26:24 +04:00
|
|
|
PreTransactionCallback* mPreTransCallback;
|
|
|
|
void* mPreTransCallbackData;
|
|
|
|
DidTransactionCallback mPostTransCallback;
|
|
|
|
void* mPostTransCallbackData;
|
2010-05-18 08:04:22 +04:00
|
|
|
gfxPattern::GraphicsFilter mFilter;
|
2012-09-30 10:20:25 +04:00
|
|
|
|
|
|
|
private:
|
2011-03-28 03:59:46 +04:00
|
|
|
/**
|
|
|
|
* Set to true in Updated(), cleared during a transaction.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDirty;
|
2010-05-18 08:04:22 +04:00
|
|
|
};
|
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
/**
|
|
|
|
* ContainerLayer that refers to a "foreign" layer tree, through an
|
|
|
|
* ID. Usage of RefLayer looks like
|
|
|
|
*
|
|
|
|
* Construction phase:
|
|
|
|
* allocate ID for layer subtree
|
|
|
|
* create RefLayer, SetReferentId(ID)
|
|
|
|
*
|
|
|
|
* Composition:
|
|
|
|
* look up subtree for GetReferentId()
|
|
|
|
* ConnectReferentLayer(subtree)
|
|
|
|
* compose
|
|
|
|
* ClearReferentLayer()
|
|
|
|
*
|
|
|
|
* Clients will usually want to Connect/Clear() on each transaction to
|
|
|
|
* avoid difficulties managing memory across multiple layer subtrees.
|
|
|
|
*/
|
|
|
|
class THEBES_API RefLayer : public ContainerLayer {
|
|
|
|
friend class LayerManager;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void InsertAfter(Layer* aChild, Layer* aAfter)
|
|
|
|
{ MOZ_NOT_REACHED("no"); }
|
|
|
|
|
|
|
|
virtual void RemoveChild(Layer* aChild)
|
|
|
|
{ MOZ_NOT_REACHED("no"); }
|
|
|
|
|
2012-08-29 14:52:55 +04:00
|
|
|
virtual void RepositionChild(Layer* aChild, Layer* aAfter)
|
|
|
|
{ MOZ_NOT_REACHED("no"); }
|
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
using ContainerLayer::SetFrameMetrics;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the ID of the layer's referent.
|
|
|
|
*/
|
|
|
|
void SetReferentId(uint64_t aId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aId != 0);
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mId != aId) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ReferentId", this));
|
2012-08-07 07:00:41 +04:00
|
|
|
mId = aId;
|
|
|
|
Mutated();
|
|
|
|
}
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Connect this ref layer to its referent, temporarily.
|
|
|
|
* ClearReferentLayer() must be called after composition.
|
|
|
|
*/
|
|
|
|
void ConnectReferentLayer(Layer* aLayer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mFirstChild && !mLastChild);
|
|
|
|
MOZ_ASSERT(!aLayer->GetParent());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
MOZ_ASSERT(aLayer->Manager() == Manager());
|
2012-07-18 03:59:45 +04:00
|
|
|
|
|
|
|
mFirstChild = mLastChild = aLayer;
|
|
|
|
aLayer->SetParent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
* |aLayer| is the same as the argument to ConnectReferentLayer().
|
|
|
|
*/
|
|
|
|
void DetachReferentLayer(Layer* aLayer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aLayer == mFirstChild && mFirstChild == mLastChild);
|
|
|
|
MOZ_ASSERT(aLayer->GetParent() == this);
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mFirstChild = mLastChild = nullptr;
|
|
|
|
aLayer->SetParent(nullptr);
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// These getters can be used anytime.
|
|
|
|
virtual RefLayer* AsRefLayer() { return this; }
|
|
|
|
|
|
|
|
virtual int64_t GetReferentId() { return mId; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
*/
|
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs);
|
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("RefLayer", TYPE_REF)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
RefLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: ContainerLayer(aManager, aImplData) , mId(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
|
|
|
Layer* mTempReferent;
|
|
|
|
// 0 is a special value that means "no ID".
|
|
|
|
uint64_t mId;
|
|
|
|
};
|
|
|
|
|
2012-03-05 22:09:05 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
void WriteSnapshotToDumpFile(Layer* aLayer, gfxASurface* aSurf);
|
|
|
|
void WriteSnapshotToDumpFile(LayerManager* aManager, gfxASurface* aSurf);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
void WriteSnapshotToDumpFile(Compositor* aCompositor, gfxASurface* aSurf);
|
2012-03-05 22:09:05 +04:00
|
|
|
#endif
|
2012-03-01 12:26:09 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* GFX_LAYERS_H */
|