Changeset 109171 in webkit


Ignore:
Timestamp:
Feb 28, 2012 5:12:57 PM (12 years ago)
Author:
enne@google.com
Message:

[chromium] Inform v8 about extra memory used for PatternSkia clamp mode
https://bugs.webkit.org/show_bug.cgi?id=79846

Reviewed by James Robinson.

For large images, creating a non-repeating Pattern in Skia can
allocate a lot of memory. Inform v8 about this so that it can
potentially garbage collect any Pattern objects that aren't being used
and that are holding onto large image copies.

  • platform/graphics/Pattern.cpp:

(WebCore::Pattern::Pattern):

  • platform/graphics/Pattern.h:

(Pattern):

  • platform/graphics/skia/PatternSkia.cpp:

(WebCore::Pattern::platformDestroy):
(WebCore::Pattern::platformPattern):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109168 r109171  
     12012-02-28  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Inform v8 about extra memory used for PatternSkia clamp mode
     4        https://bugs.webkit.org/show_bug.cgi?id=79846
     5
     6        Reviewed by James Robinson.
     7
     8        For large images, creating a non-repeating Pattern in Skia can
     9        allocate a lot of memory. Inform v8 about this so that it can
     10        potentially garbage collect any Pattern objects that aren't being used
     11        and that are holding onto large image copies.
     12
     13        * platform/graphics/Pattern.cpp:
     14        (WebCore::Pattern::Pattern):
     15        * platform/graphics/Pattern.h:
     16        (Pattern):
     17        * platform/graphics/skia/PatternSkia.cpp:
     18        (WebCore::Pattern::platformDestroy):
     19        (WebCore::Pattern::platformPattern):
     20
    1212012-02-28  Jonathan Backer  <backer@chromium.org>
    222
  • trunk/Source/WebCore/platform/graphics/Pattern.cpp

    r95901 r109171  
    3838#if USE(SKIA)
    3939    , m_pattern(0)
     40    , m_externalMemoryAllocated(0)
    4041#endif
    4142{
  • trunk/Source/WebCore/platform/graphics/Pattern.h

    r95922 r109171  
    9696    AffineTransform m_patternSpaceTransformation;
    9797    PlatformPatternPtr m_pattern;
     98#if USE(SKIA)
     99    size_t m_externalMemoryAllocated;
     100#endif
    98101};
    99102
  • trunk/Source/WebCore/platform/graphics/skia/PatternSkia.cpp

    r95901 r109171  
    3939#include "SkShader.h"
    4040
     41#include <v8.h>
     42
    4143namespace WebCore {
    4244
     
    4547    SkSafeUnref(m_pattern);
    4648    m_pattern = 0;
     49    if (m_externalMemoryAllocated) {
     50        v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externalMemoryAllocated);
     51        m_externalMemoryAllocated = 0;
     52    }
    4753}
    4854
     
    9096        canvas.drawBitmap(image->bitmap(), 0, 0);
    9197        m_pattern = SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY);
     98
     99        m_externalMemoryAllocated = bm2.getSafeSize();
     100        v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externalMemoryAllocated);
    92101    }
    93102    m_pattern->setLocalMatrix(m_patternSpaceTransformation);
Note: See TracChangeset for help on using the changeset viewer.