Title: [208339] trunk/Source/WebCore
Revision
208339
Author
[email protected]
Date
2016-11-03 12:09:42 -0700 (Thu, 03 Nov 2016)

Log Message

[Win][Direct2D] Native Windows widgets are drawn upside-down
https://bugs.webkit.org/show_bug.cgi?id=164370

Reviewed by Alex Christensen.

When we return from drawing in GDI code, we need to flip the resulting
bitmap so that it draws in the proper orientation in Direct2D.

Tested by existing widget tests.

* platform/graphics/win/GraphicsContextDirect2D.cpp:
(WebCore::GraphicsContext::releaseWindowsContext): Flip before drawing
to our Direct2D context.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208338 => 208339)


--- trunk/Source/WebCore/ChangeLog	2016-11-03 18:47:09 UTC (rev 208338)
+++ trunk/Source/WebCore/ChangeLog	2016-11-03 19:09:42 UTC (rev 208339)
@@ -1,3 +1,19 @@
+2016-11-03  Brent Fulgham  <[email protected]>
+
+        [Win][Direct2D] Native Windows widgets are drawn upside-down
+        https://bugs.webkit.org/show_bug.cgi?id=164370
+
+        Reviewed by Alex Christensen.
+
+        When we return from drawing in GDI code, we need to flip the resulting
+        bitmap so that it draws in the proper orientation in Direct2D.
+
+        Tested by existing widget tests.
+
+        * platform/graphics/win/GraphicsContextDirect2D.cpp:
+        (WebCore::GraphicsContext::releaseWindowsContext): Flip before drawing
+        to our Direct2D context.
+
 2016-11-01  Gavin Barraclough  <[email protected]>
 
         Remove PageThrottler & all related code

Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp (208338 => 208339)


--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp	2016-11-03 18:47:09 UTC (rev 208338)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp	2016-11-03 19:09:42 UTC (rev 208339)
@@ -268,8 +268,22 @@
     HRESULT hr = platformContext()->CreateBitmap(pixelData.size(), pixelData.buffer(), pixelData.bytesPerRow(), &bitmapProperties, &bitmap);
     ASSERT(SUCCEEDED(hr));
 
-    platformContext()->DrawBitmap(bitmap.get(), dstRect);
+    D2DContextStateSaver stateSaver(*m_data);
 
+    // Note: The content in the HDC is inverted compared to Direct2D, so it needs to be flipped.
+    auto context = platformContext();
+
+    D2D1_MATRIX_3X2_F currentTransform;
+    context->GetTransform(&currentTransform);
+
+    AffineTransform transform(currentTransform);
+    transform.translate(dstRect.location());
+    transform.scale(1.0, -1.0);
+    transform.translate(0, -dstRect.height());
+
+    context->SetTransform(transform);
+    context->DrawBitmap(bitmap.get(), D2D1::RectF(0, 0, dstRect.width(), dstRect.height()));
+
     ::DeleteDC(hdc);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to