Skip to content
Permalink
Browse files
[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):

Canonical link: https://commits.webkit.org/96929@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109171 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
quisquous committed Feb 29, 2012
1 parent 8ab4de9 commit 1bbf25dab491066570df04560a05061eaec9e09d
Showing 4 changed files with 33 additions and 0 deletions.
@@ -1,3 +1,23 @@
2012-02-28 Adrienne Walker <enne@google.com>

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

2012-02-28 Jonathan Backer <backer@chromium.org>

[chromium] Reset damage tracker on visibility change.
@@ -37,6 +37,7 @@ Pattern::Pattern(PassRefPtr<Image> image, bool repeatX, bool repeatY)
, m_repeatY(repeatY)
#if USE(SKIA)
, m_pattern(0)
, m_externalMemoryAllocated(0)
#endif
{
ASSERT(m_tileImage);
@@ -95,6 +95,9 @@ class Pattern : public RefCounted<Pattern> {
bool m_repeatY;
AffineTransform m_patternSpaceTransformation;
PlatformPatternPtr m_pattern;
#if USE(SKIA)
size_t m_externalMemoryAllocated;
#endif
};

} //namespace
@@ -38,12 +38,18 @@
#include "SkColorShader.h"
#include "SkShader.h"

#include <v8.h>

namespace WebCore {

void Pattern::platformDestroy()
{
SkSafeUnref(m_pattern);
m_pattern = 0;
if (m_externalMemoryAllocated) {
v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externalMemoryAllocated);
m_externalMemoryAllocated = 0;
}
}

PlatformPatternPtr Pattern::platformPattern(const AffineTransform& patternTransform)
@@ -89,6 +95,9 @@ PlatformPatternPtr Pattern::platformPattern(const AffineTransform& patternTransf
SkCanvas canvas(bm2);
canvas.drawBitmap(image->bitmap(), 0, 0);
m_pattern = SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY);

m_externalMemoryAllocated = bm2.getSafeSize();
v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externalMemoryAllocated);
}
m_pattern->setLocalMatrix(m_patternSpaceTransformation);
return m_pattern;

0 comments on commit 1bbf25d

Please sign in to comment.