diff --git a/gfx/2d/DrawTargetD2D1.cpp b/gfx/2d/DrawTargetD2D1.cpp index 2ad9240f039a..88dc187d80ca 100644 --- a/gfx/2d/DrawTargetD2D1.cpp +++ b/gfx/2d/DrawTargetD2D1.cpp @@ -238,8 +238,7 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface, mDC->FillRectangle(D2DRect(aDest), brush); } - Rect destBounds = mTransform.TransformBounds(aDest); - FinalizeDrawing(aOptions.mCompositionOp, ColorPattern(Color()), &destBounds); + FinalizeDrawing(aOptions.mCompositionOp, ColorPattern(Color())); } void @@ -1345,7 +1344,7 @@ DrawTargetD2D1::PrepareForDrawing(CompositionOp aOp, const Pattern &aPattern) } void -DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern, const Rect* aAffectedRect /* = nullptr */) +DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern) { bool patternSupported = IsPatternSupportedByD2D(aPattern); @@ -1408,25 +1407,15 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern, cons return; } - Point outOffset; - // We don't need to preserve the current content of this layer if the output + // We don't need to preserve the current content of this layer as the output // of the blend effect should completely replace it. - bool shouldPreserveContent = !!aAffectedRect && !aAffectedRect->Contains(Rect(0, 0, mSize.width, mSize.height)); - RefPtr tmpImage = GetImageForLayerContent(shouldPreserveContent, aAffectedRect, &outOffset); + RefPtr tmpImage = GetImageForLayerContent(false); if (!tmpImage) { return; } blendEffect->SetInput(0, tmpImage); blendEffect->SetInput(1, source); - - if (outOffset != Point()) { - RefPtr 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)); 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 -DrawTargetD2D1::GetImageForLayerContent(bool aShouldPreserveContent, const Rect* aBounds /* = nullptr */, Point* aOutOffset /* = nullptr */) +DrawTargetD2D1::GetImageForLayerContent(bool aShouldPreserveContent) { PopAllClips(); - if (aOutOffset) { - *aOutOffset = Point(); - } - if (!CurrentLayer().mCurrentList) { RefPtr 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::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)); - D2D1_SIZE_U size = mBitmap->GetPixelSize(); - 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->CreateBitmap(mBitmap->GetPixelSize(), nullptr, 0, &props, getter_AddRefs(tmpBitmap)); mDC->SetTransform(D2D1::IdentityMatrix()); 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()); } diff --git a/gfx/2d/DrawTargetD2D1.h b/gfx/2d/DrawTargetD2D1.h index f924f5495b74..3d9ac21cba29 100644 --- a/gfx/2d/DrawTargetD2D1.h +++ b/gfx/2d/DrawTargetD2D1.h @@ -180,9 +180,7 @@ private: void MarkChanged(); bool ShouldClipTemporarySurfaceDrawing(CompositionOp aOp, const Pattern& aPattern, bool aClipIsComplex); void PrepareForDrawing(CompositionOp aOp, const Pattern &aPattern); - // aAffectedRect may be used to supply the bounds of the drawing operations in order to prevent - // excessive surface area being operated on - void FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern, const Rect* aAffectedRect = nullptr); + void FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern); void FlushTransformToDC() { if (mTransformDirty) { mDC->SetTransform(D2DMatrix(mTransform)); @@ -192,11 +190,7 @@ private: void AddDependencyOnSource(SourceSurfaceD2D1* aSource); // 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 - // 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 GetImageForLayerContent(bool aShouldPreserveContent = true, const Rect* aBounds = nullptr, Point* aOutOffset = nullptr); + already_AddRefed GetImageForLayerContent(bool aShouldPreserveContent = true); ID2D1Image* CurrentTarget() {