2011-02-04 18:11:24 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 11:12:37 +00: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 07:56:18 +00:00
|
|
|
|
|
|
|
#ifndef GFX_LAYERS_H
|
|
|
|
#define GFX_LAYERS_H
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
#include <stdint.h> // for uint32_t, uint64_t, uint8_t
|
|
|
|
#include <stdio.h> // for FILE
|
|
|
|
#include <sys/types.h> // for int32_t, int64_t
|
|
|
|
#include "FrameMetrics.h" // for FrameMetrics
|
2015-04-12 02:03:00 +00:00
|
|
|
#include "Units.h" // for LayerMargin, LayerPoint, ParentLayerIntRect
|
2015-09-25 05:38:58 +00:00
|
|
|
#include "gfxContext.h"
|
2013-09-24 20:45:14 +00:00
|
|
|
#include "gfxTypes.h"
|
2013-12-20 16:46:29 +00:00
|
|
|
#include "gfxPoint.h" // for gfxPoint
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "gfxRect.h" // for gfxRect
|
2014-02-12 15:07:46 +00:00
|
|
|
#include "gfx2DGlue.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2, etc
|
|
|
|
#include "mozilla/DebugOnly.h" // for DebugOnly
|
2013-09-24 10:04:14 +00:00
|
|
|
#include "mozilla/EventForwards.h" // for nsPaintEvent
|
2015-04-12 02:03:00 +00:00
|
|
|
#include "mozilla/Maybe.h" // for Maybe
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h" // for already_AddRefed
|
2014-06-24 06:29:54 +00:00
|
|
|
#include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
|
2015-08-17 23:44:42 +00:00
|
|
|
#include "mozilla/UniquePtr.h" // for UniquePtr
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/gfx/BaseMargin.h" // for BaseMargin
|
|
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
|
|
|
#include "mozilla/gfx/UserData.h" // for UserData, etc
|
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 09:20:52 +00:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
|
|
|
#include "nsAutoPtr.h" // for nsAutoPtr, nsRefPtr, etc
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsCSSProperty.h" // for nsCSSProperty
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
|
|
|
#include "nsISupportsImpl.h" // for Layer::Release, etc
|
2015-05-07 09:07:53 +00:00
|
|
|
#include "nsRect.h" // for mozilla::gfx::IntRect
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "nsRegion.h" // for nsIntRegion
|
|
|
|
#include "nsString.h" // for nsCString
|
|
|
|
#include "nsTArray.h" // for nsTArray
|
|
|
|
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray
|
|
|
|
#include "nscore.h" // for nsACString, nsAString
|
2015-05-19 18:15:34 +00:00
|
|
|
#include "mozilla/Logging.h" // for PRLogModuleInfo
|
2015-01-29 19:41:55 +00:00
|
|
|
#include "nsIWidget.h" // For plugin window configuration information structs
|
2014-07-09 19:26:18 +00:00
|
|
|
#include "gfxVR.h"
|
2015-05-27 23:35:00 +00:00
|
|
|
#include "ImageContainer.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
class gfxContext;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
extern uint8_t gLayerManagerLayerBuilder;
|
2012-08-21 04:06:46 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
namespace mozilla {
|
2012-08-21 04:06:46 +00:00
|
|
|
|
2014-08-10 07:06:44 +00:00
|
|
|
class ComputedTimingFunction;
|
2012-08-21 04:06:46 +00:00
|
|
|
class FrameLayerBuilder;
|
2014-06-24 06:29:54 +00:00
|
|
|
class StyleAnimationValue;
|
2012-08-21 04:06:46 +00:00
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace gl
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace gfx
|
2013-08-11 23:17:23 +00:00
|
|
|
|
2014-05-08 15:32:00 +00:00
|
|
|
namespace dom {
|
|
|
|
class OverfillCallback;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
2014-05-08 15:32:00 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
namespace layers {
|
|
|
|
|
2012-07-31 17:28:20 +00:00
|
|
|
class Animation;
|
2012-08-20 13:35:42 +00:00
|
|
|
class AnimationData;
|
2015-10-12 03:21:02 +00:00
|
|
|
class AsyncCanvasRenderer;
|
2013-04-17 21:39:13 +00:00
|
|
|
class AsyncPanZoomController;
|
2014-06-18 02:42:34 +00:00
|
|
|
class ClientLayerManager;
|
2010-03-01 07:56:18 +00:00
|
|
|
class Layer;
|
2014-08-28 02:13:41 +00:00
|
|
|
class LayerMetricsWrapper;
|
2014-09-26 17:06:08 +00:00
|
|
|
class PaintedLayer;
|
2010-03-01 07:56:18 +00:00
|
|
|
class ContainerLayer;
|
2010-03-01 23:09:35 +00:00
|
|
|
class ImageLayer;
|
2010-05-13 00:56:11 +00:00
|
|
|
class ColorLayer;
|
2010-05-18 04:04:22 +00:00
|
|
|
class CanvasLayer;
|
2011-02-16 22:43:30 +00:00
|
|
|
class ReadbackLayer;
|
|
|
|
class ReadbackProcessor;
|
2012-07-17 23:59:45 +00:00
|
|
|
class RefLayer;
|
2013-04-25 22:25:33 +00:00
|
|
|
class LayerComposite;
|
2012-03-18 23:02:38 +00:00
|
|
|
class ShadowableLayer;
|
2011-08-09 19:38:26 +00:00
|
|
|
class ShadowLayerForwarder;
|
2013-04-25 22:25:33 +00:00
|
|
|
class LayerManagerComposite;
|
2010-07-21 21:17:33 +00: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 09:20:52 +00:00
|
|
|
class Compositor;
|
2015-06-08 16:53:41 +00:00
|
|
|
class FrameUniformityData;
|
2015-06-18 23:07:21 +00:00
|
|
|
class PersistentBufferProvider;
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2014-07-27 20:32:00 +00:00
|
|
|
namespace layerscope {
|
|
|
|
class LayersPacket;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace layerscope
|
2014-07-27 20:32:00 +00:00
|
|
|
|
2015-01-03 02:10:46 +00:00
|
|
|
#define MOZ_LAYER_DECL_NAME(n, e) \
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual const char* Name() const override { return n; } \
|
|
|
|
virtual LayerType GetType() const override { return e; }
|
2010-07-02 01:01:09 +00:00
|
|
|
|
2015-10-22 21:02:14 +00:00
|
|
|
// Defined in LayerUserData.h; please include that file instead.
|
|
|
|
class LayerUserData;
|
|
|
|
|
2010-03-01 07:56:18 +00: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 09:20:52 +00:00
|
|
|
* safely transmitted across threads. We have other scenarios (e.g. mobile
|
2010-03-01 07:56:18 +00: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 09:20:52 +00:00
|
|
|
*
|
2010-03-01 07:56:18 +00: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 09:20:52 +00:00
|
|
|
*
|
2010-03-01 07:56:18 +00: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 09:20:52 +00:00
|
|
|
*
|
2010-03-01 07:56:18 +00: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 09:20:52 +00:00
|
|
|
*
|
2010-03-01 07:56:18 +00: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
|
2015-07-13 13:44:11 +00:00
|
|
|
* the Construction phase.
|
2014-09-26 17:06:08 +00:00
|
|
|
* 2) Drawing: PaintedLayers are rendered into in this phase, in tree
|
|
|
|
* order. When the client has finished drawing into the PaintedLayers, it should
|
2010-03-01 07:56:18 +00:00
|
|
|
* 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 09:20:52 +00:00
|
|
|
*
|
2010-03-01 07:56:18 +00: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 09:20:52 +00:00
|
|
|
*
|
2010-03-01 07:56:18 +00:00
|
|
|
* Layers are refcounted. The layer manager holds a reference to the
|
|
|
|
* root layer, and each container layer holds a reference to its children.
|
|
|
|
*/
|
2013-05-29 21:59:24 +00:00
|
|
|
class LayerManager {
|
2010-04-01 18:05:40 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(LayerManager)
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2014-04-10 08:49:49 +00:00
|
|
|
protected:
|
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
|
|
typedef mozilla::gfx::IntSize IntSize;
|
|
|
|
typedef mozilla::gfx::SurfaceFormat SurfaceFormat;
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
public:
|
2012-08-15 21:55:38 +00:00
|
|
|
LayerManager()
|
|
|
|
: mDestroyed(false)
|
|
|
|
, mSnapEffectiveTransforms(true)
|
|
|
|
, mId(0)
|
|
|
|
, mInTransaction(false)
|
2010-07-21 18:06:33 +00:00
|
|
|
{
|
|
|
|
InitLog();
|
|
|
|
}
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2010-08-07 05:09:17 +00: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 07:28:55 +00:00
|
|
|
virtual void Destroy()
|
|
|
|
{
|
|
|
|
mDestroyed = true;
|
|
|
|
mUserData.Destroy();
|
|
|
|
mRoot = nullptr;
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsDestroyed() { return mDestroyed; }
|
2010-08-07 05:09:17 +00:00
|
|
|
|
2011-08-09 19:38:26 +00:00
|
|
|
virtual ShadowLayerForwarder* AsShadowForwarder()
|
2012-07-30 14:20:58 +00:00
|
|
|
{ return nullptr; }
|
2011-08-09 19:38:26 +00:00
|
|
|
|
2013-04-25 22:25:33 +00:00
|
|
|
virtual LayerManagerComposite* AsLayerManagerComposite()
|
2012-07-30 14:20:58 +00:00
|
|
|
{ return nullptr; }
|
2011-08-09 19:38:26 +00:00
|
|
|
|
2014-06-18 02:42:34 +00:00
|
|
|
virtual ClientLayerManager* AsClientLayerManager()
|
|
|
|
{ return nullptr; }
|
|
|
|
|
2012-07-17 17:03:51 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this LayerManager is owned by an nsIWidget,
|
|
|
|
* and is used for drawing into the widget.
|
|
|
|
*/
|
|
|
|
virtual bool IsWidgetLayerManager() { return true; }
|
2014-06-19 18:22:17 +00:00
|
|
|
virtual bool IsInactiveLayerManager() { return false; }
|
2012-07-17 17:03:51 +00:00
|
|
|
|
2010-03-01 07:56:18 +00: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 09:20:52 +00:00
|
|
|
* there must be no transaction currently in progress.
|
2010-03-01 07:56:18 +00: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 04:06:46 +00:00
|
|
|
|
2012-08-13 10:10:10 +00:00
|
|
|
enum EndTransactionFlags {
|
|
|
|
END_DEFAULT = 0,
|
|
|
|
END_NO_IMMEDIATE_REDRAW = 1 << 0, // Do not perform the drawing phase
|
2014-09-26 17:06:08 +00:00
|
|
|
END_NO_COMPOSITE = 1 << 1, // Do not composite after drawing painted layer contents.
|
2013-12-16 05:38:42 +00:00
|
|
|
END_NO_REMOTE_COMPOSITE = 1 << 2 // Do not schedule a composition with a remote Compositor, if one exists.
|
2012-08-13 10:10:10 +00:00
|
|
|
};
|
|
|
|
|
2012-08-21 04:06:46 +00:00
|
|
|
FrameLayerBuilder* GetLayerBuilder() {
|
2012-08-29 05:48:15 +00:00
|
|
|
return reinterpret_cast<FrameLayerBuilder*>(GetUserData(&gLayerManagerLayerBuilder));
|
2012-08-21 04:06:46 +00:00
|
|
|
}
|
|
|
|
|
2011-01-19 08:27:54 +00:00
|
|
|
/**
|
|
|
|
* Attempts to end an "empty transaction". There must have been no
|
|
|
|
* changes to the layer tree since the BeginTransaction().
|
2014-09-26 17:06:08 +00:00
|
|
|
* It's possible for this to fail; PaintedLayers may need to be updated
|
2011-01-19 08:27:54 +00:00
|
|
|
* 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 10:10:10 +00:00
|
|
|
virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
2011-01-25 08:45:17 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
2014-09-26 17:06:08 +00:00
|
|
|
* Function called to draw the contents of each PaintedLayer.
|
2010-05-21 03:20:48 +00:00
|
|
|
* aRegionToDraw contains the region that needs to be drawn.
|
2010-03-03 21:37:04 +00: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 03:20:48 +00:00
|
|
|
* The callee must draw all of aRegionToDraw.
|
2014-09-26 17:06:08 +00:00
|
|
|
* This region is relative to 0,0 in the PaintedLayer.
|
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 09:20:52 +00:00
|
|
|
*
|
2015-09-15 13:41:42 +00:00
|
|
|
* aDirtyRegion should contain the total region that is be due to be painted
|
|
|
|
* during the transaction, even though only aRegionToDraw should be drawn
|
|
|
|
* during this call. aRegionToDraw must be entirely contained within
|
|
|
|
* aDirtyRegion. If the total dirty region is unknown it is okay to pass a
|
|
|
|
* subregion of the total dirty region, e.g. just aRegionToDraw, though it
|
|
|
|
* may not be as efficient.
|
2015-07-21 08:19:25 +00:00
|
|
|
*
|
2010-03-03 21:37:04 +00:00
|
|
|
* aRegionToInvalidate contains a region whose contents have been
|
|
|
|
* changed by the layer manager and which must therefore be invalidated.
|
2010-07-15 21:07:51 +00: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-03 21:37:04 +00:00
|
|
|
* consistently use subpixel-AA or not.
|
2014-09-26 17:06:08 +00:00
|
|
|
* This region is relative to 0,0 in the PaintedLayer.
|
2010-07-15 21:07:51 +00:00
|
|
|
* 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 09:20:52 +00:00
|
|
|
*
|
2010-05-21 03:20:48 +00: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 09:20:52 +00:00
|
|
|
*
|
2014-09-26 17:06:08 +00:00
|
|
|
* The origin of aContext is 0,0 in the PaintedLayer.
|
2010-03-01 07:56:18 +00:00
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
typedef void (* DrawPaintedLayerCallback)(PaintedLayer* aLayer,
|
2010-05-21 03:20:48 +00:00
|
|
|
gfxContext* aContext,
|
|
|
|
const nsIntRegion& aRegionToDraw,
|
2015-09-15 13:41:42 +00:00
|
|
|
const nsIntRegion& aDirtyRegion,
|
2013-11-06 19:10:50 +00:00
|
|
|
DrawRegionClip aClip,
|
2010-03-03 21:37:04 +00:00
|
|
|
const nsIntRegion& aRegionToInvalidate,
|
2010-05-21 03:20:48 +00:00
|
|
|
void* aCallbackData);
|
2011-09-26 13:20:42 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
2010-05-21 03:20:48 +00:00
|
|
|
* Finish the construction phase of the transaction, perform the
|
|
|
|
* drawing phase, and end the transaction.
|
2014-09-26 17:06:08 +00:00
|
|
|
* During the drawing phase, all PaintedLayers in the tree are
|
2010-05-21 03:20:48 +00:00
|
|
|
* drawn in tree order, exactly once each, except for those layers
|
|
|
|
* where it is known that the visible region is empty.
|
2010-03-01 07:56:18 +00:00
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
|
2011-09-26 13:20:42 +00:00
|
|
|
void* aCallbackData,
|
|
|
|
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2013-12-16 05:38:42 +00:00
|
|
|
/**
|
|
|
|
* Schedule a composition with the remote Compositor, if one exists
|
|
|
|
* for this LayerManager. Useful in conjunction with the END_NO_REMOTE_COMPOSITE
|
|
|
|
* flag to EndTransaction.
|
|
|
|
*/
|
|
|
|
virtual void Composite() {}
|
|
|
|
|
2012-08-13 10:10:10 +00:00
|
|
|
virtual bool HasShadowManagerInternal() const { return false; }
|
|
|
|
bool HasShadowManager() const { return HasShadowManagerInternal(); }
|
2015-01-29 19:41:55 +00:00
|
|
|
virtual void StorePluginWidgetConfigurations(const nsTArray<nsIWidget::Configuration>& aConfigurations) {}
|
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 09:20:52 +00:00
|
|
|
bool IsSnappingEffectiveTransforms() { return mSnapEffectiveTransforms; }
|
2010-11-08 09:06:15 +00:00
|
|
|
|
2014-07-18 06:48:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the layer manager can't render component alpha
|
|
|
|
* layers, and layer building should do it's best to avoid
|
|
|
|
* creating them.
|
|
|
|
*/
|
|
|
|
virtual bool ShouldAvoidComponentAlphaLayers() { return false; }
|
|
|
|
|
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 09:20:52 +00:00
|
|
|
/**
|
2012-07-23 03:00:36 +00:00
|
|
|
* Returns true if this LayerManager can properly support layers with
|
2014-07-18 06:48:23 +00:00
|
|
|
* SurfaceMode::SURFACE_COMPONENT_ALPHA. LayerManagers that can't will use
|
|
|
|
* transparent surfaces (and lose subpixel-AA for text).
|
2012-07-23 03:00:36 +00:00
|
|
|
*/
|
2014-07-18 06:48:23 +00:00
|
|
|
virtual bool AreComponentAlphaLayersEnabled();
|
2012-07-23 03:00:36 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2011-02-10 08:58:11 +00: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 07:56:18 +00:00
|
|
|
*/
|
|
|
|
virtual void SetRoot(Layer* aLayer) = 0;
|
2010-05-31 23:29:37 +00:00
|
|
|
/**
|
|
|
|
* Can be called anytime
|
|
|
|
*/
|
|
|
|
Layer* GetRoot() { return mRoot; }
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2012-09-26 20:41:56 +00:00
|
|
|
/**
|
|
|
|
* Does a breadth-first search from the root layer to find the first
|
2014-08-28 02:13:41 +00:00
|
|
|
* scrollable layer, and returns its ViewID. Note that there may be
|
|
|
|
* other layers in the tree which share the same ViewID.
|
2012-09-26 20:41:56 +00:00
|
|
|
* Can be called any time.
|
|
|
|
*/
|
2014-08-28 02:13:41 +00:00
|
|
|
FrameMetrics::ViewID GetRootScrollableLayerId();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does a breadth-first search from the root layer to find the first
|
|
|
|
* scrollable layer, and returns all the layers that have that ViewID
|
|
|
|
* as the first scrollable metrics in their ancestor chain. If no
|
|
|
|
* scrollable layers are found it just returns the root of the tree if
|
|
|
|
* there is one.
|
|
|
|
*/
|
|
|
|
void GetRootScrollableLayers(nsTArray<Layer*>& aArray);
|
2012-09-26 20:41:56 +00:00
|
|
|
|
2013-01-10 09:10:20 +00: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 09:20:52 +00:00
|
|
|
* Returns a list of all descendant layers for which
|
2014-08-21 09:40:00 +00:00
|
|
|
* GetFrameMetrics().IsScrollable() is true and that
|
|
|
|
* do not already have an ancestor in the return list.
|
2013-01-10 09:10:20 +00:00
|
|
|
*/
|
|
|
|
void GetScrollableLayers(nsTArray<Layer*>& aArray);
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Called when a managee has mutated.
|
2011-01-26 06:26:37 +00:00
|
|
|
* Subclasses overriding this method must first call their
|
|
|
|
* superclass's impl
|
2010-07-21 21:17:33 +00:00
|
|
|
*/
|
2011-01-26 06:26:37 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// In debug builds, we check some properties of |aLayer|.
|
|
|
|
virtual void Mutated(Layer* aLayer);
|
|
|
|
#else
|
2010-07-21 21:17:33 +00:00
|
|
|
virtual void Mutated(Layer* aLayer) { }
|
2011-01-26 06:26:37 +00:00
|
|
|
#endif
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2013-09-17 17:55:09 +00:00
|
|
|
/**
|
2014-09-26 17:07:06 +00:00
|
|
|
* Hints that can be used during PaintedLayer creation to influence the type
|
2013-09-17 17:55:09 +00:00
|
|
|
* or properties of the layer created.
|
|
|
|
*
|
|
|
|
* NONE: No hint.
|
|
|
|
* SCROLLABLE: This layer may represent scrollable content.
|
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
enum PaintedLayerCreationHint {
|
2013-09-17 17:55:09 +00:00
|
|
|
NONE, SCROLLABLE
|
|
|
|
};
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2014-09-26 17:06:08 +00:00
|
|
|
* Create a PaintedLayer for this manager's layer tree.
|
2010-03-01 07:56:18 +00:00
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
virtual already_AddRefed<PaintedLayer> CreatePaintedLayer() = 0;
|
2013-09-17 17:55:09 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2014-09-26 17:06:08 +00:00
|
|
|
* Create a PaintedLayer for this manager's layer tree, with a creation hint
|
2013-09-17 17:55:09 +00:00
|
|
|
* parameter to help optimise the type of layer created.
|
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
virtual already_AddRefed<PaintedLayer> CreatePaintedLayerWithHint(PaintedLayerCreationHint) {
|
|
|
|
return CreatePaintedLayer();
|
2013-09-17 17:55:09 +00:00
|
|
|
}
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ContainerLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
|
2010-03-01 23:09:35 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create an ImageLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ImageLayer> CreateImageLayer() = 0;
|
2010-05-13 00:56:11 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ColorLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ColorLayer> CreateColorLayer() = 0;
|
2010-05-18 04:04:22 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a CanvasLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() = 0;
|
2011-02-16 22:43:30 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ReadbackLayer for this manager's layer tree.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer() { return nullptr; }
|
2012-07-17 23:59:45 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a RefLayer for this manager's layer tree.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
virtual already_AddRefed<RefLayer> CreateRefLayer() { return nullptr; }
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2010-03-01 23:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-01 02:18:30 +00:00
|
|
|
* Can be called anytime, from any thread.
|
2012-07-13 19:38:09 +00:00
|
|
|
*
|
|
|
|
* Creates an Image container which forwards its images to the compositor within
|
2015-05-27 23:35:00 +00:00
|
|
|
* layer transactions on the main thread or asynchronously using the ImageBridge IPDL protocol.
|
|
|
|
* In the case of asynchronous, If the protocol is not available, the returned ImageContainer
|
|
|
|
* will forward images within layer transactions.
|
2010-03-01 23:09:35 +00:00
|
|
|
*/
|
2015-05-27 23:35:00 +00:00
|
|
|
static already_AddRefed<ImageContainer> CreateImageContainer(ImageContainer::Mode flag
|
|
|
|
= ImageContainer::SYNCHRONOUS);
|
2010-03-30 18:58:37 +00: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 09:20:52 +00:00
|
|
|
|
2014-04-07 03:11:17 +00:00
|
|
|
/**
|
|
|
|
* Type of layers backend that will be used to composite this layer tree.
|
|
|
|
* When compositing is done remotely, then this returns the layers type
|
|
|
|
* of the compositor.
|
|
|
|
*/
|
|
|
|
virtual LayersBackend GetCompositorBackendType() { return GetBackendType(); }
|
|
|
|
|
2010-09-08 03:27:29 +00:00
|
|
|
/**
|
2014-04-10 08:49:49 +00:00
|
|
|
* Creates a DrawTarget which is optimized for inter-operating with this
|
|
|
|
* layer manager.
|
2010-09-08 03:27:29 +00:00
|
|
|
*/
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<DrawTarget>
|
2014-04-10 08:49:49 +00:00
|
|
|
CreateOptimalDrawTarget(const IntSize &aSize,
|
|
|
|
SurfaceFormat 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 09:20:52 +00:00
|
|
|
|
2012-06-26 02:43:31 +00:00
|
|
|
/**
|
2014-04-10 08:49:49 +00:00
|
|
|
* Creates a DrawTarget for alpha masks which is optimized for inter-
|
|
|
|
* operating with this layer manager. In contrast to CreateOptimalDrawTarget,
|
|
|
|
* this surface is optimised for drawing alpha only and we assume that
|
|
|
|
* drawing the mask is fairly simple.
|
2012-06-26 02:43:31 +00:00
|
|
|
*/
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<DrawTarget>
|
2014-04-10 08:49:49 +00:00
|
|
|
CreateOptimalMaskDrawTarget(const IntSize &aSize);
|
2012-06-25 22:54:05 +00:00
|
|
|
|
2011-06-24 17:41:18 +00:00
|
|
|
/**
|
2013-08-23 06:13:55 +00:00
|
|
|
* Creates a DrawTarget for use with canvas which is optimized for
|
|
|
|
* inter-operating with this layermanager.
|
2011-06-24 17:41:18 +00:00
|
|
|
*/
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<mozilla::gfx::DrawTarget>
|
2011-06-24 17:41:18 +00:00
|
|
|
CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
|
|
|
|
mozilla::gfx::SurfaceFormat aFormat);
|
|
|
|
|
2015-06-18 23:07:21 +00:00
|
|
|
/**
|
|
|
|
* Creates a PersistentBufferProvider for use with canvas which is optimized for
|
|
|
|
* inter-operating with this layermanager.
|
|
|
|
*/
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<PersistentBufferProvider>
|
2015-06-18 23:07:21 +00:00
|
|
|
CreatePersistentBufferProvider(const mozilla::gfx::IntSize &aSize,
|
|
|
|
mozilla::gfx::SurfaceFormat aFormat);
|
|
|
|
|
2013-12-20 16:46:29 +00:00
|
|
|
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) { return true; }
|
2011-06-24 17:41:18 +00:00
|
|
|
|
2012-05-22 23:15:16 +00:00
|
|
|
/**
|
2012-09-28 06:57:33 +00:00
|
|
|
* returns the maximum texture size on this layer backend, or INT32_MAX
|
2012-05-22 23:15:16 +00:00
|
|
|
* if there is no maximum
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t GetMaxTextureSize() const = 0;
|
2012-05-22 23:15:16 +00:00
|
|
|
|
2010-09-03 18:01:05 +00:00
|
|
|
/**
|
|
|
|
* Return the name of the layer manager's backend.
|
|
|
|
*/
|
|
|
|
virtual void GetBackendName(nsAString& aName) = 0;
|
|
|
|
|
2010-09-02 09:18:39 +00: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 17:03:50 +00:00
|
|
|
{
|
2015-10-22 19:39:30 +00:00
|
|
|
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerUserDataDestroy);
|
2012-07-17 17:03:50 +00:00
|
|
|
}
|
2010-09-02 09:18:39 +00:00
|
|
|
/**
|
|
|
|
* This can be used anytime. Ownership passes to the caller!
|
|
|
|
*/
|
2015-10-22 20:57:29 +00:00
|
|
|
nsAutoPtr<LayerUserData> RemoveUserData(void* aKey);
|
|
|
|
|
2010-09-02 09:18:39 +00:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasUserData(void* aKey)
|
2012-07-17 17:03:50 +00:00
|
|
|
{
|
2012-08-04 00:38:44 +00:00
|
|
|
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
2012-07-17 17:03:50 +00:00
|
|
|
}
|
2010-09-02 09:18:39 +00:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime. Ownership is retained by the layer
|
|
|
|
* manager.
|
|
|
|
*/
|
2013-07-02 16:27:17 +00:00
|
|
|
LayerUserData* GetUserData(void* aKey) const
|
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 09:20:52 +00:00
|
|
|
{
|
2012-07-17 17:03:50 +00:00
|
|
|
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
|
|
|
}
|
2010-05-31 23:29:37 +00:00
|
|
|
|
2012-11-08 03:51:55 +00: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 15:50:15 +00:00
|
|
|
/**
|
|
|
|
* Flag the next paint as the first for a document.
|
|
|
|
*/
|
|
|
|
virtual void SetIsFirstPaint() {}
|
|
|
|
|
2013-06-18 07:58:43 +00:00
|
|
|
/**
|
|
|
|
* Make sure that the previous transaction has been entirely
|
|
|
|
* completed.
|
|
|
|
*
|
|
|
|
* Note: This may sychronously wait on a remote compositor
|
|
|
|
* to complete rendering.
|
|
|
|
*/
|
|
|
|
virtual void FlushRendering() { }
|
|
|
|
|
2013-06-18 07:59:29 +00:00
|
|
|
/**
|
|
|
|
* Checks if we need to invalidate the OS widget to trigger
|
|
|
|
* painting when updating this layer manager.
|
|
|
|
*/
|
|
|
|
virtual bool NeedsWidgetInvalidation() { return true; }
|
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
virtual const char* Name() const { return "???"; }
|
2010-07-21 18:06:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
2014-06-19 22:36:25 +00:00
|
|
|
* aStream.
|
2010-07-21 18:06:33 +00:00
|
|
|
*/
|
2014-06-19 22:36:25 +00:00
|
|
|
void Dump(std::stringstream& aStream, const char* aPrefix="", bool aDumpHtml=false);
|
2010-07-21 18:06:33 +00:00
|
|
|
/**
|
2014-06-19 22:36:25 +00:00
|
|
|
* Dump information about just this layer manager itself to aStream
|
2010-07-21 18:06:33 +00:00
|
|
|
*/
|
2014-06-19 22:36:25 +00:00
|
|
|
void DumpSelf(std::stringstream& aStream, const char* aPrefix="");
|
2014-08-02 10:03:00 +00:00
|
|
|
void Dump();
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2014-07-27 20:32:00 +00:00
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
|
|
|
* layerscope packet.
|
|
|
|
*/
|
|
|
|
void Dump(layerscope::LayersPacket* aPacket);
|
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
/**
|
|
|
|
* 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 18:47:44 +00: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.
|
|
|
|
*/
|
2013-11-27 07:32:19 +00:00
|
|
|
virtual uint32_t StartFrameTimeRecording(int32_t aBufferSize);
|
2013-01-23 18:47:44 +00:00
|
|
|
|
|
|
|
/**
|
2013-11-27 07:32:19 +00:00
|
|
|
* Clears, then populates aFrameIntervals with the recorded frame timing
|
|
|
|
* data. The array will be empty if data was overwritten since
|
|
|
|
* aStartIndex was obtained.
|
2013-01-23 18:47:44 +00:00
|
|
|
*/
|
2013-11-27 07:32:19 +00:00
|
|
|
virtual void StopFrameTimeRecording(uint32_t aStartIndex,
|
|
|
|
nsTArray<float>& aFrameIntervals);
|
2012-01-05 22:40:35 +00:00
|
|
|
|
2013-11-27 07:32:19 +00:00
|
|
|
void RecordFrame();
|
2012-01-05 22:40:35 +00:00
|
|
|
void PostPresent();
|
|
|
|
|
2012-10-11 17:54:27 +00:00
|
|
|
void BeginTabSwitch();
|
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
static bool IsLogEnabled();
|
|
|
|
static PRLogModuleInfo* GetLog() { return sLog; }
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2012-07-18 16:31:40 +00:00
|
|
|
bool IsCompositingCheap(LayersBackend aBackend)
|
2013-01-10 10:02:21 +00:00
|
|
|
{
|
2014-01-23 18:26:41 +00:00
|
|
|
// LayersBackend::LAYERS_NONE is an error state, but in that case we should try to
|
2013-01-10 10:02:21 +00:00
|
|
|
// avoid loading the compositor!
|
2014-01-23 18:26:41 +00:00
|
|
|
return LayersBackend::LAYERS_BASIC != aBackend && LayersBackend::LAYERS_NONE != aBackend;
|
2013-01-10 10:02:21 +00:00
|
|
|
}
|
2011-02-04 18:11:24 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool IsCompositingCheap() { return true; }
|
2011-02-04 18:11:24 +00:00
|
|
|
|
2012-08-15 21:55:38 +00:00
|
|
|
bool IsInTransaction() const { return mInTransaction; }
|
2015-06-08 16:53:41 +00:00
|
|
|
virtual void GetFrameUniformity(FrameUniformityData* aOutData) { }
|
2014-05-08 15:32:00 +00:00
|
|
|
virtual bool RequestOverfill(mozilla::dom::OverfillCallback* aCallback) { return true; }
|
|
|
|
virtual void RunOverfillCallback(const uint32_t aOverfill) { }
|
2012-08-15 21:55:38 +00:00
|
|
|
|
2014-02-13 00:20:41 +00:00
|
|
|
virtual void SetRegionToClear(const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
mRegionToClear = aRegion;
|
|
|
|
}
|
|
|
|
|
2014-05-09 09:48:32 +00:00
|
|
|
virtual bool SupportsMixBlendModes(EnumSet<gfx::CompositionOp>& aMixBlendModes)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SupportsMixBlendMode(gfx::CompositionOp aMixBlendMode)
|
|
|
|
{
|
|
|
|
EnumSet<gfx::CompositionOp> modes(aMixBlendMode);
|
|
|
|
return SupportsMixBlendModes(modes);
|
|
|
|
}
|
|
|
|
|
2014-09-02 19:23:34 +00:00
|
|
|
virtual float RequestProperty(const nsAString& property) { return -1; }
|
|
|
|
|
2014-12-22 00:35:41 +00:00
|
|
|
const TimeStamp& GetAnimationReadyTime() const {
|
|
|
|
return mAnimationReadyTime;
|
|
|
|
}
|
|
|
|
|
2015-06-04 20:51:10 +00:00
|
|
|
virtual bool AsyncPanZoomEnabled() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-22 19:39:30 +00:00
|
|
|
static void LayerUserDataDestroy(void* data);
|
|
|
|
|
2010-05-31 23:29:37 +00:00
|
|
|
protected:
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<Layer> mRoot;
|
2012-07-17 17:03:50 +00:00
|
|
|
gfx::UserData mUserData;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDestroyed;
|
|
|
|
bool mSnapEffectiveTransforms;
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2014-02-13 00:20:41 +00:00
|
|
|
nsIntRegion mRegionToClear;
|
|
|
|
|
2014-04-04 16:27:02 +00:00
|
|
|
// Protected destructor, to discourage deletion outside of Release():
|
|
|
|
virtual ~LayerManager() {}
|
|
|
|
|
2014-06-19 22:36:25 +00:00
|
|
|
// Print interesting information about this into aStreamo. Internally
|
2010-07-21 18:06:33 +00:00
|
|
|
// used to implement Dump*() and Log*().
|
2014-06-19 22:36:25 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2014-07-27 20:32:00 +00:00
|
|
|
// Print interesting information about this into layerscope packet.
|
|
|
|
// Internally used to implement Dump().
|
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket);
|
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
static void InitLog();
|
|
|
|
static PRLogModuleInfo* sLog;
|
2012-07-17 23:59:45 +00:00
|
|
|
uint64_t mId;
|
2012-08-15 21:55:38 +00:00
|
|
|
bool mInTransaction;
|
2014-12-22 00:35:41 +00:00
|
|
|
// The time when painting most recently finished. This is recorded so that
|
|
|
|
// we can time any play-pending animations from this point.
|
|
|
|
TimeStamp mAnimationReadyTime;
|
2012-01-05 22:40:35 +00:00
|
|
|
private:
|
2013-01-23 18:47:44 +00: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;
|
|
|
|
nsTArray<float> mIntervals;
|
|
|
|
uint32_t mLatestStartIndex;
|
|
|
|
uint32_t mCurrentRunStartIndex;
|
|
|
|
};
|
|
|
|
FramesTimingRecording mRecording;
|
|
|
|
|
2012-10-11 17:54:27 +00:00
|
|
|
TimeStamp mTabSwitchStart;
|
2010-03-01 07:56:18 +00:00
|
|
|
};
|
|
|
|
|
2012-07-31 17:28:20 +00:00
|
|
|
typedef InfallibleTArray<Animation> AnimationArray;
|
|
|
|
|
|
|
|
struct AnimData {
|
2014-06-24 06:29:54 +00:00
|
|
|
InfallibleTArray<mozilla::StyleAnimationValue> mStartValues;
|
|
|
|
InfallibleTArray<mozilla::StyleAnimationValue> mEndValues;
|
2014-08-10 07:06:44 +00:00
|
|
|
InfallibleTArray<nsAutoPtr<mozilla::ComputedTimingFunction> > mFunctions;
|
2012-07-31 17:28:20 +00:00
|
|
|
};
|
2010-05-21 03:20:48 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* A Layer represents anything that can be rendered onto a destination
|
|
|
|
* surface.
|
|
|
|
*/
|
2013-05-29 21:59:24 +00:00
|
|
|
class 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 09:20:52 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(Layer)
|
2010-03-01 07:56:18 +00:00
|
|
|
|
|
|
|
public:
|
2011-02-16 22:43:30 +00:00
|
|
|
// Keep these in alphabetical order
|
2010-07-02 01:01:09 +00:00
|
|
|
enum LayerType {
|
2011-02-16 22:43:30 +00:00
|
|
|
TYPE_CANVAS,
|
|
|
|
TYPE_COLOR,
|
2010-07-02 01:01:09 +00:00
|
|
|
TYPE_CONTAINER,
|
|
|
|
TYPE_IMAGE,
|
2011-02-16 22:43:30 +00:00
|
|
|
TYPE_READBACK,
|
2012-07-17 23:59:45 +00:00
|
|
|
TYPE_REF,
|
2011-02-16 22:43:30 +00:00
|
|
|
TYPE_SHADOW,
|
2014-09-26 17:07:06 +00:00
|
|
|
TYPE_PAINTED
|
2010-07-02 01:01:09 +00:00
|
|
|
};
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
2010-08-07 05:09:17 +00: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 07:56:18 +00:00
|
|
|
*/
|
|
|
|
LayerManager* Manager() { return mManager; }
|
|
|
|
|
2010-09-02 09:18:40 +00: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 01:26:14 +00: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 09:18:40 +00:00
|
|
|
*/
|
2011-10-06 21:23:18 +00:00
|
|
|
CONTENT_COMPONENT_ALPHA = 0x02,
|
|
|
|
|
2014-07-18 06:48:23 +00:00
|
|
|
/**
|
|
|
|
* If this is set then one of the descendant layers of this one has
|
|
|
|
* CONTENT_COMPONENT_ALPHA set.
|
|
|
|
*/
|
|
|
|
CONTENT_COMPONENT_ALPHA_DESCENDANT = 0x04,
|
|
|
|
|
2011-10-06 21:23:18 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-09-17 01:31:00 +00:00
|
|
|
CONTENT_EXTEND_3D_CONTEXT = 0x08,
|
2012-12-12 05:21:23 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-07-18 06:48:23 +00:00
|
|
|
CONTENT_MAY_CHANGE_TRANSFORM = 0x10,
|
2013-12-13 18:53:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable subpixel AA for this layer. This is used if the display isn't suited
|
|
|
|
* for subpixel AA like hidpi or rotated content.
|
|
|
|
*/
|
2015-06-26 22:13:50 +00:00
|
|
|
CONTENT_DISABLE_SUBPIXEL_AA = 0x20,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If this is set then the layer contains content that may look objectionable
|
|
|
|
* if not handled as an active layer (such as text with an animated transform).
|
|
|
|
* This is for internal layout/FrameLayerBuilder usage only until flattening
|
|
|
|
* code is obsoleted. See bug 633097
|
|
|
|
*/
|
2015-09-17 01:31:00 +00:00
|
|
|
CONTENT_DISABLE_FLATTENING = 0x40,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This layer is hidden if the backface of the layer is visible
|
|
|
|
* to user.
|
|
|
|
*/
|
|
|
|
CONTENT_BACKFACE_HIDDEN = 0x80
|
2010-09-02 09:18:40 +00:00
|
|
|
};
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2010-09-02 09:18:40 +00:00
|
|
|
* This lets layout make some promises about what will be drawn into the
|
2014-09-26 17:06:08 +00:00
|
|
|
* visible region of the PaintedLayer. This enables internal quality
|
2010-09-02 09:18:40 +00:00
|
|
|
* and performance optimizations.
|
2010-03-01 07:56:18 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
void SetContentFlags(uint32_t aFlags)
|
2010-07-21 21:17:33 +00:00
|
|
|
{
|
2010-12-20 01:26:14 +00: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 03:00:41 +00:00
|
|
|
if (mContentFlags != aFlags) {
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ContentFlags", this));
|
2012-08-07 03:00:41 +00:00
|
|
|
mContentFlags = aFlags;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
}
|
2014-09-15 20:09:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* The union of the bounds of all the display item that got flattened
|
|
|
|
* into this layer. This is intended to be an approximation to the
|
|
|
|
* size of the layer if the nearest scrollable ancestor had an infinitely
|
|
|
|
* large displayport. Computing this more exactly is too expensive,
|
|
|
|
* but this approximation is sufficient for what we need to use it for.
|
|
|
|
*/
|
2015-05-07 09:07:53 +00:00
|
|
|
virtual void SetLayerBounds(const gfx::IntRect& aLayerBounds)
|
2014-09-15 20:09:52 +00:00
|
|
|
{
|
|
|
|
if (!mLayerBounds.IsEqualEdges(aLayerBounds)) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) LayerBounds", this));
|
|
|
|
mLayerBounds = aLayerBounds;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2010-09-17 19:29:52 +00: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 09:20:52 +00:00
|
|
|
*
|
2010-09-17 19:29:52 +00: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 07:56:18 +00:00
|
|
|
*/
|
2010-07-21 21:17:33 +00:00
|
|
|
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
2012-08-07 03:00:41 +00:00
|
|
|
if (!mVisibleRegion.IsEqual(aRegion)) {
|
2013-03-22 02:17:28 +00: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 03:00:41 +00:00
|
|
|
mVisibleRegion = aRegion;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
}
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2014-08-12 00:00:36 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the (sub)document metrics used to render the Layer subtree
|
2014-08-28 02:13:40 +00:00
|
|
|
* rooted at this. Note that a layer may have multiple FrameMetrics
|
|
|
|
* objects; calling this function will remove all of them and replace
|
|
|
|
* them with the provided FrameMetrics. See the documentation for
|
|
|
|
* SetFrameMetrics(const nsTArray<FrameMetrics>&) for more details.
|
2014-08-12 00:00:36 +00:00
|
|
|
*/
|
|
|
|
void SetFrameMetrics(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
2014-08-28 02:13:40 +00:00
|
|
|
if (mFrameMetrics.Length() != 1 || mFrameMetrics[0] != aFrameMetrics) {
|
2014-08-12 00:00:36 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FrameMetrics", this));
|
2014-08-28 02:13:40 +00:00
|
|
|
mFrameMetrics.ReplaceElementsAt(0, mFrameMetrics.Length(), aFrameMetrics);
|
|
|
|
FrameMetricsChanged();
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the (sub)document metrics used to render the Layer subtree
|
|
|
|
* rooted at this. There might be multiple metrics on this layer
|
|
|
|
* because the layer may, for example, be contained inside multiple
|
|
|
|
* nested scrolling subdocuments. In general a Layer having multiple
|
|
|
|
* FrameMetrics objects is conceptually equivalent to having a stack
|
|
|
|
* of ContainerLayers that have been flattened into this Layer.
|
2014-08-28 02:13:41 +00:00
|
|
|
* See the documentation in LayerMetricsWrapper.h for a more detailed
|
|
|
|
* explanation of this conceptual equivalence.
|
2014-08-28 02:13:40 +00:00
|
|
|
*
|
|
|
|
* Note also that there is actually a many-to-many relationship between
|
|
|
|
* Layers and FrameMetrics, because multiple Layers may have identical
|
|
|
|
* FrameMetrics objects. This happens when those layers belong to the
|
|
|
|
* same scrolling subdocument and therefore end up with the same async
|
|
|
|
* transform when they are scrolled by the APZ code.
|
|
|
|
*/
|
|
|
|
void SetFrameMetrics(const nsTArray<FrameMetrics>& aMetricsArray)
|
|
|
|
{
|
|
|
|
if (mFrameMetrics != aMetricsArray) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FrameMetrics", this));
|
|
|
|
mFrameMetrics = aMetricsArray;
|
|
|
|
FrameMetricsChanged();
|
2014-08-12 00:00:36 +00:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-16 10:47:06 +00:00
|
|
|
/*
|
|
|
|
* Compositor event handling
|
|
|
|
* =========================
|
|
|
|
* When a touch-start event (or similar) is sent to the AsyncPanZoomController,
|
|
|
|
* it needs to decide whether the event should be sent to the main thread.
|
|
|
|
* Each layer has a list of event handling regions. When the compositor needs
|
|
|
|
* to determine how to handle a touch event, it scans the layer tree from top
|
|
|
|
* to bottom in z-order (traversing children before their parents). Points
|
|
|
|
* outside the clip region for a layer cause that layer (and its subtree)
|
|
|
|
* to be ignored. If a layer has a mask layer, and that mask layer's alpha
|
|
|
|
* value is zero at the event point, then the layer and its subtree should
|
|
|
|
* be ignored.
|
|
|
|
* For each layer, if the point is outside its hit region, we ignore the layer
|
|
|
|
* and move onto the next. If the point is inside its hit region but
|
|
|
|
* outside the dispatch-to-content region, we can initiate a gesture without
|
|
|
|
* consulting the content thread. Otherwise we must dispatch the event to
|
|
|
|
* content.
|
2015-02-17 02:30:02 +00:00
|
|
|
* Note that if a layer or any ancestor layer has a ForceEmptyHitRegion
|
|
|
|
* override in GetEventRegionsOverride() then the hit-region must be treated
|
|
|
|
* as empty. Similarly, if there is a ForceDispatchToContent override then
|
|
|
|
* the dispatch-to-content region must be treated as encompassing the entire
|
|
|
|
* hit region, and therefore we must consult the content thread before
|
|
|
|
* initiating a gesture. (If both flags are set, ForceEmptyHitRegion takes
|
|
|
|
* priority.)
|
2013-12-16 10:47:06 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the event handling region.
|
|
|
|
*/
|
|
|
|
void SetEventRegions(const EventRegions& aRegions)
|
|
|
|
{
|
|
|
|
if (mEventRegions != aRegions) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) eventregions were %s, now %s", this,
|
|
|
|
mEventRegions.ToString().get(), aRegions.ToString().get()));
|
|
|
|
mEventRegions = aRegions;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the opacity which will be applied to this layer as it
|
|
|
|
* is composited to the destination.
|
|
|
|
*/
|
2010-07-21 21:17:33 +00:00
|
|
|
void SetOpacity(float aOpacity)
|
|
|
|
{
|
2012-08-07 03:00:41 +00:00
|
|
|
if (mOpacity != aOpacity) {
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Opacity", this));
|
2012-08-07 03:00:41 +00:00
|
|
|
mOpacity = aOpacity;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
}
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2014-02-12 15:07:46 +00:00
|
|
|
void SetMixBlendMode(gfx::CompositionOp aMixBlendMode)
|
2013-09-15 03:23:46 +00:00
|
|
|
{
|
|
|
|
if (mMixBlendMode != aMixBlendMode) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) MixBlendMode", this));
|
|
|
|
mMixBlendMode = aMixBlendMode;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2014-06-19 00:04:05 +00:00
|
|
|
|
2013-09-15 03:30:00 +00:00
|
|
|
void SetForceIsolatedGroup(bool aForceIsolatedGroup)
|
|
|
|
{
|
|
|
|
if(mForceIsolatedGroup != aForceIsolatedGroup) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ForceIsolatedGroup", this));
|
|
|
|
mForceIsolatedGroup = aForceIsolatedGroup;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2014-06-19 00:04:05 +00:00
|
|
|
|
2013-09-15 03:30:00 +00:00
|
|
|
bool GetForceIsolatedGroup() const
|
|
|
|
{
|
|
|
|
return mForceIsolatedGroup;
|
|
|
|
}
|
2013-09-15 03:23:46 +00:00
|
|
|
|
2010-03-01 07:56:18 +00: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 09:20:52 +00:00
|
|
|
* If aRect is null no clipping will be performed.
|
2010-03-01 07:56:18 +00:00
|
|
|
*/
|
2015-04-12 02:03:00 +00:00
|
|
|
void SetClipRect(const Maybe<ParentLayerIntRect>& aRect)
|
2010-03-01 07:56:18 +00:00
|
|
|
{
|
2015-04-12 02:03:00 +00:00
|
|
|
if (mClipRect) {
|
2012-08-07 03:00:41 +00:00
|
|
|
if (!aRect) {
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is <none>", this,
|
2015-04-12 02:03:00 +00:00
|
|
|
mClipRect->x, mClipRect->y, mClipRect->width, mClipRect->height));
|
|
|
|
mClipRect.reset();
|
2012-08-07 03:00:41 +00:00
|
|
|
Mutated();
|
|
|
|
} else {
|
2015-04-12 02:03:00 +00:00
|
|
|
if (!aRect->IsEqualEdges(*mClipRect)) {
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is %d,%d,%d,%d", this,
|
2015-04-12 02:03:00 +00:00
|
|
|
mClipRect->x, mClipRect->y, mClipRect->width, mClipRect->height,
|
2013-03-22 02:17:28 +00:00
|
|
|
aRect->x, aRect->y, aRect->width, aRect->height));
|
2015-04-12 02:03:00 +00:00
|
|
|
mClipRect = aRect;
|
2012-08-07 03:00:41 +00:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aRect) {
|
2013-03-22 02:17:28 +00: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));
|
2015-04-12 02:03:00 +00:00
|
|
|
mClipRect = aRect;
|
2013-03-22 02:17:28 +00:00
|
|
|
Mutated();
|
2012-08-07 03:00:41 +00:00
|
|
|
}
|
2010-03-01 07:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-07 05:09:17 +00:00
|
|
|
|
2012-01-18 01:35:49 +00: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) {
|
2014-01-27 15:28:47 +00:00
|
|
|
bool maskIs2D = aMaskLayer->GetTransform().CanDraw2D();
|
2012-06-26 02:43:31 +00:00
|
|
|
NS_ASSERTION(maskIs2D, "Mask layer has invalid transform.");
|
2012-01-18 01:35:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-07 03:00:41 +00:00
|
|
|
if (mMaskLayer != aMaskLayer) {
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) MaskLayer", this));
|
2012-08-07 03:00:41 +00:00
|
|
|
mMaskLayer = aMaskLayer;
|
|
|
|
Mutated();
|
|
|
|
}
|
2012-01-18 01:35:49 +00:00
|
|
|
}
|
|
|
|
|
2015-06-21 16:27:31 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Add a FrameMetrics-associated mask layer.
|
|
|
|
*/
|
2015-10-18 05:24:48 +00:00
|
|
|
void SetAncestorMaskLayers(const nsTArray<RefPtr<Layer>>& aLayers) {
|
2015-06-21 16:27:31 +00:00
|
|
|
if (aLayers != mAncestorMaskLayers) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) AncestorMaskLayers", this));
|
|
|
|
mAncestorMaskLayers = aLayers;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-01 23:08:28 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Tell this layer what its transform should be. The transformation
|
|
|
|
* is applied when compositing the layer into its parent container.
|
|
|
|
*/
|
2014-01-27 15:28:33 +00:00
|
|
|
void SetBaseTransform(const gfx::Matrix4x4& aMatrix)
|
2010-07-21 21:17:33 +00: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 09:20:52 +00:00
|
|
|
NS_ASSERTION(!aMatrix.IsSingular(),
|
2012-11-29 22:11:04 +00:00
|
|
|
"Shouldn't be trying to draw with a singular matrix!");
|
2012-10-03 05:55:50 +00:00
|
|
|
mPendingTransform = nullptr;
|
2014-01-27 15:29:06 +00:00
|
|
|
if (mTransform == aMatrix) {
|
2012-08-07 03:00:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) BaseTransform", this));
|
2014-01-27 15:29:06 +00:00
|
|
|
mTransform = aMatrix;
|
2010-07-21 21:17:33 +00:00
|
|
|
Mutated();
|
|
|
|
}
|
2010-03-01 23:08:28 +00:00
|
|
|
|
2012-10-03 05:55:50 +00: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.
|
|
|
|
*/
|
2014-01-27 15:28:33 +00:00
|
|
|
void SetBaseTransformForNextTransaction(const gfx::Matrix4x4& aMatrix)
|
2012-10-03 05:55:50 +00:00
|
|
|
{
|
2014-01-27 15:29:06 +00:00
|
|
|
mPendingTransform = new gfx::Matrix4x4(aMatrix);
|
2012-10-03 05:55:50 +00:00
|
|
|
}
|
|
|
|
|
2012-08-03 21:29:22 +00:00
|
|
|
void SetPostScale(float aXScale, float aYScale)
|
2012-07-31 02:20:00 +00:00
|
|
|
{
|
2012-11-02 07:13:08 +00:00
|
|
|
if (mPostXScale == aXScale && mPostYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PostScale", this));
|
2012-08-03 21:29:22 +00:00
|
|
|
mPostXScale = aXScale;
|
|
|
|
mPostYScale = aYScale;
|
2012-07-31 02:20:00 +00:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2012-05-04 05:00:57 +00: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 10:58:45 +00: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 05:00:25 +00:00
|
|
|
|
2012-08-20 13:35:42 +00:00
|
|
|
// Call AddAnimation to add a new animation to this layer from layout code.
|
2014-03-05 04:13:21 +00:00
|
|
|
// Caller must fill in all the properties of the returned animation.
|
2015-03-31 22:05:55 +00:00
|
|
|
// A later animation overrides an earlier one.
|
2014-03-05 04:13:21 +00:00
|
|
|
Animation* AddAnimation();
|
2012-07-31 17:28:20 +00: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);
|
2014-12-22 00:35:41 +00:00
|
|
|
// Go through all animations in this layer and its children and, for
|
|
|
|
// any animations with a null start time, update their start time such
|
|
|
|
// that at |aReadyTime| the animation's current time corresponds to its
|
|
|
|
// 'initial current time' value.
|
|
|
|
void StartPendingAnimations(const TimeStamp& aReadyTime);
|
2012-07-31 17:28:20 +00:00
|
|
|
|
2014-03-05 04:13:21 +00:00
|
|
|
// These are a parallel to AddAnimation and clearAnimations, except
|
|
|
|
// they add pending animations that apply only when the next
|
|
|
|
// transaction is begun. (See also
|
|
|
|
// SetBaseTransformForNextTransaction.)
|
|
|
|
Animation* AddAnimationForNextTransaction();
|
|
|
|
void ClearAnimationsForNextTransaction();
|
|
|
|
|
2013-03-07 10:17:33 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2015-08-18 18:27:18 +00:00
|
|
|
* If a layer represents a fixed position element, this data is stored on the
|
|
|
|
* layer for use by the compositor.
|
2015-08-17 23:44:42 +00:00
|
|
|
*
|
|
|
|
* - |aScrollId| identifies the scroll frame that this element is fixed
|
|
|
|
* with respect to.
|
|
|
|
*
|
|
|
|
* - |aAnchor| is the point on the layer that 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).
|
2015-09-04 21:26:33 +00:00
|
|
|
*
|
|
|
|
* - |aIsClipFixed| is true if this layer's clip rect and mask layer
|
|
|
|
* should also remain fixed during async scrolling/animations.
|
|
|
|
* This is the case for fixed position layers, but not for
|
|
|
|
* fixed background layers.
|
2015-08-17 23:44:42 +00:00
|
|
|
*/
|
|
|
|
void SetFixedPositionData(FrameMetrics::ViewID aScrollId,
|
2015-09-04 21:26:33 +00:00
|
|
|
const LayerPoint& aAnchor,
|
|
|
|
bool aIsClipFixed)
|
2013-03-28 10:58:45 +00:00
|
|
|
{
|
2015-08-17 23:44:42 +00:00
|
|
|
if (!mFixedPositionData ||
|
|
|
|
mFixedPositionData->mScrollId != aScrollId ||
|
2015-09-04 21:26:33 +00:00
|
|
|
mFixedPositionData->mAnchor != aAnchor ||
|
|
|
|
mFixedPositionData->mIsClipFixed != aIsClipFixed) {
|
2015-08-17 23:44:42 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FixedPositionData", this));
|
|
|
|
if (!mFixedPositionData) {
|
|
|
|
mFixedPositionData = MakeUnique<FixedPositionData>();
|
|
|
|
}
|
|
|
|
mFixedPositionData->mScrollId = aScrollId;
|
|
|
|
mFixedPositionData->mAnchor = aAnchor;
|
2015-09-04 21:26:33 +00:00
|
|
|
mFixedPositionData->mIsClipFixed = aIsClipFixed;
|
2013-03-28 10:58:45 +00:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2013-03-07 10:17:33 +00:00
|
|
|
|
2013-09-12 04:17:58 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* If a layer is "sticky position", |aScrollId| holds the scroll identifier
|
|
|
|
* of the scrollable content that contains it. The difference between the two
|
|
|
|
* rectangles |aOuter| and |aInner| is treated as two intervals in each
|
|
|
|
* dimension, with the current scroll position at the origin. For each
|
|
|
|
* dimension, while that component of the scroll position lies within either
|
|
|
|
* interval, the layer should not move relative to its scrolling container.
|
|
|
|
*/
|
|
|
|
void SetStickyPositionData(FrameMetrics::ViewID aScrollId, LayerRect aOuter,
|
|
|
|
LayerRect aInner)
|
|
|
|
{
|
|
|
|
if (!mStickyPositionData ||
|
|
|
|
!mStickyPositionData->mOuter.IsEqualEdges(aOuter) ||
|
|
|
|
!mStickyPositionData->mInner.IsEqualEdges(aInner)) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) StickyPositionData", this));
|
|
|
|
if (!mStickyPositionData) {
|
|
|
|
mStickyPositionData = new StickyPositionData;
|
|
|
|
}
|
|
|
|
mStickyPositionData->mScrollId = aScrollId;
|
|
|
|
mStickyPositionData->mOuter = aOuter;
|
|
|
|
mStickyPositionData->mInner = aInner;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-10 03:14:53 +00:00
|
|
|
enum ScrollDirection {
|
2013-12-12 18:34:50 +00:00
|
|
|
NONE,
|
2013-12-10 03:14:53 +00:00
|
|
|
VERTICAL,
|
|
|
|
HORIZONTAL
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* If a layer is a scrollbar layer, |aScrollId| holds the scroll identifier
|
|
|
|
* of the scrollable content that the scrollbar is for.
|
|
|
|
*/
|
2015-04-13 03:03:02 +00:00
|
|
|
void SetScrollbarData(FrameMetrics::ViewID aScrollId, ScrollDirection aDir, float aThumbRatio)
|
2013-12-10 03:14:53 +00:00
|
|
|
{
|
2013-12-12 18:34:50 +00:00
|
|
|
if (mScrollbarTargetId != aScrollId ||
|
2015-04-13 03:03:02 +00:00
|
|
|
mScrollbarDirection != aDir ||
|
|
|
|
mScrollbarThumbRatio != aThumbRatio)
|
|
|
|
{
|
2013-12-10 03:14:53 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ScrollbarData", this));
|
|
|
|
mScrollbarTargetId = aScrollId;
|
|
|
|
mScrollbarDirection = aDir;
|
2015-04-13 03:03:02 +00:00
|
|
|
mScrollbarThumbRatio = aThumbRatio;
|
2013-12-10 03:14:53 +00:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-14 07:55:17 +00:00
|
|
|
// Set during construction for the container layer of scrollbar components.
|
|
|
|
void SetIsScrollbarContainer()
|
|
|
|
{
|
|
|
|
if (!mIsScrollbarContainer) {
|
|
|
|
mIsScrollbarContainer = true;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
// These getters can be used anytime.
|
|
|
|
float GetOpacity() { return mOpacity; }
|
2014-02-12 15:07:46 +00:00
|
|
|
gfx::CompositionOp GetMixBlendMode() const { return mMixBlendMode; }
|
2015-04-12 02:03:00 +00:00
|
|
|
const Maybe<ParentLayerIntRect>& GetClipRect() const { return mClipRect; }
|
2014-09-09 23:57:12 +00:00
|
|
|
uint32_t GetContentFlags() { return mContentFlags; }
|
2015-05-07 09:07:53 +00:00
|
|
|
const gfx::IntRect& GetLayerBounds() const { return mLayerBounds; }
|
2014-08-20 18:04:37 +00:00
|
|
|
const nsIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
|
2014-08-28 02:13:40 +00:00
|
|
|
const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const;
|
|
|
|
uint32_t GetFrameMetricsCount() const { return mFrameMetrics.Length(); }
|
|
|
|
const nsTArray<FrameMetrics>& GetAllFrameMetrics() { return mFrameMetrics; }
|
2014-08-28 02:13:41 +00:00
|
|
|
bool HasScrollableFrameMetrics() const;
|
2014-08-28 02:13:42 +00:00
|
|
|
bool IsScrollInfoLayer() const;
|
2013-12-16 10:47:06 +00:00
|
|
|
const EventRegions& GetEventRegions() const { return mEventRegions; }
|
2010-03-01 07:56:18 +00:00
|
|
|
ContainerLayer* GetParent() { return mParent; }
|
|
|
|
Layer* GetNextSibling() { return mNextSibling; }
|
2013-07-02 16:27:17 +00:00
|
|
|
const Layer* GetNextSibling() const { return mNextSibling; }
|
2010-03-01 07:56:18 +00:00
|
|
|
Layer* GetPrevSibling() { return mPrevSibling; }
|
2013-07-02 16:27:17 +00:00
|
|
|
const Layer* GetPrevSibling() const { return mPrevSibling; }
|
|
|
|
virtual Layer* GetFirstChild() const { return nullptr; }
|
|
|
|
virtual Layer* GetLastChild() const { return nullptr; }
|
2014-01-27 15:28:47 +00:00
|
|
|
const gfx::Matrix4x4 GetTransform() const;
|
2014-01-27 15:29:06 +00:00
|
|
|
const gfx::Matrix4x4& GetBaseTransform() const { return mTransform; }
|
2015-01-03 01:06:14 +00:00
|
|
|
// Note: these are virtual because ContainerLayerComposite overrides them.
|
|
|
|
virtual float GetPostXScale() const { return mPostXScale; }
|
|
|
|
virtual float GetPostYScale() const { return mPostYScale; }
|
2011-04-06 05:00:25 +00:00
|
|
|
bool GetIsFixedPosition() { return mIsFixedPosition; }
|
2013-09-12 04:17:58 +00:00
|
|
|
bool GetIsStickyPosition() { return mStickyPositionData; }
|
2015-08-17 23:44:42 +00:00
|
|
|
FrameMetrics::ViewID GetFixedPositionScrollContainerId() { return mFixedPositionData ? mFixedPositionData->mScrollId : FrameMetrics::NULL_SCROLL_ID; }
|
|
|
|
LayerPoint GetFixedPositionAnchor() { return mFixedPositionData ? mFixedPositionData->mAnchor : LayerPoint(); }
|
2015-09-04 21:26:33 +00:00
|
|
|
bool IsClipFixed() { return mFixedPositionData ? mFixedPositionData->mIsClipFixed : false; }
|
2013-09-12 04:17:58 +00:00
|
|
|
FrameMetrics::ViewID GetStickyScrollContainerId() { return mStickyPositionData->mScrollId; }
|
|
|
|
const LayerRect& GetStickyScrollRangeOuter() { return mStickyPositionData->mOuter; }
|
|
|
|
const LayerRect& GetStickyScrollRangeInner() { return mStickyPositionData->mInner; }
|
2013-12-10 03:14:53 +00:00
|
|
|
FrameMetrics::ViewID GetScrollbarTargetContainerId() { return mScrollbarTargetId; }
|
|
|
|
ScrollDirection GetScrollbarDirection() { return mScrollbarDirection; }
|
2015-04-13 03:03:02 +00:00
|
|
|
float GetScrollbarThumbRatio() { return mScrollbarThumbRatio; }
|
2015-01-14 07:55:17 +00:00
|
|
|
bool IsScrollbarContainer() { return mIsScrollbarContainer; }
|
2013-07-02 16:27:17 +00:00
|
|
|
Layer* GetMaskLayer() const { return mMaskLayer; }
|
2014-08-12 00:00:37 +00:00
|
|
|
|
2015-06-21 16:27:31 +00:00
|
|
|
// Ancestor mask layers are associated with FrameMetrics, but for simplicity
|
|
|
|
// in maintaining the layer tree structure we attach them to the layer.
|
|
|
|
size_t GetAncestorMaskLayerCount() const {
|
|
|
|
return mAncestorMaskLayers.Length();
|
|
|
|
}
|
|
|
|
Layer* GetAncestorMaskLayerAt(size_t aIndex) const {
|
|
|
|
return mAncestorMaskLayers.ElementAt(aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasMaskLayers() const {
|
|
|
|
return GetMaskLayer() || mAncestorMaskLayers.Length() > 0;
|
|
|
|
}
|
|
|
|
|
2015-06-02 23:34:28 +00:00
|
|
|
/*
|
|
|
|
* Get the combined clip rect of the Layer clip and all clips on FrameMetrics.
|
|
|
|
* This is intended for use in Layout. The compositor needs to apply async
|
|
|
|
* transforms to find the combined clip.
|
|
|
|
*/
|
|
|
|
Maybe<ParentLayerIntRect> GetCombinedClipRect() const;
|
2012-07-30 18:36:12 +00:00
|
|
|
|
2015-01-29 19:41:55 +00:00
|
|
|
/**
|
|
|
|
* Retrieve the root level visible region for |this| taking into account
|
|
|
|
* clipping applied to parent layers of |this| as well as subtracting
|
|
|
|
* visible regions of higher siblings of this layer and each ancestor.
|
|
|
|
*
|
|
|
|
* Note translation values for offsets of visible regions and accumulated
|
|
|
|
* aLayerOffset are integer rounded using Point's RoundedToInt.
|
|
|
|
*
|
|
|
|
* @param aResult - the resulting visible region of this layer.
|
|
|
|
* @param aLayerOffset - this layer's total offset from the root layer.
|
|
|
|
* @return - false if during layer tree traversal a parent or sibling
|
|
|
|
* transform is found to be non-translational. This method returns early
|
|
|
|
* in this case, results will not be valid. Returns true on successful
|
|
|
|
* traversal.
|
|
|
|
*/
|
|
|
|
bool GetVisibleRegionRelativeToRootLayer(nsIntRegion& aResult,
|
|
|
|
nsIntPoint* aLayerOffset);
|
|
|
|
|
2013-02-12 21:00:54 +00: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 17:28:20 +00:00
|
|
|
AnimationArray& GetAnimations() { return mAnimations; }
|
|
|
|
InfallibleTArray<AnimData>& GetAnimationData() { return mAnimationData; }
|
2012-10-03 05:55:50 +00:00
|
|
|
|
2012-12-11 21:12:43 +00:00
|
|
|
uint64_t GetAnimationGeneration() { return mAnimationGeneration; }
|
|
|
|
void SetAnimationGeneration(uint64_t aCount) { mAnimationGeneration = aCount; }
|
|
|
|
|
2015-02-26 22:45:37 +00:00
|
|
|
bool HasTransformAnimation() const;
|
|
|
|
|
2013-05-16 12:34:24 +00:00
|
|
|
/**
|
|
|
|
* Returns the local transform for this layer: either mTransform or,
|
|
|
|
* for shadow layers, GetShadowTransform()
|
|
|
|
*/
|
2014-01-27 15:28:18 +00:00
|
|
|
const gfx::Matrix4x4 GetLocalTransform();
|
2013-05-16 12:34:24 +00:00
|
|
|
|
2013-05-30 00:38:27 +00:00
|
|
|
/**
|
|
|
|
* Returns the local opacity for this layer: either mOpacity or,
|
|
|
|
* for shadow layers, GetShadowOpacity()
|
|
|
|
*/
|
|
|
|
const float GetLocalOpacity();
|
|
|
|
|
2012-10-03 05:55:50 +00: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-21 21:17:33 +00: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 18:06:33 +00: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 06:19:26 +00:00
|
|
|
bool CanUseOpaqueSurface();
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2011-01-03 01:48:09 +00:00
|
|
|
SurfaceMode GetSurfaceMode()
|
|
|
|
{
|
|
|
|
if (CanUseOpaqueSurface())
|
2014-01-23 18:26:41 +00:00
|
|
|
return SurfaceMode::SURFACE_OPAQUE;
|
2011-01-03 01:48:09 +00:00
|
|
|
if (mContentFlags & CONTENT_COMPONENT_ALPHA)
|
2014-01-23 18:26:41 +00:00
|
|
|
return SurfaceMode::SURFACE_COMPONENT_ALPHA;
|
|
|
|
return SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
|
2011-01-03 01:48:09 +00:00
|
|
|
}
|
|
|
|
|
2015-09-30 07:02:00 +00:00
|
|
|
// Returns true if this layer can be treated as opaque for visibility
|
|
|
|
// computation. A layer may be non-opaque for visibility even if it
|
|
|
|
// is not transparent, for example, if it has a mix-blend-mode.
|
|
|
|
bool IsOpaqueForVisibility();
|
|
|
|
|
2010-09-02 09:18:39 +00: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 09:20:52 +00:00
|
|
|
{
|
2015-10-22 19:39:30 +00:00
|
|
|
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManager::LayerUserDataDestroy);
|
2012-07-17 17:03:50 +00:00
|
|
|
}
|
2010-09-02 09:18:39 +00:00
|
|
|
/**
|
|
|
|
* This can be used anytime. Ownership passes to the caller!
|
|
|
|
*/
|
2015-10-22 20:57:29 +00:00
|
|
|
nsAutoPtr<LayerUserData> RemoveUserData(void* aKey);
|
2010-09-02 09:18:39 +00:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasUserData(void* aKey)
|
2012-07-17 17:03:50 +00:00
|
|
|
{
|
2012-08-04 00:38:44 +00:00
|
|
|
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
2012-07-17 17:03:50 +00:00
|
|
|
}
|
2010-09-02 09:18:39 +00:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime. Ownership is retained by the layer
|
|
|
|
* manager.
|
|
|
|
*/
|
2013-07-02 16:27:17 +00:00
|
|
|
LayerUserData* GetUserData(void* aKey) const
|
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 09:20:52 +00:00
|
|
|
{
|
2012-07-17 17:03:50 +00:00
|
|
|
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
|
|
|
}
|
2010-05-21 03:20:48 +00:00
|
|
|
|
2010-08-20 23:24:41 +00: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 03:20:48 +00:00
|
|
|
/**
|
2014-09-26 17:07:06 +00:00
|
|
|
* Dynamic downcast to a PaintedLayer. Returns null if this is not
|
2014-09-26 17:06:08 +00:00
|
|
|
* a PaintedLayer.
|
2010-05-21 03:20:48 +00:00
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
virtual PaintedLayer* AsPaintedLayer() { return nullptr; }
|
2010-07-02 01:01:09 +00:00
|
|
|
|
2011-04-11 20:53:01 +00:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a ContainerLayer. Returns null if this is not
|
|
|
|
* a ContainerLayer.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
virtual ContainerLayer* AsContainerLayer() { return nullptr; }
|
2013-07-02 16:27:17 +00:00
|
|
|
virtual const ContainerLayer* AsContainerLayer() const { return nullptr; }
|
2011-04-11 20:53:01 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a RefLayer. Returns null if this is not a
|
|
|
|
* RefLayer.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
virtual RefLayer* AsRefLayer() { return nullptr; }
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2012-11-19 17:58:38 +00:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a Color. Returns null if this is not a
|
|
|
|
* ColorLayer.
|
|
|
|
*/
|
|
|
|
virtual ColorLayer* AsColorLayer() { return nullptr; }
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
/**
|
2013-04-25 22:25:33 +00:00
|
|
|
* Dynamic cast to a LayerComposite. Return null if this is not a
|
|
|
|
* LayerComposite. Can be used anytime.
|
2010-10-13 22:55:45 +00:00
|
|
|
*/
|
2013-04-25 22:25:33 +00:00
|
|
|
virtual LayerComposite* AsLayerComposite() { return nullptr; }
|
2010-10-13 22:55:45 +00:00
|
|
|
|
2012-03-18 23:02:38 +00:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a ShadowableLayer. Return null if this is not a
|
|
|
|
* ShadowableLayer. Can be used anytime.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
virtual ShadowableLayer* AsShadowableLayer() { return nullptr; }
|
2012-03-18 23:02:38 +00:00
|
|
|
|
2010-10-13 22:55:45 +00: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.
|
2015-04-12 02:03:00 +00:00
|
|
|
const Maybe<ParentLayerIntRect>& GetEffectiveClipRect();
|
2010-10-13 22:55:45 +00:00
|
|
|
const nsIntRegion& GetEffectiveVisibleRegion();
|
2013-09-15 03:23:46 +00:00
|
|
|
|
2015-09-17 01:31:00 +00:00
|
|
|
bool Extend3DContext() {
|
|
|
|
return GetContentFlags() & CONTENT_EXTEND_3D_CONTEXT;
|
|
|
|
}
|
2015-10-23 03:29:00 +00:00
|
|
|
bool Combines3DTransformWithAncestors() {
|
|
|
|
return GetParent() &&
|
2015-10-22 03:22:45 +00:00
|
|
|
reinterpret_cast<Layer*>(GetParent())->Extend3DContext();
|
2015-10-21 07:35:00 +00:00
|
|
|
}
|
2015-10-23 03:29:00 +00:00
|
|
|
bool Is3DContextLeaf() {
|
|
|
|
return !Extend3DContext() && Combines3DTransformWithAncestors();
|
|
|
|
}
|
2015-09-17 01:31:00 +00:00
|
|
|
/**
|
|
|
|
* It is true if the user can see the back of the layer and the
|
|
|
|
* backface is hidden. The compositor should skip the layer if the
|
|
|
|
* result is true.
|
|
|
|
*/
|
|
|
|
bool IsBackfaceHidden();
|
|
|
|
bool IsVisible() {
|
|
|
|
// For containers extending 3D context, visible region
|
|
|
|
// is meaningless, since they are just intermediate result of
|
|
|
|
// content.
|
|
|
|
return !GetEffectiveVisibleRegion().IsEmpty() || Extend3DContext();
|
|
|
|
}
|
|
|
|
|
2010-11-08 09:06:15 +00: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();
|
2014-06-19 00:04:05 +00:00
|
|
|
|
2013-09-15 03:23:46 +00:00
|
|
|
/**
|
|
|
|
* Returns the blendmode of this layer.
|
|
|
|
*/
|
2014-02-12 15:07:46 +00:00
|
|
|
gfx::CompositionOp GetEffectiveMixBlendMode();
|
2014-06-19 00:04:05 +00:00
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-01-25 01:49:19 +00:00
|
|
|
const gfx::Matrix4x4& GetEffectiveTransform() const { return mEffectiveTransform; }
|
2010-11-08 09:06:15 +00:00
|
|
|
|
2014-12-07 01:12:50 +00:00
|
|
|
/**
|
|
|
|
* This returns the effective transform for Layer's buffer computed by
|
|
|
|
* ComputeEffectiveTransforms. Typically this is a transform that transforms
|
|
|
|
* this layer's buffer 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.
|
|
|
|
*
|
|
|
|
* By default, its value is same to GetEffectiveTransform().
|
|
|
|
* When ImageLayer is rendered with ScaleMode::STRETCH,
|
|
|
|
* it becomes different from GetEffectiveTransform().
|
|
|
|
*/
|
|
|
|
virtual const gfx::Matrix4x4& GetEffectiveTransformForBuffer() const
|
|
|
|
{
|
|
|
|
return mEffectiveTransform;
|
|
|
|
}
|
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
/**
|
|
|
|
* @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 09:20:52 +00:00
|
|
|
*
|
2010-11-08 09:06:15 +00:00
|
|
|
* We promise that when this is called on a layer, all ancestor layers
|
|
|
|
* have already had ComputeEffectiveTransforms called.
|
|
|
|
*/
|
2014-01-27 15:28:04 +00:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& 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 09:20:52 +00:00
|
|
|
|
2012-02-07 22:27:44 +00:00
|
|
|
/**
|
2015-07-01 01:07:09 +00:00
|
|
|
* Computes the effective transform for mask layers, if this layer has any.
|
2012-02-07 22:27:44 +00:00
|
|
|
*/
|
2015-07-01 01:07:09 +00:00
|
|
|
void ComputeEffectiveTransformForMaskLayers(const gfx::Matrix4x4& aTransformToSurface);
|
|
|
|
static void ComputeEffectiveTransformForMaskLayer(Layer* aMaskLayer,
|
|
|
|
const gfx::Matrix4x4& aTransformToSurface);
|
2012-02-07 22:27:44 +00:00
|
|
|
|
2011-02-25 07:44:22 +00:00
|
|
|
/**
|
|
|
|
* Calculate the scissor rect required when rendering this layer.
|
2011-05-23 00:27:03 +00: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.
|
2011-02-25 07:44:22 +00:00
|
|
|
*/
|
2014-09-10 19:59:00 +00:00
|
|
|
RenderTargetIntRect CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect);
|
2010-10-13 22:55:45 +00:00
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
virtual const char* Name() const =0;
|
|
|
|
virtual LayerType GetType() const =0;
|
2010-07-02 01:01:09 +00:00
|
|
|
|
2010-03-01 07:56:18 +00: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 18:06:33 +00:00
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
2014-06-19 22:36:25 +00:00
|
|
|
* aStream.
|
2010-07-21 18:06:33 +00:00
|
|
|
*/
|
2014-06-19 22:36:25 +00:00
|
|
|
void Dump(std::stringstream& aStream, const char* aPrefix="", bool aDumpHtml=false);
|
2010-07-21 18:06:33 +00:00
|
|
|
/**
|
2014-06-19 22:36:25 +00:00
|
|
|
* Dump information about just this layer manager itself to aStream.
|
2010-07-21 18:06:33 +00:00
|
|
|
*/
|
2014-06-19 22:36:25 +00:00
|
|
|
void DumpSelf(std::stringstream& aStream, const char* aPrefix="");
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2014-07-27 20:32:00 +00:00
|
|
|
/**
|
|
|
|
* Dump information about this layer and its child & sibling layers to
|
|
|
|
* layerscope packet.
|
|
|
|
*/
|
|
|
|
void Dump(layerscope::LayersPacket* aPacket, const void* aParent);
|
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
/**
|
|
|
|
* 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="");
|
|
|
|
|
2014-06-19 22:36:25 +00:00
|
|
|
// Print interesting information about this into aStream. Internally
|
|
|
|
// used to implement Dump*() and Log*(). If subclasses have
|
2014-03-12 02:27:33 +00:00
|
|
|
// additional interesting properties, they should override this with
|
|
|
|
// an implementation that first calls the base implementation then
|
|
|
|
// appends additional info to aTo.
|
2014-06-19 22:36:25 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
2014-03-12 02:27:33 +00:00
|
|
|
|
2014-07-27 20:32:00 +00:00
|
|
|
// Just like PrintInfo, but this function dump information into layerscope packet,
|
|
|
|
// instead of a StringStream. It is also internally used to implement Dump();
|
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent);
|
|
|
|
|
2015-08-03 06:11:00 +00:00
|
|
|
/**
|
|
|
|
* Store display list log.
|
|
|
|
*/
|
|
|
|
void SetDisplayListLog(const char *log);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return display list log.
|
|
|
|
*/
|
|
|
|
void GetDisplayListLog(nsCString& log);
|
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
static bool IsLogEnabled() { return LayerManager::IsLogEnabled(); }
|
|
|
|
|
2012-08-29 05:47:18 +00:00
|
|
|
/**
|
|
|
|
* Returns the current area of the layer (in layer-space coordinates)
|
|
|
|
* marked as needed to be recomposited.
|
|
|
|
*/
|
2012-08-29 05:48:43 +00:00
|
|
|
const nsIntRegion& GetInvalidRegion() { return mInvalidRegion; }
|
2015-10-27 17:15:02 +00:00
|
|
|
const void AddInvalidRegion(const nsIntRegion& aRegion) {
|
|
|
|
mInvalidRegion.Or(mInvalidRegion, aRegion);
|
|
|
|
}
|
2012-08-29 05:47:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark the entirety of the layer's visible region as being invalid.
|
|
|
|
*/
|
2012-08-29 05:48:43 +00:00
|
|
|
void SetInvalidRectToVisibleRegion() { mInvalidRegion = GetVisibleRegion(); }
|
2012-08-29 05:47:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds to the current invalid rect.
|
|
|
|
*/
|
2015-05-07 09:07:53 +00:00
|
|
|
void AddInvalidRect(const gfx::IntRect& aRect) { mInvalidRegion.Or(mInvalidRegion, aRect); }
|
2012-08-29 05:47:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the invalid rect, marking the layer as being identical to what is currently
|
|
|
|
* composited.
|
|
|
|
*/
|
2012-08-29 05:48:43 +00:00
|
|
|
void ClearInvalidRect() { mInvalidRegion.SetEmpty(); }
|
2012-08-29 05:47:18 +00:00
|
|
|
|
2014-08-12 00:00:37 +00:00
|
|
|
// These functions allow attaching an AsyncPanZoomController to this layer,
|
|
|
|
// and can be used anytime.
|
2014-08-28 02:13:40 +00:00
|
|
|
// A layer has an APZC at index aIndex only-if GetFrameMetrics(aIndex).IsScrollable();
|
|
|
|
// attempting to get an APZC for a non-scrollable metrics will return null.
|
|
|
|
// The aIndex for these functions must be less than GetFrameMetricsCount().
|
|
|
|
void SetAsyncPanZoomController(uint32_t aIndex, AsyncPanZoomController *controller);
|
|
|
|
AsyncPanZoomController* GetAsyncPanZoomController(uint32_t aIndex) const;
|
|
|
|
// The FrameMetricsChanged function is used internally to ensure the APZC array length
|
|
|
|
// matches the frame metrics array length.
|
|
|
|
private:
|
|
|
|
void FrameMetricsChanged();
|
|
|
|
public:
|
2014-08-12 00:00:37 +00:00
|
|
|
|
2012-10-03 05:55:50 +00:00
|
|
|
void ApplyPendingUpdatesForThisTransaction();
|
2012-08-29 05:47:18 +00:00
|
|
|
|
2012-04-27 00:24:53 +00:00
|
|
|
#ifdef DEBUG
|
2012-08-22 15:56:38 +00:00
|
|
|
void SetDebugColorIndex(uint32_t aIndex) { mDebugColorIndex = aIndex; }
|
|
|
|
uint32_t GetDebugColorIndex() { return mDebugColorIndex; }
|
2012-04-27 00:24:53 +00: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 09:20:52 +00:00
|
|
|
virtual LayerRenderState GetRenderState() { return LayerRenderState(); }
|
|
|
|
|
2013-03-22 02:17:28 +00:00
|
|
|
void Mutated()
|
|
|
|
{
|
|
|
|
mManager->Mutated(this);
|
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2014-07-09 02:01:54 +00:00
|
|
|
virtual int32_t GetMaxLayerSize() { return Manager()->GetMaxTextureSize(); }
|
|
|
|
|
2014-08-04 03:29:55 +00: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();
|
|
|
|
|
2014-07-30 18:36:15 +00:00
|
|
|
RenderTargetRect TransformRectToRenderTarget(const LayerIntRect& aRect);
|
|
|
|
|
2014-08-22 15:53:24 +00:00
|
|
|
/**
|
|
|
|
* Add debugging information to the layer dump.
|
|
|
|
*/
|
|
|
|
void AddExtraDumpInfo(const nsACString& aStr)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
mExtraDumpInfo.AppendElement(aStr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear debugging information. Useful for recycling.
|
|
|
|
*/
|
|
|
|
void ClearExtraDumpInfo()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
mExtraDumpInfo.Clear();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-05-19 17:56:31 +00:00
|
|
|
/**
|
|
|
|
* Replace the current effective transform with the given one,
|
|
|
|
* returning the old one. This is currently added as a hack for VR
|
|
|
|
* rendering, and might go away if we find a better way to do this.
|
|
|
|
* If you think you have a need for this method, talk with
|
|
|
|
* vlad/mstange/mwoodrow first.
|
|
|
|
*/
|
|
|
|
virtual gfx::Matrix4x4 ReplaceEffectiveTransform(const gfx::Matrix4x4& aNewEffectiveTransform) {
|
|
|
|
gfx::Matrix4x4 old = mEffectiveTransform;
|
|
|
|
mEffectiveTransform = aNewEffectiveTransform;
|
2015-07-02 15:58:24 +00:00
|
|
|
ComputeEffectiveTransformForMaskLayers(mEffectiveTransform);
|
2015-05-19 17:56:31 +00:00
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2014-02-11 04:01:49 +00:00
|
|
|
protected:
|
|
|
|
Layer(LayerManager* aManager, void* aImplData);
|
|
|
|
|
2014-04-04 16:27:02 +00:00
|
|
|
// Protected destructor, to discourage deletion outside of Release():
|
|
|
|
virtual ~Layer();
|
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
/**
|
2012-12-06 23:58:13 +00: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.
|
|
|
|
*/
|
2014-01-27 15:27:20 +00:00
|
|
|
gfx::Matrix4x4 SnapTransformTranslation(const gfx::Matrix4x4& aTransform,
|
|
|
|
gfx::Matrix* aResidualTransform);
|
2012-12-06 23:58:13 +00:00
|
|
|
/**
|
|
|
|
* 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 09:06:15 +00:00
|
|
|
* @param aSnapRect a rectangle whose edges should be snapped to pixel
|
2012-12-06 23:58:13 +00: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 09:06:15 +00:00
|
|
|
*/
|
2014-01-27 15:27:20 +00:00
|
|
|
gfx::Matrix4x4 SnapTransform(const gfx::Matrix4x4& aTransform,
|
|
|
|
const gfxRect& aSnapRect,
|
|
|
|
gfx::Matrix* aResidualTransform);
|
2010-11-08 09:06:15 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
LayerManager* mManager;
|
|
|
|
ContainerLayer* mParent;
|
|
|
|
Layer* mNextSibling;
|
|
|
|
Layer* mPrevSibling;
|
|
|
|
void* mImplData;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<Layer> mMaskLayer;
|
|
|
|
nsTArray<RefPtr<Layer>> mAncestorMaskLayers;
|
2012-07-17 17:03:50 +00:00
|
|
|
gfx::UserData mUserData;
|
2015-05-07 09:07:53 +00:00
|
|
|
gfx::IntRect mLayerBounds;
|
2010-05-31 23:29:37 +00:00
|
|
|
nsIntRegion mVisibleRegion;
|
2014-08-28 02:13:40 +00:00
|
|
|
nsTArray<FrameMetrics> mFrameMetrics;
|
2013-12-16 10:47:06 +00:00
|
|
|
EventRegions mEventRegions;
|
2014-01-27 15:29:06 +00:00
|
|
|
gfx::Matrix4x4 mTransform;
|
2012-10-03 05:55:50 +00: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).
|
2014-01-27 15:29:06 +00:00
|
|
|
nsAutoPtr<gfx::Matrix4x4> mPendingTransform;
|
2012-08-03 21:29:22 +00:00
|
|
|
float mPostXScale;
|
|
|
|
float mPostYScale;
|
2014-01-25 01:49:19 +00:00
|
|
|
gfx::Matrix4x4 mEffectiveTransform;
|
2012-07-31 17:28:20 +00:00
|
|
|
AnimationArray mAnimations;
|
2014-03-05 04:13:21 +00:00
|
|
|
// See mPendingTransform above.
|
|
|
|
nsAutoPtr<AnimationArray> mPendingAnimations;
|
2012-07-31 17:28:20 +00:00
|
|
|
InfallibleTArray<AnimData> mAnimationData;
|
2010-03-01 07:56:18 +00:00
|
|
|
float mOpacity;
|
2014-02-12 15:07:46 +00:00
|
|
|
gfx::CompositionOp mMixBlendMode;
|
2013-09-15 03:30:00 +00:00
|
|
|
bool mForceIsolatedGroup;
|
2015-04-12 02:03:00 +00:00
|
|
|
Maybe<ParentLayerIntRect> mClipRect;
|
2015-05-07 09:07:53 +00:00
|
|
|
gfx::IntRect mTileSourceRect;
|
2012-08-29 05:48:43 +00:00
|
|
|
nsIntRegion mInvalidRegion;
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<AsyncPanZoomController> > mApzcs;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mContentFlags;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mUseTileSourceRect;
|
|
|
|
bool mIsFixedPosition;
|
2015-08-17 23:44:42 +00:00
|
|
|
struct FixedPositionData {
|
|
|
|
FrameMetrics::ViewID mScrollId;
|
|
|
|
LayerPoint mAnchor;
|
2015-09-04 21:26:33 +00:00
|
|
|
bool mIsClipFixed;
|
2015-08-17 23:44:42 +00:00
|
|
|
};
|
|
|
|
UniquePtr<FixedPositionData> mFixedPositionData;
|
2013-09-12 04:17:58 +00:00
|
|
|
struct StickyPositionData {
|
|
|
|
FrameMetrics::ViewID mScrollId;
|
|
|
|
LayerRect mOuter;
|
|
|
|
LayerRect mInner;
|
|
|
|
};
|
|
|
|
nsAutoPtr<StickyPositionData> mStickyPositionData;
|
2013-12-10 03:14:53 +00:00
|
|
|
FrameMetrics::ViewID mScrollbarTargetId;
|
|
|
|
ScrollDirection mScrollbarDirection;
|
2015-04-29 11:22:27 +00:00
|
|
|
// The scrollbar thumb ratio is the ratio of the thumb position (in the CSS
|
|
|
|
// pixels of the scrollframe's parent's space) to the scroll position (in the
|
|
|
|
// CSS pixels of the scrollframe's space).
|
|
|
|
float mScrollbarThumbRatio;
|
2015-01-14 07:55:17 +00:00
|
|
|
bool mIsScrollbarContainer;
|
2012-08-22 15:56:38 +00:00
|
|
|
DebugOnly<uint32_t> mDebugColorIndex;
|
2012-12-11 21:12:43 +00: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;
|
2014-08-22 15:53:24 +00:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
nsTArray<nsCString> mExtraDumpInfo;
|
|
|
|
#endif
|
2015-08-03 06:11:00 +00:00
|
|
|
// Store display list log.
|
|
|
|
nsCString mDisplayListLog;
|
2010-03-01 07:56:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-09-26 17:07:06 +00:00
|
|
|
* A Layer which we can paint into. It is a conceptually
|
2014-09-26 17:06:08 +00:00
|
|
|
* infinite surface, but each PaintedLayer has an associated "valid region"
|
|
|
|
* of contents that it is currently storing, which is finite. PaintedLayer
|
2010-03-01 07:56:18 +00:00
|
|
|
* 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 09:20:52 +00:00
|
|
|
*
|
2014-09-26 17:06:08 +00:00
|
|
|
* PaintedLayers are rendered into during the drawing phase of a transaction.
|
2010-03-01 07:56:18 +00:00
|
|
|
*
|
2014-09-26 17:06:08 +00:00
|
|
|
* Currently the contents of a PaintedLayer are in the device output color
|
2010-03-01 07:56:18 +00:00
|
|
|
* space.
|
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
class PaintedLayer : public Layer {
|
2010-03-01 07:56:18 +00:00
|
|
|
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 12:11:28 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set whether ComputeEffectiveTransforms should compute the
|
|
|
|
* "residual translation" --- the translation that should be applied *before*
|
2014-09-26 17:06:08 +00:00
|
|
|
* mEffectiveTransform to get the ideal transform for this PaintedLayer.
|
2011-06-22 12:11:28 +00:00
|
|
|
* 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 07:56:18 +00:00
|
|
|
|
2010-05-31 23:29:37 +00:00
|
|
|
/**
|
|
|
|
* Can be used anytime
|
|
|
|
*/
|
2010-09-03 20:10:46 +00:00
|
|
|
const nsIntRegion& GetValidRegion() const { return mValidRegion; }
|
2010-05-31 23:29:37 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual PaintedLayer* AsPaintedLayer() override { return this; }
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2014-09-26 17:07:06 +00:00
|
|
|
MOZ_LAYER_DECL_NAME("PaintedLayer", TYPE_PAINTED)
|
2010-07-02 01:01:09 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
2010-11-08 09:06:15 +00:00
|
|
|
{
|
2014-01-27 15:28:18 +00:00
|
|
|
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
2014-01-27 15:27:20 +00:00
|
|
|
gfx::Matrix residual;
|
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform,
|
2012-07-30 14:20:58 +00:00
|
|
|
mAllowResidualTranslation ? &residual : nullptr);
|
2012-12-06 23:58:13 +00:00
|
|
|
// The residual can only be a translation because SnapTransformTranslation
|
|
|
|
// only changes the transform if it's a translation
|
2014-01-27 15:27:20 +00:00
|
|
|
NS_ASSERTION(residual.IsTranslation(),
|
2011-06-22 12:11:28 +00:00
|
|
|
"Residual transform can only be a translation");
|
2014-01-27 15:27:20 +00:00
|
|
|
if (!gfx::ThebesPoint(residual.GetTranslation()).WithinEpsilonOf(mResidualTranslation, 1e-3f)) {
|
|
|
|
mResidualTranslation = gfx::ThebesPoint(residual.GetTranslation());
|
2015-09-17 01:31:00 +00:00
|
|
|
DebugOnly<mozilla::gfx::Point> transformedOrig =
|
|
|
|
idealTransform * mozilla::gfx::Point();
|
|
|
|
#ifdef DEBUG
|
|
|
|
DebugOnly<mozilla::gfx::Point> transformed =
|
|
|
|
idealTransform * mozilla::gfx::Point(mResidualTranslation.x,
|
|
|
|
mResidualTranslation.y) -
|
|
|
|
*&transformedOrig;
|
|
|
|
#endif
|
|
|
|
NS_ASSERTION(-0.5 <= (&transformed)->x && (&transformed)->x < 0.5 &&
|
|
|
|
-0.5 <= (&transformed)->y && (&transformed)->y < 0.5,
|
|
|
|
"Residual translation out of range");
|
2011-06-22 12:11:28 +00:00
|
|
|
mValidRegion.SetEmpty();
|
|
|
|
}
|
2015-07-01 01:07:09 +00:00
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
2010-11-08 09:06:15 +00:00
|
|
|
}
|
|
|
|
|
2014-09-26 17:06:08 +00:00
|
|
|
LayerManager::PaintedLayerCreationHint GetCreationHint() const { return mCreationHint; }
|
2014-06-13 16:11:08 +00:00
|
|
|
|
2011-02-16 22:43:30 +00:00
|
|
|
bool UsedForReadback() { return mUsedForReadback; }
|
|
|
|
void SetUsedForReadback(bool aUsed) { mUsedForReadback = aUsed; }
|
2015-07-29 16:03:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if aLayer is optimized for the given PaintedLayerCreationHint.
|
|
|
|
*/
|
|
|
|
virtual bool IsOptimizedFor(LayerManager::PaintedLayerCreationHint aCreationHint)
|
|
|
|
{ return true; }
|
|
|
|
|
2011-06-22 12:11:28 +00:00
|
|
|
/**
|
|
|
|
* Returns the residual translation. Apply this translation when drawing
|
2014-09-26 17:06:08 +00:00
|
|
|
* into the PaintedLayer so that when mEffectiveTransform is applied afterwards
|
2011-06-22 12:11:28 +00:00
|
|
|
* 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-16 22:43:30 +00:00
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
protected:
|
2014-09-26 17:06:08 +00:00
|
|
|
PaintedLayer(LayerManager* aManager, void* aImplData,
|
|
|
|
LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE)
|
2010-09-03 20:10:46 +00:00
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mValidRegion()
|
2014-06-13 16:11:08 +00:00
|
|
|
, mCreationHint(aCreationHint)
|
2011-02-16 22:43:30 +00:00
|
|
|
, mUsedForReadback(false)
|
2011-06-22 12:11:28 +00:00
|
|
|
, mAllowResidualTranslation(false)
|
2010-12-20 01:26:14 +00:00
|
|
|
{
|
|
|
|
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
|
|
|
|
}
|
2010-05-31 23:29:37 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-27 20:32:00 +00:00
|
|
|
|
2011-06-22 12:11:28 +00: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-05-31 23:29:37 +00:00
|
|
|
nsIntRegion mValidRegion;
|
2014-06-13 16:11:08 +00:00
|
|
|
/**
|
|
|
|
* The creation hint that was used when constructing this layer.
|
|
|
|
*/
|
2014-09-26 17:06:08 +00:00
|
|
|
const LayerManager::PaintedLayerCreationHint mCreationHint;
|
2011-02-16 22:43:30 +00:00
|
|
|
/**
|
2014-09-26 17:06:08 +00:00
|
|
|
* Set when this PaintedLayer is participating in readback, i.e. some
|
2011-02-16 22:43:30 +00:00
|
|
|
* ReadbackLayer (may) be getting its background from this layer.
|
|
|
|
*/
|
|
|
|
bool mUsedForReadback;
|
2011-06-22 12:11:28 +00:00
|
|
|
/**
|
|
|
|
* True when
|
|
|
|
*/
|
|
|
|
bool mAllowResidualTranslation;
|
2010-03-01 07:56:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A Layer which other layers render into. It holds references to its
|
|
|
|
* children.
|
|
|
|
*/
|
2013-05-29 21:59:24 +00:00
|
|
|
class ContainerLayer : public Layer {
|
2010-03-01 07:56:18 +00:00
|
|
|
public:
|
2013-07-02 16:01:46 +00:00
|
|
|
|
|
|
|
~ContainerLayer();
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-02-21 21:50:25 +00:00
|
|
|
virtual bool InsertAfter(Layer* aChild, Layer* aAfter);
|
2010-03-01 07:56:18 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Remove aChild from the child list of this container. aChild must
|
|
|
|
* be a child of this container.
|
|
|
|
*/
|
2014-02-21 21:50:25 +00:00
|
|
|
virtual bool RemoveChild(Layer* aChild);
|
2012-08-29 10:52:55 +00: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.
|
|
|
|
*/
|
2014-02-21 21:50:25 +00:00
|
|
|
virtual bool RepositionChild(Layer* aChild, Layer* aAfter);
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2012-08-03 21:29:22 +00:00
|
|
|
void SetPreScale(float aXScale, float aYScale)
|
|
|
|
{
|
2012-11-02 07:13:08 +00:00
|
|
|
if (mPreXScale == aXScale && mPreYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
2013-01-08 09:39:12 +00:00
|
|
|
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PreScale", this));
|
2012-08-03 21:29:22 +00:00
|
|
|
mPreXScale = aXScale;
|
|
|
|
mPreYScale = aYScale;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2013-01-08 09:39:12 +00: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 09:20:52 +00:00
|
|
|
{
|
2013-01-08 09:39:12 +00:00
|
|
|
if (mInheritedXScale == aXScale && mInheritedYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) InheritedScale", this));
|
2013-01-08 09:39:12 +00:00
|
|
|
mInheritedXScale = aXScale;
|
|
|
|
mInheritedYScale = aYScale;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2015-01-03 01:06:14 +00:00
|
|
|
void SetScaleToResolution(bool aScaleToResolution, float aResolution)
|
|
|
|
{
|
|
|
|
if (mScaleToResolution == aScaleToResolution && mPresShellResolution == aResolution) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ScaleToResolution", this));
|
|
|
|
mScaleToResolution = aScaleToResolution;
|
|
|
|
mPresShellResolution = aResolution;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override;
|
2011-08-09 19:38:26 +00:00
|
|
|
|
2011-10-06 21:23:18 +00:00
|
|
|
void SortChildrenBy3DZOrder(nsTArray<Layer*>& aArray);
|
|
|
|
|
2010-09-03 20:10:45 +00:00
|
|
|
// These getters can be used anytime.
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual ContainerLayer* AsContainerLayer() override { return this; }
|
|
|
|
virtual const ContainerLayer* AsContainerLayer() const override { return this; }
|
2013-07-02 16:27:17 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual Layer* GetFirstChild() const override { return mFirstChild; }
|
|
|
|
virtual Layer* GetLastChild() const override { return mLastChild; }
|
2013-07-02 16:27:17 +00:00
|
|
|
float GetPreXScale() const { return mPreXScale; }
|
|
|
|
float GetPreYScale() const { return mPreYScale; }
|
|
|
|
float GetInheritedXScale() const { return mInheritedXScale; }
|
|
|
|
float GetInheritedYScale() const { return mInheritedYScale; }
|
2015-01-03 01:06:14 +00:00
|
|
|
float GetPresShellResolution() const { return mPresShellResolution; }
|
|
|
|
bool ScaleToResolution() const { return mScaleToResolution; }
|
2014-07-11 20:45:22 +00:00
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
MOZ_LAYER_DECL_NAME("ContainerLayer", TYPE_CONTAINER)
|
2010-07-02 01:01:09 +00:00
|
|
|
|
2010-11-08 09:06:15 +00: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.
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override = 0;
|
2010-11-08 09:06:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 06:19:26 +00:00
|
|
|
bool UseIntermediateSurface() { return mUseIntermediateSurface; }
|
2010-11-08 09:06:15 +00:00
|
|
|
|
2011-05-23 00:27:03 +00:00
|
|
|
/**
|
|
|
|
* Returns the rectangle covered by the intermediate surface,
|
2014-07-30 18:36:15 +00:00
|
|
|
* in this layer's coordinate system.
|
|
|
|
*
|
|
|
|
* NOTE: Since this layer has an intermediate surface it follows
|
|
|
|
* that LayerPixel == RenderTargetPixel
|
2011-05-23 00:27:03 +00:00
|
|
|
*/
|
2014-07-30 18:36:15 +00:00
|
|
|
RenderTargetIntRect GetIntermediateSurfaceRect()
|
2011-05-23 00:27:03 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mUseIntermediateSurface, "Must have intermediate surface");
|
2014-07-30 18:36:15 +00:00
|
|
|
return RenderTargetPixel::FromUntyped(mVisibleRegion.GetBounds());
|
2011-05-23 00:27:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this container has more than one non-empty child
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasMultipleChildren();
|
2010-11-08 09:06:15 +00:00
|
|
|
|
2011-01-03 01:48:09 +00: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 06:19:26 +00:00
|
|
|
bool SupportsComponentAlphaChildren() { return mSupportsComponentAlphaChildren; }
|
2011-01-03 01:48:09 +00:00
|
|
|
|
2014-04-16 17:56:52 +00:00
|
|
|
/**
|
|
|
|
* Returns true if aLayer or any layer in its parent chain has the opaque
|
|
|
|
* content flag set.
|
|
|
|
*/
|
|
|
|
static bool HasOpaqueAncestorLayer(Layer* aLayer);
|
|
|
|
|
2014-11-18 22:33:36 +00:00
|
|
|
void SetChildrenChanged(bool aVal) {
|
|
|
|
mChildrenChanged = aVal;
|
|
|
|
}
|
|
|
|
|
2015-02-17 02:30:02 +00:00
|
|
|
void SetEventRegionsOverride(EventRegionsOverride aVal) {
|
|
|
|
if (mEventRegionsOverride == aVal) {
|
2015-02-10 21:28:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-17 02:30:02 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) EventRegionsOverride", this));
|
|
|
|
mEventRegionsOverride = aVal;
|
2015-02-10 21:28:07 +00:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2015-02-17 02:30:02 +00:00
|
|
|
EventRegionsOverride GetEventRegionsOverride() const {
|
|
|
|
return mEventRegionsOverride;
|
2015-02-10 21:28:07 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 19:26:18 +00:00
|
|
|
/**
|
|
|
|
* VR
|
|
|
|
*/
|
|
|
|
void SetVRHMDInfo(gfx::VRHMDInfo* aHMD) { mHMDInfo = aHMD; }
|
|
|
|
gfx::VRHMDInfo* GetVRHMDInfo() { return mHMDInfo; }
|
|
|
|
|
2015-05-19 17:56:31 +00:00
|
|
|
/**
|
|
|
|
* Replace the current effective transform with the given one,
|
|
|
|
* returning the old one. This is currently added as a hack for VR
|
|
|
|
* rendering, and might go away if we find a better way to do this.
|
|
|
|
* If you think you have a need for this method, talk with
|
|
|
|
* vlad/mstange/mwoodrow first.
|
|
|
|
*/
|
|
|
|
gfx::Matrix4x4 ReplaceEffectiveTransform(const gfx::Matrix4x4& aNewEffectiveTransform) override {
|
|
|
|
gfx::Matrix4x4 old = mEffectiveTransform;
|
|
|
|
mEffectiveTransform = aNewEffectiveTransform;
|
|
|
|
ComputeEffectiveTransformsForChildren(mEffectiveTransform);
|
2015-07-02 15:58:24 +00:00
|
|
|
ComputeEffectiveTransformForMaskLayers(mEffectiveTransform);
|
2015-05-19 17:56:31 +00:00
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
protected:
|
2011-02-16 22:43:30 +00:00
|
|
|
friend class ReadbackProcessor;
|
|
|
|
|
|
|
|
void DidInsertChild(Layer* aLayer);
|
|
|
|
void DidRemoveChild(Layer* aLayer);
|
|
|
|
|
2015-09-17 01:31:00 +00:00
|
|
|
void Collect3DContextLeaves(nsTArray<Layer*>& aToSort);
|
|
|
|
|
2013-07-02 16:01:46 +00:00
|
|
|
ContainerLayer(LayerManager* aManager, void* aImplData);
|
2010-03-01 07:56:18 +00:00
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
/**
|
|
|
|
* A default implementation of ComputeEffectiveTransforms for use by OpenGL
|
|
|
|
* and D3D.
|
|
|
|
*/
|
2014-01-27 15:28:04 +00:00
|
|
|
void DefaultComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface);
|
2010-11-08 09:06:15 +00:00
|
|
|
|
2014-05-09 10:06:20 +00:00
|
|
|
/**
|
|
|
|
* A default implementation to compute and set the value for SupportsComponentAlphaChildren().
|
|
|
|
*
|
|
|
|
* If aNeedsSurfaceCopy is provided, then it is set to true if the caller needs to copy the background
|
|
|
|
* up into the intermediate surface created, false otherwise.
|
|
|
|
*/
|
|
|
|
void DefaultComputeSupportsComponentAlphaChildren(bool* aNeedsSurfaceCopy = nullptr);
|
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
/**
|
|
|
|
* Loops over the children calling ComputeEffectiveTransforms on them.
|
|
|
|
*/
|
2014-01-27 15:28:04 +00:00
|
|
|
void ComputeEffectiveTransformsForChildren(const gfx::Matrix4x4& aTransformToSurface);
|
2010-11-08 09:06:15 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-09-03 20:10:45 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-27 20:32:00 +00:00
|
|
|
|
2015-09-17 01:31:00 +00:00
|
|
|
/**
|
|
|
|
* True for if the container start a new 3D context extended by one
|
|
|
|
* or more children.
|
|
|
|
*/
|
|
|
|
bool Creates3DContextWithExtendingChildren();
|
|
|
|
|
2010-03-01 07:56:18 +00:00
|
|
|
Layer* mFirstChild;
|
2010-11-16 23:33:56 +00:00
|
|
|
Layer* mLastChild;
|
2012-08-03 21:29:22 +00:00
|
|
|
float mPreXScale;
|
|
|
|
float mPreYScale;
|
2013-01-08 09:39:12 +00:00
|
|
|
// The resolution scale inherited from the parent layer. This will already
|
|
|
|
// be part of mTransform.
|
|
|
|
float mInheritedXScale;
|
|
|
|
float mInheritedYScale;
|
2015-01-03 01:06:14 +00:00
|
|
|
// For layers corresponding to an nsDisplayResolution, the resolution of the
|
|
|
|
// associated pres shell; for other layers, 1.0.
|
|
|
|
float mPresShellResolution;
|
|
|
|
// Whether the compositor should scale to mPresShellResolution.
|
|
|
|
bool mScaleToResolution;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mUseIntermediateSurface;
|
|
|
|
bool mSupportsComponentAlphaChildren;
|
|
|
|
bool mMayHaveReadbackChild;
|
2014-11-18 22:33:36 +00:00
|
|
|
// This is updated by ComputeDifferences. This will be true if we need to invalidate
|
|
|
|
// the intermediate surface.
|
|
|
|
bool mChildrenChanged;
|
2015-02-17 02:30:02 +00:00
|
|
|
EventRegionsOverride mEventRegionsOverride;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfx::VRHMDInfo> mHMDInfo;
|
2010-03-01 07:56:18 +00:00
|
|
|
};
|
|
|
|
|
2010-05-13 00:56:11 +00:00
|
|
|
/**
|
2010-05-13 00:56:11 +00: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 00:56:11 +00:00
|
|
|
*/
|
2013-05-29 21:59:24 +00:00
|
|
|
class ColorLayer : public Layer {
|
2010-05-13 00:56:11 +00:00
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual ColorLayer* AsColorLayer() override { return this; }
|
2012-11-19 17:58:38 +00:00
|
|
|
|
2010-05-13 00:56:11 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the color of the layer.
|
|
|
|
*/
|
2015-09-25 01:16:45 +00:00
|
|
|
virtual void SetColor(const gfx::Color& aColor)
|
2010-05-13 00:56:11 +00:00
|
|
|
{
|
2013-03-28 10:58:45 +00:00
|
|
|
if (mColor != aColor) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Color", this));
|
|
|
|
mColor = aColor;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-05-13 00:56:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-07 09:07:53 +00:00
|
|
|
void SetBounds(const gfx::IntRect& aBounds)
|
2013-07-09 14:11:00 +00:00
|
|
|
{
|
|
|
|
if (!mBounds.IsEqualEdges(aBounds)) {
|
|
|
|
mBounds = aBounds;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 09:07:53 +00:00
|
|
|
const gfx::IntRect& GetBounds()
|
2013-07-09 14:11:00 +00:00
|
|
|
{
|
|
|
|
return mBounds;
|
|
|
|
}
|
|
|
|
|
2010-05-13 00:56:11 +00:00
|
|
|
// This getter can be used anytime.
|
2015-09-25 01:16:45 +00:00
|
|
|
virtual const gfx::Color& GetColor() { return mColor; }
|
2010-05-13 00:56:11 +00:00
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
MOZ_LAYER_DECL_NAME("ColorLayer", TYPE_COLOR)
|
2010-07-02 01:01:09 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
2010-11-08 09:06:15 +00:00
|
|
|
{
|
2014-01-27 15:28:18 +00:00
|
|
|
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
2014-01-27 15:27:20 +00:00
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, nullptr);
|
2015-07-01 01:07:09 +00:00
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
2010-11-08 09:06:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-13 00:56:11 +00:00
|
|
|
protected:
|
|
|
|
ColorLayer(LayerManager* aManager, void* aImplData)
|
2015-09-25 01:16:45 +00:00
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mColor()
|
2010-05-13 00:56:11 +00:00
|
|
|
{}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-27 20:32:00 +00:00
|
|
|
|
2015-05-07 09:07:53 +00:00
|
|
|
gfx::IntRect mBounds;
|
2015-09-25 01:16:45 +00:00
|
|
|
gfx::Color mColor;
|
2010-05-13 00:56:11 +00:00
|
|
|
};
|
|
|
|
|
2010-05-18 04:04:22 +00: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.
|
|
|
|
*/
|
2013-05-29 21:59:24 +00:00
|
|
|
class CanvasLayer : public Layer {
|
2010-05-18 04:04:22 +00:00
|
|
|
public:
|
|
|
|
struct Data {
|
|
|
|
Data()
|
2015-06-18 23:07:22 +00:00
|
|
|
: mBufferProvider(nullptr)
|
2013-02-13 23:26:24 +00:00
|
|
|
, mGLContext(nullptr)
|
2015-10-12 03:21:03 +00:00
|
|
|
, mRenderer(nullptr)
|
2014-10-08 04:15:39 +00:00
|
|
|
, mFrontbufferGLTex(0)
|
2013-02-13 23:26:24 +00:00
|
|
|
, mSize(0,0)
|
2014-05-14 16:26:13 +00:00
|
|
|
, mHasAlpha(false)
|
2014-06-19 00:04:06 +00:00
|
|
|
, mIsGLAlphaPremult(true)
|
2010-05-18 04:04:22 +00:00
|
|
|
{ }
|
|
|
|
|
2015-10-12 03:21:03 +00:00
|
|
|
// One of these three must be specified for Canvas2D, but never more than one
|
2015-06-18 23:07:21 +00:00
|
|
|
PersistentBufferProvider* mBufferProvider; // A BufferProvider for the Canvas contents
|
2014-02-06 14:46:30 +00:00
|
|
|
mozilla::gl::GLContext* mGLContext; // or this, for GL.
|
2015-10-12 03:21:03 +00:00
|
|
|
AsyncCanvasRenderer* mRenderer; // or this, for OffscreenCanvas
|
2013-02-13 23:26:24 +00:00
|
|
|
|
2014-10-08 04:15:39 +00:00
|
|
|
// Frontbuffer override
|
|
|
|
uint32_t mFrontbufferGLTex;
|
2014-03-05 21:49:37 +00:00
|
|
|
|
2013-02-13 23:26:24 +00:00
|
|
|
// The size of the canvas content
|
2015-06-03 11:45:24 +00:00
|
|
|
gfx::IntSize mSize;
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2014-05-14 16:26:13 +00:00
|
|
|
// Whether the canvas drawingbuffer has an alpha channel.
|
|
|
|
bool mHasAlpha;
|
|
|
|
|
2013-02-13 23:26:24 +00:00
|
|
|
// Whether mGLContext contains data that is alpha-premultiplied.
|
|
|
|
bool mIsGLAlphaPremult;
|
2010-05-18 04:04:22 +00: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;
|
|
|
|
|
2013-12-04 22:46:20 +00:00
|
|
|
/**
|
|
|
|
* Check the data is owned by this layer is still valid for rendering
|
|
|
|
*/
|
|
|
|
virtual bool IsDataValid(const Data& aData) { return true; }
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
/**
|
2011-03-27 23:59:46 +00:00
|
|
|
* Notify this CanvasLayer that the canvas surface contents have
|
|
|
|
* changed (or will change) before the next transaction.
|
2010-05-18 04:04:22 +00:00
|
|
|
*/
|
2012-08-29 05:47:18 +00:00
|
|
|
void Updated() { mDirty = true; SetInvalidRectToVisibleRegion(); }
|
2011-03-27 23:59:46 +00:00
|
|
|
|
2012-09-30 06:20:25 +00: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 09:20:52 +00:00
|
|
|
bool IsDirty()
|
|
|
|
{
|
2012-09-30 06:20:25 +00: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 09:20:52 +00:00
|
|
|
return mDirty;
|
2012-09-30 06:20:25 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 23:26:24 +00: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;
|
|
|
|
}
|
|
|
|
|
2015-07-02 15:58:24 +00:00
|
|
|
const nsIntRect& GetBounds() const { return mBounds; }
|
|
|
|
|
2013-02-13 23:26:24 +00:00
|
|
|
protected:
|
|
|
|
void FirePreTransactionCallback()
|
|
|
|
{
|
|
|
|
if (mPreTransCallback) {
|
|
|
|
mPreTransCallback(mPreTransCallbackData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2011-03-27 23:59:46 +00: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-13 23:26:24 +00:00
|
|
|
mPostTransCallback = aCallback;
|
|
|
|
mPostTransCallbackData = aClosureData;
|
2011-03-27 23:59:46 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the filter used to resample this image (if necessary).
|
|
|
|
*/
|
2015-10-06 00:18:10 +00:00
|
|
|
void SetFilter(gfx::Filter aFilter)
|
2013-03-28 10:58:45 +00:00
|
|
|
{
|
|
|
|
if (mFilter != aFilter) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
|
|
|
|
mFilter = aFilter;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2015-10-06 00:18:10 +00:00
|
|
|
gfx::Filter GetFilter() const { return mFilter; }
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2010-07-21 18:06:33 +00:00
|
|
|
MOZ_LAYER_DECL_NAME("CanvasLayer", TYPE_CANVAS)
|
2010-07-02 01:01:09 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
2010-11-08 09:06:15 +00:00
|
|
|
{
|
|
|
|
// Snap our local transform first, and snap the inherited transform as well.
|
|
|
|
// This makes our snapping equivalent to what would happen if our content
|
2014-09-26 17:06:08 +00:00
|
|
|
// was drawn into a PaintedLayer (gfxContext would snap using the local
|
|
|
|
// transform, then we'd snap again when compositing the PaintedLayer).
|
2014-01-27 15:27:20 +00:00
|
|
|
mEffectiveTransform =
|
2014-01-27 15:28:18 +00:00
|
|
|
SnapTransform(GetLocalTransform(), gfxRect(0, 0, mBounds.width, mBounds.height),
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr)*
|
2014-01-27 15:28:04 +00:00
|
|
|
SnapTransformTranslation(aTransformToSurface, nullptr);
|
2015-07-01 01:07:09 +00:00
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
2010-11-08 09:06:15 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 03:21:02 +00:00
|
|
|
bool GetIsAsyncRenderer() const
|
|
|
|
{
|
|
|
|
return !!mAsyncRenderer;
|
|
|
|
}
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
protected:
|
2015-10-12 03:21:02 +00:00
|
|
|
CanvasLayer(LayerManager* aManager, void* aImplData);
|
|
|
|
virtual ~CanvasLayer();
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-27 20:32:00 +00:00
|
|
|
|
2011-03-27 23:59:46 +00:00
|
|
|
void FireDidTransactionCallback()
|
|
|
|
{
|
2013-02-13 23:26:24 +00:00
|
|
|
if (mPostTransCallback) {
|
|
|
|
mPostTransCallback(mPostTransCallbackData);
|
2011-03-27 23:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
/**
|
|
|
|
* 0, 0, canvaswidth, canvasheight
|
|
|
|
*/
|
2015-05-07 09:07:53 +00:00
|
|
|
gfx::IntRect mBounds;
|
2013-02-13 23:26:24 +00:00
|
|
|
PreTransactionCallback* mPreTransCallback;
|
|
|
|
void* mPreTransCallbackData;
|
|
|
|
DidTransactionCallback mPostTransCallback;
|
|
|
|
void* mPostTransCallbackData;
|
2015-10-06 00:18:10 +00:00
|
|
|
gfx::Filter mFilter;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<AsyncCanvasRenderer> mAsyncRenderer;
|
2012-09-30 06:20:25 +00:00
|
|
|
|
|
|
|
private:
|
2011-03-27 23:59:46 +00:00
|
|
|
/**
|
|
|
|
* Set to true in Updated(), cleared during a transaction.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDirty;
|
2010-05-18 04:04:22 +00:00
|
|
|
};
|
|
|
|
|
2012-07-17 23:59:45 +00: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.
|
|
|
|
*/
|
2013-05-29 21:59:24 +00:00
|
|
|
class RefLayer : public ContainerLayer {
|
2012-07-17 23:59:45 +00:00
|
|
|
friend class LayerManager;
|
|
|
|
|
|
|
|
private:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool InsertAfter(Layer* aChild, Layer* aAfter) override
|
2014-02-21 21:50:25 +00:00
|
|
|
{ MOZ_CRASH(); return false; }
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool RemoveChild(Layer* aChild) override
|
2014-02-21 21:50:25 +00:00
|
|
|
{ MOZ_CRASH(); return false; }
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool RepositionChild(Layer* aChild, Layer* aAfter) override
|
2014-02-21 21:50:25 +00:00
|
|
|
{ MOZ_CRASH(); return false; }
|
2012-08-29 10:52:55 +00:00
|
|
|
|
2014-08-12 00:00:36 +00:00
|
|
|
using Layer::SetFrameMetrics;
|
2012-07-17 23:59:45 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the ID of the layer's referent.
|
|
|
|
*/
|
|
|
|
void SetReferentId(uint64_t aId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aId != 0);
|
2012-08-07 03:00:41 +00:00
|
|
|
if (mId != aId) {
|
2013-03-22 02:17:28 +00:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ReferentId", this));
|
2012-08-07 03:00:41 +00:00
|
|
|
mId = aId;
|
|
|
|
Mutated();
|
|
|
|
}
|
2012-07-17 23:59:45 +00: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());
|
2014-10-14 22:11:38 +00:00
|
|
|
if (aLayer->Manager() != Manager()) {
|
|
|
|
// This can happen when e.g. rendering while dragging tabs
|
|
|
|
// between windows - aLayer's manager may be the manager for the
|
|
|
|
// old window's tab. In that case, it will be changed before the
|
|
|
|
// next render (see SetLayerManager). It is simply easier to
|
|
|
|
// ignore the rendering here than it is to pause it.
|
|
|
|
NS_WARNING("ConnectReferentLayer failed - Incorrect LayerManager");
|
|
|
|
return;
|
|
|
|
}
|
2012-07-17 23:59:45 +00:00
|
|
|
|
|
|
|
mFirstChild = mLastChild = aLayer;
|
|
|
|
aLayer->SetParent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
* |aLayer| is the same as the argument to ConnectReferentLayer().
|
|
|
|
*/
|
|
|
|
void DetachReferentLayer(Layer* aLayer)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
mFirstChild = mLastChild = nullptr;
|
|
|
|
aLayer->SetParent(nullptr);
|
2012-07-17 23:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// These getters can be used anytime.
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual RefLayer* AsRefLayer() override { return this; }
|
2012-07-17 23:59:45 +00:00
|
|
|
|
|
|
|
virtual int64_t GetReferentId() { return mId; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override;
|
2012-07-17 23:59:45 +00:00
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("RefLayer", TYPE_REF)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
RefLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: ContainerLayer(aManager, aImplData) , mId(0)
|
|
|
|
{}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-27 20:32:00 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
// 0 is a special value that means "no ID".
|
|
|
|
uint64_t mId;
|
|
|
|
};
|
|
|
|
|
2014-01-07 21:06:08 +00:00
|
|
|
void SetAntialiasingFlags(Layer* aLayer, gfx::DrawTarget* aTarget);
|
2013-11-18 02:07:08 +00:00
|
|
|
|
2012-03-05 18:09:05 +00:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2014-01-08 08:37:58 +00:00
|
|
|
void WriteSnapshotToDumpFile(Layer* aLayer, gfx::DataSourceSurface* aSurf);
|
|
|
|
void WriteSnapshotToDumpFile(LayerManager* aManager, gfx::DataSourceSurface* aSurf);
|
2013-09-27 00:37:19 +00:00
|
|
|
void WriteSnapshotToDumpFile(Compositor* aCompositor, gfx::DrawTarget* aTarget);
|
2012-03-05 18:09:05 +00:00
|
|
|
#endif
|
2012-03-01 08:26:09 +00:00
|
|
|
|
2014-08-18 20:13:12 +00:00
|
|
|
// A utility function used by different LayerManager implementations.
|
2015-05-07 09:07:53 +00:00
|
|
|
gfx::IntRect ToOutsideIntRect(const gfxRect &aRect);
|
2014-08-18 20:13:12 +00:00
|
|
|
|
2015-05-07 09:07:53 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2010-03-01 07:56:18 +00:00
|
|
|
|
|
|
|
#endif /* GFX_LAYERS_H */
|