Title: [284902] trunk
- Revision
- 284902
- Author
- [email protected]
- Date
- 2021-10-26 14:50:28 -0700 (Tue, 26 Oct 2021)
Log Message
[GPU Process] `DisplayList::Recorder::getCTM` should include the device scale factor
https://bugs.webkit.org/show_bug.cgi?id=230647
Reviewed by Simon Fraser.
Source/WebCore:
New test: BifurcatedGraphicsContextTests.ApplyDeviceScaleFactor
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::getCTM const):
(WebCore::DisplayList::Recorder::applyDeviceScaleFactor):
applyDeviceScaleFactor previously did not apply the scale to the CTM,
causing the DisplayList::Recorder's idea of the CTM to get out of sync
with the context being replayed into.
We don't call GraphicsContext::scale() directly (like GraphicsContextCG does)
because applyDeviceScaleFactor on the replay side will apply the scale
to the replayed context's CTM.
Tools:
* TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp:
(TestWebKitAPI::TEST):
Add a test that getCTM returns the correct scale after applyDeviceScaleFactor is called.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (284901 => 284902)
--- trunk/Source/WebCore/ChangeLog 2021-10-26 21:49:46 UTC (rev 284901)
+++ trunk/Source/WebCore/ChangeLog 2021-10-26 21:50:28 UTC (rev 284902)
@@ -1,3 +1,23 @@
+2021-10-26 Tim Horton <[email protected]>
+
+ [GPU Process] `DisplayList::Recorder::getCTM` should include the device scale factor
+ https://bugs.webkit.org/show_bug.cgi?id=230647
+
+ Reviewed by Simon Fraser.
+
+ New test: BifurcatedGraphicsContextTests.ApplyDeviceScaleFactor
+
+ * platform/graphics/displaylists/DisplayListRecorder.cpp:
+ (WebCore::DisplayList::Recorder::getCTM const):
+ (WebCore::DisplayList::Recorder::applyDeviceScaleFactor):
+ applyDeviceScaleFactor previously did not apply the scale to the CTM,
+ causing the DisplayList::Recorder's idea of the CTM to get out of sync
+ with the context being replayed into.
+
+ We don't call GraphicsContext::scale() directly (like GraphicsContextCG does)
+ because applyDeviceScaleFactor on the replay side will apply the scale
+ to the replayed context's CTM.
+
2021-10-26 Chris Dumez <[email protected]>
Changing the src attribute of the <img> element inside an ImageDocument does not trigger a load
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (284901 => 284902)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-10-26 21:49:46 UTC (rev 284901)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-10-26 21:50:28 UTC (rev 284902)
@@ -232,7 +232,6 @@
AffineTransform Recorder::getCTM(GraphicsContext::IncludeDeviceScale) const
{
- // FIXME: <https://webkit.org/b/230647> ([GPU Process] add support for `IncludeDeviceScale` inside `DisplayList::Recorder::getCTM`)
return currentState().ctm;
}
@@ -495,6 +494,10 @@
void Recorder::applyDeviceScaleFactor(float deviceScaleFactor)
{
+ // We modify the state directly here instead of calling GraphicsContext::scale()
+ // because the recorded item will scale() when replayed.
+ currentState().scale({ deviceScaleFactor, deviceScaleFactor });
+
// FIXME: this changes the baseCTM, which will invalidate all of our cached extents.
// Assert that it's only called early on?
recordApplyDeviceScaleFactor(deviceScaleFactor);
Modified: trunk/Tools/ChangeLog (284901 => 284902)
--- trunk/Tools/ChangeLog 2021-10-26 21:49:46 UTC (rev 284901)
+++ trunk/Tools/ChangeLog 2021-10-26 21:50:28 UTC (rev 284902)
@@ -1,3 +1,14 @@
+2021-10-26 Tim Horton <[email protected]>
+
+ [GPU Process] `DisplayList::Recorder::getCTM` should include the device scale factor
+ https://bugs.webkit.org/show_bug.cgi?id=230647
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp:
+ (TestWebKitAPI::TEST):
+ Add a test that getCTM returns the correct scale after applyDeviceScaleFactor is called.
+
2021-10-26 Jonathan Bedard <[email protected]>
[webkitscmpy] Comment and close pull-requests
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp (284901 => 284902)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp 2021-10-26 21:49:46 UTC (rev 284901)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp 2021-10-26 21:50:28 UTC (rev 284902)
@@ -278,6 +278,32 @@
EXPECT_EQ(primaryContext.clipBounds(), FloatRect(25, 25, 50, 50));
}
+TEST(BifurcatedGraphicsContextTests, ApplyDeviceScaleFactor)
+{
+ auto colorSpace = DestinationColorSpace::SRGB();
+ auto primaryCGContext = adoptCF(CGBitmapContextCreate(nullptr, 100, 100, 8, 4 * 100, colorSpace.platformColorSpace(), kCGImageAlphaPremultipliedLast));
+
+ GraphicsContextCG primaryContextCG(primaryCGContext.get());
+ GraphicsContext& primaryContext = primaryContextCG;
+
+ InMemoryDisplayList displayList;
+ RecorderImpl secondaryContextDL(displayList, { }, FloatRect(0, 0, 100, 100), { });
+ GraphicsContext& secondaryContext = secondaryContextDL;
+
+ BifurcatedGraphicsContext ctx(primaryContext, secondaryContext);
+
+ ctx.applyDeviceScaleFactor(2);
+
+ auto primaryCTM = primaryContext.getCTM(GraphicsContext::IncludeDeviceScale::DefinitelyIncludeDeviceScale);
+ auto secondaryCTM = secondaryContext.getCTM(GraphicsContext::IncludeDeviceScale::DefinitelyIncludeDeviceScale);
+
+ EXPECT_EQ(primaryCTM.xScale(), secondaryCTM.xScale());
+ EXPECT_EQ(primaryCTM.yScale(), secondaryCTM.yScale());
+
+ EXPECT_EQ(primaryCTM.xScale(), 2);
+ EXPECT_EQ(primaryCTM.yScale(), 2);
+}
+
} // namespace TestWebKitAPI
#endif // USE(CG)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes