michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_BASICIMPLDATA_H michael@0: #define GFX_BASICIMPLDATA_H michael@0: michael@0: #include "Layers.h" // for Layer (ptr only), etc michael@0: #include "gfxContext.h" // for gfxContext, etc michael@0: #include "nsDebug.h" // for NS_ASSERTION michael@0: #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc michael@0: #include "mozilla/gfx/Types.h" michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class ReadbackProcessor; michael@0: class SurfaceDescriptor; michael@0: michael@0: /** michael@0: * This is the ImplData for all Basic layers. It also exposes methods michael@0: * private to the Basic implementation that are common to all Basic layer types. michael@0: * In particular, there is an internal Paint() method that we can use michael@0: * to paint the contents of non-Thebes layers. michael@0: * michael@0: * The class hierarchy for Basic layers is like this: michael@0: * BasicImplData michael@0: * Layer | | | michael@0: * | | | | michael@0: * +-> ContainerLayer | | | michael@0: * | | | | | michael@0: * | +-> BasicContainerLayer <--+ | | michael@0: * | | | michael@0: * +-> ThebesLayer | | michael@0: * | | | | michael@0: * | +-> BasicThebesLayer <---------+ | michael@0: * | | michael@0: * +-> ImageLayer | michael@0: * | | michael@0: * +-> BasicImageLayer <--------------+ michael@0: */ michael@0: class BasicImplData { michael@0: public: michael@0: BasicImplData() : mHidden(false), michael@0: mClipToVisibleRegion(false), michael@0: mDrawAtomically(false), michael@0: mOperator(gfx::CompositionOp::OP_OVER) michael@0: { michael@0: MOZ_COUNT_CTOR(BasicImplData); michael@0: } michael@0: virtual ~BasicImplData() michael@0: { michael@0: MOZ_COUNT_DTOR(BasicImplData); michael@0: } michael@0: michael@0: /** michael@0: * Layers that paint themselves, such as ImageLayers, should paint michael@0: * in response to this method call. aContext will already have been michael@0: * set up to account for all the properties of the layer (transform, michael@0: * opacity, etc). michael@0: */ michael@0: virtual void Paint(gfx::DrawTarget* aDT, michael@0: const gfx::Point& aDeviceOffset, michael@0: Layer* aMaskLayer) {} michael@0: michael@0: /** michael@0: * Like Paint() but called for ThebesLayers with the additional parameters michael@0: * they need. michael@0: * If mClipToVisibleRegion is set, then the layer must clip to its michael@0: * effective visible region (snapped or unsnapped, it doesn't matter). michael@0: */ michael@0: virtual void PaintThebes(gfxContext* aContext, michael@0: Layer* aMasklayer, michael@0: LayerManager::DrawThebesLayerCallback aCallback, michael@0: void* aCallbackData, michael@0: ReadbackProcessor* aReadback) {} michael@0: michael@0: virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback, michael@0: void* aCallbackData) {} michael@0: michael@0: /** michael@0: * Layers will get this call when their layer manager is destroyed, this michael@0: * indicates they should clear resources they don't really need after their michael@0: * LayerManager ceases to exist. michael@0: */ michael@0: virtual void ClearCachedResources() {} michael@0: michael@0: /** michael@0: * This variable is set by MarkLayersHidden() before painting. It indicates michael@0: * that the layer should not be composited during this transaction. michael@0: */ michael@0: void SetHidden(bool aCovered) { mHidden = aCovered; } michael@0: bool IsHidden() const { return false; } michael@0: /** michael@0: * This variable is set by MarkLayersHidden() before painting. This is michael@0: * the operator to be used when compositing the layer in this transaction. It must michael@0: * be OVER or SOURCE. michael@0: */ michael@0: void SetOperator(gfx::CompositionOp aOperator) michael@0: { michael@0: NS_ASSERTION(aOperator == gfx::CompositionOp::OP_OVER || michael@0: aOperator == gfx::CompositionOp::OP_SOURCE, michael@0: "Bad composition operator"); michael@0: mOperator = aOperator; michael@0: } michael@0: michael@0: gfx::CompositionOp GetOperator() const { return mOperator; } michael@0: gfxContext::GraphicsOperator DeprecatedGetOperator() const michael@0: { michael@0: return gfx::ThebesOp(mOperator); michael@0: } michael@0: michael@0: /** michael@0: * Return a surface for this layer. Will use an existing surface, if michael@0: * possible, or may create a temporary surface. Implement this michael@0: * method for any layers that might be used as a mask. Should only michael@0: * return false if a surface cannot be created. If true is michael@0: * returned, only one of |aSurface| or |aDescriptor| is valid. michael@0: */ michael@0: virtual TemporaryRef GetAsSourceSurface() { return nullptr; } michael@0: michael@0: bool GetClipToVisibleRegion() { return mClipToVisibleRegion; } michael@0: void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; } michael@0: michael@0: void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; } michael@0: michael@0: protected: michael@0: bool mHidden; michael@0: bool mClipToVisibleRegion; michael@0: bool mDrawAtomically; michael@0: gfx::CompositionOp mOperator; michael@0: }; michael@0: michael@0: } // layers michael@0: } // mozilla michael@0: michael@0: #endif