Changeset 92430 in webkit


Ignore:
Timestamp:
Aug 4, 2011, 4:46:59 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Implement a global resource limit for DrawingBuffer to limit the amount of GPU memory used by 2d canvas backing stores
https://bugs.webkit.org/show_bug.cgi?id=65655

Patch by James Robinson <jamesr@chromium.org> on 2011-08-04
Reviewed by Kenneth Russell.

  • platform/graphics/gpu/DrawingBuffer.cpp:

(WebCore::DrawingBuffer::setResourceLimit):
(WebCore::DrawingBuffer::clear):
(WebCore::DrawingBuffer::reset):

  • platform/graphics/gpu/DrawingBuffer.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92425 r92430  
     12011-08-04  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Implement a global resource limit for DrawingBuffer to limit the amount of GPU memory used by 2d canvas backing stores
     4        https://bugs.webkit.org/show_bug.cgi?id=65655
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * platform/graphics/gpu/DrawingBuffer.cpp:
     9        (WebCore::DrawingBuffer::setResourceLimit):
     10        (WebCore::DrawingBuffer::clear):
     11        (WebCore::DrawingBuffer::reset):
     12        * platform/graphics/gpu/DrawingBuffer.h:
     13
    1142011-08-04  Kenichi Ishibashi  <bashi@chromium.org>
    215
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp

    r90872 r92430  
    3939namespace WebCore {
    4040
     41// Global resource ceiling (expressed in terms of pixels) for DrawingBuffer creation and resize.
     42// When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() calls that would
     43// exceed the global cap will instead clear the buffer.
     44#if PLATFORM(CHROMIUM) // Currently, this cap only exists for chromium.
     45static int s_maximumResourceUsePixels = 16 * 1024 * 1024;
     46#else
     47static int s_maximumResourceUsePixels = 0;
     48#endif
     49static int s_currentResourceUsePixels = 0;
     50
    4151PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, const IntSize& size)
    4252{
     
    6171
    6272    m_context->makeContextCurrent();
     73    if (!m_size.isEmpty())
     74        s_currentResourceUsePixels -= m_size.width() * m_size.height();
    6375
    6476    if (m_colorBuffer) {
     
    203215    m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
    204216    if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) {
    205       clear();
    206       return false;
    207     }
     217        clear();
     218        return false;
     219    }
     220
     221    int pixelDelta = newSize.width() * newSize.height();
     222    if (!m_size.isEmpty())
     223        pixelDelta -= m_size.width() * m_size.height();
     224
     225    if (s_maximumResourceUsePixels && (s_currentResourceUsePixels + pixelDelta) > s_maximumResourceUsePixels) {
     226        clear();
     227        return false;
     228    }
     229    s_currentResourceUsePixels += pixelDelta;
    208230
    209231    const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes();
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h

    r87987 r92430  
    5959public:
    6060    friend class GraphicsContext3D;
    61    
     61
    6262    ~DrawingBuffer();
    6363
     
    115115   
    116116    DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported);
    117    
     117
    118118    // Platform specific function called after reset() so each platform can do extra work if needed
    119119    void didReset();
Note: See TracChangeset for help on using the changeset viewer.