diff --git a/gfx/2d/DrawTargetD2D1.cpp b/gfx/2d/DrawTargetD2D1.cpp index 6a6b168d45b..e6eacc9d80a 100644 --- a/gfx/2d/DrawTargetD2D1.cpp +++ b/gfx/2d/DrawTargetD2D1.cpp @@ -128,14 +128,27 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface, return; } - mDC->CreateImageBrush(image, - D2D1::ImageBrushProperties(samplingBounds, - D2D1_EXTEND_MODE_CLAMP, - D2D1_EXTEND_MODE_CLAMP, - D2DInterpolationMode(aSurfOptions.mFilter)), - D2D1::BrushProperties(aOptions.mAlpha, D2DMatrix(transform)), - byRef(brush)); - mDC->FillRectangle(D2DRect(aDest), brush); + RefPtr bitmap; + if (aSurface->GetType() == SurfaceType::D2D1_1_IMAGE) { + // If this is called with a DataSourceSurface it might do a partial upload + // that our DrawBitmap call doesn't support. + image->QueryInterface((ID2D1Bitmap**)byRef(bitmap)); + } + + if (bitmap && aSurfOptions.mSamplingBounds == SamplingBounds::UNBOUNDED) { + mDC->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha, D2DFilter(aSurfOptions.mFilter), D2DRect(aSource)); + } else { + // This has issues ignoring the alpha channel on windows 7 with images marked opaque. + MOZ_ASSERT(aSurface->GetFormat() != SurfaceFormat::B8G8R8X8); + mDC->CreateImageBrush(image, + D2D1::ImageBrushProperties(samplingBounds, + D2D1_EXTEND_MODE_CLAMP, + D2D1_EXTEND_MODE_CLAMP, + D2DInterpolationMode(aSurfOptions.mFilter)), + D2D1::BrushProperties(aOptions.mAlpha, D2DMatrix(transform)), + byRef(brush)); + mDC->FillRectangle(D2DRect(aDest), brush); + } FinalizeDrawing(aOptions.mCompositionOp, ColorPattern(Color())); }