Bug 942672. When a gfxContext has a DrawTarget there's an extra device transform that we need to take account of here. r=mattwoodrow
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 02 Dec 2013 10:10:50 +1300
changeset 158183 08fd80f4b2bf181ac285c6047838f5a731318d13
parent 158182 b3af7dbf540f5f2b88d0d3a49721f5655d166919
child 158184 54a8c5aae115f03f77ab9854c9fa1ec6daefeeac
push id36943
push userrocallahan@mozilla.com
push dateMon, 02 Dec 2013 01:08:51 +0000
treeherdermozilla-inbound@08fd80f4b2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs942672
milestone28.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
Bug 942672. When a gfxContext has a DrawTarget there's an extra device transform that we need to take account of here. r=mattwoodrow
gfx/thebes/gfxXlibNativeRenderer.cpp
layout/reftests/bugs/942672-1-ref.html
layout/reftests/bugs/942672-1.html
layout/reftests/bugs/reftest.list
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -526,20 +526,24 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
                          int32_t(clipExtents.Height()));
     drawingRect.IntersectRect(drawingRect, intExtents);
 
     gfxPoint offset(drawingRect.x, drawingRect.y);
 
     DrawingMethod method;
     cairo_surface_t* cairoTarget = nullptr;
     DrawTarget* drawTarget = nullptr;
+    gfxPoint deviceTranslation;
     if (ctx->IsCairo()) {
         cairoTarget = cairo_get_group_target(ctx->GetCairo());
+        deviceTranslation = ctx->CurrentMatrix().GetTranslation();
     } else {
         drawTarget = ctx->GetDrawTarget();
+        Matrix dtTransform = drawTarget->GetTransform();
+        deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32);
         cairoTarget = static_cast<cairo_surface_t*>
             (drawTarget->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE));
     }
 
     cairo_surface_t* tempXlibSurface =
         CreateTempXlibSurface(cairoTarget, drawTarget, size,
                               canDrawOverBackground, flags, screen, visual,
                               &method);
@@ -547,17 +551,17 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
         return;
 
     bool drawIsOpaque = (flags & DRAW_IS_OPAQUE) != 0;
     if (!drawIsOpaque) {
         cairo_t* tmpCtx = cairo_create(tempXlibSurface);
         if (method == eCopyBackground) {
             NS_ASSERTION(cairoTarget, "eCopyBackground only used when there's a cairoTarget");
             cairo_set_operator(tmpCtx, CAIRO_OPERATOR_SOURCE);
-            gfxPoint pt = -(offset + ctx->CurrentMatrix().GetTranslation());
+            gfxPoint pt = -(offset + deviceTranslation);
             cairo_set_source_surface(tmpCtx, cairoTarget, pt.x, pt.y);
             // The copy from the tempXlibSurface to the target context should
             // use operator SOURCE, but that would need a mask to bound the
             // operation.  Here we only copy opaque backgrounds so operator
             // OVER will behave like SOURCE masked by the surface.
             NS_ASSERTION(cairo_surface_get_content(tempXlibSurface) == CAIRO_CONTENT_COLOR,
                          "Don't copy background with a transparent surface");
         } else {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/942672-1-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML>
+<html>
+<body style="background:white">
+<div style="opacity:0.5; background:white; height:200px;"><button>Hello</button></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/942672-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML>
+<html>
+<body style="background:white">
+<div style="opacity:0.5; height:200px;"><button>Hello</button></div>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1780,8 +1780,9 @@ fuzzy(1,10000) fuzzy-if(Android&&Android
 fuzzy-if(Android,8,400) == 906199-1.html 906199-1-ref.html
 == 921716-1.html 921716-1-ref.html
 fuzzy-if(cocoaWidget,1,40) == 928607-1.html 928607-1-ref.html
 == 931464-1.html 931464-1-ref.html
 == 931853.html 931853-ref.html
 == 931853-quirks.html 931853-quirks-ref.html
 == 936670-1.svg 936670-1-ref.svg
 == 941940-1.html 941940-1-ref.html
+== 942672-1.html 942672-1-ref.html