gfx/layers/basic/BasicImplData.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef GFX_BASICIMPLDATA_H
michael@0 6 #define GFX_BASICIMPLDATA_H
michael@0 7
michael@0 8 #include "Layers.h" // for Layer (ptr only), etc
michael@0 9 #include "gfxContext.h" // for gfxContext, etc
michael@0 10 #include "nsDebug.h" // for NS_ASSERTION
michael@0 11 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
michael@0 12 #include "mozilla/gfx/Types.h"
michael@0 13
michael@0 14 namespace mozilla {
michael@0 15 namespace layers {
michael@0 16
michael@0 17 class ReadbackProcessor;
michael@0 18 class SurfaceDescriptor;
michael@0 19
michael@0 20 /**
michael@0 21 * This is the ImplData for all Basic layers. It also exposes methods
michael@0 22 * private to the Basic implementation that are common to all Basic layer types.
michael@0 23 * In particular, there is an internal Paint() method that we can use
michael@0 24 * to paint the contents of non-Thebes layers.
michael@0 25 *
michael@0 26 * The class hierarchy for Basic layers is like this:
michael@0 27 * BasicImplData
michael@0 28 * Layer | | |
michael@0 29 * | | | |
michael@0 30 * +-> ContainerLayer | | |
michael@0 31 * | | | | |
michael@0 32 * | +-> BasicContainerLayer <--+ | |
michael@0 33 * | | |
michael@0 34 * +-> ThebesLayer | |
michael@0 35 * | | | |
michael@0 36 * | +-> BasicThebesLayer <---------+ |
michael@0 37 * | |
michael@0 38 * +-> ImageLayer |
michael@0 39 * | |
michael@0 40 * +-> BasicImageLayer <--------------+
michael@0 41 */
michael@0 42 class BasicImplData {
michael@0 43 public:
michael@0 44 BasicImplData() : mHidden(false),
michael@0 45 mClipToVisibleRegion(false),
michael@0 46 mDrawAtomically(false),
michael@0 47 mOperator(gfx::CompositionOp::OP_OVER)
michael@0 48 {
michael@0 49 MOZ_COUNT_CTOR(BasicImplData);
michael@0 50 }
michael@0 51 virtual ~BasicImplData()
michael@0 52 {
michael@0 53 MOZ_COUNT_DTOR(BasicImplData);
michael@0 54 }
michael@0 55
michael@0 56 /**
michael@0 57 * Layers that paint themselves, such as ImageLayers, should paint
michael@0 58 * in response to this method call. aContext will already have been
michael@0 59 * set up to account for all the properties of the layer (transform,
michael@0 60 * opacity, etc).
michael@0 61 */
michael@0 62 virtual void Paint(gfx::DrawTarget* aDT,
michael@0 63 const gfx::Point& aDeviceOffset,
michael@0 64 Layer* aMaskLayer) {}
michael@0 65
michael@0 66 /**
michael@0 67 * Like Paint() but called for ThebesLayers with the additional parameters
michael@0 68 * they need.
michael@0 69 * If mClipToVisibleRegion is set, then the layer must clip to its
michael@0 70 * effective visible region (snapped or unsnapped, it doesn't matter).
michael@0 71 */
michael@0 72 virtual void PaintThebes(gfxContext* aContext,
michael@0 73 Layer* aMasklayer,
michael@0 74 LayerManager::DrawThebesLayerCallback aCallback,
michael@0 75 void* aCallbackData,
michael@0 76 ReadbackProcessor* aReadback) {}
michael@0 77
michael@0 78 virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback,
michael@0 79 void* aCallbackData) {}
michael@0 80
michael@0 81 /**
michael@0 82 * Layers will get this call when their layer manager is destroyed, this
michael@0 83 * indicates they should clear resources they don't really need after their
michael@0 84 * LayerManager ceases to exist.
michael@0 85 */
michael@0 86 virtual void ClearCachedResources() {}
michael@0 87
michael@0 88 /**
michael@0 89 * This variable is set by MarkLayersHidden() before painting. It indicates
michael@0 90 * that the layer should not be composited during this transaction.
michael@0 91 */
michael@0 92 void SetHidden(bool aCovered) { mHidden = aCovered; }
michael@0 93 bool IsHidden() const { return false; }
michael@0 94 /**
michael@0 95 * This variable is set by MarkLayersHidden() before painting. This is
michael@0 96 * the operator to be used when compositing the layer in this transaction. It must
michael@0 97 * be OVER or SOURCE.
michael@0 98 */
michael@0 99 void SetOperator(gfx::CompositionOp aOperator)
michael@0 100 {
michael@0 101 NS_ASSERTION(aOperator == gfx::CompositionOp::OP_OVER ||
michael@0 102 aOperator == gfx::CompositionOp::OP_SOURCE,
michael@0 103 "Bad composition operator");
michael@0 104 mOperator = aOperator;
michael@0 105 }
michael@0 106
michael@0 107 gfx::CompositionOp GetOperator() const { return mOperator; }
michael@0 108 gfxContext::GraphicsOperator DeprecatedGetOperator() const
michael@0 109 {
michael@0 110 return gfx::ThebesOp(mOperator);
michael@0 111 }
michael@0 112
michael@0 113 /**
michael@0 114 * Return a surface for this layer. Will use an existing surface, if
michael@0 115 * possible, or may create a temporary surface. Implement this
michael@0 116 * method for any layers that might be used as a mask. Should only
michael@0 117 * return false if a surface cannot be created. If true is
michael@0 118 * returned, only one of |aSurface| or |aDescriptor| is valid.
michael@0 119 */
michael@0 120 virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
michael@0 121
michael@0 122 bool GetClipToVisibleRegion() { return mClipToVisibleRegion; }
michael@0 123 void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; }
michael@0 124
michael@0 125 void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; }
michael@0 126
michael@0 127 protected:
michael@0 128 bool mHidden;
michael@0 129 bool mClipToVisibleRegion;
michael@0 130 bool mDrawAtomically;
michael@0 131 gfx::CompositionOp mOperator;
michael@0 132 };
michael@0 133
michael@0 134 } // layers
michael@0 135 } // mozilla
michael@0 136
michael@0 137 #endif

mercurial