Bug 147242 - [Win] Support High DPI drawing with CACFLayers
Summary: [Win] Support High DPI drawing with CACFLayers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords:
Depends on: 146335
Blocks:
  Show dependency treegraph
 
Reported: 2015-07-23 16:11 PDT by Brent Fulgham
Modified: 2015-12-22 10:57 PST (History)
2 users (show)

See Also:


Attachments
Patch (2.96 KB, patch)
2015-11-20 11:49 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch v2 (Ignore) (2.63 KB, patch)
2015-11-20 13:26 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (2.03 KB, patch)
2015-11-20 13:30 PST, Brent Fulgham
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2015-07-23 16:11:13 PDT
This is a follow-up to Bug 146335, which added support for High DPI use in our non-accelerated drawing paths.

The Windows platform doesn't allow a single device scaling factor to be applied to individual windows. Instead, high DPI state is handled by working with larger pixel surfaces at higher DPIs, and performing scaling calculations to control widget size, positioning, etc. Yuck!

This patch applies the proper scaling at various phases of our CACFLayer sizing and positioning.
Comment 1 Brent Fulgham 2015-07-23 16:12:10 PDT
Note: Just like with Bug 146335, these scaling calculations are all done at 1x, unless the WebKit client opts into a high DPI state.

Currently, testing is just to make sure no regressions to existing 1x drawing on Windows (and all drawing on other platforms) are not affected.
Comment 2 Brent Fulgham 2015-11-20 11:49:50 PST
Created attachment 265975 [details]
Patch
Comment 3 Tim Horton 2015-11-20 12:11:06 PST
Comment on attachment 265975 [details]
Patch

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

> Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp:128
> +    CACFLayerSetContentsScale(layer->platformLayer(), scaleFactor);

Does the base layer actually have contents? Why do we have to set contentsScale?
Comment 4 Simon Fraser (smfr) 2015-11-20 12:11:40 PST
Comment on attachment 265975 [details]
Patch

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

> Source/WebCore/ChangeLog:15
> +        operations are don properly.

don

> Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:230
> +#if HAVE(CACFLAYER_SETCONTENTSSCALE)
> +    float scaleFactor = CACFLayerGetContentsScale(owner()->platformLayer());
> +    CACFLayerSetContentsScale(layer.platformLayer(), scaleFactor);
> +#endif

This is confusing; I'm not sure how owner()->platformLayer() and layer.platformLayer() are different.

Why isn't this handled via GraphicsLayerCA::deviceOrPageScaleFactorChanged() as it is for other platforms?
Comment 5 Brent Fulgham 2015-11-20 12:32:27 PST
Comment on attachment 265975 [details]
Patch

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

>> Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:230
>> +#endif
> 
> This is confusing; I'm not sure how owner()->platformLayer() and layer.platformLayer() are different.
> 
> Why isn't this handled via GraphicsLayerCA::deviceOrPageScaleFactorChanged() as it is for other platforms?

Hmmmmm. I'll investigate before moving forward.
Comment 6 Brent Fulgham 2015-11-20 13:26:07 PST
(In reply to comment #3)
> Comment on attachment 265975 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=265975&action=review
> 
> > Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp:128
> > +    CACFLayerSetContentsScale(layer->platformLayer(), scaleFactor);
> 
> Does the base layer actually have contents? Why do we have to set
> contentsScale?

According to the CA engineer who did the Windows work, this is needed for some arcane Windows-related reason.
Comment 7 Brent Fulgham 2015-11-20 13:26:58 PST
Created attachment 265987 [details]
Patch v2 (Ignore)
Comment 8 Brent Fulgham 2015-11-20 13:28:11 PST
(In reply to comment #5)
> Comment on attachment 265975 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=265975&action=review
> 
> >> Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:230
> >> +#endif
> > 
> > This is confusing; I'm not sure how owner()->platformLayer() and layer.platformLayer() are different.
> > 
> > Why isn't this handled via GraphicsLayerCA::deviceOrPageScaleFactorChanged() as it is for other platforms?
> 
> Hmmmmm. I'll investigate before moving forward.

It looks like this isn't needed. In fact, I wasn't even being consistent, as the other places where CACFLayerInsertSublayer was being called did not have the scaling factor change included.
Comment 9 Brent Fulgham 2015-11-20 13:30:11 PST
Created attachment 265989 [details]
Patch
Comment 10 Brent Fulgham 2015-11-20 14:35:03 PST
Committed r192700: <http://trac.webkit.org/changeset/192700>