[Cocoa] Migrate WKSetPatternPhaseInUserSpace() and WKGetUserToBaseCTM() from WKSI
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Oct 2015 19:50:09 +0000 (19:50 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Oct 2015 19:50:09 +0000 (19:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150460

Reviewed by Tim Horton.

Source/WebCore:

No reason to use WKSI for these calls.

No new tests because there is no behavior change.

* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::applyStrokePattern):
(WebCore::GraphicsContext::applyFillPattern):
(WebCore::GraphicsContext::setPlatformShadow):
* platform/graphics/cg/GraphicsContextCG.h:
(WebCore::getUserToBaseCTM):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::putByteArray):
* platform/graphics/mac/GraphicsContextMac.mm:
(WebCore::setPatternPhaseInUserSpace):
(WebCore::GraphicsContext::drawLineForDocumentMarker):
* platform/ios/WebCoreSystemInterfaceIOS.mm:
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Source/WebKit/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Deleted.

Source/WebKit2:

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.h
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm
Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm

index 1817b9b..b52b0a1 100644 (file)
@@ -1,3 +1,29 @@
+2015-10-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Migrate WKSetPatternPhaseInUserSpace() and WKGetUserToBaseCTM() from WKSI
+        https://bugs.webkit.org/show_bug.cgi?id=150460
+
+        Reviewed by Tim Horton.
+
+        No reason to use WKSI for these calls.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::applyStrokePattern):
+        (WebCore::GraphicsContext::applyFillPattern):
+        (WebCore::GraphicsContext::setPlatformShadow):
+        * platform/graphics/cg/GraphicsContextCG.h:
+        (WebCore::getUserToBaseCTM):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::putByteArray):
+        * platform/graphics/mac/GraphicsContextMac.mm:
+        (WebCore::setPatternPhaseInUserSpace):
+        (WebCore::GraphicsContext::drawLineForDocumentMarker):
+        * platform/ios/WebCoreSystemInterfaceIOS.mm:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+
 2015-10-22  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: Basic createObjectStore implementation.
index fc2a8ae..f3ecc82 100644 (file)
@@ -583,7 +583,7 @@ void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint*
 void GraphicsContext::applyStrokePattern()
 {
     CGContextRef cgContext = platformContext();
-    AffineTransform userToBaseCTM = AffineTransform(wkGetUserToBaseCTM(cgContext));
+    AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext));
 
     RetainPtr<CGPatternRef> platformPattern = adoptCF(m_state.strokePattern->createPlatformPattern(userToBaseCTM));
     if (!platformPattern)
@@ -599,7 +599,7 @@ void GraphicsContext::applyStrokePattern()
 void GraphicsContext::applyFillPattern()
 {
     CGContextRef cgContext = platformContext();
-    AffineTransform userToBaseCTM = AffineTransform(wkGetUserToBaseCTM(cgContext));
+    AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext));
 
     RetainPtr<CGPatternRef> platformPattern = adoptCF(m_state.fillPattern->createPlatformPattern(userToBaseCTM));
     if (!platformPattern)
