- Revision
- 130565
- Author
- [email protected]
- Date
- 2012-10-05 15:56:38 -0700 (Fri, 05 Oct 2012)
Log Message
[cg] GraphicsContextCG should ask CG whether the shadow offset workaround is required
https://bugs.webkit.org/show_bug.cgi?id=98565
<rdar://problem/12436468>
Reviewed by Simon Fraser.
On Mountain Lion and above, CG can tell us whether we need to work around incorrect
shadow offsets. Prior to Mountain Lion, we should assume we need to apply the workaround.
No new tests, as this requires an obscure configuration to test.
* WebCore.exp.in:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::applyShadowOffsetWorkaroundIfNeeded):
(WebCore::GraphicsContext::setPlatformShadow):
* platform/mac/WebCoreSystemInterface.h: Add wkCGContextDrawsWithCorrectShadowOffsets.
* platform/mac/WebCoreSystemInterface.mm: Add wkCGContextDrawsWithCorrectShadowOffsets.
Add wkCGContextDrawsWithCorrectShadowOffsets.
* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (130564 => 130565)
--- trunk/Source/WebCore/ChangeLog 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebCore/ChangeLog 2012-10-05 22:56:38 UTC (rev 130565)
@@ -1,3 +1,23 @@
+2012-10-05 Tim Horton <[email protected]>
+
+ [cg] GraphicsContextCG should ask CG whether the shadow offset workaround is required
+ https://bugs.webkit.org/show_bug.cgi?id=98565
+ <rdar://problem/12436468>
+
+ Reviewed by Simon Fraser.
+
+ On Mountain Lion and above, CG can tell us whether we need to work around incorrect
+ shadow offsets. Prior to Mountain Lion, we should assume we need to apply the workaround.
+
+ No new tests, as this requires an obscure configuration to test.
+
+ * WebCore.exp.in:
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::applyShadowOffsetWorkaroundIfNeeded):
+ (WebCore::GraphicsContext::setPlatformShadow):
+ * platform/mac/WebCoreSystemInterface.h: Add wkCGContextDrawsWithCorrectShadowOffsets.
+ * platform/mac/WebCoreSystemInterface.mm: Add wkCGContextDrawsWithCorrectShadowOffsets.
+
2012-10-05 Anders Carlsson <[email protected]>
Try to fix the build.
Modified: trunk/Source/WebCore/WebCore.exp.in (130564 => 130565)
--- trunk/Source/WebCore/WebCore.exp.in 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-10-05 22:56:38 UTC (rev 130565)
@@ -1422,6 +1422,9 @@
_suggestedFilenameWithMIMEType
_wkCGContextGetShouldSmoothFonts
_wkCGContextResetClip
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+_wkCGContextDrawsWithCorrectShadowOffsets
+#endif
_wkCGPatternCreateWithImageAndTransform
_wkCopyCFLocalizationPreferredName
_wkCopyCFURLResponseSuggestedFilename
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (130564 => 130565)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2012-10-05 22:56:38 UTC (rev 130565)
@@ -1130,6 +1130,32 @@
return true;
}
+static void applyShadowOffsetWorkaroundIfNeeded(const GraphicsContext& context, CGFloat& xOffset, CGFloat& yOffset)
+{
+#if !PLATFORM(IOS)
+ if (context.isAcceleratedContext())
+ return;
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+ if (wkCGContextDrawsWithCorrectShadowOffsets(context.platformContext()))
+ return;
+#endif
+
+ // Work around <rdar://problem/5539388> by ensuring that the offsets will get truncated
+ // to the desired integer. Also see: <rdar://problem/10056277>
+ static const CGFloat extraShadowOffset = narrowPrecisionToCGFloat(1.0 / 128);
+ if (xOffset > 0)
+ xOffset += extraShadowOffset;
+ else if (xOffset < 0)
+ xOffset -= extraShadowOffset;
+
+ if (yOffset > 0)
+ yOffset += extraShadowOffset;
+ else if (yOffset < 0)
+ yOffset -= extraShadowOffset;
+#endif
+}
+
void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, const Color& color, ColorSpace colorSpace)
{
if (paintingDisabled())
@@ -1163,24 +1189,8 @@
// Extreme "blur" values can make text drawing crash or take crazy long times, so clamp
blurRadius = min(blurRadius, narrowPrecisionToCGFloat(1000.0));
+ applyShadowOffsetWorkaroundIfNeeded(*this, xOffset, yOffset);
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
- if (!isAcceleratedContext()) {
- // Work around <rdar://problem/5539388> by ensuring that the offsets will get truncated
- // to the desired integer. Also see: <rdar://problem/10056277>
- static const CGFloat extraShadowOffset = narrowPrecisionToCGFloat(1.0 / 128);
- if (xOffset > 0)
- xOffset += extraShadowOffset;
- else if (xOffset < 0)
- xOffset -= extraShadowOffset;
-
- if (yOffset > 0)
- yOffset += extraShadowOffset;
- else if (yOffset < 0)
- yOffset -= extraShadowOffset;
- }
-#endif
-
// Check for an invalid color, as this means that the color was not set for the shadow
// and we should therefore just use the default shadow color.
if (!color.isValid())
Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (130564 => 130565)
--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h 2012-10-05 22:56:38 UTC (rev 130565)
@@ -120,6 +120,9 @@
wkPatternTilingConstantSpacing
} wkPatternTiling;
extern void (*wkCGContextResetClip)(CGContextRef);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+extern bool (*wkCGContextDrawsWithCorrectShadowOffsets)(CGContextRef);
+#endif
extern CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
extern CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadStreamRef, void *),
void (*formFinalize)(CFReadStreamRef, void *),
Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (130564 => 130565)
--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm 2012-10-05 22:56:38 UTC (rev 130565)
@@ -33,6 +33,9 @@
#endif
BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
void (*wkCGContextResetClip)(CGContextRef);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+bool (*wkCGContextDrawsWithCorrectShadowOffsets)(CGContextRef);
+#endif
CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
Modified: trunk/Source/WebKit/mac/ChangeLog (130564 => 130565)
--- trunk/Source/WebKit/mac/ChangeLog 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebKit/mac/ChangeLog 2012-10-05 22:56:38 UTC (rev 130565)
@@ -1,3 +1,16 @@
+2012-10-05 Tim Horton <[email protected]>
+
+ [cg] GraphicsContextCG should ask CG whether the shadow offset workaround is required
+ https://bugs.webkit.org/show_bug.cgi?id=98565
+ <rdar://problem/12436468>
+
+ Reviewed by Simon Fraser.
+
+ Add wkCGContextDrawsWithCorrectShadowOffsets.
+
+ * WebCoreSupport/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface):
+
2012-10-04 Eric Carlson <[email protected]>
Allow ports to override text track rendering style
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm (130564 => 130565)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm 2012-10-05 22:56:38 UTC (rev 130565)
@@ -49,6 +49,9 @@
INIT(CGContextGetShouldSmoothFonts);
INIT(CGPatternCreateWithImageAndTransform);
INIT(CGContextResetClip);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+ INIT(CGContextDrawsWithCorrectShadowOffsets);
+#endif
INIT(CopyCFLocalizationPreferredName);
INIT(CopyCONNECTProxyResponse);
INIT(CopyNSURLResponseStatusLine);
Modified: trunk/Source/WebKit2/ChangeLog (130564 => 130565)
--- trunk/Source/WebKit2/ChangeLog 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-05 22:56:38 UTC (rev 130565)
@@ -1,3 +1,16 @@
+2012-10-05 Tim Horton <[email protected]>
+
+ [cg] GraphicsContextCG should ask CG whether the shadow offset workaround is required
+ https://bugs.webkit.org/show_bug.cgi?id=98565
+ <rdar://problem/12436468>
+
+ Reviewed by Simon Fraser.
+
+ Add wkCGContextDrawsWithCorrectShadowOffsets.
+
+ * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface):
+
2012-10-04 Eric Carlson <[email protected]>
Allow ports to override text track rendering style
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (130564 => 130565)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm 2012-10-05 22:53:14 UTC (rev 130564)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm 2012-10-05 22:56:38 UTC (rev 130565)
@@ -44,6 +44,9 @@
INIT(CGContextGetShouldSmoothFonts);
INIT(CGPatternCreateWithImageAndTransform);
INIT(CGContextResetClip);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+ INIT(CGContextDrawsWithCorrectShadowOffsets);
+#endif
INIT(CopyCONNECTProxyResponse);
INIT(CopyNSURLResponseStatusLine);
INIT(CreateCTLineWithUniCharProvider);