2012-04-17 02:23:03 +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/. */
|
|
|
|
|
|
|
|
#ifndef GFX_BASICIMPLDATA_H
|
|
|
|
#define GFX_BASICIMPLDATA_H
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "Layers.h" // for Layer (ptr only), etc
|
|
|
|
#include "gfxContext.h" // for gfxContext, etc
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
2014-02-27 01:36:35 +04:00
|
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
2014-02-12 19:07:46 +04:00
|
|
|
#include "mozilla/gfx/Types.h"
|
|
|
|
|
2012-04-17 02:23:03 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
class ReadbackProcessor;
|
|
|
|
class SurfaceDescriptor;
|
|
|
|
|
2012-04-17 02:23:03 +04:00
|
|
|
/**
|
|
|
|
* This is the ImplData for all Basic layers. It also exposes methods
|
|
|
|
* private to the Basic implementation that are common to all Basic layer types.
|
|
|
|
* In particular, there is an internal Paint() method that we can use
|
2014-09-26 21:07:06 +04:00
|
|
|
* to paint the contents of non-PaintedLayers.
|
2012-04-17 02:23:03 +04:00
|
|
|
*
|
|
|
|
* The class hierarchy for Basic layers is like this:
|
|
|
|
* BasicImplData
|
|
|
|
* Layer | | |
|
|
|
|
* | | | |
|
|
|
|
* +-> ContainerLayer | | |
|
|
|
|
* | | | | |
|
|
|
|
* | +-> BasicContainerLayer <--+ | |
|
|
|
|
* | | |
|
2014-09-26 21:06:08 +04:00
|
|
|
* +-> PaintedLayer | |
|
2012-04-17 02:23:03 +04:00
|
|
|
* | | | |
|
2014-09-26 21:06:08 +04:00
|
|
|
* | +-> BasicPaintedLayer <---------+ |
|
2012-04-17 02:23:03 +04:00
|
|
|
* | |
|
|
|
|
* +-> ImageLayer |
|
|
|
|
* | |
|
|
|
|
* +-> BasicImageLayer <--------------+
|
|
|
|
*/
|
|
|
|
class BasicImplData {
|
|
|
|
public:
|
|
|
|
BasicImplData() : mHidden(false),
|
|
|
|
mClipToVisibleRegion(false),
|
|
|
|
mDrawAtomically(false),
|
2014-02-12 19:07:46 +04:00
|
|
|
mOperator(gfx::CompositionOp::OP_OVER)
|
2012-04-17 02:23:03 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(BasicImplData);
|
|
|
|
}
|
|
|
|
virtual ~BasicImplData()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(BasicImplData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Layers that paint themselves, such as ImageLayers, should paint
|
|
|
|
* in response to this method call. aContext will already have been
|
|
|
|
* set up to account for all the properties of the layer (transform,
|
|
|
|
* opacity, etc).
|
|
|
|
*/
|
2014-05-12 04:31:27 +04:00
|
|
|
virtual void Paint(gfx::DrawTarget* aDT,
|
|
|
|
const gfx::Point& aDeviceOffset,
|
|
|
|
Layer* aMaskLayer) {}
|
2012-04-17 02:23:03 +04:00
|
|
|
|
|
|
|
/**
|
2014-09-26 21:06:08 +04:00
|
|
|
* Like Paint() but called for PaintedLayers with the additional parameters
|
2012-04-17 02:23:03 +04:00
|
|
|
* they need.
|
|
|
|
* If mClipToVisibleRegion is set, then the layer must clip to its
|
|
|
|
* effective visible region (snapped or unsnapped, it doesn't matter).
|
|
|
|
*/
|
|
|
|
virtual void PaintThebes(gfxContext* aContext,
|
Backout 61fd66629c4f, 7c8121f8d3af & 2a2e9cf8fd41 (bug 539356), e31a5e6545d3 (bug 761884), 85fa80bd9792, a284ccb25b83, 2865904db9fc, 34e07b09c426, e9b3d41e0360, cef00ebcd6c8, f943b729ac14 & 783f298401b6 (bug 539356), 330a086f1570 (bug 741682), d80219c8842c (bug 739671), e8c96b4fd4da, 313af486e68d, 0adc41ff56dc, 0cd288a38085, f1d43208825c, 4859876972f3, eec8ef3ebe48, f7f29fcd1845, 6079b229d306, f23c3a7e7ce0, 9824458a41e2 & 6748b5496059 (bug 539356) for mochitest-4 orange & talos regressions on multiple platforms
2012-06-11 13:08:32 +04:00
|
|
|
Layer* aMasklayer,
|
2014-09-26 21:06:08 +04:00
|
|
|
LayerManager::DrawPaintedLayerCallback aCallback,
|
2014-05-12 04:31:28 +04:00
|
|
|
void* aCallbackData) {}
|
2012-04-17 02:23:03 +04:00
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback,
|
2014-05-12 04:31:28 +04:00
|
|
|
void* aCallbackData,
|
|
|
|
ReadbackProcessor* aReadback) {}
|
2013-10-15 07:23:21 +04:00
|
|
|
|
2012-04-17 02:23:03 +04:00
|
|
|
/**
|
|
|
|
* Layers will get this call when their layer manager is destroyed, this
|
|
|
|
* indicates they should clear resources they don't really need after their
|
|
|
|
* LayerManager ceases to exist.
|
|
|
|
*/
|
|
|
|
virtual void ClearCachedResources() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This variable is set by MarkLayersHidden() before painting. It indicates
|
|
|
|
* that the layer should not be composited during this transaction.
|
|
|
|
*/
|
|
|
|
void SetHidden(bool aCovered) { mHidden = aCovered; }
|
|
|
|
bool IsHidden() const { return false; }
|
|
|
|
/**
|
|
|
|
* This variable is set by MarkLayersHidden() before painting. This is
|
|
|
|
* the operator to be used when compositing the layer in this transaction. It must
|
|
|
|
* be OVER or SOURCE.
|
|
|
|
*/
|
2014-02-12 19:07:46 +04:00
|
|
|
void SetOperator(gfx::CompositionOp aOperator)
|
2012-04-17 02:23:03 +04:00
|
|
|
{
|
2014-02-12 19:07:46 +04:00
|
|
|
NS_ASSERTION(aOperator == gfx::CompositionOp::OP_OVER ||
|
|
|
|
aOperator == gfx::CompositionOp::OP_SOURCE,
|
2012-04-17 02:23:03 +04:00
|
|
|
"Bad composition operator");
|
|
|
|
mOperator = aOperator;
|
|
|
|
}
|
2014-02-12 19:07:46 +04:00
|
|
|
|
|
|
|
gfx::CompositionOp GetOperator() const { return mOperator; }
|
|
|
|
gfxContext::GraphicsOperator DeprecatedGetOperator() const
|
|
|
|
{
|
|
|
|
return gfx::ThebesOp(mOperator);
|
|
|
|
}
|
Backout 61fd66629c4f, 7c8121f8d3af & 2a2e9cf8fd41 (bug 539356), e31a5e6545d3 (bug 761884), 85fa80bd9792, a284ccb25b83, 2865904db9fc, 34e07b09c426, e9b3d41e0360, cef00ebcd6c8, f943b729ac14 & 783f298401b6 (bug 539356), 330a086f1570 (bug 741682), d80219c8842c (bug 739671), e8c96b4fd4da, 313af486e68d, 0adc41ff56dc, 0cd288a38085, f1d43208825c, 4859876972f3, eec8ef3ebe48, f7f29fcd1845, 6079b229d306, f23c3a7e7ce0, 9824458a41e2 & 6748b5496059 (bug 539356) for mochitest-4 orange & talos regressions on multiple platforms
2012-06-11 13:08:32 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a surface for this layer. Will use an existing surface, if
|
2012-07-12 16:51:58 +04:00
|
|
|
* possible, or may create a temporary surface. Implement this
|
|
|
|
* method for any layers that might be used as a mask. Should only
|
|
|
|
* return false if a surface cannot be created. If true is
|
|
|
|
* returned, only one of |aSurface| or |aDescriptor| is valid.
|
Backout 61fd66629c4f, 7c8121f8d3af & 2a2e9cf8fd41 (bug 539356), e31a5e6545d3 (bug 761884), 85fa80bd9792, a284ccb25b83, 2865904db9fc, 34e07b09c426, e9b3d41e0360, cef00ebcd6c8, f943b729ac14 & 783f298401b6 (bug 539356), 330a086f1570 (bug 741682), d80219c8842c (bug 739671), e8c96b4fd4da, 313af486e68d, 0adc41ff56dc, 0cd288a38085, f1d43208825c, 4859876972f3, eec8ef3ebe48, f7f29fcd1845, 6079b229d306, f23c3a7e7ce0, 9824458a41e2 & 6748b5496059 (bug 539356) for mochitest-4 orange & talos regressions on multiple platforms
2012-06-11 13:08:32 +04:00
|
|
|
*/
|
2014-04-01 08:02:09 +04:00
|
|
|
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
|
2012-04-17 02:23:03 +04:00
|
|
|
|
|
|
|
bool GetClipToVisibleRegion() { return mClipToVisibleRegion; }
|
|
|
|
void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; }
|
|
|
|
|
|
|
|
void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool mHidden;
|
|
|
|
bool mClipToVisibleRegion;
|
|
|
|
bool mDrawAtomically;
|
2014-02-12 19:07:46 +04:00
|
|
|
gfx::CompositionOp mOperator;
|
2012-04-17 02:23:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // layers
|
|
|
|
} // mozilla
|
|
|
|
|
|
|
|
#endif
|