Bug 1266430: Support offsets in DrawTargetD2D1::CopySurface when using PartialUploading. r=jrmuizel
MozReview-Commit-ID: 7D4iWbecNPm
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -358,45 +358,51 @@ DrawTargetD2D1::CopySurface(SourceSurfac
{
MarkChanged();
PopAllClips();
mDC->SetTransform(D2D1::IdentityMatrix());
mTransformDirty = true;
- Matrix mat;
+ Matrix mat = Matrix::Translation(aDestination.x - aSourceRect.x, aDestination.y - aSourceRect.y);
RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, mat, ExtendMode::CLAMP);
if (!image) {
gfxWarning() << "Couldn't get image for surface.";
return;
}
- if (!mat.IsIdentity()) {
- gfxDebug() << *this << ": At this point complex partial uploads are not supported for CopySurface.";
+ if (mat.HasNonIntegerTranslation()) {
+ gfxDebug() << *this << ": At this point scaled partial uploads are not supported for CopySurface.";
return;
}
+ IntRect sourceRect = aSourceRect;
+ sourceRect.x += (aDestination.x - aSourceRect.x) - mat._31;
+ sourceRect.width -= (aDestination.x - aSourceRect.x) - mat._31;
+ sourceRect.y += (aDestination.y - aSourceRect.y) - mat._32;
+ sourceRect.height -= (aDestination.y - aSourceRect.y) - mat._32;
+
RefPtr<ID2D1Bitmap> bitmap;
image->QueryInterface((ID2D1Bitmap**)getter_AddRefs(bitmap));
if (bitmap && mFormat == SurfaceFormat::A8) {
RefPtr<ID2D1SolidColorBrush> brush;
mDC->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White),
D2D1::BrushProperties(), getter_AddRefs(brush));
mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
mDC->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_COPY);
mDC->FillOpacityMask(bitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS);
mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
mDC->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_SOURCE_OVER);
return;
}
- Rect srcRect(Float(aSourceRect.x), Float(aSourceRect.y),
+ Rect srcRect(Float(sourceRect.x), Float(sourceRect.y),
Float(aSourceRect.width), Float(aSourceRect.height));
Rect dstRect(Float(aDestination.x), Float(aDestination.y),
Float(aSourceRect.width), Float(aSourceRect.height));
if (bitmap) {
mDC->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_COPY);
mDC->DrawBitmap(bitmap, D2DRect(dstRect), 1.0f,