Bug 1220629 - Part 1: Add PushLayer/PopLayer API to DrawTarget baseclass. r=jrmuizel
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -934,16 +934,45 @@ public:
virtual void PushClipRect(const Rect &aRect) = 0;
/** Pop a clip from the DrawTarget. A pop without a corresponding push will
* be ignored.
*/
virtual void PopClip() = 0;
/**
+ * Push a 'layer' to the DrawTarget, a layer is a temporary surface that all
+ * drawing will be redirected to, this is used for example to support group
+ * opacity or the masking of groups. Clips must be balanced within a layer,
+ * i.e. between a matching PushLayer/PopLayer pair there must be as many
+ * PushClip(Rect) calls as there are PopClip calls.
+ *
+ * @param aOpaque Whether the layer will be opaque
+ * @param aOpacity Opacity of the layer
+ * @param aMask Mask applied to the layer
+ * @param aMaskTransform Transform applied to the layer mask
+ * @param aBounds Optional bounds in device space to which the layer is
+ * limited in size.
+ * @param aCopyBackground Whether to copy the background into the layer, this
+ * is only supported when aOpaque is true.
+ */
+ virtual void PushLayer(bool aOpaque, Float aOpacity,
+ SourceSurface* aMask,
+ const Matrix& aMaskTransform,
+ const IntRect& aBounds = IntRect(),
+ bool aCopyBackground = false) { MOZ_CRASH(); }
+
+ /**
+ * This balances a call to PushLayer and proceeds to blend the layer back
+ * onto the background. This blend will blend the temporary surface back
+ * onto the target in device space using POINT sampling and operator over.
+ */
+ virtual void PopLayer() { MOZ_CRASH(); }
+
+ /**
* Create a SourceSurface optimized for use with this DrawTarget from
* existing bitmap data in memory.
*
* The SourceSurface does not take ownership of aData, and may be freed at any time.
*/
virtual already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
const IntSize &aSize,
int32_t aStride,
@@ -1079,16 +1108,20 @@ public:
void SetOpaqueRect(const IntRect &aRect) {
mOpaqueRect = aRect;
}
const IntRect &GetOpaqueRect() const {
return mOpaqueRect;
}
+ virtual bool IsCurrentGroupOpaque() {
+ return GetFormat() == SurfaceFormat::B8G8R8X8;
+ }
+
virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) {
mPermitSubpixelAA = aPermitSubpixelAA;
}
bool GetPermitSubpixelAA() {
return mPermitSubpixelAA;
}