Bug 1400573: Back out initial fix for bug 1392453. r=mchang

MozReview-Commit-ID: 3c3vJbL4kXS
This commit is contained in:
Bas Schouten 2017-09-20 14:57:25 +02:00
Родитель 085ed59d74
Коммит 973de6713e
2 изменённых файлов: 9 добавлений и 40 удалений

Просмотреть файл

@ -238,8 +238,7 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface,
mDC->FillRectangle(D2DRect(aDest), brush); mDC->FillRectangle(D2DRect(aDest), brush);
} }
Rect destBounds = mTransform.TransformBounds(aDest); FinalizeDrawing(aOptions.mCompositionOp, ColorPattern(Color()));
FinalizeDrawing(aOptions.mCompositionOp, ColorPattern(Color()), &destBounds);
} }
void void
@ -1345,7 +1344,7 @@ DrawTargetD2D1::PrepareForDrawing(CompositionOp aOp, const Pattern &aPattern)
} }
void void
DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern, const Rect* aAffectedRect /* = nullptr */) DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern)
{ {
bool patternSupported = IsPatternSupportedByD2D(aPattern); bool patternSupported = IsPatternSupportedByD2D(aPattern);
@ -1408,25 +1407,15 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern, cons
return; return;
} }
Point outOffset; // We don't need to preserve the current content of this layer as the output
// We don't need to preserve the current content of this layer if the output
// of the blend effect should completely replace it. // of the blend effect should completely replace it.
bool shouldPreserveContent = !!aAffectedRect && !aAffectedRect->Contains(Rect(0, 0, mSize.width, mSize.height)); RefPtr<ID2D1Image> tmpImage = GetImageForLayerContent(false);
RefPtr<ID2D1Image> tmpImage = GetImageForLayerContent(shouldPreserveContent, aAffectedRect, &outOffset);
if (!tmpImage) { if (!tmpImage) {
return; return;
} }
blendEffect->SetInput(0, tmpImage); blendEffect->SetInput(0, tmpImage);
blendEffect->SetInput(1, source); blendEffect->SetInput(1, source);
if (outOffset != Point()) {
RefPtr<ID2D1Effect> transformEffect;
mDC->CreateEffect(CLSID_D2D12DAffineTransform, getter_AddRefs(transformEffect));
transformEffect->SetInput(0, tmpImage);
transformEffect->SetValue(D2D1_2DAFFINETRANSFORM_PROP_TRANSFORM_MATRIX, D2D1::Matrix3x2F::Translation(outOffset.x, outOffset.y));
blendEffect->SetInputEffect(0, transformEffect);
}
blendEffect->SetValue(D2D1_BLEND_PROP_MODE, D2DBlendMode(aOp)); blendEffect->SetValue(D2D1_BLEND_PROP_MODE, D2DBlendMode(aOp));
mDC->DrawImage(blendEffect, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY); mDC->DrawImage(blendEffect, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY);
@ -1518,14 +1507,10 @@ DrawTargetD2D1::GetDeviceSpaceClipRect(D2D1_RECT_F& aClipRect, bool& aIsPixelAli
} }
already_AddRefed<ID2D1Image> already_AddRefed<ID2D1Image>
DrawTargetD2D1::GetImageForLayerContent(bool aShouldPreserveContent, const Rect* aBounds /* = nullptr */, Point* aOutOffset /* = nullptr */) DrawTargetD2D1::GetImageForLayerContent(bool aShouldPreserveContent)
{ {
PopAllClips(); PopAllClips();
if (aOutOffset) {
*aOutOffset = Point();
}
if (!CurrentLayer().mCurrentList) { if (!CurrentLayer().mCurrentList) {
RefPtr<ID2D1Bitmap> tmpBitmap; RefPtr<ID2D1Bitmap> tmpBitmap;
HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), getter_AddRefs(tmpBitmap)); HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), getter_AddRefs(tmpBitmap));
@ -1555,20 +1540,10 @@ DrawTargetD2D1::GetImageForLayerContent(bool aShouldPreserveContent, const Rect*
D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_TARGET, D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_TARGET,
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_PREMULTIPLIED)); D2D1_ALPHA_MODE_PREMULTIPLIED));
D2D1_SIZE_U size = mBitmap->GetPixelSize(); mDC->CreateBitmap(mBitmap->GetPixelSize(), nullptr, 0, &props, getter_AddRefs(tmpBitmap));
D2D1_POINT_2F offset = D2D1::Point2F();
if (aBounds) {
size.width = aBounds->width;
size.height = aBounds->height;
offset.x = -aBounds->x;
offset.y = -aBounds->y;
aOutOffset->x = aBounds->x;
aOutOffset->y = aBounds->y;
}
mDC->CreateBitmap(size, nullptr, 0, &props, getter_AddRefs(tmpBitmap));
mDC->SetTransform(D2D1::IdentityMatrix()); mDC->SetTransform(D2D1::IdentityMatrix());
mDC->SetTarget(tmpBitmap); mDC->SetTarget(tmpBitmap);
mDC->DrawImage(list, offset, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY); mDC->DrawImage(list, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY);
mDC->SetTarget(CurrentTarget()); mDC->SetTarget(CurrentTarget());
} }

Просмотреть файл

@ -180,9 +180,7 @@ private:
void MarkChanged(); void MarkChanged();
bool ShouldClipTemporarySurfaceDrawing(CompositionOp aOp, const Pattern& aPattern, bool aClipIsComplex); bool ShouldClipTemporarySurfaceDrawing(CompositionOp aOp, const Pattern& aPattern, bool aClipIsComplex);
void PrepareForDrawing(CompositionOp aOp, const Pattern &aPattern); void PrepareForDrawing(CompositionOp aOp, const Pattern &aPattern);
// aAffectedRect may be used to supply the bounds of the drawing operations in order to prevent void FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern);
// excessive surface area being operated on
void FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern, const Rect* aAffectedRect = nullptr);
void FlushTransformToDC() { void FlushTransformToDC() {
if (mTransformDirty) { if (mTransformDirty) {
mDC->SetTransform(D2DMatrix(mTransform)); mDC->SetTransform(D2DMatrix(mTransform));
@ -192,11 +190,7 @@ private:
void AddDependencyOnSource(SourceSurfaceD2D1* aSource); void AddDependencyOnSource(SourceSurfaceD2D1* aSource);
// Must be called with all clips popped and an identity matrix set. // Must be called with all clips popped and an identity matrix set.
// aBounds can be specified to allow the function to return only part of the layer contents already_AddRefed<ID2D1Image> GetImageForLayerContent(bool aShouldPreserveContent = true);
// aOutOffset will return the offset that should be applied to move the ID2D1Image onto the
// correct portion of the destination layer. If !aBounds this will always be 0,0 and can be
// ignored.
already_AddRefed<ID2D1Image> GetImageForLayerContent(bool aShouldPreserveContent = true, const Rect* aBounds = nullptr, Point* aOutOffset = nullptr);
ID2D1Image* CurrentTarget() ID2D1Image* CurrentTarget()
{ {