@@ -1070,7 +1070,7 @@ void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, con
     CGContextRef context = platformContext();
 
     if (!m_state.shadowsIgnoreTransforms) {
-        CGAffineTransform userToBaseCTM = wkGetUserToBaseCTM(context);
+        CGAffineTransform userToBaseCTM = getUserToBaseCTM(context);
 
         CGFloat A = userToBaseCTM.a * userToBaseCTM.a + userToBaseCTM.b * userToBaseCTM.b;
         CGFloat B = userToBaseCTM.a * userToBaseCTM.c + userToBaseCTM.b * userToBaseCTM.d;
index 7ce7376..3c6cfe6 100644 (file)
@@ -36,6 +36,11 @@ CGColorSpaceRef deviceRGBColorSpaceRef();
 WEBCORE_EXPORT CGColorSpaceRef sRGBColorSpaceRef();
 CGColorSpaceRef linearRGBColorSpaceRef();
 
+inline CGAffineTransform getUserToBaseCTM(CGContextRef context)
+{
+    return CGAffineTransformConcat(CGContextGetCTM(context), CGAffineTransformInvert(CGContextGetBaseCTM(context)));
+}
+
 static inline CGColorSpaceRef cachedCGColorSpace(ColorSpace colorSpace)
 {
     switch (colorSpace) {
index f6095f6..3223202 100644 (file)
@@ -322,7 +322,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
     CGContextRef destContext = context().platformContext();
     CGContextSaveGState(destContext);
     if (coordinateSystem == LogicalCoordinateSystem)
-        CGContextConcatCTM(destContext, AffineTransform(wkGetUserToBaseCTM(destContext)).inverse());
+        CGContextConcatCTM(destContext, AffineTransform(getUserToBaseCTM(destContext)).inverse());
     else
         CGContextConcatCTM(destContext, AffineTransform(CGContextGetCTM(destContext)).inverse());
     CGContextResetClip(destContext);
index ace1905..78514c8 100644 (file)
@@ -155,6 +155,14 @@ void GraphicsContext::updateDocumentMarkerResources()
     correctionPatternColor = nullptr;
 }
 
+static inline void setPatternPhaseInUserSpace(CGContextRef context, CGPoint phasePoint)
+{
+    CGAffineTransform userToBase = getUserToBaseCTM(context);
+    CGPoint phase = CGPointApplyAffineTransform(phasePoint, userToBase);
+
+    CGContextSetPatternPhase(context, CGSizeMake(phase.x, phase.y));
+}
+
 // WebKit on Mac is a standard platform component, so it must use the standard platform artwork for underline.
 void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& point, float width, DocumentMarkerLineStyle style)
 {
@@ -251,7 +259,7 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& point, float w
     
     // FIXME: This code should not use NSGraphicsContext currentContext
     // In order to remove this requirement we will need to use CGPattern instead of NSColor
-    // FIXME: This code should not be using wkSetPatternPhaseInUserSpace, as this approach is wrong
+    // FIXME: This code should not be using setPatternPhaseInUserSpace, as this approach is wrong
     // for transforms.
 
     // Draw underline.
@@ -270,7 +278,7 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& point, float w
     WKSetPattern(context, dotPattern, YES, YES);
 #endif
 
-    wkSetPatternPhaseInUserSpace(context, offsetPoint);
+    setPatternPhaseInUserSpace(context, offsetPoint);
 
 #if !PLATFORM(IOS)
     NSRectFillUsingOperation(NSMakeRect(offsetPoint.x(), offsetPoint.y(), width, patternHeight), NSCompositeSourceOver);
index a787c82..c6e4c16 100644 (file)
@@ -32,8 +32,6 @@ WEBCORE_EXPORT CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef
 WEBCORE_EXPORT void (*wkClearGlyphVector)(void* glyphs);
 WEBCORE_EXPORT OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
 WEBCORE_EXPORT NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
-WEBCORE_EXPORT void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint point);
-WEBCORE_EXPORT CGAffineTransform (*wkGetUserToBaseCTM)(CGContextRef);
 WEBCORE_EXPORT bool (*wkCGContextIsPDFContext)(CGContextRef);
 WEBCORE_EXPORT NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
 WEBCORE_EXPORT void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
index a42a3ac..046dd6b 100644 (file)
@@ -197,8 +197,6 @@ extern void (*wkSetCookieStoragePrivateBrowsingEnabled)(BOOL);
 extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
 #endif
 extern void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
-extern void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint);
-extern CGAffineTransform (*wkGetUserToBaseCTM)(CGContextRef);
 extern bool (*wkCGContextIsPDFContext)(CGContextRef);
 extern unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount);
 extern int (*wkGetHTTPRequestPriority)(CFURLRequestRef);
index fffafc2..188f412 100644 (file)
@@ -76,8 +76,6 @@ void (*wkQTClearMediaDownloadCache)();
 
 void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*, BOOL);
 void (*wkSetDragImage)(NSImage*, NSPoint offset);
-void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint point);
-CGAffineTransform (*wkGetUserToBaseCTM)(CGContextRef);
 bool (*wkCGContextIsPDFContext)(CGContextRef);
 void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
 unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount);
index 29f1511..8b8d072 100644 (file)
@@ -1,3 +1,13 @@
+2015-10-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Migrate WKSetPatternPhaseInUserSpace() and WKGetUserToBaseCTM() from WKSI
+        https://bugs.webkit.org/show_bug.cgi?id=150460
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Deleted.
+
 2015-10-21  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         NetworkProcess: DNS prefetch happens in the Web Process
index 98a7a5b..8c205b4 100644 (file)
@@ -93,9 +93,7 @@ void InitWebCoreSystemInterface(void)
     INIT(SetHTTPRequestMinimumFastLanePriority);
     INIT(HTTPRequestEnablePipelining);
     INIT(SetNSURLRequestShouldContentSniff);
-    INIT(SetPatternPhaseInUserSpace);
     INIT(CGContextIsPDFContext);
-    INIT(GetUserToBaseCTM);
 #if ENABLE(VIDEO) && !PLATFORM(IOS)
     INIT(QTIncludeOnlyModernMediaFileTypes);
     INIT(QTMovieDisableComponent);
index 9c70138..80abd69 100644 (file)
@@ -1,3 +1,13 @@
+2015-10-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Migrate WKSetPatternPhaseInUserSpace() and WKGetUserToBaseCTM() from WKSI
+        https://bugs.webkit.org/show_bug.cgi?id=150460
+
+        Reviewed by Tim Horton.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Deleted.
+
 2015-10-22  Alex Christensen  <achristensen@webkit.org>
 
         Initial NSURLSession WebResourceLoader implementation
index dd9897b..dce2574 100644 (file)
@@ -62,7 +62,6 @@ void InitWebCoreSystemInterface(void)
 #if !PLATFORM(IOS)
         INIT(SignedPublicKeyAndChallengeString);
 #endif
-        INIT(GetUserToBaseCTM);
         INIT(GetWebDefaultCFStringEncoding);
         INIT(CGContextIsPDFContext);
 #if !PLATFORM(IOS)
@@ -99,7 +98,6 @@ void InitWebCoreSystemInterface(void)
         INIT(SetHTTPRequestPriority);
         INIT(SetHTTPRequestMinimumFastLanePriority);
         INIT(SetNSURLRequestShouldContentSniff);
-        INIT(SetPatternPhaseInUserSpace);
         INIT(CreatePrivateStorageSession);
         INIT(CopyRequestWithStorageSession);
         INIT(CopyHTTPCookieStorage);