Title: [108840] trunk/Source/WebKit/chromium
Revision
108840
Author
[email protected]
Date
2012-02-24 13:08:00 -0800 (Fri, 24 Feb 2012)

Log Message

[chromium] Purge Skia's GPU texture cache using GL_CHROMIUM_gpu_memory_manager
https://bugs.webkit.org/show_bug.cgi?id=78265

Patch by Michal Mocny <[email protected]> on 2012-02-24
Reviewed by Stephen White.

* src/GraphicsContext3DChromium.cpp:
(GrMemoryAllocationChangedCallback):
(WebCore::GrMemoryAllocationChangedCallback::GrMemoryAllocationChangedCallback):
(WebCore::GrMemoryAllocationChangedCallback::onGpuMemoryAllocationChanged):
(WebCore):
(WebCore::GraphicsContext3DPrivate::grContext):

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (108839 => 108840)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-02-24 21:06:27 UTC (rev 108839)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-02-24 21:08:00 UTC (rev 108840)
@@ -1,3 +1,17 @@
+2012-02-24  Michal Mocny  <[email protected]>
+
+        [chromium] Purge Skia's GPU texture cache using GL_CHROMIUM_gpu_memory_manager
+        https://bugs.webkit.org/show_bug.cgi?id=78265
+
+        Reviewed by Stephen White.
+
+        * src/GraphicsContext3DChromium.cpp:
+        (GrMemoryAllocationChangedCallback):
+        (WebCore::GrMemoryAllocationChangedCallback::GrMemoryAllocationChangedCallback):
+        (WebCore::GrMemoryAllocationChangedCallback::onGpuMemoryAllocationChanged):
+        (WebCore):
+        (WebCore::GraphicsContext3DPrivate::grContext):
+
 2012-02-24  James Robinson  <[email protected]>
 
         [chromium] Remove deprecated and unused WebGraphicsContext3D::initialize call

Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp (108839 => 108840)


--- trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2012-02-24 21:06:27 UTC (rev 108839)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2012-02-24 21:08:00 UTC (rev 108840)
@@ -158,6 +158,23 @@
 }
 
 #if USE(SKIA)
+class GrMemoryAllocationChangedCallback : public Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM {
+public:
+    GrMemoryAllocationChangedCallback(GraphicsContext3DPrivate* context)
+        : m_context(context)
+    {
+    }
+
+    virtual void onGpuMemoryAllocationChanged(size_t gpuResourceSizeInBytes)
+    {
+        if (!gpuResourceSizeInBytes && m_context->grContext())
+            m_context->grContext()->freeGpuResources();
+    }
+
+private:
+    GraphicsContext3DPrivate* m_context;
+};
+
 GrContext* GraphicsContext3DPrivate::grContext()
 {
     // Limit the number of textures we hold in the bitmap->texture cache.
@@ -168,8 +185,12 @@
     if (!m_grContext) {
         SkAutoTUnref<GrGLInterface> interface(m_impl->createGrGLInterface());
         m_grContext = GrContext::Create(kOpenGL_Shaders_GrEngine, reinterpret_cast<GrPlatform3DContext>(interface.get()));
-        if (m_grContext)
+        if (m_grContext) {
             m_grContext->setTextureCacheLimits(maxTextureCacheCount, maxTextureCacheBytes);
+            Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(getExtensions());
+            if (extensions3DChromium->supports("GL_CHROMIUM_gpu_memory_manager"))
+                extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(adoptPtr(new GrMemoryAllocationChangedCallback(this)));
+        }
     }
     return m_grContext;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to