diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index 54a47c939d3..d922faafd78 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -939,6 +939,7 @@ DrawTargetD2D::PushClip(const Path *aPath) } mCurrentClipMaskTexture = NULL; + mCurrentClippedGeometry = NULL; RefPtr pathD2D = static_cast(const_cast(aPath)); @@ -977,6 +978,7 @@ void DrawTargetD2D::PushClipRect(const Rect &aRect) { mCurrentClipMaskTexture = NULL; + mCurrentClippedGeometry = NULL; if (!mTransform.IsRectilinear()) { // Whoops, this isn't a rectangle in device space, Direct2D will not deal // with this transform the way we want it to. @@ -1009,6 +1011,7 @@ void DrawTargetD2D::PopClip() { mCurrentClipMaskTexture = NULL; + mCurrentClippedGeometry = NULL; if (mClipsArePushed) { if (mPushedClips.back().mLayer) { mRT->PopLayer(); @@ -1531,11 +1534,14 @@ DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aP TemporaryRef DrawTargetD2D::GetClippedGeometry() { - RefPtr currentSink; - RefPtr clippedGeometry; + if (mCurrentClippedGeometry) { + return mCurrentClippedGeometry; + } - factory()->CreatePathGeometry(byRef(clippedGeometry)); - clippedGeometry->Open(byRef(currentSink)); + RefPtr currentSink; + + factory()->CreatePathGeometry(byRef(mCurrentClippedGeometry)); + mCurrentClippedGeometry->Open(byRef(currentSink)); std::vector::iterator iter = mPushedClips.begin(); @@ -1558,21 +1564,21 @@ DrawTargetD2D::GetClippedGeometry() newGeom->Open(byRef(currentSink)); if (iter->mPath) { - clippedGeometry->CombineWithGeometry(iter->mPath->GetGeometry(), D2D1_COMBINE_MODE_INTERSECT, + mCurrentClippedGeometry->CombineWithGeometry(iter->mPath->GetGeometry(), D2D1_COMBINE_MODE_INTERSECT, iter->mTransform, currentSink); } else { RefPtr rectGeom; factory()->CreateRectangleGeometry(iter->mBounds, byRef(rectGeom)); - clippedGeometry->CombineWithGeometry(rectGeom, D2D1_COMBINE_MODE_INTERSECT, - D2D1::IdentityMatrix(), currentSink); + mCurrentClippedGeometry->CombineWithGeometry(rectGeom, D2D1_COMBINE_MODE_INTERSECT, + D2D1::IdentityMatrix(), currentSink); } currentSink->Close(); - clippedGeometry = newGeom; + mCurrentClippedGeometry = newGeom; } - return clippedGeometry; + return mCurrentClippedGeometry; } TemporaryRef diff --git a/gfx/2d/DrawTargetD2D.h b/gfx/2d/DrawTargetD2D.h index 9bce7d0ebf9..30d35a84018 100644 --- a/gfx/2d/DrawTargetD2D.h +++ b/gfx/2d/DrawTargetD2D.h @@ -215,6 +215,7 @@ private: RefPtr mDevice; RefPtr mTexture; RefPtr mCurrentClipMaskTexture; + RefPtr mCurrentClippedGeometry; mutable RefPtr mRT; // Temporary texture and render target used for supporting alternative operators.