WebKit Bugzilla
Attachment 361827 Details for
Bug 194555
: BitmapRenderer should handle existing ImageBuffers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194555-20190213082316.patch (text/plain), 6.19 KB, created by
Dean Jackson
on 2019-02-12 13:23:18 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2019-02-12 13:23:18 PST
Size:
6.19 KB
patch
obsolete
>Subversion Revision: 241125 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c2a1672b1bf022b6bbcffcdc5ef172431e7de24c..d9a125bf18ec03e8be823de532347e1c01b31b2b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2019-02-12 Dean Jackson <dino@apple.com> >+ >+ BitmapRenderer should handle existing ImageBuffers >+ https://bugs.webkit.org/show_bug.cgi?id=194555 >+ <rdar://problem/47857150> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Our logic in ImageBitmapRenderingContext assumed that >+ it had always created the ImageBuffer being used. However, it's >+ valid to call something like toBlob() or toDataURL() before creating >+ a context, so we need to handle the case where an ImageBuffer >+ already exists. >+ >+ Test: fast/canvas/bitmaprenderer-created-after-toBlob.html >+ >+ * html/HTMLCanvasElement.cpp: >+ (WebCore::HTMLCanvasElement::createImageBuffer const): Move some logic into setImageBuffer. >+ (WebCore::HTMLCanvasElement::setImageBuffer const): Make sure to clear the state saver. >+ > 2019-02-07 Zalan Bujtas <zalan@apple.com> > > [LFC][Out-of-flow] Use the containing block's padding width when computing min/max width. >diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp >index 7a70b24a20eab8bf88f0d41ce1889677e717a1f9..2680210e7812b7995ed49d7235e7a130d9d725f9 100644 >--- a/Source/WebCore/html/HTMLCanvasElement.cpp >+++ b/Source/WebCore/html/HTMLCanvasElement.cpp >@@ -1002,22 +1002,6 @@ void HTMLCanvasElement::createImageBuffer() const > > auto hostWindow = (document().view() && document().view()->root()) ? document().view()->root()->hostWindow() : nullptr; > setImageBuffer(ImageBuffer::create(size(), renderingMode, 1, ColorSpaceSRGB, hostWindow)); >- if (!m_imageBuffer) >- return; >- m_imageBuffer->context().setShadowsIgnoreTransforms(true); >- m_imageBuffer->context().setImageInterpolationQuality(defaultInterpolationQuality); >- m_imageBuffer->context().setStrokeThickness(1); >- m_contextStateSaver = std::make_unique<GraphicsContextStateSaver>(m_imageBuffer->context()); >- >- JSC::JSLockHolder lock(HTMLElement::scriptExecutionContext()->vm()); >- HTMLElement::scriptExecutionContext()->vm().heap.reportExtraMemoryAllocated(memoryCost()); >- >-#if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS) >- if (m_context && m_context->is2d()) { >- // Recalculate compositing requirements if acceleration state changed. >- const_cast<HTMLCanvasElement*>(this)->invalidateStyleAndLayerComposition(); >- } >-#endif > } > > void HTMLCanvasElement::setImageBuffer(std::unique_ptr<ImageBuffer>&& buffer) const >@@ -1027,6 +1011,7 @@ void HTMLCanvasElement::setImageBuffer(std::unique_ptr<ImageBuffer>&& buffer) co > > { > auto locker = holdLock(m_imageBufferAssignmentLock); >+ m_contextStateSaver = nullptr; > m_imageBuffer = WTFMove(buffer); > } > >@@ -1038,6 +1023,23 @@ void HTMLCanvasElement::setImageBuffer(std::unique_ptr<ImageBuffer>&& buffer) co > > if (m_context && m_imageBuffer && previousMemoryCost != currentMemoryCost) > InspectorInstrumentation::didChangeCanvasMemory(*m_context); >+ >+ if (!m_imageBuffer) >+ return; >+ m_imageBuffer->context().setShadowsIgnoreTransforms(true); >+ m_imageBuffer->context().setImageInterpolationQuality(defaultInterpolationQuality); >+ m_imageBuffer->context().setStrokeThickness(1); >+ m_contextStateSaver = std::make_unique<GraphicsContextStateSaver>(m_imageBuffer->context()); >+ >+ JSC::JSLockHolder lock(HTMLElement::scriptExecutionContext()->vm()); >+ HTMLElement::scriptExecutionContext()->vm().heap.reportExtraMemoryAllocated(memoryCost()); >+ >+#if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS) >+ if (m_context && m_context->is2d()) { >+ // Recalculate compositing requirements if acceleration state changed. >+ const_cast<HTMLCanvasElement*>(this)->invalidateStyleAndLayerComposition(); >+ } >+#endif > } > > void HTMLCanvasElement::setImageBufferAndMarkDirty(std::unique_ptr<ImageBuffer>&& buffer) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 92df95ad5352450f1faba39888407349772739db..cc28c9e81a1f631342e41071a59fb1afec445260 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+2019-02-12 Dean Jackson <dino@apple.com> >+ >+ BitmapRenderer should handle existing ImageBuffers >+ https://bugs.webkit.org/show_bug.cgi?id=194555 >+ <rdar://problem/47857150> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test that creates a canvas, triggers an ImageBuffer to be created, then >+ creates the bitmaprenderer context. >+ >+ * fast/canvas/bitmaprenderer-created-after-toBlob-expected.txt: Added. >+ * fast/canvas/bitmaprenderer-created-after-toBlob.html: Added. >+ > 2019-02-07 Zalan Bujtas <zalan@apple.com> > > [LFC][Out-of-flow] Use the containing block's padding width when computing min/max width. >diff --git a/LayoutTests/fast/canvas/bitmaprenderer-created-after-toBlob-expected.txt b/LayoutTests/fast/canvas/bitmaprenderer-created-after-toBlob-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..3b3302d05314db3f654425a2575c6ed04e048398 >--- /dev/null >+++ b/LayoutTests/fast/canvas/bitmaprenderer-created-after-toBlob-expected.txt >@@ -0,0 +1 @@ >+Should not crash. >diff --git a/LayoutTests/fast/canvas/bitmaprenderer-created-after-toBlob.html b/LayoutTests/fast/canvas/bitmaprenderer-created-after-toBlob.html >new file mode 100644 >index 0000000000000000000000000000000000000000..a139f5050279ce1feb145a25ed3abde042427f5a >--- /dev/null >+++ b/LayoutTests/fast/canvas/bitmaprenderer-created-after-toBlob.html >@@ -0,0 +1,22 @@ >+<script> >+if (window.testRunner) >+ testRunner.dumpAsText(); >+ >+function callback() { >+ if (window.GCController) >+ return GCController.collect(); >+ >+ // Force garbage collection >+ for (let i=0; i < 100; i++) >+ var a = new Uint8Array(1024*1024); >+} >+ >+function run() { >+ var c = document.createElement("canvas"); >+ c.toBlob(callback); >+ var ctx = c.getContext("bitmaprenderer"); >+} >+ >+window.addEventListener("load", run, false); >+</script> >+Should not crash.
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
Flags:
thorton
:
review+
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194555
: 361827 |
361850