Bug 1246641: Also execute an occasional EndDraw for CommandLists used by non-operator OVER drawing. r=jrmuizel
MozReview-Commit-ID: H3V3z8ZIiIK
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -27,17 +27,17 @@ ID2D1Factory1* DrawTargetD2D1::mFactory
ID2D1Factory1 *D2DFactory1()
{
return DrawTargetD2D1::factory();
}
DrawTargetD2D1::DrawTargetD2D1()
: mPushedLayers(1)
- , mPushedLayersSincePurge(0)
+ , mUsedCommandListsSincePurge(0)
{
}
DrawTargetD2D1::~DrawTargetD2D1()
{
PopAllClips();
if (mSnapshot) {
@@ -92,24 +92,24 @@ DrawTargetD2D1::Snapshot()
// this can cause issues with memory usage (see bug 1238328). EndDraw/BeginDraw
// are expensive though, especially relatively when little work is done, so
// we try to reduce the amount of times we execute these purges.
static const uint32_t kPushedLayersBeforePurge = 25;
void
DrawTargetD2D1::Flush()
{
- if ((mPushedLayersSincePurge >= kPushedLayersBeforePurge) &&
+ if ((mUsedCommandListsSincePurge >= kPushedLayersBeforePurge) &&
mPushedLayers.size() == 1) {
// It's important to pop all clips as otherwise layers can forget about
// their clip when doing an EndDraw. When we have layers pushed we cannot
// easily pop all underlying clips to delay the purge until we have no
// layers pushed.
PopAllClips();
- mPushedLayersSincePurge = 0;
+ mUsedCommandListsSincePurge = 0;
mDC->EndDraw();
mDC->BeginDraw();
} else {
mDC->Flush();
}
// We no longer depend on any target.
for (TargetSet::iterator iter = mDependingOnTargets.begin();
@@ -269,16 +269,17 @@ DrawTargetD2D1::ClearRect(const Rect &aR
mDC->Clear();
mDC->PopAxisAlignedClip();
PopClip();
return;
}
RefPtr<ID2D1CommandList> list;
+ mUsedCommandListsSincePurge++;
mDC->CreateCommandList(getter_AddRefs(list));
mDC->SetTarget(list);
IntRect addClipRect;
RefPtr<ID2D1Geometry> geom = GetClippedGeometry(&addClipRect);
RefPtr<ID2D1SolidColorBrush> brush;
mDC->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), getter_AddRefs(brush));
@@ -798,17 +799,17 @@ DrawTargetD2D1::PushLayer(bool aOpaque,
pushedLayer.mOldPermitSubpixelAA = mPermitSubpixelAA;
mPermitSubpixelAA = aOpaque;
mDC->CreateCommandList(getter_AddRefs(pushedLayer.mCurrentList));
mPushedLayers.push_back(pushedLayer);
mDC->SetTarget(CurrentTarget());
- mPushedLayersSincePurge++;
+ mUsedCommandListsSincePurge++;
}
void
DrawTargetD2D1::PopLayer()
{
MOZ_ASSERT(CurrentLayer().mPushedClips.size() == 0);
RefPtr<ID2D1CommandList> list = CurrentLayer().mCurrentList;
@@ -1127,16 +1128,17 @@ DrawTargetD2D1::PrepareForDrawing(Compos
return;
}
PopAllClips();
mDC->CreateCommandList(getter_AddRefs(mCommandList));
mDC->SetTarget(mCommandList);
+ mUsedCommandListsSincePurge++;
PushAllClips();
FlushTransformToDC();
}
void
DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern)
{
--- a/gfx/2d/DrawTargetD2D1.h
+++ b/gfx/2d/DrawTargetD2D1.h
@@ -261,17 +261,17 @@ private:
// The latest snapshot of this surface. This needs to be told when this
// target is modified. We keep it alive as a cache.
RefPtr<SourceSurfaceD2D1> mSnapshot;
// A list of targets we need to flush when we're modified.
TargetSet mDependentTargets;
// A list of targets which have this object in their mDependentTargets set
TargetSet mDependingOnTargets;
- uint32_t mPushedLayersSincePurge;
+ uint32_t mUsedCommandListsSincePurge;
static ID2D1Factory1 *mFactory;
static IDWriteFactory *mDWriteFactory;
};
}
}