Title: [109171] trunk/Source/WebCore
Revision
109171
Author
[email protected]
Date
2012-02-28 17:12:57 -0800 (Tue, 28 Feb 2012)

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109170 => 109171)


--- trunk/Source/WebCore/ChangeLog	2012-02-29 00:38:28 UTC (rev 109170)
+++ trunk/Source/WebCore/ChangeLog	2012-02-29 01:12:57 UTC (rev 109171)
@@ -1,3 +1,23 @@
+2012-02-28  Adrienne Walker  <[email protected]>
+
+        [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  <[email protected]>
 
         [chromium] Reset damage tracker on visibility change.

Modified: trunk/Source/WebCore/platform/graphics/Pattern.cpp (109170 => 109171)


--- trunk/Source/WebCore/platform/graphics/Pattern.cpp	2012-02-29 00:38:28 UTC (rev 109170)
+++ trunk/Source/WebCore/platform/graphics/Pattern.cpp	2012-02-29 01:12:57 UTC (rev 109171)
@@ -37,6 +37,7 @@
     , m_repeatY(repeatY)
 #if USE(SKIA)
     , m_pattern(0)
+    , m_externalMemoryAllocated(0)
 #endif
 {
     ASSERT(m_tileImage);

Modified: trunk/Source/WebCore/platform/graphics/Pattern.h (109170 => 109171)


--- trunk/Source/WebCore/platform/graphics/Pattern.h	2012-02-29 00:38:28 UTC (rev 109170)
+++ trunk/Source/WebCore/platform/graphics/Pattern.h	2012-02-29 01:12:57 UTC (rev 109171)
@@ -95,6 +95,9 @@
     bool m_repeatY;
     AffineTransform m_patternSpaceTransformation;
     PlatformPatternPtr m_pattern;
+#if USE(SKIA)
+    size_t m_externalMemoryAllocated;
+#endif
 };
 
 } //namespace

Modified: trunk/Source/WebCore/platform/graphics/skia/PatternSkia.cpp (109170 => 109171)


--- trunk/Source/WebCore/platform/graphics/skia/PatternSkia.cpp	2012-02-29 00:38:28 UTC (rev 109170)
+++ trunk/Source/WebCore/platform/graphics/skia/PatternSkia.cpp	2012-02-29 01:12:57 UTC (rev 109171)
@@ -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
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to