WebKit Bugzilla
Attachment 356278 Details for
Bug 192217
: CSS Painting API should scale display list when drawing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192217-20181130181214.patch (text/plain), 10.52 KB, created by
Justin Michaud
on 2018-11-30 18:12:15 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Justin Michaud
Created:
2018-11-30 18:12:15 PST
Size:
10.52 KB
patch
obsolete
>Subversion Revision: 238725 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b905292e27deb41144513652c4833266122fe0c9..b4d14e29a03707155b5b659d8678c057d330ea1e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,18 @@ >+2018-11-30 Justin Michaud <justin_michaud@apple.com> >+ >+ CSS Painting API should scale display list when drawing >+ https://bugs.webkit.org/show_bug.cgi?id=192217 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When we replay the display list, fix the scaling. The separate buffer is needed to make sure that globalCompositeOperation functions correctly. >+ >+ * html/CustomPaintCanvas.cpp: >+ (WebCore::CustomPaintCanvas::replayDisplayList const): >+ * html/CustomPaintCanvas.h: >+ * platform/graphics/CustomPaintImage.cpp: >+ (WebCore::CustomPaintImage::doCustomPaint): >+ > 2018-11-29 Simon Fraser <simon.fraser@apple.com> > > Overflow scrolling layers need to be self-painting >diff --git a/Source/WebCore/html/CustomPaintCanvas.cpp b/Source/WebCore/html/CustomPaintCanvas.cpp >index f93f909aab3bbcf8cd6118ce34b000e487aab631..aa977041e22fc04764e37890b42b513806d2205d 100644 >--- a/Source/WebCore/html/CustomPaintCanvas.cpp >+++ b/Source/WebCore/html/CustomPaintCanvas.cpp >@@ -93,6 +93,28 @@ ExceptionOr<RefPtr<PaintRenderingContext2D>> CustomPaintCanvas::getContext() > return { RefPtr<PaintRenderingContext2D> { &downcast<PaintRenderingContext2D>(*m_context) } }; > } > >+void CustomPaintCanvas::replayDisplayList(GraphicsContext* ctx) const >+{ >+ ASSERT(!m_destinationGraphicsContext); >+ if (!width() || !height()) >+ return; >+ >+ // FIXME: Using an intermediate buffer is not needed if there are no composite operations. >+ auto clipBounds = ctx->clipBounds(); >+ >+ auto image = ImageBuffer::createCompatibleBuffer(clipBounds.size(), *ctx); >+ if (!image) >+ return; >+ >+ m_destinationGraphicsContext = &image->context(); >+ m_destinationGraphicsContext->translate(-clipBounds.location()); >+ if (m_context) >+ m_context->paintRenderingResultsToCanvas(); >+ m_destinationGraphicsContext = nullptr; >+ >+ ctx->drawImageBuffer(*image, clipBounds); >+} >+ > Image* CustomPaintCanvas::copiedImage() const > { > ASSERT(!m_destinationGraphicsContext); >diff --git a/Source/WebCore/html/CustomPaintCanvas.h b/Source/WebCore/html/CustomPaintCanvas.h >index 99571fdf73b8268ee65d1def00aad4deecadd138..e1fa62b4db74079abb945d7bf3861ea3a68fbe91 100644 >--- a/Source/WebCore/html/CustomPaintCanvas.h >+++ b/Source/WebCore/html/CustomPaintCanvas.h >@@ -70,6 +70,7 @@ public: > > AffineTransform baseTransform() const final { ASSERT(m_destinationGraphicsContext && m_copiedBuffer); return m_copiedBuffer->baseTransform(); } > Image* copiedImage() const final; >+ void replayDisplayList(GraphicsContext*) const; > > using RefCounted::ref; > using RefCounted::deref; >diff --git a/Source/WebCore/platform/graphics/CustomPaintImage.cpp b/Source/WebCore/platform/graphics/CustomPaintImage.cpp >index 034da561fe6b282245c83091ac3de1e287f7833e..ec482265770d175efae8e9cd2db62d651453a27c 100644 >--- a/Source/WebCore/platform/graphics/CustomPaintImage.cpp >+++ b/Source/WebCore/platform/graphics/CustomPaintImage.cpp >@@ -129,11 +129,7 @@ ImageDrawResult CustomPaintImage::doCustomPaint(GraphicsContext& destContext, co > if (result.type() != CallbackResultType::Success) > return ImageDrawResult::DidNothing; > >- auto image = canvas->copiedImage(); >- if (!image) >- return ImageDrawResult::DidNothing; >- >- destContext.drawImage(*image, FloatPoint()); >+ canvas->replayDisplayList(&destContext); > > return ImageDrawResult::DidDraw; > } >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 5d288ac8ec165e856d76937a9577a72c6554b800..c2b10e90f9029486188e6c0438bf81f8705b335c 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2018-11-30 Justin Michaud <justin_michaud@apple.com> >+ >+ CSS Painting API should scale display list when drawing >+ https://bugs.webkit.org/show_bug.cgi?id=192217 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/css-custom-paint/properties-expected.html: >+ * fast/css-custom-paint/registerPaintBindings-expected.html: >+ * fast/css-custom-paint/simple-hidpi-expected.html: Added. >+ * fast/css-custom-paint/simple-hidpi.html: Added. >+ * fast/css-custom-paint/worklet-expected.html: >+ > 2018-11-29 Simon Fraser <simon.fraser@apple.com> > > Overflow scrolling layers need to be self-painting >diff --git a/LayoutTests/fast/css-custom-paint/properties-expected.html b/LayoutTests/fast/css-custom-paint/properties-expected.html >index 3697e9bbcabb3ecb95c3606d11a4484cbebf405a..6d32e7dbc0c104e0c1d29e985b30dd51a5f86d3b 100644 >--- a/LayoutTests/fast/css-custom-paint/properties-expected.html >+++ b/LayoutTests/fast/css-custom-paint/properties-expected.html >@@ -6,13 +6,17 @@ canvas { > } > </style> > >-<canvas id="paint" width="150px" height="150px" ></canvas> >-<canvas id="paint2" width="150px" height="150px" ></canvas> >+<canvas id="paint" style="width: 150px; height: 150px;" ></canvas> >+<canvas id="paint2" style="width: 150px; height: 150px;" ></canvas> > > <script id="code"> > for (canvasID of ['paint', 'paint2']) { >- var canvas = document.getElementById(canvasID); >- var ctx = canvas.getContext('2d'); >+ const canvas = document.getElementById(canvasID); >+ canvas.width = 150 * window.devicePixelRatio; >+ canvas.height = 150 * window.devicePixelRatio; >+ >+ const ctx = canvas.getContext('2d'); >+ ctx.scale(window.devicePixelRatio, window.devicePixelRatio); > > for (var i = 0; i < 6; i++){ > for (var j = 0; j < 6; j++){ >diff --git a/LayoutTests/fast/css-custom-paint/registerPaintBindings-expected.html b/LayoutTests/fast/css-custom-paint/registerPaintBindings-expected.html >index 4b42b62da13eda819610b3197b4e45a5473bdcf3..3fd4415d6f0d57044fda4805ab4610104ae8230a 100644 >--- a/LayoutTests/fast/css-custom-paint/registerPaintBindings-expected.html >+++ b/LayoutTests/fast/css-custom-paint/registerPaintBindings-expected.html >@@ -1,10 +1,14 @@ > <!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] --> > >-<canvas id="paint" width="150px" height="150px" ></canvas> >+<canvas id="paint" style="width: 150px; height: 150px;" ></canvas> > > <script id="code"> >-var canvas = document.getElementById('paint'); >-var ctx = canvas.getContext('2d'); >+const canvas = document.getElementById('paint'); >+canvas.width = 150 * window.devicePixelRatio; >+canvas.height = 150 * window.devicePixelRatio; >+ >+const ctx = canvas.getContext('2d'); >+ctx.scale(window.devicePixelRatio, window.devicePixelRatio); > > for (var i = 0; i < 6; i++){ > for (var j = 0; j < 6; j++){ >diff --git a/LayoutTests/fast/css-custom-paint/simple-hidpi-expected.html b/LayoutTests/fast/css-custom-paint/simple-hidpi-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..43882e8fc285e49fee2793737680e5dfc1106a3d >--- /dev/null >+++ b/LayoutTests/fast/css-custom-paint/simple-hidpi-expected.html >@@ -0,0 +1,31 @@ >+<!DOCTYPE html> >+<script> >+ function startTest() { >+ if (window.testRunner) { >+ testRunner.waitUntilDone(); >+ testRunner.setBackingScaleFactor(2, finishTest); >+ } >+ } >+ >+ function finishTest() { >+ const canvas = document.getElementById('paint'); >+ canvas.width = 150 * window.devicePixelRatio; >+ canvas.height = 150 * window.devicePixelRatio; >+ >+ const ctx = canvas.getContext('2d'); >+ ctx.scale(window.devicePixelRatio, window.devicePixelRatio); >+ >+ for (var i = 0; i < 6; i++){ >+ for (var j = 0; j < 6; j++){ >+ ctx.fillStyle = 'rgb(' + Math.floor(255 - 42.5 * i) + ',' + >+ Math.floor(255 - 42.5 * j) + ',0)'; >+ ctx.fillRect(j * 25, i * 25, 25, 25); >+ } >+ } >+ setTimeout(function() { testRunner.notifyDone(); }, 0); >+ } >+</script> >+<body onload="startTest();"> >+<canvas id="paint" style="width: 150px; height: 150px;" width=150 height=150 ></canvas> >+ >+</body> >diff --git a/LayoutTests/fast/css-custom-paint/simple-hidpi.html b/LayoutTests/fast/css-custom-paint/simple-hidpi.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b23931d503ab5c2b41495404465ef564db78dff7 >--- /dev/null >+++ b/LayoutTests/fast/css-custom-paint/simple-hidpi.html >@@ -0,0 +1,47 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] --> >+<script src="resources/testharness.js"></script> >+<script> >+ function startTest() { >+ if (window.testRunner) { >+ testRunner.waitUntilDone(); >+ testRunner.setBackingScaleFactor(2, finishTest); >+ } >+ } >+ >+ function finishTest() { >+ setTimeout(function() { testRunner.notifyDone(); }, 0); >+ } >+</script> >+<body onload="startTest();"> >+<meta name="author" title="Justin Michaud" href="mailto:justin_michaud@webkit.org"> >+<meta name="assert" content="test hidpi scaling"> >+<link rel="help" content="https://drafts.css-houdini.org/css-paint-api-1/"> >+ >+<style> >+ #paint { >+ background-image: paint(my-paint); >+ width: 150px; >+ height: 150px; >+ } >+</style> >+ >+<div id="paint"></div> >+ >+<script id="code" type="text/worklet"> >+registerPaint('my-paint', class { >+ paint(ctx, geom, properties) { >+ for (var i = 0; i < 6; i++){ >+ for (var j = 0; j < 6; j++){ >+ ctx.fillStyle = 'rgb(' + Math.floor(255 - 42.5 * i) + ',' + >+ Math.floor(255 - 42.5 * j) + ',0)'; >+ ctx.fillRect(j * 25, i * 25, 25, 25); >+ } >+ } >+ } >+}); >+</script> >+ >+<script> >+importWorklet(CSS.paintWorklet, document.getElementById('code').textContent); >+</script> >+</body> >diff --git a/LayoutTests/fast/css-custom-paint/worklet-expected.html b/LayoutTests/fast/css-custom-paint/worklet-expected.html >index 4b42b62da13eda819610b3197b4e45a5473bdcf3..3fd4415d6f0d57044fda4805ab4610104ae8230a 100644 >--- a/LayoutTests/fast/css-custom-paint/worklet-expected.html >+++ b/LayoutTests/fast/css-custom-paint/worklet-expected.html >@@ -1,10 +1,14 @@ > <!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] --> > >-<canvas id="paint" width="150px" height="150px" ></canvas> >+<canvas id="paint" style="width: 150px; height: 150px;" ></canvas> > > <script id="code"> >-var canvas = document.getElementById('paint'); >-var ctx = canvas.getContext('2d'); >+const canvas = document.getElementById('paint'); >+canvas.width = 150 * window.devicePixelRatio; >+canvas.height = 150 * window.devicePixelRatio; >+ >+const ctx = canvas.getContext('2d'); >+ctx.scale(window.devicePixelRatio, window.devicePixelRatio); > > for (var i = 0; i < 6; i++){ > for (var j = 0; j < 6; j++){
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192217
:
356142
|
356167
|
356243
| 356278