Skip to content

[HDR] Moving the WebView from a screen to another should change backing store formats. #47099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

mattwoodrow
Copy link
Contributor

@mattwoodrow mattwoodrow commented Jun 24, 2025

a08fe89

[HDR] Moving the WebView from a screen to another should change backing store formats.
https://bugs.webkit.org/show_bug.cgi?id=294757
<rdar://problem/153908494>

Reviewed by Simon Fraser.

Add code to PlatformCALayerClient/GraphicsLayerClient to query the currently
supported ContentsFormats for the screen that the layer is on. Use this version,
rather than querying the values for the primary display for all layers.

Add change handling to Page (similar to deviceOrPageScaleFactorChanged) that
notifies all GraphicsLayers when this result might change.

* Source/WebCore/page/LocalFrame.cpp:
(WebCore::LocalFrame::screenContentsFormatsChanged):
* Source/WebCore/page/LocalFrame.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::screenPropertiesDidChange):
(WebCore::Page::windowScreenDidChange):
* Source/WebCore/page/Page.h:
* Source/WebCore/platform/PlatformScreen.h:
* Source/WebCore/platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::noteScreenContentsFormatsChangedIncludingDescendants):
* Source/WebCore/platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::screenContentsFormatsChanged):
* Source/WebCore/platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::screenContentsFormats const):
* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::createPlatformCALayer):
(WebCore::GraphicsLayerCA::ensureStructuralLayer):
* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.h:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.mm:
(WebCore::PlatformCALayer::contentsFormatForLayer):
* Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h:
* Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp:
(WebCore::TileCoverageMap::screenContentsFormats const):
* Source/WebCore/platform/graphics/ca/TileCoverageMap.h:
* Source/WebCore/platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::screenContentsFormats const):
* Source/WebCore/platform/graphics/ca/TileGrid.h:
* Source/WebCore/platform/ios/PlatformScreenIOS.mm:
(WebCore::screenSupportsHighDynamicRange):
* Source/WebCore/platform/mac/PlatformScreenMac.mm:
(WebCore::screenSupportsHighDynamicRange):
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::screenContentsFormats const):
* Source/WebCore/rendering/RenderLayerBacking.h:
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::screenContentsFormatsChanged):
* Source/WebCore/rendering/RenderLayerCompositor.h:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.mm:
(WebKit::GraphicsLayerCARemote::createPlatformCALayer):

Canonical link: https://commits.webkit.org/296635@main

39555cd

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@mattwoodrow mattwoodrow requested a review from cdumez as a code owner June 24, 2025 03:44
@mattwoodrow mattwoodrow self-assigned this Jun 24, 2025
@mattwoodrow mattwoodrow added the Images For bugs in image handling. label Jun 24, 2025
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
Copy link
Contributor

@smfr smfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write an API test for this?

@@ -223,7 +223,8 @@ class LocalFrame final : public Frame {
WEBCORE_EXPORT float frameScaleFactor() const;

void deviceOrPageScaleFactorChanged();

void screenContentsFormatsChanged();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is a bit abstract. Does a screen have a "contents format"? It's more like screenSupportedContentsFormats or screenAppropriateContentsFormats

@@ -1729,6 +1729,14 @@ void Page::screenPropertiesDidChange()
updateDisplayEDRSuppression();
#endif

#if HAVE(SUPPORT_HDR_DISPLAY)
if (m_screenSupportsHDR != screenSupportsHighDynamicRange(m_displayID)) {
m_screenSupportsHDR = screenSupportsHighDynamicRange(m_displayID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not call screenSupportsHighDynamicRange(m_displayID) twice.

@@ -1748,6 +1756,14 @@ void Page::windowScreenDidChange(PlatformDisplayID displayID, std::optional<Fram
document.windowScreenDidChange(displayID);
});

#if HAVE(SUPPORT_HDR_DISPLAY)
if (m_screenSupportsHDR != screenSupportsHighDynamicRange(m_displayID)) {
m_screenSupportsHDR = screenSupportsHighDynamicRange(m_displayID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should share some code with screenPropertiesDidChange().

@mattwoodrow mattwoodrow removed the merging-blocked Applied to prevent a change from being merged label Jun 25, 2025
@mattwoodrow mattwoodrow force-pushed the eng/hdr-screen-change branch from 478b6b6 to 3f3d861 Compare June 25, 2025 02:40
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 25, 2025
@mattwoodrow mattwoodrow removed the merging-blocked Applied to prevent a change from being merged label Jun 25, 2025
@mattwoodrow mattwoodrow force-pushed the eng/hdr-screen-change branch from 3f3d861 to 39555cd Compare June 25, 2025 03:14
@mattwoodrow mattwoodrow added the merge-queue Applied to send a pull request to merge-queue label Jun 25, 2025
…ng store formats.

https://bugs.webkit.org/show_bug.cgi?id=294757
<rdar://problem/153908494>

Reviewed by Simon Fraser.

Add code to PlatformCALayerClient/GraphicsLayerClient to query the currently
supported ContentsFormats for the screen that the layer is on. Use this version,
rather than querying the values for the primary display for all layers.

Add change handling to Page (similar to deviceOrPageScaleFactorChanged) that
notifies all GraphicsLayers when this result might change.

* Source/WebCore/page/LocalFrame.cpp:
(WebCore::LocalFrame::screenContentsFormatsChanged):
* Source/WebCore/page/LocalFrame.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::screenPropertiesDidChange):
(WebCore::Page::windowScreenDidChange):
* Source/WebCore/page/Page.h:
* Source/WebCore/platform/PlatformScreen.h:
* Source/WebCore/platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::noteScreenContentsFormatsChangedIncludingDescendants):
* Source/WebCore/platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::screenContentsFormatsChanged):
* Source/WebCore/platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::screenContentsFormats const):
* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::createPlatformCALayer):
(WebCore::GraphicsLayerCA::ensureStructuralLayer):
* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.h:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.mm:
(WebCore::PlatformCALayer::contentsFormatForLayer):
* Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h:
* Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp:
(WebCore::TileCoverageMap::screenContentsFormats const):
* Source/WebCore/platform/graphics/ca/TileCoverageMap.h:
* Source/WebCore/platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::screenContentsFormats const):
* Source/WebCore/platform/graphics/ca/TileGrid.h:
* Source/WebCore/platform/ios/PlatformScreenIOS.mm:
(WebCore::screenSupportsHighDynamicRange):
* Source/WebCore/platform/mac/PlatformScreenMac.mm:
(WebCore::screenSupportsHighDynamicRange):
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::screenContentsFormats const):
* Source/WebCore/rendering/RenderLayerBacking.h:
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::screenContentsFormatsChanged):
* Source/WebCore/rendering/RenderLayerCompositor.h:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.mm:
(WebKit::GraphicsLayerCARemote::createPlatformCALayer):

Canonical link: https://commits.webkit.org/296635@main
@webkit-commit-queue
Copy link
Collaborator

Committed 296635@main (a08fe89): https://commits.webkit.org/296635@main

Reviewed commits have been landed. Closing PR #47099 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit a08fe89 into WebKit:main Jun 25, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Images For bugs in image handling.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants