2011-02-04 21:11:24 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
#ifndef GFX_LAYERS_H
|
|
|
|
#define GFX_LAYERS_H
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
#include <map>
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for uint32_t, uint64_t, uint8_t
|
|
|
|
#include <stdio.h> // for FILE
|
2017-04-18 15:43:08 +03:00
|
|
|
#include <sys/types.h> // for int32_t
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "FrameMetrics.h" // for FrameMetrics
|
2015-04-12 05:03:00 +03:00
|
|
|
#include "Units.h" // for LayerMargin, LayerPoint, ParentLayerIntRect
|
2015-09-25 08:38:58 +03:00
|
|
|
#include "gfxContext.h"
|
2013-09-25 00:45:14 +04:00
|
|
|
#include "gfxTypes.h"
|
2013-12-20 20:46:29 +04:00
|
|
|
#include "gfxPoint.h" // for gfxPoint
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxRect.h" // for gfxRect
|
2014-02-12 19:07:46 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2, etc
|
2016-11-24 08:11:30 +03:00
|
|
|
#include "mozilla/Array.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/DebugOnly.h" // for DebugOnly
|
2013-09-24 14:04:14 +04:00
|
|
|
#include "mozilla/EventForwards.h" // for nsPaintEvent
|
2015-04-12 05:03:00 +03:00
|
|
|
#include "mozilla/Maybe.h" // for Maybe
|
2016-04-28 01:57:44 +03:00
|
|
|
#include "mozilla/Poison.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h" // for already_AddRefed
|
2014-06-24 10:29:54 +04:00
|
|
|
#include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
|
2015-08-18 02:44:42 +03:00
|
|
|
#include "mozilla/UniquePtr.h" // for UniquePtr
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/BaseMargin.h" // for BaseMargin
|
|
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2016-04-18 20:49:14 +03:00
|
|
|
#include "mozilla/gfx/TiledRegion.h" // for TiledIntRegion
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
|
|
|
#include "mozilla/gfx/UserData.h" // for UserData, etc
|
2017-07-21 09:21:47 +03:00
|
|
|
#include "mozilla/layers/AnimationInfo.h" // for AnimationInfo
|
2016-12-07 02:39:01 +03:00
|
|
|
#include "mozilla/layers/BSPTree.h" // for LayerPolygon
|
2017-08-03 08:55:14 +03:00
|
|
|
#include "mozilla/layers/CanvasRenderer.h"
|
2017-01-25 03:41:18 +03:00
|
|
|
#include "mozilla/layers/LayerAttributes.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
|
|
|
#include "nsAutoPtr.h" // for nsAutoPtr, nsRefPtr, etc
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
2016-08-10 02:28:19 +03:00
|
|
|
#include "nsCSSPropertyID.h" // for nsCSSPropertyID
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
|
|
|
#include "nsISupportsImpl.h" // for Layer::Release, etc
|
2015-05-07 12:07:53 +03:00
|
|
|
#include "nsRect.h" // for mozilla::gfx::IntRect
|
2013-08-12 03:17:23 +04: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 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h" // for PRLogModuleInfo
|
2015-01-29 22:41:55 +03:00
|
|
|
#include "nsIWidget.h" // For plugin window configuration information structs
|
2015-05-28 02:35:00 +03:00
|
|
|
#include "ImageContainer.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
class gfxContext;
|
2017-02-15 00:49:27 +03:00
|
|
|
class nsDisplayListBuilder;
|
|
|
|
class nsDisplayItem;
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
extern uint8_t gLayerManagerLayerBuilder;
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
namespace mozilla {
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2014-08-10 11:06:44 +04:00
|
|
|
class ComputedTimingFunction;
|
2012-08-21 08:06:46 +04:00
|
|
|
class FrameLayerBuilder;
|
2014-06-24 10:29:54 +04:00
|
|
|
class StyleAnimationValue;
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gl
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
2013-08-12 03:17:23 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
namespace layers {
|
|
|
|
|
2012-07-31 21:28:20 +04:00
|
|
|
class Animation;
|
2015-10-12 06:21:02 +03:00
|
|
|
class AsyncCanvasRenderer;
|
2013-04-18 01:39:13 +04:00
|
|
|
class AsyncPanZoomController;
|
2016-11-07 19:38:45 +03:00
|
|
|
class BasicLayerManager;
|
2014-06-18 06:42:34 +04:00
|
|
|
class ClientLayerManager;
|
2017-02-16 06:03:20 +03:00
|
|
|
class HostLayerManager;
|
2010-03-01 10:56:18 +03:00
|
|
|
class Layer;
|
2014-08-28 06:13:41 +04:00
|
|
|
class LayerMetricsWrapper;
|
2014-09-26 21:06:08 +04:00
|
|
|
class PaintedLayer;
|
2010-03-01 10:56:18 +03:00
|
|
|
class ContainerLayer;
|
2010-03-02 02:09:35 +03:00
|
|
|
class ImageLayer;
|
2017-02-15 00:49:27 +03:00
|
|
|
class DisplayItemLayer;
|
2010-05-13 04:56:11 +04:00
|
|
|
class ColorLayer;
|
2017-02-08 22:31:45 +03:00
|
|
|
class CompositorAnimations;
|
2017-02-01 10:12:37 +03:00
|
|
|
class CompositorBridgeChild;
|
2016-11-24 08:11:29 +03:00
|
|
|
class TextLayer;
|
2010-05-18 08:04:22 +04:00
|
|
|
class CanvasLayer;
|
2016-11-24 08:11:30 +03:00
|
|
|
class BorderLayer;
|
2011-02-17 01:43:30 +03:00
|
|
|
class ReadbackLayer;
|
|
|
|
class ReadbackProcessor;
|
2012-07-18 03:59:45 +04:00
|
|
|
class RefLayer;
|
2016-11-24 08:11:27 +03:00
|
|
|
class HostLayer;
|
2017-06-13 09:00:49 +03:00
|
|
|
class FocusTarget;
|
2016-12-04 11:35:33 +03:00
|
|
|
class KnowsCompositor;
|
2012-03-19 03:02:38 +04:00
|
|
|
class ShadowableLayer;
|
2011-08-09 23:38:26 +04:00
|
|
|
class ShadowLayerForwarder;
|
2013-04-26 02:25:33 +04:00
|
|
|
class LayerManagerComposite;
|
2010-07-22 01:17:33 +04:00
|
|
|
class SpecificLayerAttributes;
|
2016-12-01 07:36:41 +03:00
|
|
|
class TransactionIdAllocator;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
class Compositor;
|
2015-06-08 19:53:41 +03:00
|
|
|
class FrameUniformityData;
|
2015-06-19 02:07:21 +03:00
|
|
|
class PersistentBufferProvider;
|
2016-11-24 08:11:29 +03:00
|
|
|
class GlyphArray;
|
2016-11-16 16:54:51 +03:00
|
|
|
class WebRenderLayerManager;
|
2017-01-25 05:51:30 +03:00
|
|
|
struct AnimData;
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
namespace layerscope {
|
|
|
|
class LayersPacket;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layerscope
|
2014-07-28 00:32:00 +04:00
|
|
|
|
2015-01-03 05:10:46 +03:00
|
|
|
#define MOZ_LAYER_DECL_NAME(n, e) \
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual const char* Name() const override { return n; } \
|
2017-04-25 06:02:48 +03:00
|
|
|
virtual LayerType GetType() const override { return e; } \
|
|
|
|
static LayerType Type() { return e; }
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2015-10-23 00:02:14 +03:00
|
|
|
// Defined in LayerUserData.h; please include that file instead.
|
|
|
|
class LayerUserData;
|
|
|
|
|
2016-12-01 07:36:41 +03:00
|
|
|
class DidCompositeObserver {
|
|
|
|
public:
|
|
|
|
virtual void DidComposite() = 0;
|
|
|
|
};
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/*
|
|
|
|
* Motivation: For truly smooth animation and video playback, we need to
|
|
|
|
* be able to compose frames and render them on a dedicated thread (i.e.
|
|
|
|
* off the main thread where DOM manipulation, script execution and layout
|
|
|
|
* induce difficult-to-bound latency). This requires Gecko to construct
|
|
|
|
* some kind of persistent scene structure (graph or tree) that can be
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* safely transmitted across threads. We have other scenarios (e.g. mobile
|
2010-03-01 10:56:18 +03:00
|
|
|
* browsing) where retaining some rendered data between paints is desired
|
|
|
|
* for performance, so again we need a retained scene structure.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* Our retained scene structure is a layer tree. Each layer represents
|
|
|
|
* content which can be composited onto a destination surface; the root
|
|
|
|
* layer is usually composited into a window, and non-root layers are
|
|
|
|
* composited into their parent layers. Layers have attributes (e.g.
|
|
|
|
* opacity and clipping) that influence their compositing.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* We want to support a variety of layer implementations, including
|
|
|
|
* a simple "immediate mode" implementation that doesn't retain any
|
|
|
|
* rendered data between paints (i.e. uses cairo in just the way that
|
|
|
|
* Gecko used it before layers were introduced). But we also don't want
|
|
|
|
* to have bifurcated "layers"/"non-layers" rendering paths in Gecko.
|
|
|
|
* Therefore the layers API is carefully designed to permit maximally
|
|
|
|
* efficient implementation in an "immediate mode" style. See the
|
|
|
|
* BasicLayerManager for such an implementation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A LayerManager controls a tree of layers. All layers in the tree
|
|
|
|
* must use the same LayerManager.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* All modifications to a layer tree must happen inside a transaction.
|
|
|
|
* Only the state of the layer tree at the end of a transaction is
|
|
|
|
* rendered. Transactions cannot be nested
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* Each transaction has two phases:
|
|
|
|
* 1) Construction: layers are created, inserted, removed and have
|
|
|
|
* properties set on them in this phase.
|
|
|
|
* BeginTransaction and BeginTransactionWithTarget start a transaction in
|
2015-07-13 16:44:11 +03:00
|
|
|
* the Construction phase.
|
2014-09-26 21:06:08 +04: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 10:56:18 +03: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 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* All layer API calls happen on the main thread.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-03-01 10:56:18 +03:00
|
|
|
* Layers are refcounted. The layer manager holds a reference to the
|
|
|
|
* root layer, and each container layer holds a reference to its children.
|
|
|
|
*/
|
2013-05-30 01:59:24 +04:00
|
|
|
class LayerManager {
|
2010-04-01 22:05:40 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(LayerManager)
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2014-04-10 12:49:49 +04:00
|
|
|
protected:
|
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
|
|
typedef mozilla::gfx::IntSize IntSize;
|
|
|
|
typedef mozilla::gfx::SurfaceFormat SurfaceFormat;
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
public:
|
2012-08-16 01:55:38 +04:00
|
|
|
LayerManager()
|
|
|
|
: mDestroyed(false)
|
|
|
|
, mSnapEffectiveTransforms(true)
|
|
|
|
, mId(0)
|
|
|
|
, mInTransaction(false)
|
2016-04-20 00:07:57 +03:00
|
|
|
, mPaintedPixelCount(0)
|
2015-10-30 01:44:31 +03:00
|
|
|
{}
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-08-07 09:09:17 +04:00
|
|
|
/**
|
|
|
|
* Release layers and resources held by this layer manager, and mark
|
|
|
|
* it as destroyed. Should do any cleanup necessary in preparation
|
|
|
|
* for its widget going away. After this call, only user data calls
|
|
|
|
* are valid on the layer manager.
|
|
|
|
*/
|
2013-04-12 11:28:55 +04:00
|
|
|
virtual void Destroy()
|
|
|
|
{
|
|
|
|
mDestroyed = true;
|
|
|
|
mUserData.Destroy();
|
|
|
|
mRoot = nullptr;
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsDestroyed() { return mDestroyed; }
|
2010-08-07 09:09:17 +04:00
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
virtual ShadowLayerForwarder* AsShadowForwarder()
|
2012-07-30 18:20:58 +04:00
|
|
|
{ return nullptr; }
|
2011-08-09 23:38:26 +04:00
|
|
|
|
2016-12-04 11:35:33 +03:00
|
|
|
virtual KnowsCompositor* AsKnowsCompositor()
|
|
|
|
{ return nullptr; }
|
|
|
|
|
2013-04-26 02:25:33 +04:00
|
|
|
virtual LayerManagerComposite* AsLayerManagerComposite()
|
2012-07-30 18:20:58 +04:00
|
|
|
{ return nullptr; }
|
2011-08-09 23:38:26 +04:00
|
|
|
|
2014-06-18 06:42:34 +04:00
|
|
|
virtual ClientLayerManager* AsClientLayerManager()
|
|
|
|
{ return nullptr; }
|
|
|
|
|
2016-11-07 19:38:45 +03:00
|
|
|
virtual BasicLayerManager* AsBasicLayerManager()
|
|
|
|
{ return nullptr; }
|
2017-02-16 06:03:20 +03:00
|
|
|
virtual HostLayerManager* AsHostLayerManager()
|
|
|
|
{ return nullptr; }
|
2016-11-07 19:38:45 +03:00
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
virtual WebRenderLayerManager* AsWebRenderLayerManager()
|
|
|
|
{ return nullptr; }
|
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
/**
|
|
|
|
* Returns true if this LayerManager is owned by an nsIWidget,
|
|
|
|
* and is used for drawing into the widget.
|
|
|
|
*/
|
|
|
|
virtual bool IsWidgetLayerManager() { return true; }
|
2014-06-19 22:22:17 +04:00
|
|
|
virtual bool IsInactiveLayerManager() { return false; }
|
2012-07-17 21:03:51 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* Start a new transaction. Nested transactions are not allowed so
|
|
|
|
* there must be no transaction currently in progress.
|
|
|
|
* This transaction will update the state of the window from which
|
|
|
|
* this LayerManager was obtained.
|
|
|
|
*/
|
2016-10-29 01:48:34 +03:00
|
|
|
virtual bool BeginTransaction() = 0;
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* Start a new transaction. Nested transactions are not allowed so
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* there must be no transaction currently in progress.
|
2010-03-01 10:56:18 +03:00
|
|
|
* This transaction will render the contents of the layer tree to
|
|
|
|
* the given target context. The rendering will be complete when
|
|
|
|
* EndTransaction returns.
|
|
|
|
*/
|
2016-10-29 01:48:34 +03:00
|
|
|
virtual bool BeginTransactionWithTarget(gfxContext* aTarget) = 0;
|
2012-08-21 08:06:46 +04:00
|
|
|
|
2012-08-13 14:10:10 +04:00
|
|
|
enum EndTransactionFlags {
|
|
|
|
END_DEFAULT = 0,
|
|
|
|
END_NO_IMMEDIATE_REDRAW = 1 << 0, // Do not perform the drawing phase
|
2014-09-26 21:06:08 +04:00
|
|
|
END_NO_COMPOSITE = 1 << 1, // Do not composite after drawing painted layer contents.
|
2013-12-16 09:38:42 +04:00
|
|
|
END_NO_REMOTE_COMPOSITE = 1 << 2 // Do not schedule a composition with a remote Compositor, if one exists.
|
2012-08-13 14:10:10 +04:00
|
|
|
};
|
|
|
|
|
2012-08-21 08:06:46 +04:00
|
|
|
FrameLayerBuilder* GetLayerBuilder() {
|
2012-08-29 09:48:15 +04:00
|
|
|
return reinterpret_cast<FrameLayerBuilder*>(GetUserData(&gLayerManagerLayerBuilder));
|
2012-08-21 08:06:46 +04:00
|
|
|
}
|
|
|
|
|
2011-01-19 11:27:54 +03:00
|
|
|
/**
|
|
|
|
* Attempts to end an "empty transaction". There must have been no
|
|
|
|
* changes to the layer tree since the BeginTransaction().
|
2014-09-26 21:06:08 +04:00
|
|
|
* It's possible for this to fail; PaintedLayers may need to be updated
|
2011-01-19 11:27:54 +03: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 14:10:10 +04:00
|
|
|
virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
2011-01-25 11:45:17 +03:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
2014-09-26 21:06:08 +04:00
|
|
|
* Function called to draw the contents of each PaintedLayer.
|
2010-05-21 07:20:48 +04:00
|
|
|
* aRegionToDraw contains the region that needs to be drawn.
|
2010-03-04 00:37:04 +03:00
|
|
|
* This would normally be a subregion of the visible region.
|
|
|
|
* The callee must draw all of aRegionToDraw. Drawing outside
|
|
|
|
* aRegionToDraw will be clipped out or ignored.
|
2010-05-21 07:20:48 +04:00
|
|
|
* The callee must draw all of aRegionToDraw.
|
2014-09-26 21:06:08 +04: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 13:20:52 +04:00
|
|
|
*
|
2015-09-15 16:41:42 +03: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 11:19:25 +03:00
|
|
|
*
|
2010-03-04 00:37:04 +03:00
|
|
|
* aRegionToInvalidate contains a region whose contents have been
|
|
|
|
* changed by the layer manager and which must therefore be invalidated.
|
2010-07-16 01:07:51 +04:00
|
|
|
* For example, this could be non-empty if a retained layer internally
|
|
|
|
* switches from RGBA to RGB or back ... we might want to repaint it to
|
2010-03-04 00:37:04 +03:00
|
|
|
* consistently use subpixel-AA or not.
|
2014-09-26 21:06:08 +04:00
|
|
|
* This region is relative to 0,0 in the PaintedLayer.
|
2010-07-16 01:07:51 +04: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 13:20:52 +04:00
|
|
|
*
|
2010-05-21 07:20:48 +04:00
|
|
|
* aContext must not be used after the call has returned.
|
|
|
|
* We guarantee that buffered contents in the visible
|
|
|
|
* region are valid once drawing is complete.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2014-09-26 21:06:08 +04:00
|
|
|
* The origin of aContext is 0,0 in the PaintedLayer.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
typedef void (* DrawPaintedLayerCallback)(PaintedLayer* aLayer,
|
2010-05-21 07:20:48 +04:00
|
|
|
gfxContext* aContext,
|
|
|
|
const nsIntRegion& aRegionToDraw,
|
2015-09-15 16:41:42 +03:00
|
|
|
const nsIntRegion& aDirtyRegion,
|
2013-11-06 23:10:50 +04:00
|
|
|
DrawRegionClip aClip,
|
2010-03-04 00:37:04 +03:00
|
|
|
const nsIntRegion& aRegionToInvalidate,
|
2010-05-21 07:20:48 +04:00
|
|
|
void* aCallbackData);
|
2011-09-26 17:20:42 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
2010-05-21 07:20:48 +04:00
|
|
|
* Finish the construction phase of the transaction, perform the
|
|
|
|
* drawing phase, and end the transaction.
|
2014-09-26 21:06:08 +04:00
|
|
|
* During the drawing phase, all PaintedLayers in the tree are
|
2010-05-21 07:20:48 +04: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 10:56:18 +03:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
|
2011-09-26 17:20:42 +04:00
|
|
|
void* aCallbackData,
|
|
|
|
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2013-12-16 09:38:42 +04: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.
|
|
|
|
*/
|
2017-06-20 11:17:21 +03:00
|
|
|
virtual void ScheduleComposite() {}
|
2013-12-16 09:38:42 +04:00
|
|
|
|
2017-04-10 09:58:29 +03:00
|
|
|
virtual void SetNeedsComposite(bool aNeedsComposite) {}
|
|
|
|
virtual bool NeedsComposite() const { return false; }
|
|
|
|
|
2012-08-13 14:10:10 +04:00
|
|
|
virtual bool HasShadowManagerInternal() const { return false; }
|
|
|
|
bool HasShadowManager() const { return HasShadowManagerInternal(); }
|
2015-01-29 22:41:55 +03: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 13:20:52 +04:00
|
|
|
bool IsSnappingEffectiveTransforms() { return mSnapEffectiveTransforms; }
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2014-07-18 10:48:23 +04: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 13:20:52 +04:00
|
|
|
/**
|
2012-07-23 07:00:36 +04:00
|
|
|
* Returns true if this LayerManager can properly support layers with
|
2014-07-18 10:48:23 +04:00
|
|
|
* SurfaceMode::SURFACE_COMPONENT_ALPHA. LayerManagers that can't will use
|
|
|
|
* transparent surfaces (and lose subpixel-AA for text).
|
2012-07-23 07:00:36 +04:00
|
|
|
*/
|
2014-07-18 10:48:23 +04:00
|
|
|
virtual bool AreComponentAlphaLayersEnabled();
|
2012-07-23 07:00:36 +04:00
|
|
|
|
2017-06-20 11:17:19 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this LayerManager always requires an intermediate surface
|
|
|
|
* to render blend operations.
|
|
|
|
*/
|
|
|
|
virtual bool BlendingRequiresIntermediateSurface() { return false; }
|
|
|
|
|
2017-06-20 11:17:22 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this LayerManager supports component alpha layers in
|
|
|
|
* situations that require a copy of the backdrop.
|
|
|
|
*/
|
|
|
|
virtual bool SupportsBackdropCopyForComponentAlpha() { return true; }
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2011-02-10 11:58:11 +03:00
|
|
|
* Set the root layer. The root layer is initially null. If there is
|
|
|
|
* no root layer, EndTransaction won't draw anything.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
|
|
|
virtual void SetRoot(Layer* aLayer) = 0;
|
2010-06-01 03:29:37 +04:00
|
|
|
/**
|
|
|
|
* Can be called anytime
|
|
|
|
*/
|
|
|
|
Layer* GetRoot() { return mRoot; }
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2012-09-27 00:41:56 +04:00
|
|
|
/**
|
|
|
|
* Does a breadth-first search from the root layer to find the first
|
2014-08-28 06:13:41 +04:00
|
|
|
* scrollable layer, and returns its ViewID. Note that there may be
|
|
|
|
* other layers in the tree which share the same ViewID.
|
2012-09-27 00:41:56 +04:00
|
|
|
* Can be called any time.
|
|
|
|
*/
|
2014-08-28 06:13:41 +04:00
|
|
|
FrameMetrics::ViewID GetRootScrollableLayerId();
|
|
|
|
|
2016-08-18 02:35:25 +03:00
|
|
|
/**
|
|
|
|
* Returns a LayerMetricsWrapper containing the Root
|
|
|
|
* Content Documents layer.
|
|
|
|
*/
|
|
|
|
LayerMetricsWrapper GetRootContentLayer();
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Called when a managee has mutated.
|
2011-01-26 09:26:37 +03:00
|
|
|
* Subclasses overriding this method must first call their
|
|
|
|
* superclass's impl
|
2010-07-22 01:17:33 +04:00
|
|
|
*/
|
|
|
|
virtual void Mutated(Layer* aLayer) { }
|
2017-01-25 03:41:18 +03:00
|
|
|
virtual void MutatedSimple(Layer* aLayer) { }
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2013-09-17 21:55:09 +04:00
|
|
|
/**
|
2014-09-26 21:07:06 +04:00
|
|
|
* Hints that can be used during PaintedLayer creation to influence the type
|
2013-09-17 21:55:09 +04:00
|
|
|
* or properties of the layer created.
|
|
|
|
*
|
|
|
|
* NONE: No hint.
|
|
|
|
* SCROLLABLE: This layer may represent scrollable content.
|
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
enum PaintedLayerCreationHint {
|
2013-09-17 21:55:09 +04:00
|
|
|
NONE, SCROLLABLE
|
|
|
|
};
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2014-09-26 21:06:08 +04:00
|
|
|
* Create a PaintedLayer for this manager's layer tree.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual already_AddRefed<PaintedLayer> CreatePaintedLayer() = 0;
|
2013-09-17 21:55:09 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2014-09-26 21:06:08 +04:00
|
|
|
* Create a PaintedLayer for this manager's layer tree, with a creation hint
|
2013-09-17 21:55:09 +04:00
|
|
|
* parameter to help optimise the type of layer created.
|
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual already_AddRefed<PaintedLayer> CreatePaintedLayerWithHint(PaintedLayerCreationHint) {
|
|
|
|
return CreatePaintedLayer();
|
2013-09-17 21:55:09 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ContainerLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
|
2010-03-02 02:09:35 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create an ImageLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ImageLayer> CreateImageLayer() = 0;
|
2010-05-13 04:56:11 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ColorLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<ColorLayer> CreateColorLayer() = 0;
|
2016-11-24 08:11:29 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a TextLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<TextLayer> CreateTextLayer() = 0;
|
2016-11-24 08:11:30 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a BorderLayer for this manager's layer tree.
|
|
|
|
*/
|
2016-12-27 06:40:40 +03:00
|
|
|
virtual already_AddRefed<BorderLayer> CreateBorderLayer() = 0;
|
2010-05-18 08:04:22 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a CanvasLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() = 0;
|
2011-02-17 01:43:30 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a ReadbackLayer for this manager's layer tree.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer() { return nullptr; }
|
2012-07-18 03:59:45 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a RefLayer for this manager's layer tree.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual already_AddRefed<RefLayer> CreateRefLayer() { return nullptr; }
|
2017-02-15 00:49:27 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Create a DisplayItemLayer for this manager's layer tree.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<DisplayItemLayer> CreateDisplayItemLayer() { return nullptr; }
|
2010-03-02 02:09:35 +03:00
|
|
|
/**
|
2012-02-01 06:18:30 +04:00
|
|
|
* Can be called anytime, from any thread.
|
2012-07-13 23:38:09 +04:00
|
|
|
*
|
|
|
|
* Creates an Image container which forwards its images to the compositor within
|
2015-05-28 02:35:00 +03: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-02 02:09:35 +03:00
|
|
|
*/
|
2015-05-28 02:35:00 +03:00
|
|
|
static already_AddRefed<ImageContainer> CreateImageContainer(ImageContainer::Mode flag
|
|
|
|
= ImageContainer::SYNCHRONOUS);
|
2010-03-30 22:58:37 +04:00
|
|
|
|
2017-03-29 08:37:11 +03:00
|
|
|
/**
|
|
|
|
* Since the lifetimes of display items and display item layers are different,
|
|
|
|
* calling this tells the layer manager that the display item layer is valid for
|
|
|
|
* only one transaction. Users should call ClearDisplayItemLayers() to remove
|
|
|
|
* references to the dead display item at the end of a transaction.
|
|
|
|
*/
|
|
|
|
virtual void TrackDisplayItemLayer(RefPtr<DisplayItemLayer> aLayer);
|
|
|
|
virtual void ClearDisplayItemLayers();
|
|
|
|
|
2010-03-30 22:58:37 +04:00
|
|
|
/**
|
|
|
|
* Type of layer manager his is. This is to be used sparsely in order to
|
|
|
|
* avoid a lot of Layers backend specific code. It should be used only when
|
|
|
|
* Layers backend specific functionality is necessary.
|
|
|
|
*/
|
|
|
|
virtual LayersBackend GetBackendType() = 0;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-04-07 07:11:17 +04: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 07:27:29 +04:00
|
|
|
/**
|
2014-04-10 12:49:49 +04:00
|
|
|
* Creates a DrawTarget which is optimized for inter-operating with this
|
|
|
|
* layer manager.
|
2010-09-08 07:27:29 +04:00
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<DrawTarget>
|
2014-04-10 12:49:49 +04: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 13:20:52 +04:00
|
|
|
|
2012-06-26 06:43:31 +04:00
|
|
|
/**
|
2014-04-10 12:49:49 +04: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 06:43:31 +04:00
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<DrawTarget>
|
2014-04-10 12:49:49 +04:00
|
|
|
CreateOptimalMaskDrawTarget(const IntSize &aSize);
|
2012-06-26 02:54:05 +04:00
|
|
|
|
2011-06-24 21:41:18 +04:00
|
|
|
/**
|
2013-08-23 10:13:55 +04:00
|
|
|
* Creates a DrawTarget for use with canvas which is optimized for
|
|
|
|
* inter-operating with this layermanager.
|
2011-06-24 21:41:18 +04:00
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<mozilla::gfx::DrawTarget>
|
2011-06-24 21:41:18 +04:00
|
|
|
CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
|
|
|
|
mozilla::gfx::SurfaceFormat aFormat);
|
|
|
|
|
2015-06-19 02:07:21 +03:00
|
|
|
/**
|
|
|
|
* Creates a PersistentBufferProvider for use with canvas which is optimized for
|
|
|
|
* inter-operating with this layermanager.
|
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<PersistentBufferProvider>
|
2015-06-19 02:07:21 +03:00
|
|
|
CreatePersistentBufferProvider(const mozilla::gfx::IntSize &aSize,
|
|
|
|
mozilla::gfx::SurfaceFormat aFormat);
|
|
|
|
|
2013-12-20 20:46:29 +04:00
|
|
|
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) { return true; }
|
2011-06-24 21:41:18 +04:00
|
|
|
|
2012-05-23 03:15:16 +04:00
|
|
|
/**
|
2012-09-28 10:57:33 +04:00
|
|
|
* returns the maximum texture size on this layer backend, or INT32_MAX
|
2012-05-23 03:15:16 +04:00
|
|
|
* if there is no maximum
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual int32_t GetMaxTextureSize() const = 0;
|
2012-05-23 03:15:16 +04:00
|
|
|
|
2010-09-03 22:01:05 +04:00
|
|
|
/**
|
|
|
|
* Return the name of the layer manager's backend.
|
|
|
|
*/
|
|
|
|
virtual void GetBackendName(nsAString& aName) = 0;
|
|
|
|
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This setter can be used anytime. The user data for all keys is
|
|
|
|
* initially null. Ownership pases to the layer manager.
|
|
|
|
*/
|
|
|
|
void SetUserData(void* aKey, LayerUserData* aData)
|
2012-07-17 21:03:50 +04:00
|
|
|
{
|
2015-10-22 22:39:30 +03:00
|
|
|
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerUserDataDestroy);
|
2012-07-17 21:03:50 +04:00
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This can be used anytime. Ownership passes to the caller!
|
|
|
|
*/
|
2016-05-25 01:17:27 +03:00
|
|
|
UniquePtr<LayerUserData> RemoveUserData(void* aKey);
|
2015-10-22 23:57:29 +03:00
|
|
|
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasUserData(void* aKey)
|
2012-07-17 21:03:50 +04:00
|
|
|
{
|
2012-08-04 04:38:44 +04:00
|
|
|
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
2012-07-17 21:03:50 +04:00
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime. Ownership is retained by the layer
|
|
|
|
* manager.
|
|
|
|
*/
|
2013-07-02 20:27:17 +04: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 13:20:52 +04:00
|
|
|
{
|
2012-07-17 21:03:50 +04:00
|
|
|
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
|
|
|
}
|
2010-06-01 03:29:37 +04:00
|
|
|
|
2012-11-08 07:51:55 +04:00
|
|
|
/**
|
|
|
|
* Must be called outside of a layers transaction.
|
|
|
|
*
|
|
|
|
* For the subtree rooted at |aSubtree|, this attempts to free up
|
|
|
|
* any free-able resources like retained buffers, but may do nothing
|
|
|
|
* at all. After this call, the layer tree is left in an undefined
|
|
|
|
* state; the layers in |aSubtree|'s subtree may no longer have
|
|
|
|
* buffers with valid content and may no longer be able to draw
|
|
|
|
* their visible and valid regions.
|
|
|
|
*
|
|
|
|
* In general, a painting or forwarding transaction on |this| must
|
|
|
|
* complete on the tree before it returns to a valid state.
|
|
|
|
*
|
|
|
|
* Resource freeing begins from |aSubtree| or |mRoot| if |aSubtree|
|
|
|
|
* is null. |aSubtree|'s manager must be this.
|
|
|
|
*/
|
|
|
|
virtual void ClearCachedResources(Layer* aSubtree = nullptr) {}
|
|
|
|
|
2012-03-12 19:50:15 +04:00
|
|
|
/**
|
|
|
|
* Flag the next paint as the first for a document.
|
|
|
|
*/
|
|
|
|
virtual void SetIsFirstPaint() {}
|
|
|
|
|
2017-06-13 09:00:49 +03:00
|
|
|
/**
|
|
|
|
* Set the current focus target to be sent with the next paint.
|
|
|
|
*/
|
|
|
|
virtual void SetFocusTarget(const FocusTarget& aFocusTarget) {}
|
|
|
|
|
2013-06-18 11:58:43 +04: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() { }
|
|
|
|
|
2017-05-15 20:03:32 +03:00
|
|
|
/**
|
|
|
|
* Make sure that the previous transaction has been
|
|
|
|
* received. This will synchronsly wait on a remote compositor. */
|
|
|
|
virtual void WaitOnTransactionProcessed() { }
|
|
|
|
|
2017-04-10 09:58:29 +03:00
|
|
|
virtual void SendInvalidRegion(const nsIntRegion& aRegion) {}
|
|
|
|
|
2013-06-18 11:59:29 +04: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 22:06:33 +04:00
|
|
|
virtual const char* Name() const { return "???"; }
|
2010-07-21 22:06:33 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
2014-06-20 02:36:25 +04:00
|
|
|
* aStream.
|
2010-07-21 22:06:33 +04:00
|
|
|
*/
|
2016-03-17 23:18:10 +03:00
|
|
|
void Dump(std::stringstream& aStream, const char* aPrefix="",
|
|
|
|
bool aDumpHtml=false, bool aSorted=false);
|
2010-07-21 22:06:33 +04:00
|
|
|
/**
|
2014-06-20 02:36:25 +04:00
|
|
|
* Dump information about just this layer manager itself to aStream
|
2010-07-21 22:06:33 +04:00
|
|
|
*/
|
2016-03-17 23:18:10 +03:00
|
|
|
void DumpSelf(std::stringstream& aStream, const char* aPrefix="", bool aSorted=false);
|
|
|
|
void Dump(bool aSorted=false);
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
|
|
|
* layerscope packet.
|
|
|
|
*/
|
|
|
|
void Dump(layerscope::LayersPacket* aPacket);
|
|
|
|
|
2010-07-21 22:06:33 +04: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 22:47:44 +04:00
|
|
|
/**
|
|
|
|
* Record (and return) frame-intervals and paint-times for frames which were presented
|
|
|
|
* between calling StartFrameTimeRecording and StopFrameTimeRecording.
|
|
|
|
*
|
|
|
|
* - Uses a cyclic buffer and serves concurrent consumers, so if Stop is called too late
|
|
|
|
* (elements were overwritten since Start), result is considered invalid and hence empty.
|
|
|
|
* - Buffer is capable of holding 10 seconds @ 60fps (or more if frames were less frequent).
|
|
|
|
* Can be changed (up to 1 hour) via pref: toolkit.framesRecording.bufferSize.
|
|
|
|
* - Note: the first frame-interval may be longer than expected because last frame
|
|
|
|
* might have been presented some time before calling StartFrameTimeRecording.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a handle which represents current recording start position.
|
|
|
|
*/
|
2013-11-27 11:32:19 +04:00
|
|
|
virtual uint32_t StartFrameTimeRecording(int32_t aBufferSize);
|
2013-01-23 22:47:44 +04:00
|
|
|
|
|
|
|
/**
|
2013-11-27 11:32:19 +04: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 22:47:44 +04:00
|
|
|
*/
|
2013-11-27 11:32:19 +04:00
|
|
|
virtual void StopFrameTimeRecording(uint32_t aStartIndex,
|
|
|
|
nsTArray<float>& aFrameIntervals);
|
2012-01-06 02:40:35 +04:00
|
|
|
|
2013-11-27 11:32:19 +04:00
|
|
|
void RecordFrame();
|
2012-10-11 21:54:27 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
static bool IsLogEnabled();
|
2015-10-30 01:44:31 +03:00
|
|
|
static mozilla::LogModule* GetLog();
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2012-07-18 20:31:40 +04:00
|
|
|
bool IsCompositingCheap(LayersBackend aBackend)
|
2013-01-10 14:02:21 +04:00
|
|
|
{
|
2014-01-23 22:26:41 +04:00
|
|
|
// LayersBackend::LAYERS_NONE is an error state, but in that case we should try to
|
2013-01-10 14:02:21 +04:00
|
|
|
// avoid loading the compositor!
|
2014-01-23 22:26:41 +04:00
|
|
|
return LayersBackend::LAYERS_BASIC != aBackend && LayersBackend::LAYERS_NONE != aBackend;
|
2013-01-10 14:02:21 +04:00
|
|
|
}
|
2011-02-04 21:11:24 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsCompositingCheap() { return true; }
|
2011-02-04 21:11:24 +03:00
|
|
|
|
2012-08-16 01:55:38 +04:00
|
|
|
bool IsInTransaction() const { return mInTransaction; }
|
2015-06-08 19:53:41 +03:00
|
|
|
virtual void GetFrameUniformity(FrameUniformityData* aOutData) { }
|
2012-08-16 01:55:38 +04:00
|
|
|
|
2014-02-13 04:20:41 +04:00
|
|
|
virtual void SetRegionToClear(const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
mRegionToClear = aRegion;
|
|
|
|
}
|
|
|
|
|
2014-09-02 23:23:34 +04:00
|
|
|
virtual float RequestProperty(const nsAString& property) { return -1; }
|
|
|
|
|
2014-12-22 03:35:41 +03:00
|
|
|
const TimeStamp& GetAnimationReadyTime() const {
|
|
|
|
return mAnimationReadyTime;
|
|
|
|
}
|
|
|
|
|
2015-06-04 23:51:10 +03:00
|
|
|
virtual bool AsyncPanZoomEnabled() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-22 22:39:30 +03:00
|
|
|
static void LayerUserDataDestroy(void* data);
|
|
|
|
|
2016-04-20 00:07:57 +03:00
|
|
|
void AddPaintedPixelCount(int32_t aCount) {
|
|
|
|
mPaintedPixelCount += aCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GetAndClearPaintedPixelCount() {
|
|
|
|
uint32_t count = mPaintedPixelCount;
|
|
|
|
mPaintedPixelCount = 0;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2016-11-30 05:59:14 +03:00
|
|
|
virtual void SetLayerObserverEpoch(uint64_t aLayerObserverEpoch) {}
|
|
|
|
|
|
|
|
virtual void DidComposite(uint64_t aTransactionId,
|
|
|
|
const mozilla::TimeStamp& aCompositeStart,
|
|
|
|
const mozilla::TimeStamp& aCompositeEnd) {}
|
|
|
|
|
2016-12-01 07:36:41 +03:00
|
|
|
virtual void AddDidCompositeObserver(DidCompositeObserver* aObserver) { MOZ_CRASH("GFX: LayerManager"); }
|
|
|
|
virtual void RemoveDidCompositeObserver(DidCompositeObserver* aObserver) { MOZ_CRASH("GFX: LayerManager"); }
|
|
|
|
|
2017-01-25 16:52:04 +03:00
|
|
|
virtual void UpdateTextureFactoryIdentifier(const TextureFactoryIdentifier& aNewIdentifier,
|
|
|
|
uint64_t aDeviceResetSeqNo) {}
|
2016-12-01 06:02:37 +03:00
|
|
|
|
|
|
|
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier()
|
|
|
|
{
|
|
|
|
return TextureFactoryIdentifier();
|
|
|
|
}
|
|
|
|
|
2016-12-01 07:36:41 +03:00
|
|
|
virtual void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) {}
|
|
|
|
|
2017-02-17 05:15:45 +03:00
|
|
|
virtual uint64_t GetLastTransactionId() { return 0; }
|
|
|
|
|
2017-02-01 10:12:37 +03:00
|
|
|
virtual CompositorBridgeChild* GetCompositorBridgeChild() { return nullptr; }
|
|
|
|
|
2010-06-01 03:29:37 +04:00
|
|
|
protected:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Layer> mRoot;
|
2012-07-17 21:03:50 +04:00
|
|
|
gfx::UserData mUserData;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDestroyed;
|
|
|
|
bool mSnapEffectiveTransforms;
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2014-02-13 04:20:41 +04:00
|
|
|
nsIntRegion mRegionToClear;
|
|
|
|
|
2014-04-04 20:27:02 +04:00
|
|
|
// Protected destructor, to discourage deletion outside of Release():
|
|
|
|
virtual ~LayerManager() {}
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
// Print interesting information about this into aStreamo. Internally
|
2010-07-21 22:06:33 +04:00
|
|
|
// used to implement Dump*() and Log*().
|
2014-06-20 02:36:25 +04:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2014-07-28 00:32:00 +04:00
|
|
|
// Print interesting information about this into layerscope packet.
|
|
|
|
// Internally used to implement Dump().
|
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket);
|
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
uint64_t mId;
|
2012-08-16 01:55:38 +04:00
|
|
|
bool mInTransaction;
|
2014-12-22 03:35:41 +03: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;
|
2016-04-20 00:07:57 +03:00
|
|
|
// The count of pixels that were painted in the current transaction.
|
|
|
|
uint32_t mPaintedPixelCount;
|
2012-01-06 02:40:35 +04:00
|
|
|
private:
|
2013-01-23 22:47:44 +04:00
|
|
|
struct FramesTimingRecording
|
|
|
|
{
|
|
|
|
// Stores state and data for frame intervals and paint times recording.
|
|
|
|
// see LayerManager::StartFrameTimeRecording() at Layers.cpp for more details.
|
|
|
|
FramesTimingRecording()
|
2016-01-19 22:14:22 +03:00
|
|
|
: mNextIndex(0)
|
|
|
|
, mLatestStartIndex(0)
|
|
|
|
, mCurrentRunStartIndex(0)
|
|
|
|
, mIsPaused(true)
|
2013-01-23 22:47:44 +04:00
|
|
|
{}
|
|
|
|
nsTArray<float> mIntervals;
|
2016-01-19 22:14:22 +03:00
|
|
|
TimeStamp mLastFrameTime;
|
|
|
|
uint32_t mNextIndex;
|
2013-01-23 22:47:44 +04:00
|
|
|
uint32_t mLatestStartIndex;
|
|
|
|
uint32_t mCurrentRunStartIndex;
|
2016-01-19 22:14:22 +03:00
|
|
|
bool mIsPaused;
|
2013-01-23 22:47:44 +04:00
|
|
|
};
|
|
|
|
FramesTimingRecording mRecording;
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
public:
|
|
|
|
/*
|
|
|
|
* Methods to store/get/clear a "pending scroll info update" object on a
|
|
|
|
* per-scrollid basis. This is used for empty transactions that push over
|
|
|
|
* scroll position updates to the APZ code.
|
|
|
|
*/
|
2017-07-12 18:14:11 +03:00
|
|
|
bool SetPendingScrollUpdateForNextTransaction(FrameMetrics::ViewID aScrollId,
|
2016-04-13 17:21:13 +03:00
|
|
|
const ScrollUpdateInfo& aUpdateInfo);
|
|
|
|
Maybe<ScrollUpdateInfo> GetPendingScrollInfoUpdate(FrameMetrics::ViewID aScrollId);
|
|
|
|
void ClearPendingScrollInfoUpdate();
|
|
|
|
private:
|
|
|
|
std::map<FrameMetrics::ViewID,ScrollUpdateInfo> mPendingScrollUpdates;
|
2017-03-29 08:37:11 +03:00
|
|
|
|
|
|
|
// Display items are only valid during this transaction.
|
|
|
|
// At the end of the transaction, we have to go and clear out
|
|
|
|
// DisplayItemLayer's and null their display item. See comment
|
|
|
|
// above DisplayItemLayer declaration.
|
|
|
|
// Since layers are ref counted, we also have to stop holding
|
|
|
|
// a reference to the display item layer as well.
|
|
|
|
nsTArray<RefPtr<DisplayItemLayer>> mDisplayItemLayers;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A Layer represents anything that can be rendered onto a destination
|
|
|
|
* surface.
|
|
|
|
*/
|
2013-05-30 01:59:24 +04: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 13:20:52 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(Layer)
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2017-01-25 05:51:30 +03:00
|
|
|
typedef InfallibleTArray<Animation> AnimationArray;
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
public:
|
2011-02-17 01:43:30 +03:00
|
|
|
// Keep these in alphabetical order
|
2010-07-02 05:01:09 +04:00
|
|
|
enum LayerType {
|
2011-02-17 01:43:30 +03:00
|
|
|
TYPE_CANVAS,
|
|
|
|
TYPE_COLOR,
|
2010-07-02 05:01:09 +04:00
|
|
|
TYPE_CONTAINER,
|
2017-02-15 00:49:27 +03:00
|
|
|
TYPE_DISPLAYITEM,
|
2010-07-02 05:01:09 +04:00
|
|
|
TYPE_IMAGE,
|
2016-11-24 08:11:29 +03:00
|
|
|
TYPE_TEXT,
|
2016-11-24 08:11:30 +03:00
|
|
|
TYPE_BORDER,
|
2011-02-17 01:43:30 +03:00
|
|
|
TYPE_READBACK,
|
2012-07-18 03:59:45 +04:00
|
|
|
TYPE_REF,
|
2011-02-17 01:43:30 +03:00
|
|
|
TYPE_SHADOW,
|
2014-09-26 21:07:06 +04:00
|
|
|
TYPE_PAINTED
|
2010-07-02 05:01:09 +04:00
|
|
|
};
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
2010-08-07 09:09:17 +04:00
|
|
|
* Returns the LayerManager this Layer belongs to. Note that the layer
|
|
|
|
* manager might be in a destroyed state, at which point it's only
|
|
|
|
* valid to set/get user data from it.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
|
|
|
LayerManager* Manager() { return mManager; }
|
|
|
|
|
2017-06-27 23:11:01 +03:00
|
|
|
/**
|
|
|
|
* This should only be called when changing layer managers from HostLayers.
|
|
|
|
*/
|
|
|
|
void SetManager(LayerManager* aManager, HostLayer* aSelf);
|
|
|
|
|
2010-09-02 13:18:40 +04:00
|
|
|
enum {
|
|
|
|
/**
|
|
|
|
* If this is set, the caller is promising that by the end of this
|
|
|
|
* transaction the entire visible region (as specified by
|
|
|
|
* SetVisibleRegion) will be filled with opaque content.
|
|
|
|
*/
|
|
|
|
CONTENT_OPAQUE = 0x01,
|
|
|
|
/**
|
2010-12-20 04:26:14 +03:00
|
|
|
* If this is set, the caller is notifying that the contents of this layer
|
|
|
|
* require per-component alpha for optimal fidelity. However, there is no
|
|
|
|
* guarantee that component alpha will be supported for this layer at
|
|
|
|
* paint time.
|
|
|
|
* This should never be set at the same time as CONTENT_OPAQUE.
|
2010-09-02 13:18:40 +04:00
|
|
|
*/
|
2011-10-07 01:23:18 +04:00
|
|
|
CONTENT_COMPONENT_ALPHA = 0x02,
|
|
|
|
|
2014-07-18 10:48:23 +04: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-07 01:23:18 +04: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 04:31:00 +03:00
|
|
|
CONTENT_EXTEND_3D_CONTEXT = 0x08,
|
2012-12-12 09:21:23 +04: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 10:48:23 +04:00
|
|
|
CONTENT_MAY_CHANGE_TRANSFORM = 0x10,
|
2013-12-13 22:53:18 +04: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-27 01:13:50 +03: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 04:31:00 +03: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 13:18:40 +04:00
|
|
|
};
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2010-09-02 13:18:40 +04:00
|
|
|
* This lets layout make some promises about what will be drawn into the
|
2014-09-26 21:06:08 +04:00
|
|
|
* visible region of the PaintedLayer. This enables internal quality
|
2010-09-02 13:18:40 +04:00
|
|
|
* and performance optimizations.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetContentFlags(uint32_t aFlags)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2010-12-20 04:26:14 +03:00
|
|
|
NS_ASSERTION((aFlags & (CONTENT_OPAQUE | CONTENT_COMPONENT_ALPHA)) !=
|
|
|
|
(CONTENT_OPAQUE | CONTENT_COMPONENT_ALPHA),
|
|
|
|
"Can't be opaque and require component alpha");
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetContentFlags(aFlags)) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ContentFlags", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2012-08-07 07:00:41 +04:00
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2014-09-16 00:09:52 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2010-09-17 23:29:52 +04:00
|
|
|
* Tell this layer which region will be visible. The visible region
|
|
|
|
* is a region which contains all the contents of the layer that can
|
|
|
|
* actually affect the rendering of the window. It can exclude areas
|
|
|
|
* that are covered by opaque contents of other layers, and it can
|
|
|
|
* exclude areas where this layer simply contains no content at all.
|
|
|
|
* (This can be an overapproximation to the "true" visible region.)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
*
|
2010-09-17 23:29:52 +04:00
|
|
|
* There is no general guarantee that drawing outside the bounds of the
|
|
|
|
* visible region will be ignored. So if a layer draws outside the bounds
|
|
|
|
* of its visible region, it needs to ensure that what it draws is valid.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2015-11-29 10:07:55 +03:00
|
|
|
virtual void SetVisibleRegion(const LayerIntRegion& aRegion)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2016-07-21 19:32:53 +03:00
|
|
|
// IsEmpty is required otherwise we get invalidation glitches.
|
|
|
|
// See bug 1288464 for investigating why.
|
|
|
|
if (!mVisibleRegion.IsEqual(aRegion) || aRegion.IsEmpty()) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) VisibleRegion was %s is %s", this,
|
|
|
|
mVisibleRegion.ToString().get(), aRegion.ToString().get()));
|
2012-08-07 07:00:41 +04:00
|
|
|
mVisibleRegion = aRegion;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2014-08-12 04:00:36 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the (sub)document metrics used to render the Layer subtree
|
2014-08-28 06:13:40 +04: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 04:00:36 +04:00
|
|
|
*/
|
2016-03-29 02:14:52 +03:00
|
|
|
void SetScrollMetadata(const ScrollMetadata& aScrollMetadata)
|
2014-08-12 04:00:36 +04:00
|
|
|
{
|
2016-04-13 17:21:13 +03:00
|
|
|
Manager()->ClearPendingScrollInfoUpdate();
|
2016-03-29 02:14:52 +03:00
|
|
|
if (mScrollMetadata.Length() != 1 || mScrollMetadata[0] != aScrollMetadata) {
|
2014-08-12 04:00:36 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FrameMetrics", this));
|
2016-03-29 02:14:52 +03:00
|
|
|
mScrollMetadata.ReplaceElementsAt(0, mScrollMetadata.Length(), aScrollMetadata);
|
|
|
|
ScrollMetadataChanged();
|
2014-08-28 06:13:40 +04:00
|
|
|
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
|
2016-03-29 02:14:52 +03:00
|
|
|
* ScrollMetadata objects is conceptually equivalent to having a stack
|
2014-08-28 06:13:40 +04:00
|
|
|
* of ContainerLayers that have been flattened into this Layer.
|
2014-08-28 06:13:41 +04:00
|
|
|
* See the documentation in LayerMetricsWrapper.h for a more detailed
|
|
|
|
* explanation of this conceptual equivalence.
|
2014-08-28 06:13:40 +04:00
|
|
|
*
|
|
|
|
* Note also that there is actually a many-to-many relationship between
|
2016-03-29 02:14:52 +03:00
|
|
|
* Layers and ScrollMetadata, because multiple Layers may have identical
|
|
|
|
* ScrollMetadata objects. This happens when those layers belong to the
|
2014-08-28 06:13:40 +04:00
|
|
|
* same scrolling subdocument and therefore end up with the same async
|
|
|
|
* transform when they are scrolled by the APZ code.
|
|
|
|
*/
|
2016-03-29 02:14:52 +03:00
|
|
|
void SetScrollMetadata(const nsTArray<ScrollMetadata>& aMetadataArray)
|
2014-08-28 06:13:40 +04:00
|
|
|
{
|
2016-04-13 17:21:13 +03:00
|
|
|
Manager()->ClearPendingScrollInfoUpdate();
|
2016-03-29 02:14:52 +03:00
|
|
|
if (mScrollMetadata != aMetadataArray) {
|
2014-08-28 06:13:40 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FrameMetrics", this));
|
2016-03-29 02:14:52 +03:00
|
|
|
mScrollMetadata = aMetadataArray;
|
|
|
|
ScrollMetadataChanged();
|
2014-08-12 04:00:36 +04:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-16 14:47:06 +04: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 05:30:02 +03: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 14:47:06 +04: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 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the opacity which will be applied to this layer as it
|
|
|
|
* is composited to the destination.
|
|
|
|
*/
|
2010-07-22 01:17:33 +04:00
|
|
|
void SetOpacity(float aOpacity)
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetOpacity(aOpacity)) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Opacity", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2012-08-07 07:00:41 +04:00
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2014-02-12 19:07:46 +04:00
|
|
|
void SetMixBlendMode(gfx::CompositionOp aMixBlendMode)
|
2013-09-15 07:23:46 +04:00
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetMixBlendMode(aMixBlendMode)) {
|
2013-09-15 07:23:46 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) MixBlendMode", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2013-09-15 07:23:46 +04:00
|
|
|
}
|
|
|
|
}
|
2014-06-19 04:04:05 +04:00
|
|
|
|
2013-09-15 07:30:00 +04:00
|
|
|
void SetForceIsolatedGroup(bool aForceIsolatedGroup)
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetForceIsolatedGroup(aForceIsolatedGroup)) {
|
2013-09-15 07:30:00 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ForceIsolatedGroup", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2013-09-15 07:30:00 +04:00
|
|
|
}
|
|
|
|
}
|
2014-06-19 04:04:05 +04:00
|
|
|
|
2013-09-15 07:30:00 +04:00
|
|
|
bool GetForceIsolatedGroup() const
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
return mSimpleAttrs.ForceIsolatedGroup();
|
2013-09-15 07:30:00 +04:00
|
|
|
}
|
2013-09-15 07:23:46 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set a clip rect which will be applied to this layer as it is
|
|
|
|
* composited to the destination. The coordinates are relative to
|
|
|
|
* the parent layer (i.e. the contents of this layer
|
|
|
|
* are transformed before this clip rect is applied).
|
|
|
|
* For the root layer, the coordinates are relative to the widget,
|
|
|
|
* in device pixels.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
* If aRect is null no clipping will be performed.
|
2010-03-01 10:56:18 +03:00
|
|
|
*/
|
2015-04-12 05:03:00 +03:00
|
|
|
void SetClipRect(const Maybe<ParentLayerIntRect>& aRect)
|
2010-03-01 10:56:18 +03:00
|
|
|
{
|
2015-04-12 05:03:00 +03:00
|
|
|
if (mClipRect) {
|
2012-08-07 07:00:41 +04:00
|
|
|
if (!aRect) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is <none>", this,
|
2015-04-12 05:03:00 +03:00
|
|
|
mClipRect->x, mClipRect->y, mClipRect->width, mClipRect->height));
|
|
|
|
mClipRect.reset();
|
2012-08-07 07:00:41 +04:00
|
|
|
Mutated();
|
|
|
|
} else {
|
2015-04-12 05:03:00 +03:00
|
|
|
if (!aRect->IsEqualEdges(*mClipRect)) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is %d,%d,%d,%d", this,
|
2015-04-12 05:03:00 +03:00
|
|
|
mClipRect->x, mClipRect->y, mClipRect->width, mClipRect->height,
|
2013-03-22 06:17:28 +04:00
|
|
|
aRect->x, aRect->y, aRect->width, aRect->height));
|
2015-04-12 05:03:00 +03:00
|
|
|
mClipRect = aRect;
|
2012-08-07 07:00:41 +04:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aRect) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was <none> is %d,%d,%d,%d", this,
|
|
|
|
aRect->x, aRect->y, aRect->width, aRect->height));
|
2015-04-12 05:03:00 +03:00
|
|
|
mClipRect = aRect;
|
2013-03-22 06:17:28 +04:00
|
|
|
Mutated();
|
2012-08-07 07:00:41 +04:00
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
}
|
|
|
|
}
|
2010-08-07 09:09:17 +04:00
|
|
|
|
2016-04-30 00:32:53 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set an optional scrolled clip on the layer.
|
|
|
|
* The scrolled clip, if present, consists of a clip rect and an optional mask.
|
|
|
|
* This scrolled clip is always scrolled by all scroll frames associated with
|
|
|
|
* this layer. (By contrast, the scroll clips stored in ScrollMetadata are
|
|
|
|
* only scrolled by scroll frames above that ScrollMetadata, and the layer's
|
|
|
|
* mClipRect is always fixed to the layer contents (which may or may not be
|
|
|
|
* scrolled by some of the scroll frames associated with the layer, depending
|
|
|
|
* on whether the layer is fixed).)
|
|
|
|
*/
|
|
|
|
void SetScrolledClip(const Maybe<LayerClip>& aScrolledClip)
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetScrolledClip(aScrolledClip)) {
|
2016-04-30 00:32:53 +03:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ScrolledClip", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2016-04-30 00:32:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-18 05:35:49 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set a layer to mask this layer.
|
|
|
|
*
|
|
|
|
* The mask layer should be applied using its effective transform (after it
|
|
|
|
* is calculated by ComputeEffectiveTransformForMaskLayer), this should use
|
|
|
|
* this layer's parent's transform and the mask layer's transform, but not
|
|
|
|
* this layer's. That is, the mask layer is specified relative to this layer's
|
|
|
|
* position in it's parent layer's coord space.
|
|
|
|
* Currently, only 2D translations are supported for the mask layer transform.
|
|
|
|
*
|
|
|
|
* Ownership of aMaskLayer passes to this.
|
|
|
|
* Typical use would be an ImageLayer with an alpha image used for masking.
|
|
|
|
* See also ContainerState::BuildMaskLayer in FrameLayerBuilder.cpp.
|
|
|
|
*/
|
|
|
|
void SetMaskLayer(Layer* aMaskLayer)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (aMaskLayer) {
|
2014-01-27 19:28:47 +04:00
|
|
|
bool maskIs2D = aMaskLayer->GetTransform().CanDraw2D();
|
2012-06-26 06:43:31 +04:00
|
|
|
NS_ASSERTION(maskIs2D, "Mask layer has invalid transform.");
|
2012-01-18 05:35:49 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-07 07:00:41 +04:00
|
|
|
if (mMaskLayer != aMaskLayer) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) MaskLayer", this));
|
2012-08-07 07:00:41 +04:00
|
|
|
mMaskLayer = aMaskLayer;
|
|
|
|
Mutated();
|
|
|
|
}
|
2012-01-18 05:35:49 +04:00
|
|
|
}
|
|
|
|
|
2015-06-21 19:27:31 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2016-05-07 02:34:16 +03:00
|
|
|
* Add mask layers associated with LayerClips.
|
2015-06-21 19:27:31 +03:00
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
void SetAncestorMaskLayers(const nsTArray<RefPtr<Layer>>& aLayers) {
|
2015-06-21 19:27:31 +03:00
|
|
|
if (aLayers != mAncestorMaskLayers) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) AncestorMaskLayers", this));
|
|
|
|
mAncestorMaskLayers = aLayers;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-07 02:34:16 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Add a mask layer associated with a LayerClip.
|
|
|
|
*/
|
|
|
|
void AddAncestorMaskLayer(const RefPtr<Layer>& aLayer) {
|
|
|
|
mAncestorMaskLayers.AppendElement(aLayer);
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2010-03-02 02:08:28 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Tell this layer what its transform should be. The transformation
|
|
|
|
* is applied when compositing the layer into its parent container.
|
|
|
|
*/
|
2014-01-27 19:28:33 +04:00
|
|
|
void SetBaseTransform(const gfx::Matrix4x4& aMatrix)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
NS_ASSERTION(!aMatrix.IsSingular(),
|
2012-11-30 02:11:04 +04:00
|
|
|
"Shouldn't be trying to draw with a singular matrix!");
|
2012-10-03 09:55:50 +04:00
|
|
|
mPendingTransform = nullptr;
|
2017-01-25 03:41:18 +03:00
|
|
|
if (!mSimpleAttrs.SetTransform(aMatrix)) {
|
2012-08-07 07:00:41 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) BaseTransform", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
2010-03-02 02:08:28 +03:00
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
/**
|
|
|
|
* Can be called at any time.
|
|
|
|
*
|
|
|
|
* Like SetBaseTransform(), but can be called before the next
|
|
|
|
* transform (i.e. outside an open transaction). Semantically, this
|
|
|
|
* method enqueues a new transform value to be set immediately after
|
|
|
|
* the next transaction is opened.
|
|
|
|
*/
|
2014-01-27 19:28:33 +04:00
|
|
|
void SetBaseTransformForNextTransaction(const gfx::Matrix4x4& aMatrix)
|
2012-10-03 09:55:50 +04:00
|
|
|
{
|
2014-01-27 19:29:06 +04:00
|
|
|
mPendingTransform = new gfx::Matrix4x4(aMatrix);
|
2012-10-03 09:55:50 +04:00
|
|
|
}
|
|
|
|
|
2012-08-04 01:29:22 +04:00
|
|
|
void SetPostScale(float aXScale, float aYScale)
|
2012-07-31 06:20:00 +04:00
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (!mSimpleAttrs.SetPostScale(aXScale, aYScale)) {
|
2012-11-02 11:13:08 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PostScale", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2012-07-31 06:20:00 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 09:00:57 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* A layer is "fixed position" when it draws content from a content
|
|
|
|
* (not chrome) document, the topmost content document has a root scrollframe
|
|
|
|
* with a displayport, but the layer does not move when that displayport scrolls.
|
|
|
|
*/
|
2013-03-28 14:58:45 +04:00
|
|
|
void SetIsFixedPosition(bool aFixedPosition)
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetIsFixedPosition(aFixedPosition)) {
|
2013-03-28 14:58:45 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) IsFixedPosition", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2013-03-28 14:58:45 +04:00
|
|
|
}
|
|
|
|
}
|
2011-04-06 09:00:25 +04:00
|
|
|
|
2015-11-03 01:38:08 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* This flag is true when the transform on the layer is a perspective
|
|
|
|
* transform. The compositor treats perspective transforms specially
|
|
|
|
* for async scrolling purposes.
|
|
|
|
*/
|
|
|
|
void SetTransformIsPerspective(bool aTransformIsPerspective)
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetTransformIsPerspective(aTransformIsPerspective)) {
|
2015-11-03 01:38:08 +03:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) TransformIsPerspective", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2015-11-03 01:38:08 +03:00
|
|
|
}
|
|
|
|
}
|
2012-07-31 21:28:20 +04:00
|
|
|
// 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.
|
2017-02-08 22:31:45 +03:00
|
|
|
void SetCompositorAnimations(const CompositorAnimations& aCompositorAnimations);
|
2014-12-22 03:35:41 +03: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 21:28:20 +04:00
|
|
|
|
2013-03-07 14:17:33 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2015-08-18 21:27:18 +03:00
|
|
|
* If a layer represents a fixed position element, this data is stored on the
|
|
|
|
* layer for use by the compositor.
|
2015-08-18 02:44:42 +03: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-05 00:26:33 +03:00
|
|
|
*
|
2015-11-11 18:07:29 +03:00
|
|
|
* - |aSides| is the set of sides to which the element is fixed relative to.
|
|
|
|
* This is used if the viewport size is changed in the compositor and
|
|
|
|
* fixed position items need to shift accordingly. This value is made up
|
|
|
|
* combining appropriate values from mozilla::SideBits.
|
2015-08-18 02:44:42 +03:00
|
|
|
*/
|
|
|
|
void SetFixedPositionData(FrameMetrics::ViewID aScrollId,
|
2015-09-05 00:26:33 +03:00
|
|
|
const LayerPoint& aAnchor,
|
2016-05-05 03:07:42 +03:00
|
|
|
int32_t aSides)
|
2013-03-28 14:58:45 +04:00
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetFixedPositionData(aScrollId, aAnchor, aSides)) {
|
2015-08-18 02:44:42 +03:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FixedPositionData", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2013-03-28 14:58:45 +04:00
|
|
|
}
|
|
|
|
}
|
2013-03-07 14:17:33 +04:00
|
|
|
|
2013-09-12 08:17:58 +04: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)
|
|
|
|
{
|
2017-01-25 03:41:18 +03:00
|
|
|
if (mSimpleAttrs.SetStickyPositionData(aScrollId, aOuter, aInner)) {
|
2013-09-12 08:17:58 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) StickyPositionData", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2013-09-12 08:17:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:14:53 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
2017-05-10 21:02:15 +03:00
|
|
|
* If a layer is a scroll thumb container layer, set the scroll identifier
|
|
|
|
* of the scroll frame scrolled by the thumb, and other data related to the
|
|
|
|
* thumb.
|
2013-12-10 07:14:53 +04:00
|
|
|
*/
|
2017-05-10 21:02:15 +03:00
|
|
|
void SetScrollThumbData(FrameMetrics::ViewID aScrollId, const ScrollThumbData& aThumbData)
|
2013-12-10 07:14:53 +04:00
|
|
|
{
|
2017-05-10 21:02:15 +03:00
|
|
|
if (mSimpleAttrs.SetScrollThumbData(aScrollId, aThumbData)) {
|
2013-12-10 07:14:53 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ScrollbarData", this));
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2013-12-10 07:14:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-14 10:55:17 +03:00
|
|
|
// Set during construction for the container layer of scrollbar components.
|
2017-02-16 01:40:03 +03:00
|
|
|
// |aScrollId| holds the scroll identifier of the scrollable content that
|
|
|
|
// the scrollbar is for.
|
|
|
|
void SetIsScrollbarContainer(FrameMetrics::ViewID aScrollId)
|
2015-01-14 10:55:17 +03:00
|
|
|
{
|
2017-02-16 01:40:03 +03:00
|
|
|
if (mSimpleAttrs.SetIsScrollbarContainer(aScrollId)) {
|
2017-01-25 03:41:18 +03:00
|
|
|
MutatedSimple();
|
2015-01-14 10:55:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-25 03:41:18 +03:00
|
|
|
// Used when forwarding transactions. Do not use at any other time.
|
|
|
|
void SetSimpleAttributes(const SimpleLayerAttributes& aAttrs) {
|
|
|
|
mSimpleAttrs = aAttrs;
|
|
|
|
}
|
|
|
|
const SimpleLayerAttributes& GetSimpleAttributes() const {
|
|
|
|
return mSimpleAttrs;
|
|
|
|
}
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
// These getters can be used anytime.
|
2017-01-25 03:41:18 +03:00
|
|
|
float GetOpacity() { return mSimpleAttrs.Opacity(); }
|
|
|
|
gfx::CompositionOp GetMixBlendMode() const { return mSimpleAttrs.MixBlendMode(); }
|
2015-04-12 05:03:00 +03:00
|
|
|
const Maybe<ParentLayerIntRect>& GetClipRect() const { return mClipRect; }
|
2017-01-25 03:41:18 +03:00
|
|
|
const Maybe<LayerClip>& GetScrolledClip() const { return mSimpleAttrs.ScrolledClip(); }
|
2016-05-05 00:30:26 +03:00
|
|
|
Maybe<ParentLayerIntRect> GetScrolledClipRect() const;
|
2017-01-25 03:41:18 +03:00
|
|
|
uint32_t GetContentFlags() { return mSimpleAttrs.ContentFlags(); }
|
2015-11-29 10:07:55 +03:00
|
|
|
const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
|
2016-03-29 02:14:52 +03:00
|
|
|
const ScrollMetadata& GetScrollMetadata(uint32_t aIndex) const;
|
2014-08-28 06:13:40 +04:00
|
|
|
const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const;
|
2016-03-29 02:14:52 +03:00
|
|
|
uint32_t GetScrollMetadataCount() const { return mScrollMetadata.Length(); }
|
|
|
|
const nsTArray<ScrollMetadata>& GetAllScrollMetadata() { return mScrollMetadata; }
|
2014-08-28 06:13:41 +04:00
|
|
|
bool HasScrollableFrameMetrics() const;
|
2017-07-19 16:24:22 +03:00
|
|
|
bool IsScrollableWithoutContent() const;
|
2013-12-16 14:47:06 +04:00
|
|
|
const EventRegions& GetEventRegions() const { return mEventRegions; }
|
2010-03-01 10:56:18 +03:00
|
|
|
ContainerLayer* GetParent() { return mParent; }
|
2016-04-28 01:57:44 +03:00
|
|
|
Layer* GetNextSibling() {
|
|
|
|
if (mNextSibling) {
|
|
|
|
mNextSibling->CheckCanary();
|
|
|
|
}
|
|
|
|
return mNextSibling;
|
|
|
|
}
|
|
|
|
const Layer* GetNextSibling() const {
|
|
|
|
if (mNextSibling) {
|
|
|
|
mNextSibling->CheckCanary();
|
|
|
|
}
|
|
|
|
return mNextSibling;
|
|
|
|
}
|
2010-03-01 10:56:18 +03:00
|
|
|
Layer* GetPrevSibling() { return mPrevSibling; }
|
2013-07-02 20:27:17 +04:00
|
|
|
const Layer* GetPrevSibling() const { return mPrevSibling; }
|
|
|
|
virtual Layer* GetFirstChild() const { return nullptr; }
|
|
|
|
virtual Layer* GetLastChild() const { return nullptr; }
|
2016-05-03 17:33:43 +03:00
|
|
|
gfx::Matrix4x4 GetTransform() const;
|
2016-01-07 02:56:58 +03:00
|
|
|
// Same as GetTransform(), but returns the transform as a strongly-typed
|
|
|
|
// matrix. Eventually this will replace GetTransform().
|
|
|
|
const CSSTransformMatrix GetTransformTyped() const;
|
2017-01-25 03:41:18 +03:00
|
|
|
const gfx::Matrix4x4& GetBaseTransform() const { return mSimpleAttrs.Transform(); }
|
2015-01-03 04:06:14 +03:00
|
|
|
// Note: these are virtual because ContainerLayerComposite overrides them.
|
2017-01-25 03:41:18 +03:00
|
|
|
virtual float GetPostXScale() const { return mSimpleAttrs.PostXScale(); }
|
|
|
|
virtual float GetPostYScale() const { return mSimpleAttrs.PostYScale(); }
|
|
|
|
bool GetIsFixedPosition() { return mSimpleAttrs.IsFixedPosition(); }
|
|
|
|
bool GetTransformIsPerspective() const { return mSimpleAttrs.TransformIsPerspective(); }
|
|
|
|
bool GetIsStickyPosition() { return mSimpleAttrs.IsStickyPosition(); }
|
|
|
|
FrameMetrics::ViewID GetFixedPositionScrollContainerId() { return mSimpleAttrs.FixedPositionScrollContainerId(); }
|
|
|
|
LayerPoint GetFixedPositionAnchor() { return mSimpleAttrs.FixedPositionAnchor(); }
|
|
|
|
int32_t GetFixedPositionSides() { return mSimpleAttrs.FixedPositionSides(); }
|
|
|
|
FrameMetrics::ViewID GetStickyScrollContainerId() { return mSimpleAttrs.StickyScrollContainerId(); }
|
|
|
|
const LayerRect& GetStickyScrollRangeOuter() { return mSimpleAttrs.StickyScrollRangeOuter(); }
|
|
|
|
const LayerRect& GetStickyScrollRangeInner() { return mSimpleAttrs.StickyScrollRangeInner(); }
|
|
|
|
FrameMetrics::ViewID GetScrollbarTargetContainerId() { return mSimpleAttrs.ScrollbarTargetContainerId(); }
|
2017-05-10 21:02:15 +03:00
|
|
|
const ScrollThumbData& GetScrollThumbData() const { return mSimpleAttrs.ThumbData(); }
|
2017-01-25 03:41:18 +03:00
|
|
|
bool IsScrollbarContainer() { return mSimpleAttrs.IsScrollbarContainer(); }
|
2013-07-02 20:27:17 +04:00
|
|
|
Layer* GetMaskLayer() const { return mMaskLayer; }
|
2017-07-12 18:14:11 +03:00
|
|
|
bool HasPendingTransform() const { return mPendingTransform; }
|
|
|
|
|
2016-04-28 01:57:44 +03:00
|
|
|
void CheckCanary() const { mCanary.Check(); }
|
2014-08-12 04:00:37 +04:00
|
|
|
|
2015-06-21 19:27:31 +03: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);
|
|
|
|
}
|
2016-05-07 02:34:16 +03:00
|
|
|
const nsTArray<RefPtr<Layer>>& GetAllAncestorMaskLayers() const {
|
|
|
|
return mAncestorMaskLayers;
|
|
|
|
}
|
2015-06-21 19:27:31 +03:00
|
|
|
|
|
|
|
bool HasMaskLayers() const {
|
|
|
|
return GetMaskLayer() || mAncestorMaskLayers.Length() > 0;
|
|
|
|
}
|
|
|
|
|
2015-06-03 02:34:28 +03: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 22:36:12 +04:00
|
|
|
|
2015-01-29 22:41:55 +03: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
|
2016-07-26 17:48:34 +03:00
|
|
|
* aLayerOffset are integer rounded using IntPoint::Round.
|
2015-01-29 22:41:55 +03:00
|
|
|
*
|
|
|
|
* @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-13 01:00:54 +04:00
|
|
|
// Note that all lengths in animation data are either in CSS pixels or app
|
|
|
|
// units and must be converted to device pixels by the compositor.
|
2017-07-21 09:21:47 +03:00
|
|
|
AnimationArray& GetAnimations() { return mAnimationInfo.GetAnimations(); }
|
|
|
|
uint64_t GetCompositorAnimationsId() { return mAnimationInfo.GetCompositorAnimationsId(); }
|
|
|
|
InfallibleTArray<AnimData>& GetAnimationData();
|
2012-10-03 09:55:50 +04:00
|
|
|
|
2017-07-21 09:21:47 +03:00
|
|
|
uint64_t GetAnimationGeneration() { return mAnimationInfo.GetAnimationGeneration(); }
|
2012-12-12 01:12:43 +04:00
|
|
|
|
2015-02-27 01:45:37 +03:00
|
|
|
bool HasTransformAnimation() const;
|
2017-04-12 11:40:48 +03:00
|
|
|
bool HasOpacityAnimation() const;
|
2015-02-27 01:45:37 +03:00
|
|
|
|
2016-12-04 02:07:40 +03:00
|
|
|
StyleAnimationValue GetBaseAnimationStyle() const
|
|
|
|
{
|
2017-07-21 09:21:47 +03:00
|
|
|
return mAnimationInfo.GetBaseAnimationStyle();
|
2016-12-04 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
2013-05-16 16:34:24 +04:00
|
|
|
/**
|
|
|
|
* Returns the local transform for this layer: either mTransform or,
|
2016-02-21 03:05:59 +03:00
|
|
|
* for shadow layers, GetShadowBaseTransform(), in either case with the
|
2016-01-07 02:56:58 +03:00
|
|
|
* pre- and post-scales applied.
|
2013-05-16 16:34:24 +04:00
|
|
|
*/
|
2016-05-03 17:33:43 +03:00
|
|
|
gfx::Matrix4x4 GetLocalTransform();
|
2013-05-16 16:34:24 +04:00
|
|
|
|
2016-01-07 02:56:58 +03:00
|
|
|
/**
|
|
|
|
* Same as GetLocalTransform(), but returns a strongly-typed matrix.
|
|
|
|
* Eventually, this will replace GetLocalTransform().
|
|
|
|
*/
|
|
|
|
const LayerToParentLayerMatrix4x4 GetLocalTransformTyped();
|
|
|
|
|
2013-05-30 04:38:27 +04:00
|
|
|
/**
|
|
|
|
* Returns the local opacity for this layer: either mOpacity or,
|
|
|
|
* for shadow layers, GetShadowOpacity()
|
|
|
|
*/
|
2016-01-06 04:08:45 +03:00
|
|
|
float GetLocalOpacity();
|
2013-05-30 04:38:27 +04:00
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
*
|
|
|
|
* Apply pending changes to layers before drawing them, if those
|
|
|
|
* pending changes haven't been overridden by later changes.
|
|
|
|
*/
|
|
|
|
void ApplyPendingUpdatesToSubtree();
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
*
|
|
|
|
* Write layer-subtype-specific attributes into aAttrs. Used to
|
|
|
|
* synchronize layer attributes to their shadows'.
|
|
|
|
*/
|
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) { }
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
// Returns true if it's OK to save the contents of aLayer in an
|
|
|
|
// opaque surface (a surface without an alpha channel).
|
|
|
|
// If we can use a surface without an alpha channel, we should, because
|
|
|
|
// it will often make painting of antialiased text faster and higher
|
|
|
|
// quality.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool CanUseOpaqueSurface();
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2011-01-03 04:48:09 +03:00
|
|
|
SurfaceMode GetSurfaceMode()
|
|
|
|
{
|
|
|
|
if (CanUseOpaqueSurface())
|
2014-01-23 22:26:41 +04:00
|
|
|
return SurfaceMode::SURFACE_OPAQUE;
|
2017-01-25 03:41:18 +03:00
|
|
|
if (GetContentFlags() & CONTENT_COMPONENT_ALPHA)
|
2014-01-23 22:26:41 +04:00
|
|
|
return SurfaceMode::SURFACE_COMPONENT_ALPHA;
|
|
|
|
return SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
|
|
|
|
2015-09-30 10:02:00 +03: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 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This setter can be used anytime. The user data for all keys is
|
|
|
|
* initially null. Ownership pases to the layer manager.
|
|
|
|
*/
|
|
|
|
void SetUserData(void* aKey, LayerUserData* aData)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2015-10-22 22:39:30 +03:00
|
|
|
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManager::LayerUserDataDestroy);
|
2012-07-17 21:03:50 +04:00
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This can be used anytime. Ownership passes to the caller!
|
|
|
|
*/
|
2016-05-25 01:17:27 +03:00
|
|
|
UniquePtr<LayerUserData> RemoveUserData(void* aKey);
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasUserData(void* aKey)
|
2012-07-17 21:03:50 +04:00
|
|
|
{
|
2012-08-04 04:38:44 +04:00
|
|
|
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
2012-07-17 21:03:50 +04:00
|
|
|
}
|
2010-09-02 13:18:39 +04:00
|
|
|
/**
|
|
|
|
* This getter can be used anytime. Ownership is retained by the layer
|
|
|
|
* manager.
|
|
|
|
*/
|
2013-07-02 20:27:17 +04: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 13:20:52 +04:00
|
|
|
{
|
2012-07-17 21:03:50 +04:00
|
|
|
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
|
|
|
}
|
2010-05-21 07:20:48 +04:00
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
/**
|
|
|
|
* |Disconnect()| is used by layers hooked up over IPC. It may be
|
|
|
|
* called at any time, and may not be called at all. Using an
|
|
|
|
* IPC-enabled layer after Destroy() (drawing etc.) results in a
|
|
|
|
* safe no-op; no crashy or uaf etc.
|
|
|
|
*
|
|
|
|
* XXX: this interface is essentially LayerManager::Destroy, but at
|
|
|
|
* Layer granularity. It might be beneficial to unify them.
|
|
|
|
*/
|
|
|
|
virtual void Disconnect() {}
|
|
|
|
|
2010-05-21 07:20:48 +04:00
|
|
|
/**
|
2014-09-26 21:07:06 +04:00
|
|
|
* Dynamic downcast to a PaintedLayer. Returns null if this is not
|
2014-09-26 21:06:08 +04:00
|
|
|
* a PaintedLayer.
|
2010-05-21 07:20:48 +04:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual PaintedLayer* AsPaintedLayer() { return nullptr; }
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2011-04-12 00:53:01 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a ContainerLayer. Returns null if this is not
|
|
|
|
* a ContainerLayer.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual ContainerLayer* AsContainerLayer() { return nullptr; }
|
2013-07-02 20:27:17 +04:00
|
|
|
virtual const ContainerLayer* AsContainerLayer() const { return nullptr; }
|
2011-04-12 00:53:01 +04:00
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a RefLayer. Returns null if this is not a
|
|
|
|
* RefLayer.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual RefLayer* AsRefLayer() { return nullptr; }
|
2012-07-18 03:59:45 +04:00
|
|
|
|
2012-11-19 21:58:38 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a Color. Returns null if this is not a
|
|
|
|
* ColorLayer.
|
|
|
|
*/
|
|
|
|
virtual ColorLayer* AsColorLayer() { return nullptr; }
|
|
|
|
|
2016-11-24 08:11:29 +03:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a TextLayer. Returns null if this is not a
|
|
|
|
* TextLayer.
|
|
|
|
*/
|
|
|
|
virtual TextLayer* AsTextLayer() { return nullptr; }
|
|
|
|
|
2016-11-24 08:11:30 +03:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a Border. Returns null if this is not a
|
|
|
|
* ColorLayer.
|
|
|
|
*/
|
|
|
|
virtual BorderLayer* AsBorderLayer() { return nullptr; }
|
|
|
|
|
2016-12-21 18:43:47 +03:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a Canvas. Returns null if this is not a
|
|
|
|
* ColorLayer.
|
|
|
|
*/
|
|
|
|
virtual CanvasLayer* AsCanvasLayer() { return nullptr; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dynamic cast to an Image. Returns null if this is not a
|
|
|
|
* ColorLayer.
|
|
|
|
*/
|
|
|
|
virtual ImageLayer* AsImageLayer() { return nullptr; }
|
|
|
|
|
2010-10-14 02:55:45 +04:00
|
|
|
/**
|
2013-04-26 02:25:33 +04:00
|
|
|
* Dynamic cast to a LayerComposite. Return null if this is not a
|
|
|
|
* LayerComposite. Can be used anytime.
|
2010-10-14 02:55:45 +04:00
|
|
|
*/
|
2016-11-24 08:11:27 +03:00
|
|
|
virtual HostLayer* AsHostLayer() { return nullptr; }
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2012-03-19 03:02:38 +04:00
|
|
|
/**
|
|
|
|
* Dynamic cast to a ShadowableLayer. Return null if this is not a
|
|
|
|
* ShadowableLayer. Can be used anytime.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual ShadowableLayer* AsShadowableLayer() { return nullptr; }
|
2012-03-19 03:02:38 +04:00
|
|
|
|
2017-02-15 00:49:27 +03:00
|
|
|
/**
|
|
|
|
* Dynamic cast as a DisplayItemLayer. Return null if not a
|
|
|
|
* DisplayItemLayer. Can be used anytime.
|
|
|
|
*/
|
|
|
|
virtual DisplayItemLayer* AsDisplayItemLayer() { return nullptr; }
|
|
|
|
|
2010-10-14 02:55:45 +04:00
|
|
|
// These getters can be used anytime. They return the effective
|
|
|
|
// values that should be used when drawing this layer to screen,
|
|
|
|
// accounting for this layer possibly being a shadow.
|
2016-05-02 18:27:35 +03:00
|
|
|
const Maybe<ParentLayerIntRect>& GetLocalClipRect();
|
2016-02-14 03:50:51 +03:00
|
|
|
const LayerIntRegion& GetLocalVisibleRegion();
|
2013-09-15 07:23:46 +04:00
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
bool Extend3DContext() {
|
|
|
|
return GetContentFlags() & CONTENT_EXTEND_3D_CONTEXT;
|
|
|
|
}
|
2015-10-23 06:29:00 +03:00
|
|
|
bool Combines3DTransformWithAncestors() {
|
|
|
|
return GetParent() &&
|
2015-10-22 06:22:45 +03:00
|
|
|
reinterpret_cast<Layer*>(GetParent())->Extend3DContext();
|
2015-10-21 10:35:00 +03:00
|
|
|
}
|
2015-10-23 06:29:00 +03:00
|
|
|
bool Is3DContextLeaf() {
|
|
|
|
return !Extend3DContext() && Combines3DTransformWithAncestors();
|
|
|
|
}
|
2015-09-17 04:31:00 +03: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.
|
2016-02-14 03:50:51 +03:00
|
|
|
return !GetLocalVisibleRegion().IsEmpty() || Extend3DContext();
|
2015-09-17 04:31:00 +03:00
|
|
|
}
|
|
|
|
|
2016-04-11 05:51:21 +03:00
|
|
|
/**
|
|
|
|
* Return true if current layer content is opaque.
|
|
|
|
* It does not guarantee that layer content is always opaque.
|
|
|
|
*/
|
|
|
|
virtual bool IsOpaque() { return GetContentFlags() & CONTENT_OPAQUE; }
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* Returns the product of the opacities of this layer and all ancestors up
|
|
|
|
* to and excluding the nearest ancestor that has UseIntermediateSurface() set.
|
|
|
|
*/
|
|
|
|
float GetEffectiveOpacity();
|
2014-06-19 04:04:05 +04:00
|
|
|
|
2013-09-15 07:23:46 +04:00
|
|
|
/**
|
|
|
|
* Returns the blendmode of this layer.
|
|
|
|
*/
|
2014-02-12 19:07:46 +04:00
|
|
|
gfx::CompositionOp GetEffectiveMixBlendMode();
|
2014-06-19 04:04:05 +04:00
|
|
|
|
2010-11-08 12:06:15 +03: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 05:49:19 +04:00
|
|
|
const gfx::Matrix4x4& GetEffectiveTransform() const { return mEffectiveTransform; }
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2014-12-07 04:12:50 +03: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 12:06:15 +03: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 13:20:52 +04:00
|
|
|
*
|
2010-11-08 12:06:15 +03:00
|
|
|
* We promise that when this is called on a layer, all ancestor layers
|
|
|
|
* have already had ComputeEffectiveTransforms called.
|
|
|
|
*/
|
2014-01-27 19:28:04 +04: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 13:20:52 +04:00
|
|
|
|
2012-02-08 02:27:44 +04:00
|
|
|
/**
|
2015-07-01 04:07:09 +03:00
|
|
|
* Computes the effective transform for mask layers, if this layer has any.
|
2012-02-08 02:27:44 +04:00
|
|
|
*/
|
2015-07-01 04:07:09 +03:00
|
|
|
void ComputeEffectiveTransformForMaskLayers(const gfx::Matrix4x4& aTransformToSurface);
|
|
|
|
static void ComputeEffectiveTransformForMaskLayer(Layer* aMaskLayer,
|
|
|
|
const gfx::Matrix4x4& aTransformToSurface);
|
2012-02-08 02:27:44 +04:00
|
|
|
|
2011-02-25 10:44:22 +03:00
|
|
|
/**
|
|
|
|
* Calculate the scissor rect required when rendering this layer.
|
2011-05-23 04:27:03 +04:00
|
|
|
* Returns a rectangle relative to the intermediate surface belonging to the
|
|
|
|
* nearest ancestor that has an intermediate surface, or relative to the root
|
|
|
|
* viewport if no ancestor has an intermediate surface, corresponding to the
|
|
|
|
* clip rect for this layer intersected with aCurrentScissorRect.
|
2011-02-25 10:44:22 +03:00
|
|
|
*/
|
2014-09-10 23:59:00 +04:00
|
|
|
RenderTargetIntRect CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect);
|
2010-10-14 02:55:45 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
virtual const char* Name() const =0;
|
|
|
|
virtual LayerType GetType() const =0;
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* Only the implementation should call this. This is per-implementation
|
|
|
|
* private data. Normally, all layers with a given layer manager
|
|
|
|
* use the same type of ImplData.
|
|
|
|
*/
|
|
|
|
void* ImplData() { return mImplData; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Only the implementation should use these methods.
|
|
|
|
*/
|
|
|
|
void SetParent(ContainerLayer* aParent) { mParent = aParent; }
|
|
|
|
void SetNextSibling(Layer* aSibling) { mNextSibling = aSibling; }
|
|
|
|
void SetPrevSibling(Layer* aSibling) { mPrevSibling = aSibling; }
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
/**
|
|
|
|
* Dump information about this layer manager and its managed tree to
|
2014-06-20 02:36:25 +04:00
|
|
|
* aStream.
|
2010-07-21 22:06:33 +04:00
|
|
|
*/
|
2016-03-17 23:18:10 +03:00
|
|
|
void Dump(std::stringstream& aStream, const char* aPrefix="",
|
2016-12-07 02:39:01 +03:00
|
|
|
bool aDumpHtml=false, bool aSorted=false,
|
|
|
|
const Maybe<gfx::Polygon>& aGeometry=Nothing());
|
2010-07-21 22:06:33 +04:00
|
|
|
/**
|
2014-06-20 02:36:25 +04:00
|
|
|
* Dump information about just this layer manager itself to aStream.
|
2010-07-21 22:06:33 +04:00
|
|
|
*/
|
2016-12-07 02:39:01 +03:00
|
|
|
void DumpSelf(std::stringstream& aStream, const char* aPrefix="",
|
|
|
|
const Maybe<gfx::Polygon>& aGeometry=Nothing());
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2014-07-28 00:32:00 +04: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 22:06:33 +04: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-20 02:36:25 +04:00
|
|
|
// Print interesting information about this into aStream. Internally
|
|
|
|
// used to implement Dump*() and Log*(). If subclasses have
|
2014-03-12 06:27:33 +04: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-20 02:36:25 +04:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
2014-03-12 06:27:33 +04:00
|
|
|
|
2014-07-28 00:32:00 +04: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 09:11:00 +03:00
|
|
|
/**
|
|
|
|
* Store display list log.
|
|
|
|
*/
|
|
|
|
void SetDisplayListLog(const char *log);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return display list log.
|
|
|
|
*/
|
|
|
|
void GetDisplayListLog(nsCString& log);
|
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
static bool IsLogEnabled() { return LayerManager::IsLogEnabled(); }
|
|
|
|
|
2012-08-29 09:47:18 +04:00
|
|
|
/**
|
|
|
|
* Returns the current area of the layer (in layer-space coordinates)
|
|
|
|
* marked as needed to be recomposited.
|
|
|
|
*/
|
2016-04-26 17:05:14 +03:00
|
|
|
const virtual gfx::TiledIntRegion& GetInvalidRegion() { return mInvalidRegion; }
|
2016-01-06 04:08:45 +03:00
|
|
|
void AddInvalidRegion(const nsIntRegion& aRegion) {
|
2016-04-18 20:49:14 +03:00
|
|
|
mInvalidRegion.Add(aRegion);
|
2015-10-27 20:15:02 +03:00
|
|
|
}
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark the entirety of the layer's visible region as being invalid.
|
|
|
|
*/
|
2016-04-18 20:49:14 +03:00
|
|
|
void SetInvalidRectToVisibleRegion()
|
|
|
|
{
|
|
|
|
mInvalidRegion.SetEmpty();
|
|
|
|
mInvalidRegion.Add(GetVisibleRegion().ToUnknownRegion());
|
|
|
|
}
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds to the current invalid rect.
|
|
|
|
*/
|
2016-04-18 20:49:14 +03:00
|
|
|
void AddInvalidRect(const gfx::IntRect& aRect) { mInvalidRegion.Add(aRect); }
|
2012-08-29 09:47:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the invalid rect, marking the layer as being identical to what is currently
|
|
|
|
* composited.
|
|
|
|
*/
|
2017-06-20 11:17:21 +03:00
|
|
|
virtual void ClearInvalidRegion() { mInvalidRegion.SetEmpty(); }
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2014-08-12 04:00:37 +04:00
|
|
|
// These functions allow attaching an AsyncPanZoomController to this layer,
|
|
|
|
// and can be used anytime.
|
2014-08-28 06:13:40 +04: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.
|
2016-10-24 20:07:01 +03:00
|
|
|
// The aIndex for these functions must be less than GetScrollMetadataCount().
|
2014-08-28 06:13:40 +04:00
|
|
|
void SetAsyncPanZoomController(uint32_t aIndex, AsyncPanZoomController *controller);
|
|
|
|
AsyncPanZoomController* GetAsyncPanZoomController(uint32_t aIndex) const;
|
2016-03-29 02:14:52 +03:00
|
|
|
// The ScrollMetadataChanged function is used internally to ensure the APZC array length
|
2014-08-28 06:13:40 +04:00
|
|
|
// matches the frame metrics array length.
|
2016-12-08 20:12:38 +03:00
|
|
|
|
|
|
|
virtual void ClearCachedResources() {}
|
2017-06-05 14:55:14 +03:00
|
|
|
|
|
|
|
virtual bool SupportsAsyncUpdate() { return false; }
|
2014-08-28 06:13:40 +04:00
|
|
|
private:
|
2016-03-29 02:14:52 +03:00
|
|
|
void ScrollMetadataChanged();
|
2014-08-28 06:13:40 +04:00
|
|
|
public:
|
2014-08-12 04:00:37 +04:00
|
|
|
|
2012-10-03 09:55:50 +04:00
|
|
|
void ApplyPendingUpdatesForThisTransaction();
|
2012-08-29 09:47:18 +04:00
|
|
|
|
2012-04-27 04:24:53 +04:00
|
|
|
#ifdef DEBUG
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetDebugColorIndex(uint32_t aIndex) { mDebugColorIndex = aIndex; }
|
|
|
|
uint32_t GetDebugColorIndex() { return mDebugColorIndex; }
|
2012-04-27 04:24:53 +04:00
|
|
|
#endif
|
|
|
|
|
2017-01-25 03:41:18 +03:00
|
|
|
void Mutated() {
|
2013-03-22 06:17:28 +04:00
|
|
|
mManager->Mutated(this);
|
|
|
|
}
|
2017-01-25 03:41:18 +03:00
|
|
|
void MutatedSimple() {
|
|
|
|
mManager->MutatedSimple(this);
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2014-07-09 06:01:54 +04:00
|
|
|
virtual int32_t GetMaxLayerSize() { return Manager()->GetMaxTextureSize(); }
|
|
|
|
|
2014-08-04 07:29:55 +04:00
|
|
|
/**
|
|
|
|
* Returns true if this layer's effective transform is not just
|
|
|
|
* a translation by integers, or if this layer or some ancestor layer
|
|
|
|
* is marked as having a transform that may change without a full layer
|
|
|
|
* transaction.
|
|
|
|
*/
|
|
|
|
bool MayResample();
|
|
|
|
|
2014-07-30 22:36:15 +04:00
|
|
|
RenderTargetRect TransformRectToRenderTarget(const LayerIntRect& aRect);
|
|
|
|
|
2014-08-22 19:53:24 +04: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
|
|
|
|
}
|
|
|
|
|
2017-07-21 09:21:47 +03:00
|
|
|
AnimationInfo& GetAnimationInfo() { return mAnimationInfo; }
|
|
|
|
|
2014-02-11 08:01:49 +04:00
|
|
|
protected:
|
|
|
|
Layer(LayerManager* aManager, void* aImplData);
|
|
|
|
|
2014-04-04 20:27:02 +04:00
|
|
|
// Protected destructor, to discourage deletion outside of Release():
|
|
|
|
virtual ~Layer();
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
2012-12-07 03:58:13 +04:00
|
|
|
* We can snap layer transforms for two reasons:
|
|
|
|
* 1) To avoid unnecessary resampling when a transform is a translation
|
|
|
|
* by a non-integer number of pixels.
|
|
|
|
* Snapping the translation to an integer number of pixels avoids
|
|
|
|
* blurring the layer and can be faster to composite.
|
|
|
|
* 2) When a layer is used to render a rectangular object, we need to
|
|
|
|
* emulate the rendering of rectangular inactive content and snap the
|
|
|
|
* edges of the rectangle to pixel boundaries. This is both to ensure
|
|
|
|
* layer rendering is consistent with inactive content rendering, and to
|
|
|
|
* avoid seams.
|
|
|
|
* This function implements type 1 snapping. If aTransform is a 2D
|
|
|
|
* translation, and this layer's layer manager has enabled snapping
|
|
|
|
* (which is the default), return aTransform with the translation snapped
|
|
|
|
* to nearest pixels. Otherwise just return aTransform. Call this when the
|
|
|
|
* layer does not correspond to a single rectangular content object.
|
|
|
|
* This function does not try to snap if aTransform has a scale, because in
|
|
|
|
* that case resampling is inevitable and there's no point in trying to
|
|
|
|
* avoid it. In fact snapping can cause problems because pixel edges in the
|
|
|
|
* layer's content can be rendered unpredictably (jiggling) as the scale
|
|
|
|
* interacts with the snapping of the translation, especially with animated
|
|
|
|
* transforms.
|
|
|
|
* @param aResidualTransform a transform to apply before the result transform
|
|
|
|
* in order to get the results to completely match aTransform.
|
|
|
|
*/
|
2014-01-27 19:27:20 +04:00
|
|
|
gfx::Matrix4x4 SnapTransformTranslation(const gfx::Matrix4x4& aTransform,
|
|
|
|
gfx::Matrix* aResidualTransform);
|
2016-11-07 09:45:00 +03:00
|
|
|
gfx::Matrix4x4 SnapTransformTranslation3D(const gfx::Matrix4x4& aTransform,
|
|
|
|
gfx::Matrix* aResidualTransform);
|
2012-12-07 03:58:13 +04: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 12:06:15 +03:00
|
|
|
* @param aSnapRect a rectangle whose edges should be snapped to pixel
|
2012-12-07 03:58:13 +04:00
|
|
|
* boundaries in the destination surface.
|
|
|
|
* @param aResidualTransform a transform to apply before the result transform
|
|
|
|
* in order to get the results to completely match aTransform.
|
2010-11-08 12:06:15 +03:00
|
|
|
*/
|
2014-01-27 19:27:20 +04:00
|
|
|
gfx::Matrix4x4 SnapTransform(const gfx::Matrix4x4& aTransform,
|
|
|
|
const gfxRect& aSnapRect,
|
|
|
|
gfx::Matrix* aResidualTransform);
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
LayerManager* mManager;
|
|
|
|
ContainerLayer* mParent;
|
|
|
|
Layer* mNextSibling;
|
|
|
|
Layer* mPrevSibling;
|
|
|
|
void* mImplData;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Layer> mMaskLayer;
|
|
|
|
nsTArray<RefPtr<Layer>> mAncestorMaskLayers;
|
2016-04-28 01:57:44 +03:00
|
|
|
// Look for out-of-bound in the middle of the structure
|
|
|
|
mozilla::CorruptionCanary mCanary;
|
2012-07-17 21:03:50 +04:00
|
|
|
gfx::UserData mUserData;
|
2017-01-25 03:41:18 +03:00
|
|
|
SimpleLayerAttributes mSimpleAttrs;
|
2015-11-29 10:07:55 +03:00
|
|
|
LayerIntRegion mVisibleRegion;
|
2016-03-29 02:14:52 +03:00
|
|
|
nsTArray<ScrollMetadata> mScrollMetadata;
|
2013-12-16 14:47:06 +04:00
|
|
|
EventRegions mEventRegions;
|
2012-10-03 09:55:50 +04:00
|
|
|
// A mutation of |mTransform| that we've queued to be applied at the
|
|
|
|
// end of the next transaction (if nothing else overrides it in the
|
|
|
|
// meantime).
|
2014-01-27 19:29:06 +04:00
|
|
|
nsAutoPtr<gfx::Matrix4x4> mPendingTransform;
|
2014-01-25 05:49:19 +04:00
|
|
|
gfx::Matrix4x4 mEffectiveTransform;
|
2017-07-21 09:21:47 +03:00
|
|
|
AnimationInfo mAnimationInfo;
|
2015-04-12 05:03:00 +03:00
|
|
|
Maybe<ParentLayerIntRect> mClipRect;
|
2015-05-07 12:07:53 +03:00
|
|
|
gfx::IntRect mTileSourceRect;
|
2016-04-18 20:49:14 +03:00
|
|
|
gfx::TiledIntRegion mInvalidRegion;
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<AsyncPanZoomController> > mApzcs;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUseTileSourceRect;
|
2016-02-26 18:52:07 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
uint32_t mDebugColorIndex;
|
|
|
|
#endif
|
2014-08-22 19:53:24 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
nsTArray<nsCString> mExtraDumpInfo;
|
|
|
|
#endif
|
2015-08-03 09:11:00 +03:00
|
|
|
// Store display list log.
|
|
|
|
nsCString mDisplayListLog;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-09-26 21:07:06 +04:00
|
|
|
* A Layer which we can paint into. It is a conceptually
|
2014-09-26 21:06:08 +04: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 10:56:18 +03: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 13:20:52 +04:00
|
|
|
*
|
2014-09-26 21:06:08 +04:00
|
|
|
* PaintedLayers are rendered into during the drawing phase of a transaction.
|
2010-03-01 10:56:18 +03:00
|
|
|
*
|
2014-09-26 21:06:08 +04:00
|
|
|
* Currently the contents of a PaintedLayer are in the device output color
|
2010-03-01 10:56:18 +03:00
|
|
|
* space.
|
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
class PaintedLayer : public Layer {
|
2010-03-01 10:56:18 +03: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 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set whether ComputeEffectiveTransforms should compute the
|
|
|
|
* "residual translation" --- the translation that should be applied *before*
|
2014-09-26 21:06:08 +04:00
|
|
|
* mEffectiveTransform to get the ideal transform for this PaintedLayer.
|
2011-06-22 16:11:28 +04: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 10:56:18 +03:00
|
|
|
|
2016-11-24 08:11:27 +03:00
|
|
|
void SetValidRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ValidRegion", this));
|
|
|
|
mValidRegion = aRegion;
|
2017-06-16 06:35:38 +03:00
|
|
|
mValidRegionIsCurrent = true;
|
2016-11-24 08:11:27 +03:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2010-06-01 03:29:37 +04:00
|
|
|
/**
|
|
|
|
* Can be used anytime
|
|
|
|
*/
|
2017-06-16 06:35:38 +03:00
|
|
|
const nsIntRegion& GetValidRegion() const
|
|
|
|
{
|
|
|
|
EnsureValidRegionIsCurrent();
|
|
|
|
return mValidRegion;
|
|
|
|
}
|
2010-06-01 03:29:37 +04:00
|
|
|
|
2017-06-16 00:29:18 +03:00
|
|
|
void InvalidateWholeLayer()
|
|
|
|
{
|
2017-06-16 06:35:38 +03:00
|
|
|
mInvalidRegion.Add(GetValidRegion().GetBounds());
|
|
|
|
ClearValidRegion();
|
2017-06-16 00:29:18 +03:00
|
|
|
}
|
|
|
|
|
2017-06-16 06:35:38 +03:00
|
|
|
void ClearValidRegion()
|
|
|
|
{
|
|
|
|
mValidRegion.SetEmpty();
|
|
|
|
mValidRegionIsCurrent = true;
|
|
|
|
}
|
2017-06-16 01:20:53 +03:00
|
|
|
void AddToValidRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
2017-06-16 06:35:38 +03:00
|
|
|
EnsureValidRegionIsCurrent();
|
2017-06-16 01:20:53 +03:00
|
|
|
mValidRegion.OrWith(aRegion);
|
|
|
|
}
|
|
|
|
void SubtractFromValidRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
2017-06-16 06:35:38 +03:00
|
|
|
EnsureValidRegionIsCurrent();
|
2017-06-16 01:20:53 +03:00
|
|
|
mValidRegion.SubOut(aRegion);
|
|
|
|
}
|
|
|
|
void UpdateValidRegionAfterInvalidRegionChanged()
|
|
|
|
{
|
2017-06-16 06:35:38 +03:00
|
|
|
// Changes to mInvalidRegion will be applied to mValidRegion on the next
|
|
|
|
// call to EnsureValidRegionIsCurrent().
|
|
|
|
mValidRegionIsCurrent = false;
|
|
|
|
}
|
|
|
|
|
2017-06-20 11:17:21 +03:00
|
|
|
void ClearInvalidRegion() override
|
2017-06-16 06:35:38 +03:00
|
|
|
{
|
|
|
|
// mInvalidRegion is about to be reset. This is the last chance to apply
|
|
|
|
// any pending changes from it to mValidRegion. Do that by calling
|
|
|
|
// EnsureValidRegionIsCurrent().
|
|
|
|
EnsureValidRegionIsCurrent();
|
|
|
|
mInvalidRegion.SetEmpty();
|
2017-06-16 01:20:53 +03:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual PaintedLayer* AsPaintedLayer() override { return this; }
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2014-09-26 21:07:06 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("PaintedLayer", TYPE_PAINTED)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
2010-11-08 12:06:15 +03:00
|
|
|
{
|
2014-01-27 19:28:18 +04:00
|
|
|
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
2014-01-27 19:27:20 +04:00
|
|
|
gfx::Matrix residual;
|
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform,
|
2012-07-30 18:20:58 +04:00
|
|
|
mAllowResidualTranslation ? &residual : nullptr);
|
2012-12-07 03:58:13 +04:00
|
|
|
// The residual can only be a translation because SnapTransformTranslation
|
|
|
|
// only changes the transform if it's a translation
|
2014-01-27 19:27:20 +04:00
|
|
|
NS_ASSERTION(residual.IsTranslation(),
|
2011-06-22 16:11:28 +04:00
|
|
|
"Residual transform can only be a translation");
|
2014-01-27 19:27:20 +04:00
|
|
|
if (!gfx::ThebesPoint(residual.GetTranslation()).WithinEpsilonOf(mResidualTranslation, 1e-3f)) {
|
|
|
|
mResidualTranslation = gfx::ThebesPoint(residual.GetTranslation());
|
2015-09-17 04:31:00 +03:00
|
|
|
DebugOnly<mozilla::gfx::Point> transformedOrig =
|
2016-09-08 19:26:03 +03:00
|
|
|
idealTransform.TransformPoint(mozilla::gfx::Point());
|
2015-09-17 04:31:00 +03:00
|
|
|
#ifdef DEBUG
|
2016-09-08 19:26:03 +03:00
|
|
|
DebugOnly<mozilla::gfx::Point> transformed = idealTransform.TransformPoint(
|
|
|
|
mozilla::gfx::Point(mResidualTranslation.x, mResidualTranslation.y)
|
|
|
|
) - *&transformedOrig;
|
2015-09-17 04:31:00 +03:00
|
|
|
#endif
|
|
|
|
NS_ASSERTION(-0.5 <= (&transformed)->x && (&transformed)->x < 0.5 &&
|
|
|
|
-0.5 <= (&transformed)->y && (&transformed)->y < 0.5,
|
|
|
|
"Residual translation out of range");
|
2017-06-16 01:20:53 +03:00
|
|
|
ClearValidRegion();
|
2011-06-22 16:11:28 +04:00
|
|
|
}
|
2015-07-01 04:07:09 +03:00
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
LayerManager::PaintedLayerCreationHint GetCreationHint() const { return mCreationHint; }
|
2014-06-13 20:11:08 +04:00
|
|
|
|
2011-02-17 01:43:30 +03:00
|
|
|
bool UsedForReadback() { return mUsedForReadback; }
|
|
|
|
void SetUsedForReadback(bool aUsed) { mUsedForReadback = aUsed; }
|
2015-07-29 19:03:01 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if aLayer is optimized for the given PaintedLayerCreationHint.
|
|
|
|
*/
|
|
|
|
virtual bool IsOptimizedFor(LayerManager::PaintedLayerCreationHint aCreationHint)
|
|
|
|
{ return true; }
|
|
|
|
|
2011-06-22 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* Returns the residual translation. Apply this translation when drawing
|
2014-09-26 21:06:08 +04:00
|
|
|
* into the PaintedLayer so that when mEffectiveTransform is applied afterwards
|
2011-06-22 16:11:28 +04: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-17 01:43:30 +03:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
protected:
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayer(LayerManager* aManager, void* aImplData,
|
|
|
|
LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE)
|
2010-09-04 00:10:46 +04:00
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mValidRegion()
|
2017-06-16 06:35:38 +03:00
|
|
|
, mValidRegionIsCurrent(true)
|
2014-06-13 20:11:08 +04:00
|
|
|
, mCreationHint(aCreationHint)
|
2011-02-17 01:43:30 +03:00
|
|
|
, mUsedForReadback(false)
|
2011-06-22 16:11:28 +04:00
|
|
|
, mAllowResidualTranslation(false)
|
2010-12-20 04:26:14 +03:00
|
|
|
{
|
|
|
|
}
|
2010-06-01 03:29:37 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-28 00:32:00 +04:00
|
|
|
|
2011-06-22 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* ComputeEffectiveTransforms snaps the ideal transform to get mEffectiveTransform.
|
|
|
|
* mResidualTranslation is the translation that should be applied *before*
|
|
|
|
* mEffectiveTransform to get the ideal transform.
|
|
|
|
*/
|
|
|
|
gfxPoint mResidualTranslation;
|
2017-06-16 01:20:53 +03:00
|
|
|
|
|
|
|
private:
|
2017-06-16 06:35:38 +03:00
|
|
|
/**
|
|
|
|
* Needs to be called prior to accessing mValidRegion, unless mValidRegion is
|
|
|
|
* being completely overwritten.
|
|
|
|
*/
|
|
|
|
void EnsureValidRegionIsCurrent() const
|
|
|
|
{
|
|
|
|
if (!mValidRegionIsCurrent) {
|
|
|
|
// Apply any pending mInvalidRegion changes to mValidRegion.
|
|
|
|
if (!mValidRegion.IsEmpty()) {
|
|
|
|
// Calling mInvalidRegion.GetRegion() is expensive.
|
|
|
|
// That's why we delay the adjustment of mValidRegion for as long as
|
|
|
|
// possible, so that multiple modifications to mInvalidRegion can be
|
|
|
|
// applied to mValidRegion in one go.
|
|
|
|
mValidRegion.SubOut(mInvalidRegion.GetRegion());
|
|
|
|
}
|
|
|
|
mValidRegionIsCurrent = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The layer's valid region. If mValidRegionIsCurrent is false, then
|
|
|
|
* mValidRegion has not yet been updated for recent changes to
|
|
|
|
* mInvalidRegion. Those pending changes can be applied by calling
|
|
|
|
* EnsureValidRegionIsCurrent().
|
|
|
|
*/
|
|
|
|
mutable nsIntRegion mValidRegion;
|
|
|
|
|
|
|
|
mutable bool mValidRegionIsCurrent;
|
2017-06-16 01:20:53 +03:00
|
|
|
|
|
|
|
protected:
|
2014-06-13 20:11:08 +04:00
|
|
|
/**
|
|
|
|
* The creation hint that was used when constructing this layer.
|
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
const LayerManager::PaintedLayerCreationHint mCreationHint;
|
2011-02-17 01:43:30 +03:00
|
|
|
/**
|
2014-09-26 21:06:08 +04:00
|
|
|
* Set when this PaintedLayer is participating in readback, i.e. some
|
2011-02-17 01:43:30 +03:00
|
|
|
* ReadbackLayer (may) be getting its background from this layer.
|
|
|
|
*/
|
|
|
|
bool mUsedForReadback;
|
2011-06-22 16:11:28 +04:00
|
|
|
/**
|
|
|
|
* True when
|
|
|
|
*/
|
|
|
|
bool mAllowResidualTranslation;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A Layer which other layers render into. It holds references to its
|
|
|
|
* children.
|
|
|
|
*/
|
2013-05-30 01:59:24 +04:00
|
|
|
class ContainerLayer : public Layer {
|
2010-03-01 10:56:18 +03:00
|
|
|
public:
|
2013-07-02 20:01:46 +04:00
|
|
|
|
|
|
|
~ContainerLayer();
|
|
|
|
|
2010-03-01 10:56:18 +03: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-22 01:50:25 +04:00
|
|
|
virtual bool InsertAfter(Layer* aChild, Layer* aAfter);
|
2010-03-01 10:56:18 +03:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Remove aChild from the child list of this container. aChild must
|
|
|
|
* be a child of this container.
|
|
|
|
*/
|
2014-02-22 01:50:25 +04:00
|
|
|
virtual bool RemoveChild(Layer* aChild);
|
2012-08-29 14:52:55 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Reposition aChild from the child list of this container. aChild must
|
|
|
|
* be a child of this container.
|
|
|
|
* If aAfter is non-null, it must be a child of this container and we
|
|
|
|
* reposition after that layer. If it's null, we reposition at the start.
|
|
|
|
*/
|
2014-02-22 01:50:25 +04:00
|
|
|
virtual bool RepositionChild(Layer* aChild, Layer* aAfter);
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2012-08-04 01:29:22 +04:00
|
|
|
void SetPreScale(float aXScale, float aYScale)
|
|
|
|
{
|
2012-11-02 11:13:08 +04:00
|
|
|
if (mPreXScale == aXScale && mPreYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
2013-01-08 13:39:12 +04:00
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PreScale", this));
|
2012-08-04 01:29:22 +04:00
|
|
|
mPreXScale = aXScale;
|
|
|
|
mPreYScale = aYScale;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2013-01-08 13:39:12 +04:00
|
|
|
void SetInheritedScale(float aXScale, float aYScale)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-01-08 13:39:12 +04:00
|
|
|
if (mInheritedXScale == aXScale && mInheritedYScale == aYScale) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) InheritedScale", this));
|
2013-01-08 13:39:12 +04:00
|
|
|
mInheritedXScale = aXScale;
|
|
|
|
mInheritedYScale = aYScale;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2015-01-03 04:06:14 +03: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 19:28:04 +03:00
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override;
|
2011-08-09 23:38:26 +04:00
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
enum class SortMode {
|
|
|
|
WITH_GEOMETRY,
|
|
|
|
WITHOUT_GEOMETRY,
|
|
|
|
};
|
2011-10-07 01:23:18 +04:00
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
nsTArray<LayerPolygon> SortChildrenBy3DZOrder(SortMode aSortMode);
|
2010-09-04 00:10:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual ContainerLayer* AsContainerLayer() override { return this; }
|
|
|
|
virtual const ContainerLayer* AsContainerLayer() const override { return this; }
|
2013-07-02 20:27:17 +04:00
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
// These getters can be used anytime.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual Layer* GetFirstChild() const override { return mFirstChild; }
|
|
|
|
virtual Layer* GetLastChild() const override { return mLastChild; }
|
2013-07-02 20:27:17 +04:00
|
|
|
float GetPreXScale() const { return mPreXScale; }
|
|
|
|
float GetPreYScale() const { return mPreYScale; }
|
|
|
|
float GetInheritedXScale() const { return mInheritedXScale; }
|
|
|
|
float GetInheritedYScale() const { return mInheritedYScale; }
|
2015-01-03 04:06:14 +03:00
|
|
|
float GetPresShellResolution() const { return mPresShellResolution; }
|
|
|
|
bool ScaleToResolution() const { return mScaleToResolution; }
|
2014-07-12 00:45:22 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("ContainerLayer", TYPE_CONTAINER)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* ContainerLayer backends need to override ComputeEffectiveTransforms
|
|
|
|
* since the decision about whether to use a temporary surface for the
|
|
|
|
* container is backend-specific. ComputeEffectiveTransforms must also set
|
|
|
|
* mUseIntermediateSurface.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override = 0;
|
2010-11-08 12:06:15 +03: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 10:19:26 +04:00
|
|
|
bool UseIntermediateSurface() { return mUseIntermediateSurface; }
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2011-05-23 04:27:03 +04:00
|
|
|
/**
|
|
|
|
* Returns the rectangle covered by the intermediate surface,
|
2014-07-30 22:36:15 +04:00
|
|
|
* in this layer's coordinate system.
|
|
|
|
*
|
|
|
|
* NOTE: Since this layer has an intermediate surface it follows
|
|
|
|
* that LayerPixel == RenderTargetPixel
|
2011-05-23 04:27:03 +04:00
|
|
|
*/
|
2014-07-30 22:36:15 +04:00
|
|
|
RenderTargetIntRect GetIntermediateSurfaceRect()
|
2011-05-23 04:27:03 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mUseIntermediateSurface, "Must have intermediate surface");
|
2016-02-14 03:50:51 +03:00
|
|
|
return RenderTargetIntRect::FromUnknownRect(GetLocalVisibleRegion().ToUnknownRegion().GetBounds());
|
2011-05-23 04:27:03 +04:00
|
|
|
}
|
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this container has more than one non-empty child
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasMultipleChildren();
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2011-01-03 04:48:09 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this container supports children with component alpha.
|
|
|
|
* Should only be called while painting a child of this layer.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SupportsComponentAlphaChildren() { return mSupportsComponentAlphaChildren; }
|
2011-01-03 04:48:09 +03:00
|
|
|
|
2014-04-16 21:56:52 +04: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-19 01:33:36 +03:00
|
|
|
void SetChildrenChanged(bool aVal) {
|
|
|
|
mChildrenChanged = aVal;
|
|
|
|
}
|
|
|
|
|
2015-02-17 05:30:02 +03:00
|
|
|
void SetEventRegionsOverride(EventRegionsOverride aVal) {
|
|
|
|
if (mEventRegionsOverride == aVal) {
|
2015-02-11 00:28:07 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-17 05:30:02 +03:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) EventRegionsOverride", this));
|
|
|
|
mEventRegionsOverride = aVal;
|
2015-02-11 00:28:07 +03:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2015-02-17 05:30:02 +03:00
|
|
|
EventRegionsOverride GetEventRegionsOverride() const {
|
|
|
|
return mEventRegionsOverride;
|
2015-02-11 00:28:07 +03:00
|
|
|
}
|
|
|
|
|
2017-06-06 13:28:00 +03:00
|
|
|
void SetFilterChain(nsTArray<CSSFilter>&& aFilterChain) {
|
|
|
|
mFilterChain = aFilterChain;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<CSSFilter>& GetFilterChain() { return mFilterChain; }
|
2017-06-20 11:17:21 +03:00
|
|
|
|
2017-08-04 07:22:49 +03:00
|
|
|
// If |aRect| is null, the entire layer should be considered invalid for
|
|
|
|
// compositing.
|
|
|
|
virtual void SetInvalidCompositeRect(const gfx::IntRect* aRect) {}
|
2017-06-06 13:28:00 +03:00
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
protected:
|
2011-02-17 01:43:30 +03:00
|
|
|
friend class ReadbackProcessor;
|
|
|
|
|
2017-01-05 21:41:10 +03:00
|
|
|
// Note that this is not virtual, and is based on the implementation of
|
|
|
|
// ContainerLayer::RemoveChild, so it should only be called where you would
|
|
|
|
// want to explicitly call the base class implementation of RemoveChild;
|
|
|
|
// e.g., while (mFirstChild) ContainerLayer::RemoveChild(mFirstChild);
|
|
|
|
void RemoveAllChildren();
|
|
|
|
|
2011-02-17 01:43:30 +03:00
|
|
|
void DidInsertChild(Layer* aLayer);
|
|
|
|
void DidRemoveChild(Layer* aLayer);
|
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
bool AnyAncestorOrThisIs3DContextLeaf();
|
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
void Collect3DContextLeaves(nsTArray<Layer*>& aToSort);
|
|
|
|
|
2016-12-07 02:39:01 +03:00
|
|
|
// Collects child layers that do not extend 3D context. For ContainerLayers
|
|
|
|
// that do extend 3D context, the 3D context leaves are collected.
|
|
|
|
nsTArray<Layer*> CollectChildren() {
|
|
|
|
nsTArray<Layer*> children;
|
|
|
|
|
|
|
|
for (Layer* layer = GetFirstChild(); layer; layer = layer->GetNextSibling()) {
|
|
|
|
ContainerLayer* container = layer->AsContainerLayer();
|
|
|
|
|
|
|
|
if (container && container->Extend3DContext() &&
|
|
|
|
!container->UseIntermediateSurface()) {
|
|
|
|
container->Collect3DContextLeaves(children);
|
|
|
|
} else {
|
|
|
|
children.AppendElement(layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return children;
|
|
|
|
}
|
|
|
|
|
2013-07-02 20:01:46 +04:00
|
|
|
ContainerLayer(LayerManager* aManager, void* aImplData);
|
2010-03-01 10:56:18 +03:00
|
|
|
|
2010-11-08 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* A default implementation of ComputeEffectiveTransforms for use by OpenGL
|
|
|
|
* and D3D.
|
|
|
|
*/
|
2014-01-27 19:28:04 +04:00
|
|
|
void DefaultComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2014-05-09 14:06:20 +04: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 12:06:15 +03:00
|
|
|
/**
|
|
|
|
* Loops over the children calling ComputeEffectiveTransforms on them.
|
|
|
|
*/
|
2014-01-27 19:28:04 +04:00
|
|
|
void ComputeEffectiveTransformsForChildren(const gfx::Matrix4x4& aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-09-04 00:10:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-28 00:32:00 +04:00
|
|
|
|
2015-09-17 04:31:00 +03:00
|
|
|
/**
|
|
|
|
* True for if the container start a new 3D context extended by one
|
|
|
|
* or more children.
|
|
|
|
*/
|
|
|
|
bool Creates3DContextWithExtendingChildren();
|
|
|
|
|
2010-03-01 10:56:18 +03:00
|
|
|
Layer* mFirstChild;
|
2010-11-17 02:33:56 +03:00
|
|
|
Layer* mLastChild;
|
2012-08-04 01:29:22 +04:00
|
|
|
float mPreXScale;
|
|
|
|
float mPreYScale;
|
2013-01-08 13:39:12 +04:00
|
|
|
// The resolution scale inherited from the parent layer. This will already
|
|
|
|
// be part of mTransform.
|
|
|
|
float mInheritedXScale;
|
|
|
|
float mInheritedYScale;
|
2015-01-03 04:06:14 +03: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 10:19:26 +04:00
|
|
|
bool mUseIntermediateSurface;
|
|
|
|
bool mSupportsComponentAlphaChildren;
|
|
|
|
bool mMayHaveReadbackChild;
|
2014-11-19 01:33:36 +03:00
|
|
|
// This is updated by ComputeDifferences. This will be true if we need to invalidate
|
|
|
|
// the intermediate surface.
|
|
|
|
bool mChildrenChanged;
|
2015-02-17 05:30:02 +03:00
|
|
|
EventRegionsOverride mEventRegionsOverride;
|
2017-06-06 13:28:00 +03:00
|
|
|
nsTArray<CSSFilter> mFilterChain;
|
2010-03-01 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
2017-02-15 00:49:27 +03:00
|
|
|
/**
|
|
|
|
* A generic layer that references back to its display item.
|
|
|
|
*
|
|
|
|
* In order to not throw away information early in the pipeline from layout -> webrender,
|
|
|
|
* we'd like a generic layer type that can represent all the nsDisplayItems instead of
|
|
|
|
* creating a new layer type for each nsDisplayItem for Webrender. Another option
|
|
|
|
* is to break down nsDisplayItems into smaller nsDisplayItems early in the pipeline.
|
|
|
|
* The problem with this is that the whole pipeline would have to deal with more
|
|
|
|
* display items, which is slower.
|
|
|
|
*
|
|
|
|
* An alternative is to create a DisplayItemLayer, but the wrinkle with this is that
|
|
|
|
* it has a pointer to its nsDisplayItem. Managing the lifetime is key as display items
|
|
|
|
* only live as long as their display list builder, which goes away at the end of a paint.
|
|
|
|
* Layers however, are retained between paints.
|
|
|
|
* It's ok to recycle a DisplayItemLayer for a different display item since its just a pointer.
|
|
|
|
* Instead, when a layer transaction is completed, it is up to the layer manager to tell
|
|
|
|
* DisplayItemLayers that the display item pointer is no longer valid.
|
|
|
|
*/
|
|
|
|
class DisplayItemLayer : public Layer {
|
|
|
|
public:
|
|
|
|
virtual DisplayItemLayer* AsDisplayItemLayer() override { return this; }
|
|
|
|
void EndTransaction();
|
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("DisplayItemLayer", TYPE_DISPLAYITEM)
|
|
|
|
|
|
|
|
void SetDisplayItem(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder) {
|
|
|
|
mItem = aItem;
|
|
|
|
mBuilder = aBuilder;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDisplayItem* GetDisplayItem() { return mItem; }
|
|
|
|
nsDisplayListBuilder* GetDisplayListBuilder() { return mBuilder; }
|
|
|
|
|
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
|
|
|
{
|
|
|
|
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, nullptr);
|
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DisplayItemLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mItem(nullptr)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
|
|
|
|
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
|
|
|
|
|
|
|
// READ COMMENT ABOVE TO ENSURE WE DON'T HAVE A DANGLING POINTER
|
|
|
|
nsDisplayItem* mItem;
|
|
|
|
nsDisplayListBuilder* mBuilder;
|
|
|
|
};
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
/**
|
2010-05-13 04:56:11 +04:00
|
|
|
* A Layer which just renders a solid color in its visible region. It actually
|
|
|
|
* can fill any area that contains the visible region, so if you need to
|
|
|
|
* restrict the area filled, set a clip region on this layer.
|
2010-05-13 04:56:11 +04:00
|
|
|
*/
|
2013-05-30 01:59:24 +04:00
|
|
|
class ColorLayer : public Layer {
|
2010-05-13 04:56:11 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual ColorLayer* AsColorLayer() override { return this; }
|
2012-11-19 21:58:38 +04:00
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the color of the layer.
|
|
|
|
*/
|
2015-09-25 04:16:45 +03:00
|
|
|
virtual void SetColor(const gfx::Color& aColor)
|
2010-05-13 04:56:11 +04:00
|
|
|
{
|
2013-03-28 14:58:45 +04:00
|
|
|
if (mColor != aColor) {
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Color", this));
|
|
|
|
mColor = aColor;
|
|
|
|
Mutated();
|
|
|
|
}
|
2010-05-13 04:56:11 +04:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:53 +03:00
|
|
|
void SetBounds(const gfx::IntRect& aBounds)
|
2013-07-09 18:11:00 +04:00
|
|
|
{
|
|
|
|
if (!mBounds.IsEqualEdges(aBounds)) {
|
|
|
|
mBounds = aBounds;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:53 +03:00
|
|
|
const gfx::IntRect& GetBounds()
|
2013-07-09 18:11:00 +04:00
|
|
|
{
|
|
|
|
return mBounds;
|
|
|
|
}
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
// This getter can be used anytime.
|
2015-09-25 04:16:45 +03:00
|
|
|
virtual const gfx::Color& GetColor() { return mColor; }
|
2010-05-13 04:56:11 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("ColorLayer", TYPE_COLOR)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
2010-11-08 12:06:15 +03:00
|
|
|
{
|
2014-01-27 19:28:18 +04:00
|
|
|
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
2014-01-27 19:27:20 +04:00
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, nullptr);
|
2015-07-01 04:07:09 +03:00
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
protected:
|
|
|
|
ColorLayer(LayerManager* aManager, void* aImplData)
|
2015-09-25 04:16:45 +03:00
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
, mColor()
|
2010-05-13 04:56:11 +04:00
|
|
|
{}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-28 00:32:00 +04:00
|
|
|
|
2015-05-07 12:07:53 +03:00
|
|
|
gfx::IntRect mBounds;
|
2015-09-25 04:16:45 +03:00
|
|
|
gfx::Color mColor;
|
2010-05-13 04:56:11 +04:00
|
|
|
};
|
|
|
|
|
2016-11-24 08:11:29 +03:00
|
|
|
/**
|
|
|
|
* A Layer which renders Glyphs.
|
|
|
|
*/
|
|
|
|
class TextLayer : public Layer {
|
|
|
|
public:
|
|
|
|
virtual TextLayer* AsTextLayer() override { return this; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
*/
|
|
|
|
void SetBounds(const gfx::IntRect& aBounds)
|
|
|
|
{
|
|
|
|
if (!mBounds.IsEqualEdges(aBounds)) {
|
|
|
|
mBounds = aBounds;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const gfx::IntRect& GetBounds()
|
|
|
|
{
|
|
|
|
return mBounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetScaledFont(gfx::ScaledFont* aScaledFont) {
|
|
|
|
if (aScaledFont != mFont) {
|
|
|
|
mFont = aScaledFont;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-23 03:57:00 +03:00
|
|
|
const nsTArray<GlyphArray>& GetGlyphs() { return mGlyphs; }
|
|
|
|
|
2016-11-24 08:11:29 +03:00
|
|
|
gfx::ScaledFont* GetScaledFont() { return mFont; }
|
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("TextLayer", TYPE_TEXT)
|
|
|
|
|
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
|
|
|
{
|
|
|
|
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, nullptr);
|
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetGlyphs(nsTArray<GlyphArray>&& aGlyphs);
|
|
|
|
protected:
|
|
|
|
TextLayer(LayerManager* aManager, void* aImplData);
|
|
|
|
~TextLayer();
|
|
|
|
|
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
|
|
|
|
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
|
|
|
|
|
|
|
gfx::IntRect mBounds;
|
|
|
|
nsTArray<GlyphArray> mGlyphs;
|
|
|
|
RefPtr<gfx::ScaledFont> mFont;
|
|
|
|
};
|
|
|
|
|
2016-11-24 08:11:30 +03:00
|
|
|
/**
|
|
|
|
* A Layer which renders a rounded rect.
|
|
|
|
*/
|
|
|
|
class BorderLayer : public Layer {
|
|
|
|
public:
|
|
|
|
virtual BorderLayer* AsBorderLayer() override { return this; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the color of the layer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Colors of each side as in css::Side
|
|
|
|
virtual void SetColors(const BorderColors& aColors)
|
|
|
|
{
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Colors", this));
|
|
|
|
PodCopy(&mColors[0], &aColors[0], 4);
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetRect(const LayerRect& aRect)
|
|
|
|
{
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Rect", this));
|
|
|
|
mRect = aRect;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Size of each rounded corner as in css::Corner, 0.0 means a
|
|
|
|
// rectangular corner.
|
|
|
|
virtual void SetCornerRadii(const BorderCorners& aCorners)
|
|
|
|
{
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Corners", this));
|
|
|
|
PodCopy(&mCorners[0], &aCorners[0], 4);
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetWidths(const BorderWidths& aWidths)
|
|
|
|
{
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Widths", this));
|
|
|
|
PodCopy(&mWidths[0], &aWidths[0], 4);
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2017-02-09 07:20:29 +03:00
|
|
|
virtual void SetStyles(const BorderStyles& aBorderStyles)
|
|
|
|
{
|
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Widths", this));
|
|
|
|
PodCopy(&mBorderStyles[0], &aBorderStyles[0], 4);
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2016-11-24 08:11:30 +03:00
|
|
|
MOZ_LAYER_DECL_NAME("BorderLayer", TYPE_BORDER)
|
|
|
|
|
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
|
|
|
{
|
|
|
|
gfx::Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
|
|
|
|
mEffectiveTransform = SnapTransformTranslation(idealTransform, nullptr);
|
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
|
|
|
}
|
|
|
|
|
2017-01-18 16:48:00 +03:00
|
|
|
const BorderColors& GetColors() { return mColors; }
|
|
|
|
const LayerRect& GetRect() { return mRect; }
|
|
|
|
const BorderCorners& GetCorners() { return mCorners; }
|
|
|
|
const BorderWidths& GetWidths() { return mWidths; }
|
|
|
|
|
2016-11-24 08:11:30 +03:00
|
|
|
protected:
|
|
|
|
BorderLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
|
|
|
|
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
|
|
|
|
|
|
|
BorderColors mColors;
|
|
|
|
LayerRect mRect;
|
|
|
|
BorderCorners mCorners;
|
|
|
|
BorderWidths mWidths;
|
2017-02-09 07:20:29 +03:00
|
|
|
BorderStyles mBorderStyles;
|
2016-11-24 08:11:30 +03:00
|
|
|
};
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
/**
|
|
|
|
* A Layer for HTML Canvas elements. It's backed by either a
|
|
|
|
* gfxASurface or a GLContext (for WebGL layers), and has some control
|
|
|
|
* for intelligent updating from the source if necessary (for example,
|
|
|
|
* if hardware compositing is not available, for reading from the GL
|
|
|
|
* buffer into an image surface that we can layer composite.)
|
|
|
|
*
|
|
|
|
* After Initialize is called, the underlying canvas Surface/GLContext
|
|
|
|
* must not be modified during a layer transaction.
|
|
|
|
*/
|
2013-05-30 01:59:24 +04:00
|
|
|
class CanvasLayer : public Layer {
|
2010-05-18 08:04:22 +04:00
|
|
|
public:
|
2016-11-24 08:11:27 +03:00
|
|
|
void SetBounds(gfx::IntRect aBounds) { mBounds = aBounds; }
|
|
|
|
|
2016-12-21 18:43:47 +03:00
|
|
|
virtual CanvasLayer* AsCanvasLayer() override { return this; }
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
/**
|
2011-03-28 03:59:46 +04:00
|
|
|
* Notify this CanvasLayer that the canvas surface contents have
|
|
|
|
* changed (or will change) before the next transaction.
|
2010-05-18 08:04:22 +04:00
|
|
|
*/
|
2017-08-03 08:55:14 +03:00
|
|
|
void Updated() { mCanvasRenderer->SetDirty(); SetInvalidRectToVisibleRegion(); }
|
2011-03-28 03:59:46 +04:00
|
|
|
|
2012-09-30 10:20:25 +04:00
|
|
|
/**
|
|
|
|
* Notify this CanvasLayer that the canvas surface contents have
|
|
|
|
* been painted since the last change.
|
|
|
|
*/
|
2017-08-03 08:55:14 +03:00
|
|
|
void Painted() { mCanvasRenderer->ResetDirty(); }
|
2012-09-30 10:20:25 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the canvas surface contents have changed since the
|
|
|
|
* last paint.
|
|
|
|
*/
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
bool IsDirty()
|
|
|
|
{
|
2012-09-30 10:20:25 +04:00
|
|
|
// We can only tell if we are dirty if we're part of the
|
|
|
|
// widget's retained layer tree.
|
|
|
|
if (!mManager || !mManager->IsWidgetLayerManager()) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-08-03 08:55:14 +03:00
|
|
|
return mCanvasRenderer->IsDirty();
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
2015-07-02 18:58:24 +03:00
|
|
|
const nsIntRect& GetBounds() const { return mBounds; }
|
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
CanvasRenderer* CreateOrGetCanvasRenderer();
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
public:
|
2011-03-28 03:59:46 +04:00
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the filter used to resample this image (if necessary).
|
|
|
|
*/
|
2016-05-25 19:01:18 +03:00
|
|
|
void SetSamplingFilter(gfx::SamplingFilter aSamplingFilter)
|
2013-03-28 14:58:45 +04:00
|
|
|
{
|
2016-05-25 19:01:18 +03:00
|
|
|
if (mSamplingFilter != aSamplingFilter) {
|
2013-03-28 14:58:45 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
|
2016-05-25 19:01:18 +03:00
|
|
|
mSamplingFilter = aSamplingFilter;
|
2013-03-28 14:58:45 +04:00
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
}
|
2016-05-25 19:01:18 +03:00
|
|
|
gfx::SamplingFilter GetSamplingFilter() const { return mSamplingFilter; }
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2010-07-21 22:06:33 +04:00
|
|
|
MOZ_LAYER_DECL_NAME("CanvasLayer", TYPE_CANVAS)
|
2010-07-02 05:01:09 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
|
2010-11-08 12:06:15 +03: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 21:06:08 +04: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 19:27:20 +04:00
|
|
|
mEffectiveTransform =
|
2014-01-27 19:28:18 +04:00
|
|
|
SnapTransform(GetLocalTransform(), gfxRect(0, 0, mBounds.width, mBounds.height),
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr)*
|
2014-01-27 19:28:04 +04:00
|
|
|
SnapTransformTranslation(aTransformToSurface, nullptr);
|
2015-07-01 04:07:09 +03:00
|
|
|
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
2010-11-08 12:06:15 +03:00
|
|
|
}
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
protected:
|
2015-10-12 06:21:02 +03:00
|
|
|
CanvasLayer(LayerManager* aManager, void* aImplData);
|
|
|
|
virtual ~CanvasLayer();
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2010-07-21 22:06:33 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-28 00:32:00 +04:00
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
virtual CanvasRenderer* CreateCanvasRendererInternal() = 0;
|
2011-03-28 03:59:46 +04:00
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
UniquePtr<CanvasRenderer> mCanvasRenderer;
|
2016-05-25 19:01:18 +03:00
|
|
|
gfx::SamplingFilter mSamplingFilter;
|
2012-09-30 10:20:25 +04:00
|
|
|
|
2011-03-28 03:59:46 +04:00
|
|
|
/**
|
2017-08-03 08:55:14 +03:00
|
|
|
* 0, 0, canvaswidth, canvasheight
|
2011-03-28 03:59:46 +04:00
|
|
|
*/
|
2017-08-03 08:55:14 +03:00
|
|
|
gfx::IntRect mBounds;
|
2010-05-18 08:04:22 +04:00
|
|
|
};
|
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
/**
|
|
|
|
* ContainerLayer that refers to a "foreign" layer tree, through an
|
|
|
|
* ID. Usage of RefLayer looks like
|
|
|
|
*
|
|
|
|
* Construction phase:
|
|
|
|
* allocate ID for layer subtree
|
|
|
|
* create RefLayer, SetReferentId(ID)
|
|
|
|
*
|
|
|
|
* Composition:
|
|
|
|
* look up subtree for GetReferentId()
|
|
|
|
* ConnectReferentLayer(subtree)
|
|
|
|
* compose
|
|
|
|
* ClearReferentLayer()
|
|
|
|
*
|
|
|
|
* Clients will usually want to Connect/Clear() on each transaction to
|
|
|
|
* avoid difficulties managing memory across multiple layer subtrees.
|
|
|
|
*/
|
2013-05-30 01:59:24 +04:00
|
|
|
class RefLayer : public ContainerLayer {
|
2012-07-18 03:59:45 +04:00
|
|
|
friend class LayerManager;
|
|
|
|
|
|
|
|
private:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool InsertAfter(Layer* aChild, Layer* aAfter) override
|
2016-05-13 23:34:41 +03:00
|
|
|
{ MOZ_CRASH("GFX: RefLayer"); return false; }
|
2012-07-18 03:59:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RemoveChild(Layer* aChild) override
|
2016-05-13 23:34:41 +03:00
|
|
|
{ MOZ_CRASH("GFX: RefLayer"); return false; }
|
2012-07-18 03:59:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RepositionChild(Layer* aChild, Layer* aAfter) override
|
2016-05-13 23:34:41 +03:00
|
|
|
{ MOZ_CRASH("GFX: RefLayer"); return false; }
|
2012-08-29 14:52:55 +04:00
|
|
|
|
2012-07-18 03:59:45 +04: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 07:00:41 +04:00
|
|
|
if (mId != aId) {
|
2013-03-22 06:17:28 +04:00
|
|
|
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ReferentId", this));
|
2012-08-07 07:00:41 +04:00
|
|
|
mId = aId;
|
|
|
|
Mutated();
|
|
|
|
}
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Connect this ref layer to its referent, temporarily.
|
|
|
|
* ClearReferentLayer() must be called after composition.
|
|
|
|
*/
|
|
|
|
void ConnectReferentLayer(Layer* aLayer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mFirstChild && !mLastChild);
|
|
|
|
MOZ_ASSERT(!aLayer->GetParent());
|
2014-10-15 02:11:38 +04: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-18 03:59:45 +04:00
|
|
|
|
|
|
|
mFirstChild = mLastChild = aLayer;
|
|
|
|
aLayer->SetParent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
* |aLayer| is the same as the argument to ConnectReferentLayer().
|
|
|
|
*/
|
|
|
|
void DetachReferentLayer(Layer* aLayer)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mFirstChild = mLastChild = nullptr;
|
|
|
|
aLayer->SetParent(nullptr);
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// These getters can be used anytime.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual RefLayer* AsRefLayer() override { return this; }
|
2012-07-18 03:59:45 +04:00
|
|
|
|
2017-04-18 15:43:08 +03:00
|
|
|
virtual uint64_t GetReferentId() { return mId; }
|
2012-07-18 03:59:45 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DRAWING PHASE ONLY
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override;
|
2012-07-18 03:59:45 +04:00
|
|
|
|
|
|
|
MOZ_LAYER_DECL_NAME("RefLayer", TYPE_REF)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
RefLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: ContainerLayer(aManager, aImplData) , mId(0)
|
|
|
|
{}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2012-07-18 03:59:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
|
2014-07-28 00:32:00 +04:00
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
// 0 is a special value that means "no ID".
|
|
|
|
uint64_t mId;
|
|
|
|
};
|
|
|
|
|
2014-01-08 01:06:08 +04:00
|
|
|
void SetAntialiasingFlags(Layer* aLayer, gfx::DrawTarget* aTarget);
|
2013-11-18 06:07:08 +04:00
|
|
|
|
2012-03-05 22:09:05 +04:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2014-01-08 12:37:58 +04:00
|
|
|
void WriteSnapshotToDumpFile(Layer* aLayer, gfx::DataSourceSurface* aSurf);
|
|
|
|
void WriteSnapshotToDumpFile(LayerManager* aManager, gfx::DataSourceSurface* aSurf);
|
2013-09-27 04:37:19 +04:00
|
|
|
void WriteSnapshotToDumpFile(Compositor* aCompositor, gfx::DrawTarget* aTarget);
|
2012-03-05 22:09:05 +04:00
|
|
|
#endif
|
2012-03-01 12:26:09 +04:00
|
|
|
|
2014-08-19 00:13:12 +04:00
|
|
|
// A utility function used by different LayerManager implementations.
|
2015-05-07 12:07:53 +03:00
|
|
|
gfx::IntRect ToOutsideIntRect(const gfxRect &aRect);
|
2014-08-19 00:13:12 +04:00
|
|
|
|
2015-05-07 12:07:53 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2010-03-01 10:56:18 +03:00
|
|
|
|
|
|
|
#endif /* GFX_LAYERS_H */
|