Changeset 104501 in webkit


Ignore:
Timestamp:
Jan 9, 2012 3:53:36 PM (12 years ago)
Author:
commit-queue@webkit.org
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 <junov@chromium.org> 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):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r104494 r104501  
     12012-01-09  Justin Novosad  <junov@chromium.org>
     2
     3        [chromium win] Creating lots of temporary canvas contexts will crash.
     4        https://bugs.webkit.org/show_bug.cgi?id=68420
     5
     6        When using the skia port, the allocation of 2d canvas backing stores
     7        no longer needs to be done through a platform API (GDI/CG) because
     8        canvases now use skia for drawing text.  Removing the allocation through
     9        GDI on windows prevents resource exhaustion due to unreferenced canvases
     10        that are awaiting garbage collection.
     11
     12        Reviewed by Stephen White.
     13
     14        No new tests: Relying on existing canvas layout tests.
     15
     16        * html/HTMLCanvasElement.cpp:
     17        (WebCore::HTMLCanvasElement::createImageBuffer):
     18        * platform/graphics/ImageBuffer.h:
     19        * platform/graphics/skia/ImageBufferSkia.cpp:
     20        (WebCore::createNonPlatformCanvas):
     21        (WebCore::ImageBuffer::ImageBuffer):
     22
    1232012-01-09  Avi Drissman  <avi@chromium.org>
    224
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r103118 r104501  
    466466        return;
    467467
    468     RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : Unaccelerated;
     468    RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated :
     469#if USE(SKIA)
     470        UnacceleratedNonPlatformBuffer;
     471#else
     472        Unaccelerated;
     473#endif
    469474    m_imageBuffer = ImageBuffer::create(bufferSize, ColorSpaceDeviceRGB, renderingMode);
    470475    if (!m_imageBuffer)
  • trunk/Source/WebCore/platform/graphics/ImageBuffer.h

    r100535 r104501  
    6060    enum RenderingMode {
    6161        Unaccelerated,
     62        UnacceleratedNonPlatformBuffer, // Use plain memory allocation rather than platform API to allocate backing store.
    6263        Accelerated
    6364    };
  • trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

    r103264 r104501  
    9494}
    9595
     96static SkCanvas* createNonPlatformCanvas(const IntSize& size)
     97{
     98    SkCanvas* canvas = new SkCanvas();
     99    canvas->setDevice(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), size.height()))->unref();
     100    return canvas;
     101}
     102
    96103ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode renderingMode, bool& success)
    97104    : m_data(size)
     
    102109    if (renderingMode == Accelerated)
    103110        canvas = adoptPtr(createAcceleratedCanvas(size, &m_data));
     111    else if (renderingMode == UnacceleratedNonPlatformBuffer)
     112        canvas = adoptPtr(createNonPlatformCanvas(size));
    104113
    105114    if (!canvas)
Note: See TracChangeset for help on using the changeset viewer.