Title: [94356] trunk/Source/WebCore
Revision
94356
Author
[email protected]
Date
2011-09-01 16:03:58 -0700 (Thu, 01 Sep 2011)

Log Message

[chromium] TextureManager overestimates the size of non-RGBA texture formats
https://bugs.webkit.org/show_bug.cgi?id=66917

Reviewed by James Robinson.

Use GraphicsContext3D to determine the size of a given texture format.
Also, make TextureManager use more GraphicsContext3D types.

* platform/graphics/GraphicsContext3D.h:
* platform/graphics/chromium/TextureManager.cpp:
(WebCore::memoryUseBytes):
* platform/graphics/chromium/TextureManager.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (94355 => 94356)


--- trunk/Source/WebCore/ChangeLog	2011-09-01 22:48:46 UTC (rev 94355)
+++ trunk/Source/WebCore/ChangeLog	2011-09-01 23:03:58 UTC (rev 94356)
@@ -1,3 +1,18 @@
+2011-08-31  Adrienne Walker  <[email protected]>
+
+        [chromium] TextureManager overestimates the size of non-RGBA texture formats
+        https://bugs.webkit.org/show_bug.cgi?id=66917
+
+        Reviewed by James Robinson.
+
+        Use GraphicsContext3D to determine the size of a given texture format.
+        Also, make TextureManager use more GraphicsContext3D types.
+
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/chromium/TextureManager.cpp:
+        (WebCore::memoryUseBytes):
+        * platform/graphics/chromium/TextureManager.h:
+
 2011-09-01  Sam Weinig  <[email protected]>
 
         Add missing Event constructors to DOMWindow.idl

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (94355 => 94356)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2011-09-01 22:48:46 UTC (rev 94355)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2011-09-01 23:03:58 UTC (rev 94356)
@@ -521,10 +521,10 @@
     // Computes the components per pixel and bytes per component
     // for the given format and type combination. Returns false if
     // either was an invalid enum.
-    bool computeFormatAndTypeParameters(GC3Denum format,
-                                        GC3Denum type,
-                                        unsigned int* componentsPerPixel,
-                                        unsigned int* bytesPerComponent);
+    static bool computeFormatAndTypeParameters(GC3Denum format,
+                                               GC3Denum type,
+                                               unsigned int* componentsPerPixel,
+                                               unsigned int* bytesPerComponent);
 
     // Computes the image size in bytes. If paddingInBytes is not null, padding
     // is also calculated in return. Returns NO_ERROR if succeed, otherwise

Modified: trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp (94355 => 94356)


--- trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp	2011-09-01 22:48:46 UTC (rev 94355)
+++ trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp	2011-09-01 23:03:58 UTC (rev 94356)
@@ -32,10 +32,16 @@
 
 namespace WebCore {
 
-static size_t memoryUseBytes(IntSize size, unsigned textureFormat)
+static size_t memoryUseBytes(IntSize size, GC3Denum textureFormat)
 {
-    // FIXME: This assumes all textures are 4 bytes/pixel, like RGBA.
-    return size.width() * size.height() * 4;
+    // FIXME: This assumes all textures are 1 byte/component.
+    const GC3Denum type = GraphicsContext3D::UNSIGNED_BYTE;
+    unsigned int componentsPerPixel = 4;
+    unsigned int bytesPerComponent = 1;
+    if (!GraphicsContext3D::computeFormatAndTypeParameters(textureFormat, type, &componentsPerPixel, &bytesPerComponent))
+        ASSERT_NOT_REACHED();
+
+    return size.width() * size.height() * componentsPerPixel * bytesPerComponent;
 }
 
 TextureManager::TextureManager(size_t memoryLimitBytes, int maxTextureSize)

Modified: trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h (94355 => 94356)


--- trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h	2011-09-01 22:48:46 UTC (rev 94355)
+++ trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h	2011-09-01 23:03:58 UTC (rev 94356)
@@ -51,7 +51,7 @@
     void releaseToken(TextureToken);
     bool hasTexture(TextureToken);
 
-    bool requestTexture(TextureToken, IntSize, unsigned textureFormat);
+    bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat);
 
     void protectTexture(TextureToken);
     void unprotectTexture(TextureToken);
@@ -74,7 +74,7 @@
 
     struct TextureInfo {
         IntSize size;
-        unsigned format;
+        GC3Denum format;
         unsigned textureId;
         bool isProtected;
     };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to