Title: [106845] branches/chromium/963/Source/WebCore
Revision
106845
Author
[email protected]
Date
2012-02-06 13:43:27 -0800 (Mon, 06 Feb 2012)

Log Message

Merge 104501 - [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):

[email protected]
Review URL: https://chromiumcodereview.appspot.com/9340004

Modified Paths

Diff

Modified: branches/chromium/963/Source/WebCore/html/HTMLCanvasElement.cpp (106844 => 106845)


--- branches/chromium/963/Source/WebCore/html/HTMLCanvasElement.cpp	2012-02-06 21:39:27 UTC (rev 106844)
+++ branches/chromium/963/Source/WebCore/html/HTMLCanvasElement.cpp	2012-02-06 21:43:27 UTC (rev 106845)
@@ -458,7 +458,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: branches/chromium/963/Source/WebCore/platform/graphics/ImageBuffer.h (106844 => 106845)


--- branches/chromium/963/Source/WebCore/platform/graphics/ImageBuffer.h	2012-02-06 21:39:27 UTC (rev 106844)
+++ branches/chromium/963/Source/WebCore/platform/graphics/ImageBuffer.h	2012-02-06 21:43:27 UTC (rev 106845)
@@ -59,6 +59,7 @@
 
     enum RenderingMode {
         Unaccelerated,
+        UnacceleratedNonPlatformBuffer, // Use plain memory allocation rather than platform API to allocate backing store.
         Accelerated
     };
     

Modified: branches/chromium/963/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (106844 => 106845)


--- branches/chromium/963/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-02-06 21:39:27 UTC (rev 106844)
+++ branches/chromium/963/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-02-06 21:43:27 UTC (rev 106845)
@@ -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