Title: [104501] trunk/Source/WebCore
Revision
104501
Author
[email protected]
Date
2012-01-09 15:53:36 -0800 (Mon, 09 Jan 2012)

Log Message

[chromium win] Creating lots of temporary canvas contexts will crash.
https://bugs.webkit.org/show_bug.cgi?id=68420

When using the skia port, the allocation of 2d canvas backing stores
no longer needs to be done through a platform API (GDI/CG) because
canvases now use skia for drawing text.  Removing the allocation through
GDI on windows prevents resource exhaustion due to unreferenced canvases
that are awaiting garbage collection.

Patch by Justin Novosad <[email protected]> on 2012-01-09
Reviewed by Stephen White.

No new tests: Relying on existing canvas layout tests.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createImageBuffer):
* platform/graphics/ImageBuffer.h:
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::createNonPlatformCanvas):
(WebCore::ImageBuffer::ImageBuffer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104500 => 104501)


--- trunk/Source/WebCore/ChangeLog	2012-01-09 23:43:07 UTC (rev 104500)
+++ trunk/Source/WebCore/ChangeLog	2012-01-09 23:53:36 UTC (rev 104501)
@@ -1,3 +1,25 @@
+2012-01-09  Justin Novosad  <[email protected]>
+
+        [chromium win] Creating lots of temporary canvas contexts will crash.
+        https://bugs.webkit.org/show_bug.cgi?id=68420
+
+        When using the skia port, the allocation of 2d canvas backing stores
+        no longer needs to be done through a platform API (GDI/CG) because
+        canvases now use skia for drawing text.  Removing the allocation through
+        GDI on windows prevents resource exhaustion due to unreferenced canvases
+        that are awaiting garbage collection.
+
+        Reviewed by Stephen White.
+
+        No new tests: Relying on existing canvas layout tests.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createImageBuffer):
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::createNonPlatformCanvas):
+        (WebCore::ImageBuffer::ImageBuffer):
+
 2012-01-09  Avi Drissman  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=75860

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (104500 => 104501)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2012-01-09 23:43:07 UTC (rev 104500)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2012-01-09 23:53:36 UTC (rev 104501)
@@ -465,7 +465,12 @@
     if (!bufferSize.width() || !bufferSize.height())
         return;
 
-    RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : Unaccelerated;
+    RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : 
+#if USE(SKIA)
+        UnacceleratedNonPlatformBuffer;
+#else
+        Unaccelerated;
+#endif
     m_imageBuffer = ImageBuffer::create(bufferSize, ColorSpaceDeviceRGB, renderingMode);
     if (!m_imageBuffer)
         return;

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (104500 => 104501)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2012-01-09 23:43:07 UTC (rev 104500)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2012-01-09 23:53:36 UTC (rev 104501)
@@ -59,6 +59,7 @@
 
     enum RenderingMode {
         Unaccelerated,
+        UnacceleratedNonPlatformBuffer, // Use plain memory allocation rather than platform API to allocate backing store.
         Accelerated
     };
     

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (104500 => 104501)


--- trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-01-09 23:43:07 UTC (rev 104500)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-01-09 23:53:36 UTC (rev 104501)
@@ -93,6 +93,13 @@
     return canvas;
 }
 
+static SkCanvas* createNonPlatformCanvas(const IntSize& size)
+{
+    SkCanvas* canvas = new SkCanvas();
+    canvas->setDevice(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), size.height()))->unref();
+    return canvas;
+}
+
 ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode renderingMode, bool& success)
     : m_data(size)
     , m_size(size)
@@ -101,6 +108,8 @@
 
     if (renderingMode == Accelerated)
         canvas = adoptPtr(createAcceleratedCanvas(size, &m_data));
+    else if (renderingMode == UnacceleratedNonPlatformBuffer)
+        canvas = adoptPtr(createNonPlatformCanvas(size));
 
     if (!canvas)
         canvas = adoptPtr(skia::TryCreateBitmapCanvas(size.width(), size.height(), false));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to