Title: [109774] branches/chromium/1025/Source/WebCore/platform/graphics
- Revision
- 109774
- Author
- e...@google.com
- Date
- 2012-03-05 11:15:53 -0800 (Mon, 05 Mar 2012)
Log Message
Merge 109171 - [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):
TBR=e...@google.com
Review URL: https://chromiumcodereview.appspot.com/9599019
Modified Paths
Diff
Modified: branches/chromium/1025/Source/WebCore/platform/graphics/Pattern.cpp (109773 => 109774)
--- branches/chromium/1025/Source/WebCore/platform/graphics/Pattern.cpp 2012-03-05 19:00:26 UTC (rev 109773)
+++ branches/chromium/1025/Source/WebCore/platform/graphics/Pattern.cpp 2012-03-05 19:15:53 UTC (rev 109774)
@@ -37,6 +37,7 @@
, m_repeatY(repeatY)
#if USE(SKIA)
, m_pattern(0)
+ , m_externalMemoryAllocated(0)
#endif
{
ASSERT(m_tileImage);
Modified: branches/chromium/1025/Source/WebCore/platform/graphics/Pattern.h (109773 => 109774)
--- branches/chromium/1025/Source/WebCore/platform/graphics/Pattern.h 2012-03-05 19:00:26 UTC (rev 109773)
+++ branches/chromium/1025/Source/WebCore/platform/graphics/Pattern.h 2012-03-05 19:15:53 UTC (rev 109774)
@@ -95,6 +95,9 @@
bool m_repeatY;
AffineTransform m_patternSpaceTransformation;
PlatformPatternPtr m_pattern;
+#if USE(SKIA)
+ size_t m_externalMemoryAllocated;
+#endif
};
} //namespace
Modified: branches/chromium/1025/Source/WebCore/platform/graphics/skia/PatternSkia.cpp (109773 => 109774)
--- branches/chromium/1025/Source/WebCore/platform/graphics/skia/PatternSkia.cpp 2012-03-05 19:00:26 UTC (rev 109773)
+++ branches/chromium/1025/Source/WebCore/platform/graphics/skia/PatternSkia.cpp 2012-03-05 19:15:53 UTC (rev 109774)
@@ -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 @@
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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes