[chromium] Updating WebGraphicsContext3D MemoryAllocation callback to accept a struct...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 19:19:12 +0000 (19:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 19:19:12 +0000 (19:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81279

Patch by Michal Mocny <mmocny@google.com> on 2012-03-19
Reviewed by James Robinson.

Source/Platform:

Adding a suggestHaveBackbuffer hint to the WebGraphicsContext3D memory allocation callback.

* chromium/public/WebGraphicsContext3D.h:
(WebGraphicsMemoryAllocationChangedCallbackCHROMIUM):
(WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM::onMemoryAllocationChanged):
* chromium/public/WebGraphicsMemoryAllocation.h: Added.
(WebKit):
(WebGraphicsMemoryAllocation):
(WebKit::WebGraphicsMemoryAllocation::WebGraphicsMemoryAllocation):

Source/WebCore:

* platform/graphics/chromium/Extensions3DChromium.h:
(GpuMemoryAllocationCHROMIUM):
(WebCore::Extensions3DChromium::GpuMemoryAllocationCHROMIUM::GpuMemoryAllocationCHROMIUM):
(GpuMemoryAllocationChangedCallbackCHROMIUM):

Source/WebKit/chromium:

* src/GraphicsContext3DChromium.cpp:
(WebCore::GrMemoryAllocationChangedCallback::onGpuMemoryAllocationChanged):
(WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::onMemoryAllocationChanged):
(GraphicsContext3DMemoryAllocationChangedCallbackAdapter):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111216 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/Platform/ChangeLog
Source/Platform/chromium/public/WebGraphicsContext3D.h
Source/Platform/chromium/public/WebGraphicsMemoryAllocation.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp

index b119213da83f6de9513ab1399e2364e061cc17d3..a30ccd2ac3568660041490f0d36f6adba97ffea3 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-19  Michal Mocny  <mmocny@google.com>
+
+        [chromium] Updating WebGraphicsContext3D MemoryAllocation callback to accept a struct with have backbuffer suggestion.
+        https://bugs.webkit.org/show_bug.cgi?id=81279
+
+        Reviewed by James Robinson.
+
+        Adding a suggestHaveBackbuffer hint to the WebGraphicsContext3D memory allocation callback.
+
+        * chromium/public/WebGraphicsContext3D.h:
+        (WebGraphicsMemoryAllocationChangedCallbackCHROMIUM):
+        (WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM::onMemoryAllocationChanged):
+        * chromium/public/WebGraphicsMemoryAllocation.h: Added.
+        (WebKit):
+        (WebGraphicsMemoryAllocation):
+        (WebKit::WebGraphicsMemoryAllocation::WebGraphicsMemoryAllocation):
+
 2012-03-19  David Reveman  <reveman@chromium.org>
 
         [Chromium] GL_EXT_occlusion_query_boolean and GL_CHROMIUM_command_buffer_query support.
index ea438dee6d040df2815afb9749663e94fa4b40b8..84c509c14c3c8e6a6efcf7ad8a82d4aa0d1b7e76 100644 (file)
@@ -32,6 +32,7 @@
 #define WebGraphicsContext3D_h
 
 #include "WebCommon.h"
+#include "WebGraphicsMemoryAllocation.h"
 #include "WebNonCopyable.h"
 #include "WebString.h"
 
@@ -129,7 +130,10 @@ public:
 
     class WebGraphicsMemoryAllocationChangedCallbackCHROMIUM {
     public:
+        // FIXME: Remove this once we switch to WebGraphicsMemoryAllocation version.
         virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes) = 0;
+        // FIXME: Make this pure virtual once we implement everywhere.
+        virtual void onMemoryAllocationChanged(WebGraphicsMemoryAllocation) { }
 
     protected:
         virtual ~WebGraphicsMemoryAllocationChangedCallbackCHROMIUM() { }
diff --git a/Source/Platform/chromium/public/WebGraphicsMemoryAllocation.h b/Source/Platform/chromium/public/WebGraphicsMemoryAllocation.h
new file mode 100644 (file)
index 0000000..33583df
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebGraphicsMemoryAllocation_h
+#define WebGraphicsMemoryAllocation_h
+
+#include "WebCommon.h"
+
+namespace WebKit {
+
+struct WebGraphicsMemoryAllocation {
+    unsigned gpuResourceSizeInBytes;
+    bool suggestHaveBackbuffer;
+
+    WebGraphicsMemoryAllocation()
+        : gpuResourceSizeInBytes(0)
+        , suggestHaveBackbuffer(false)
+    {
+    }
+
+    WebGraphicsMemoryAllocation(unsigned gpuResourceSizeInBytes, bool suggestHaveBackbuffer)
+        : gpuResourceSizeInBytes(gpuResourceSizeInBytes)
+        , suggestHaveBackbuffer(suggestHaveBackbuffer)
+    {
+    }
+};
+
+} // namespace WebKit
+
+#endif
+
index 4202af074b011630e62bded01f46c1d91eee779c..3bae57bac35fc376e1b4dd31f702886b04d26668 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-19  Michal Mocny  <mmocny@google.com>
+
+        [chromium] Updating WebGraphicsContext3D MemoryAllocation callback to accept a struct with have backbuffer suggestion.
+        https://bugs.webkit.org/show_bug.cgi?id=81279
+
+        Reviewed by James Robinson.
+
+        * platform/graphics/chromium/Extensions3DChromium.h:
+        (GpuMemoryAllocationCHROMIUM):
+        (WebCore::Extensions3DChromium::GpuMemoryAllocationCHROMIUM::GpuMemoryAllocationCHROMIUM):
+        (GpuMemoryAllocationChangedCallbackCHROMIUM):
+
 2012-03-19  Tony Chang  <tony@chromium.org>
 
         flex-item-align: stretch should only grow, never shrink
index 428219a2e84b01f6d1cae89581a94afb2eee8118..f946fe6279ee9784508f85fbc80b6e92692c75f8 100644 (file)
@@ -103,9 +103,20 @@ public:
     void setVisibilityCHROMIUM(bool);
 
     // GL_CHROMIUM_gpu_memory_manager
+    struct GpuMemoryAllocationCHROMIUM {
+        size_t gpuResourceSizeInBytes;
+        bool suggestHaveBackbuffer;
+
+        GpuMemoryAllocationCHROMIUM(size_t gpuResourceSizeInBytes, bool suggestHaveBackbuffer)
+            : gpuResourceSizeInBytes(gpuResourceSizeInBytes)
+            , suggestHaveBackbuffer(suggestHaveBackbuffer)
+        {
+        }
+    };
     class GpuMemoryAllocationChangedCallbackCHROMIUM {
     public:
-        virtual void onGpuMemoryAllocationChanged(size_t gpuResourceSizeInBytes) = 0;
+
+        virtual void onGpuMemoryAllocationChanged(GpuMemoryAllocationCHROMIUM) = 0;
         virtual ~GpuMemoryAllocationChangedCallbackCHROMIUM() { }
     };
     void setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<GpuMemoryAllocationChangedCallbackCHROMIUM>);
index 69daa4379d61771761b6f4b3392a053391ff51ff..985b35b8bc8836f95b972ff2e706d7742087eb29 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-19  Michal Mocny  <mmocny@google.com>
+
+        [chromium] Updating WebGraphicsContext3D MemoryAllocation callback to accept a struct with have backbuffer suggestion.
+        https://bugs.webkit.org/show_bug.cgi?id=81279
+
+        Reviewed by James Robinson.
+
+        * src/GraphicsContext3DChromium.cpp:
+        (WebCore::GrMemoryAllocationChangedCallback::onGpuMemoryAllocationChanged):
+        (WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::onMemoryAllocationChanged):
+        (GraphicsContext3DMemoryAllocationChangedCallbackAdapter):
+
 2012-03-19  David Reveman  <reveman@chromium.org>
 
         [Chromium] GL_EXT_occlusion_query_boolean and GL_CHROMIUM_command_buffer_query support.
index 75e97a9d995ce292c8819694843c1312704bfe8f..ec14521408a951a795adc339644a01144d83fa26 100644 (file)
@@ -174,13 +174,13 @@ public:
     {
     }
 
-    virtual void onGpuMemoryAllocationChanged(size_t gpuResourceSizeInBytes)
+    virtual void onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation)
     {
         GrContext* context = m_context->grContext();
         if (!context)
             return;
 
-        if (!gpuResourceSizeInBytes) {
+        if (!allocation.gpuResourceSizeInBytes) {
             context->freeGpuResources();
             context->setTextureCacheLimits(0, 0);
         } else
@@ -1367,9 +1367,15 @@ public:
     virtual ~GraphicsContext3DMemoryAllocationChangedCallbackAdapter() { }
 
     virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes)
+    {
+        // FIXME: Remove this once clients start using WebGraphicsMemoryAllocation exclusively.
+        onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation(gpuResourceSizeInBytes, true));
+    }
+
+    virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation allocation)
     {
         if (m_memoryAllocationChangedCallback)
-            m_memoryAllocationChangedCallback->onGpuMemoryAllocationChanged(gpuResourceSizeInBytes);
+            m_memoryAllocationChangedCallback->onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM(allocation.gpuResourceSizeInBytes, allocation.suggestHaveBackbuffer));
     }
 
 private: