author | Bas Schouten <bschouten@mozilla.com> |
Fri, 22 Sep 2017 19:37:02 +0200 | |
changeset 382569 | 5d42f8d147c677923fb04ed83a7e41e9a27d4c91 |
parent 382568 | a130f9b289dfd85efc1cde484f892dc53cd5086c |
child 382570 | 0d8a4ea4b26846cac9ff7df12dce86486d82b451 |
push id | 32562 |
push user | archaeopteryx@coole-files.de |
push date | Sat, 23 Sep 2017 09:38:29 +0000 |
treeherder | mozilla-central@8db0c4ecd94c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mchang |
bugs | 1392453 |
milestone | 58.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
gfx/2d/DrawTargetD2D1.cpp | file | annotate | diff | comparison | revisions | |
gfx/2d/DrawTargetD2D1.h | file | annotate | diff | comparison | revisions |
--- a/gfx/2d/DrawTargetD2D1.cpp +++ b/gfx/2d/DrawTargetD2D1.cpp @@ -40,17 +40,17 @@ StaticRefPtr<ID2D1Factory1> DrawTargetD2 RefPtr<ID2D1Factory1> D2DFactory() { return DrawTargetD2D1::factory(); } DrawTargetD2D1::DrawTargetD2D1() : mPushedLayers(1) , mUsedCommandListsSincePurge(0) - , mDidComplexBlendWithListInList(false) + , mComplexBlendsWithListInList(0) , mDeviceSeq(0) { } DrawTargetD2D1::~DrawTargetD2D1() { PopAllClips(); @@ -945,16 +945,18 @@ DrawTargetD2D1::PopLayer() list->Close(); mDC->SetTransform(D2D1::IdentityMatrix()); mTransformDirty = true; DCCommandSink sink(mDC); list->Stream(&sink); + mComplexBlendsWithListInList = 0; + mDC->PopLayer(); } already_AddRefed<SourceSurface> DrawTargetD2D1::CreateSourceSurfaceFromData(unsigned char *aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat) const @@ -1415,22 +1417,17 @@ DrawTargetD2D1::FinalizeDrawing(Composit } blendEffect->SetInput(0, tmpImage); blendEffect->SetInput(1, source); blendEffect->SetValue(D2D1_BLEND_PROP_MODE, D2DBlendMode(aOp)); mDC->DrawImage(blendEffect, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY); - // This may seem a little counter intuitive. If this is false, we go through the regular - // codepaths and set it to true. When this was true, GetImageForLayerContent will return - // a bitmap for the current command list and we will no longer have a complex blend - // with a list for tmpImage. Therefore we can set it to false again. - mDidComplexBlendWithListInList = !mDidComplexBlendWithListInList; - + mComplexBlendsWithListInList++; return; } const RadialGradientPattern *pat = static_cast<const RadialGradientPattern*>(&aPattern); if (pat->mCenter1 == pat->mCenter2 && pat->mRadius1 == pat->mRadius2) { // Draw nothing! return; } @@ -1501,16 +1498,18 @@ DrawTargetD2D1::GetDeviceSpaceClipRect(D aClipRect = IntersectRect(aClipRect, iter->mBounds); if (!iter->mIsPixelAligned) { aIsPixelAligned = false; } } return true; } +static const uint32_t sComplexBlendsWithListAllowedInList = 4; + already_AddRefed<ID2D1Image> DrawTargetD2D1::GetImageForLayerContent(bool aShouldPreserveContent) { PopAllClips(); if (!CurrentLayer().mCurrentList) { RefPtr<ID2D1Bitmap> tmpBitmap; HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), getter_AddRefs(tmpBitmap)); @@ -1530,36 +1529,37 @@ DrawTargetD2D1::GetImageForLayerContent( return tmpBitmap.forget(); } else { RefPtr<ID2D1CommandList> list = CurrentLayer().mCurrentList; mDC->CreateCommandList(getter_AddRefs(CurrentLayer().mCurrentList)); mDC->SetTarget(CurrentTarget()); list->Close(); RefPtr<ID2D1Bitmap1> tmpBitmap; - if (mDidComplexBlendWithListInList) { + if (mComplexBlendsWithListInList >= sComplexBlendsWithListAllowedInList) { D2D1_BITMAP_PROPERTIES1 props = D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_TARGET, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)); mDC->CreateBitmap(mBitmap->GetPixelSize(), nullptr, 0, &props, getter_AddRefs(tmpBitmap)); mDC->SetTransform(D2D1::IdentityMatrix()); mDC->SetTarget(tmpBitmap); mDC->DrawImage(list, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY); mDC->SetTarget(CurrentTarget()); + mComplexBlendsWithListInList = 0; } DCCommandSink sink(mDC); if (aShouldPreserveContent) { list->Stream(&sink); PushAllClips(); } - if (mDidComplexBlendWithListInList) { + if (tmpBitmap) { return tmpBitmap.forget(); } return list.forget(); } } already_AddRefed<ID2D1Geometry>
--- a/gfx/2d/DrawTargetD2D1.h +++ b/gfx/2d/DrawTargetD2D1.h @@ -286,17 +286,17 @@ private: TargetSet mDependingOnTargets; uint32_t mUsedCommandListsSincePurge; // When a BlendEffect has been drawn to a command list, and that command list is // subsequently used -again- as an input to a blend effect for a command list, // this causes an infinite recursion inside D2D as it tries to resolve the bounds. // If we resolve the current command list before this happens // we can avoid the subsequent hang. (See bug 1293586) - bool mDidComplexBlendWithListInList; + uint32_t mComplexBlendsWithListInList; static StaticRefPtr<ID2D1Factory1> mFactory; // This value is uesed to verify if the DrawTarget is created by a stale device. uint32_t mDeviceSeq; // List of effects we use bool EnsureLuminanceEffect(); RefPtr<ID2D1Effect> mLuminanceEffect;