1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/basic/BasicImplData.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,137 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef GFX_BASICIMPLDATA_H 1.9 +#define GFX_BASICIMPLDATA_H 1.10 + 1.11 +#include "Layers.h" // for Layer (ptr only), etc 1.12 +#include "gfxContext.h" // for gfxContext, etc 1.13 +#include "nsDebug.h" // for NS_ASSERTION 1.14 +#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc 1.15 +#include "mozilla/gfx/Types.h" 1.16 + 1.17 +namespace mozilla { 1.18 +namespace layers { 1.19 + 1.20 +class ReadbackProcessor; 1.21 +class SurfaceDescriptor; 1.22 + 1.23 +/** 1.24 + * This is the ImplData for all Basic layers. It also exposes methods 1.25 + * private to the Basic implementation that are common to all Basic layer types. 1.26 + * In particular, there is an internal Paint() method that we can use 1.27 + * to paint the contents of non-Thebes layers. 1.28 + * 1.29 + * The class hierarchy for Basic layers is like this: 1.30 + * BasicImplData 1.31 + * Layer | | | 1.32 + * | | | | 1.33 + * +-> ContainerLayer | | | 1.34 + * | | | | | 1.35 + * | +-> BasicContainerLayer <--+ | | 1.36 + * | | | 1.37 + * +-> ThebesLayer | | 1.38 + * | | | | 1.39 + * | +-> BasicThebesLayer <---------+ | 1.40 + * | | 1.41 + * +-> ImageLayer | 1.42 + * | | 1.43 + * +-> BasicImageLayer <--------------+ 1.44 + */ 1.45 +class BasicImplData { 1.46 +public: 1.47 + BasicImplData() : mHidden(false), 1.48 + mClipToVisibleRegion(false), 1.49 + mDrawAtomically(false), 1.50 + mOperator(gfx::CompositionOp::OP_OVER) 1.51 + { 1.52 + MOZ_COUNT_CTOR(BasicImplData); 1.53 + } 1.54 + virtual ~BasicImplData() 1.55 + { 1.56 + MOZ_COUNT_DTOR(BasicImplData); 1.57 + } 1.58 + 1.59 + /** 1.60 + * Layers that paint themselves, such as ImageLayers, should paint 1.61 + * in response to this method call. aContext will already have been 1.62 + * set up to account for all the properties of the layer (transform, 1.63 + * opacity, etc). 1.64 + */ 1.65 + virtual void Paint(gfx::DrawTarget* aDT, 1.66 + const gfx::Point& aDeviceOffset, 1.67 + Layer* aMaskLayer) {} 1.68 + 1.69 + /** 1.70 + * Like Paint() but called for ThebesLayers with the additional parameters 1.71 + * they need. 1.72 + * If mClipToVisibleRegion is set, then the layer must clip to its 1.73 + * effective visible region (snapped or unsnapped, it doesn't matter). 1.74 + */ 1.75 + virtual void PaintThebes(gfxContext* aContext, 1.76 + Layer* aMasklayer, 1.77 + LayerManager::DrawThebesLayerCallback aCallback, 1.78 + void* aCallbackData, 1.79 + ReadbackProcessor* aReadback) {} 1.80 + 1.81 + virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback, 1.82 + void* aCallbackData) {} 1.83 + 1.84 + /** 1.85 + * Layers will get this call when their layer manager is destroyed, this 1.86 + * indicates they should clear resources they don't really need after their 1.87 + * LayerManager ceases to exist. 1.88 + */ 1.89 + virtual void ClearCachedResources() {} 1.90 + 1.91 + /** 1.92 + * This variable is set by MarkLayersHidden() before painting. It indicates 1.93 + * that the layer should not be composited during this transaction. 1.94 + */ 1.95 + void SetHidden(bool aCovered) { mHidden = aCovered; } 1.96 + bool IsHidden() const { return false; } 1.97 + /** 1.98 + * This variable is set by MarkLayersHidden() before painting. This is 1.99 + * the operator to be used when compositing the layer in this transaction. It must 1.100 + * be OVER or SOURCE. 1.101 + */ 1.102 + void SetOperator(gfx::CompositionOp aOperator) 1.103 + { 1.104 + NS_ASSERTION(aOperator == gfx::CompositionOp::OP_OVER || 1.105 + aOperator == gfx::CompositionOp::OP_SOURCE, 1.106 + "Bad composition operator"); 1.107 + mOperator = aOperator; 1.108 + } 1.109 + 1.110 + gfx::CompositionOp GetOperator() const { return mOperator; } 1.111 + gfxContext::GraphicsOperator DeprecatedGetOperator() const 1.112 + { 1.113 + return gfx::ThebesOp(mOperator); 1.114 + } 1.115 + 1.116 + /** 1.117 + * Return a surface for this layer. Will use an existing surface, if 1.118 + * possible, or may create a temporary surface. Implement this 1.119 + * method for any layers that might be used as a mask. Should only 1.120 + * return false if a surface cannot be created. If true is 1.121 + * returned, only one of |aSurface| or |aDescriptor| is valid. 1.122 + */ 1.123 + virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; } 1.124 + 1.125 + bool GetClipToVisibleRegion() { return mClipToVisibleRegion; } 1.126 + void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; } 1.127 + 1.128 + void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; } 1.129 + 1.130 +protected: 1.131 + bool mHidden; 1.132 + bool mClipToVisibleRegion; 1.133 + bool mDrawAtomically; 1.134 + gfx::CompositionOp mOperator; 1.135 +}; 1.136 + 1.137 +} // layers 1.138 +} // mozilla 1.139 + 1.140 +#endif