Bug 179339 - [CG] Adopt CGContextDrawPathDirect()
Summary: [CG] Adopt CGContextDrawPathDirect()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-06 12:47 PST by Said Abou-Hallawa
Modified: 2017-11-06 18:28 PST (History)
6 users (show)

See Also:


Attachments
Patch (4.67 KB, patch)
2017-11-06 13:55 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (6.16 KB, patch)
2017-11-06 15:58 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2017-11-06 12:47:03 PST
This API is only available starting from macOS 10.12: Sierra. We should only use it if we want to draw a CGPath to the context. Instead of calling CGContextBeginPath() followed by CGContextAddPath() then followed by a drawing path function, we call CGContextDrawPathDirect() and pass the CGPath and the CGPathDrawingMode.
Comment 1 Said Abou-Hallawa 2017-11-06 12:47:36 PST
<rdar://problem/26283575>
Comment 2 Said Abou-Hallawa 2017-11-06 13:55:39 PST
Created attachment 326155 [details]
Patch
Comment 3 Simon Fraser (smfr) 2017-11-06 13:59:40 PST
Comment on attachment 326155 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=326155&action=review

> Source/WebCore/ChangeLog:19
> +        shadow because we add the CGPatn to the layerContext and at the end we

CGPatn?

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:645
> -    CGContextBeginPath(context);
> -    CGContextAddPath(context, path.platformPath());
> -
>      if (state.fillPattern)
>          applyFillPattern();
>      if (state.strokePattern)
>          applyStrokePattern();

Is it OK for the add path to happen after applying the fill and stroke patterns?

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:649
> +#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)

Let's put a #define USE_DRAW_PATH_DIRECT ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)) at the top of the file and use that.

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:711
> -    CGContextBeginPath(context);
> -    CGContextAddPath(context, path.platformPath());
> -
>      if (m_state.fillPattern)
>          applyFillPattern();

Ditto.
Comment 4 Said Abou-Hallawa 2017-11-06 15:58:32 PST
Created attachment 326163 [details]
Patch
Comment 5 Said Abou-Hallawa 2017-11-06 16:51:53 PST
Comment on attachment 326155 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=326155&action=review

>> Source/WebCore/ChangeLog:19
>> +        shadow because we add the CGPatn to the layerContext and at the end we
> 
> CGPatn?

Fixed.

>> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:645
>>          applyStrokePattern();
> 
> Is it OK for the add path to happen after applying the fill and stroke patterns?

Yes. Setting the fill pattern, the stroke pattern or beginning and adding the path can happen in any order. Only the drawing function looks at these settings and use them to draw the path.

>> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:649
>> +#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
> 
> Let's put a #define USE_DRAW_PATH_DIRECT ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)) at the top of the file and use that.

Done. I dropped __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000 because it seems we do not support iOS less than 100000. We do similar thing with calling CGColorSpaceCreateWithName() in GraphicsContextCG.cpp.
Comment 6 WebKit Commit Bot 2017-11-06 18:28:49 PST
Comment on attachment 326163 [details]
Patch

Clearing flags on attachment: 326163

Committed r224527: <https://trac.webkit.org/changeset/224527>
Comment 7 WebKit Commit Bot 2017-11-06 18:28:50 PST
All reviewed patches have been landed.  Closing bug.