Title: [198242] trunk/Tools
Revision
198242
Author
[email protected]
Date
2016-03-15 16:51:19 -0700 (Tue, 15 Mar 2016)

Log Message

[iOS Simulator] Test result snapshots are upside down
https://bugs.webkit.org/show_bug.cgi?id=154761

Reviewed by Simon Fraser.

* WebKitTestRunner/cg/TestInvocationCG.cpp:
(WTR::createCGContextFromImage):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
In r97104, Simon added code to take WindowServer snapshots, which came
in flipped, and added code to flip them back. At this point, WindowServer
snapshots got flipped, and software snapshots did not.

In r140067, Simon noticed that WindowServer ref test images were upside-down
on Mac (not sure why this changed), so turned off the flipping code (but
didn't delete it!). Now, WindowServer snapshots and software snapshots both
are not flipped.

In r190304, Carlos added an enum for the source of the snapshot ("WebView"
for window server snapshots, and "WebContent" for software snapshots),
and - critically - changed the flipping logic to flip software snapshots!

We didn't notice this on Mac because at this point we've made it so that
we *always* have WindowServer snapshots, but on iOS we still don't have
WindowServer snapshots, so now they're flipped.

And that's how we got here.

To restore the behavior from r140067, and correctly unflip snapshots on
iOS, just delete this code.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (198241 => 198242)


--- trunk/Tools/ChangeLog	2016-03-15 23:29:53 UTC (rev 198241)
+++ trunk/Tools/ChangeLog	2016-03-15 23:51:19 UTC (rev 198242)
@@ -1,3 +1,35 @@
+2016-03-15  Tim Horton  <[email protected]>
+
+        [iOS Simulator] Test result snapshots are upside down
+        https://bugs.webkit.org/show_bug.cgi?id=154761
+
+        Reviewed by Simon Fraser.
+
+        * WebKitTestRunner/cg/TestInvocationCG.cpp:
+        (WTR::createCGContextFromImage):
+        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
+        In r97104, Simon added code to take WindowServer snapshots, which came
+        in flipped, and added code to flip them back. At this point, WindowServer
+        snapshots got flipped, and software snapshots did not.
+
+        In r140067, Simon noticed that WindowServer ref test images were upside-down
+        on Mac (not sure why this changed), so turned off the flipping code (but
+        didn't delete it!). Now, WindowServer snapshots and software snapshots both
+        are not flipped.
+
+        In r190304, Carlos added an enum for the source of the snapshot ("WebView"
+        for window server snapshots, and "WebContent" for software snapshots),
+        and - critically - changed the flipping logic to flip software snapshots!
+
+        We didn't notice this on Mac because at this point we've made it so that
+        we *always* have WindowServer snapshots, but on iOS we still don't have
+        WindowServer snapshots, so now they're flipped.
+
+        And that's how we got here.
+
+        To restore the behavior from r140067, and correctly unflip snapshots on
+        iOS, just delete this code.
+
 2016-03-15  Alexey Proskuryakov  <[email protected]>
 
         run-api-tests doesn't print test name when the test crashes

Modified: trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp (198241 => 198242)


--- trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2016-03-15 23:29:53 UTC (rev 198241)
+++ trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2016-03-15 23:51:19 UTC (rev 198242)
@@ -46,12 +46,7 @@
 
 namespace WTR {
 
-enum FlipGraphicsContextOrNot {
-    DontFlipGraphicsContext,
-    FlipGraphicsContext
-};
-
-static CGContextRef createCGContextFromImage(WKImageRef wkImage, FlipGraphicsContextOrNot flip = DontFlipGraphicsContext)
+static CGContextRef createCGContextFromImage(WKImageRef wkImage)
 {
     RetainPtr<CGImageRef> image = adoptCF(WKImageCreateCGImage(wkImage));
 
@@ -62,16 +57,9 @@
     // Creating this bitmap in the device color space should prevent any color conversion when the image of the web view is drawn into it.
     RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
     CGContextRef context = CGBitmapContextCreate(0, pixelsWide, pixelsHigh, 8, rowBytes, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
+
     
-    if (flip == FlipGraphicsContext) {
-        CGContextSaveGState(context);
-        CGContextScaleCTM(context, 1, -1);
-        CGContextTranslateCTM(context, 0, -static_cast<CGFloat>(pixelsHigh));
-    }
-    
     CGContextDrawImage(context, CGRectMake(0, 0, pixelsWide, pixelsHigh), image.get());
-    if (flip == FlipGraphicsContext)
-        CGContextRestoreGState(context);
 
     return context;
 }
@@ -156,7 +144,7 @@
 
 void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects, SnapshotResultType snapshotType)
 {
-    RetainPtr<CGContextRef> context = adoptCF(createCGContextFromImage(image, snapshotType == SnapshotResultType::WebView ? DontFlipGraphicsContext : FlipGraphicsContext));
+    RetainPtr<CGContextRef> context = adoptCF(createCGContextFromImage(image));
 
     // A non-null repaintRects array means we're doing a repaint test.
     if (repaintRects)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to