Title: [203424] trunk/Source/WebCore
Revision
203424
Author
[email protected]
Date
2016-07-19 15:43:41 -0700 (Tue, 19 Jul 2016)

Log Message

REGRESSION(202927): The first slide is the only displayed slide when Quicklooking a Keynote file
https://bugs.webkit.org/show_bug.cgi?id=159948
<rdar://problem/27391012>

Reviewed by Simon Fraser.

There is an iOS bug (<rdar://problem/27416744>) that is causing us
to not always get a color space on CGContextRefs. Investigation of this
exposed some optimizations we can take when we are creating ImageBuffers.
In particular, if we have a bitmap context or an IOSurfaceContext we
can simply copy their color space using API. Otherwise we stick with
the existing CGContextCopyDeviceColorSpace.

Lastly, if for some reason we are unable to copy the device color space,
we should fall back to sRGB.

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::createCompatibleBuffer):
* platform/spi/cg/CoreGraphicsSPI.h: Add some SPI and enums.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203423 => 203424)


--- trunk/Source/WebCore/ChangeLog	2016-07-19 22:35:51 UTC (rev 203423)
+++ trunk/Source/WebCore/ChangeLog	2016-07-19 22:43:41 UTC (rev 203424)
@@ -1,3 +1,26 @@
+2016-07-19  Dean Jackson  <[email protected]>
+
+        REGRESSION(202927): The first slide is the only displayed slide when Quicklooking a Keynote file
+        https://bugs.webkit.org/show_bug.cgi?id=159948
+        <rdar://problem/27391012>
+
+        Reviewed by Simon Fraser.
+
+        There is an iOS bug (<rdar://problem/27416744>) that is causing us
+        to not always get a color space on CGContextRefs. Investigation of this
+        exposed some optimizations we can take when we are creating ImageBuffers.
+        In particular, if we have a bitmap context or an IOSurfaceContext we
+        can simply copy their color space using API. Otherwise we stick with
+        the existing CGContextCopyDeviceColorSpace.
+
+        Lastly, if for some reason we are unable to copy the device color space,
+        we should fall back to sRGB.
+
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::createCompatibleBuffer):
+        * platform/spi/cg/CoreGraphicsSPI.h: Add some SPI and enums.
+
+
 2016-07-19  George Ruan  <[email protected]>
 
         HTMLVideoElement frames do not update on iOS when src is a MediaStream blob

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (203423 => 203424)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2016-07-19 22:35:51 UTC (rev 203423)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2016-07-19 22:43:41 UTC (rev 203424)
@@ -79,7 +79,22 @@
     float resolutionScale = context.scaleFactor().width();
     RetainPtr<CGColorSpaceRef> colorSpace;
 #if PLATFORM(COCOA)
-    colorSpace = adoptCF(CGContextCopyDeviceColorSpace(context.platformContext()));
+    CGContextRef cgContext = context.platformContext();
+    switch (CGContextGetType(cgContext)) {
+    case kCGContextTypeBitmap:
+        colorSpace = adoptCF(CGBitmapContextGetColorSpace(cgContext));
+        break;
+#if USE(IOSURFACE)
+    case kCGContextTypeIOSurface:
+        colorSpace = adoptCF(CGIOSurfaceContextGetColorSpace(cgContext));
+        break;
+#endif
+    default:
+        colorSpace = adoptCF(CGContextCopyDeviceColorSpace(cgContext));
+    }
+
+    if (!colorSpace)
+        colorSpace = sRGBColorSpaceRef();
 #else
     colorSpace = sRGBColorSpaceRef();
 #endif

Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (203423 => 203424)


--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2016-07-19 22:35:51 UTC (rev 203423)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2016-07-19 22:43:41 UTC (rev 203424)
@@ -74,6 +74,19 @@
 typedef const struct CGColorTransform* CGColorTransformRef;
 
 typedef enum {
+    kCGContextTypeUnknown,
+    kCGContextTypePDF,
+    kCGContextTypePostScript,
+    kCGContextTypeWindow,
+    kCGContextTypeBitmap,
+    kCGContextTypeGL,
+    kCGContextTypeDisplayList,
+    kCGContextTypeKSeparation,
+    kCGContextTypeIOSurface,
+    kCGContextTypeCount
+} CGContextType;
+
+typedef enum {
     kCGCompositeCopy = 1,
     kCGCompositeSover = 2,
 } CGCompositeOperation;
@@ -156,6 +169,7 @@
 void CGContextSetCompositeOperation(CGContextRef, CGCompositeOperation);
 void CGContextSetShouldAntialiasFonts(CGContextRef, bool shouldAntialiasFonts);
 void CGContextResetClip(CGContextRef);
+CGContextType CGContextGetType(CGContextRef);
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
 void CGContextSetFontDilation(CGContextRef, CGSize);
 void CGContextSetFontRenderingStyle(CGContextRef, CGFontRenderingStyle);
@@ -182,6 +196,7 @@
 CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef, size_t, size_t, size_t, size_t, CGColorSpaceRef, CGBitmapInfo);
 CGImageRef CGIOSurfaceContextCreateImage(CGContextRef);
 CGImageRef CGIOSurfaceContextCreateImageReference(CGContextRef);
+CGColorSpaceRef CGIOSurfaceContextGetColorSpace(CGContextRef);
 #endif
 
 #if PLATFORM(COCOA)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to