Title: [97718] trunk/Source/WebCore
Revision
97718
Author
[email protected]
Date
2011-10-17 22:04:10 -0700 (Mon, 17 Oct 2011)

Log Message

[TexMap][QT] TexMapGL renders a strange one-pixel border of BitmapTexture.
https://bugs.webkit.org/show_bug.cgi?id=70293

TextureMapperGL renders the strange border in
http://www.webkit.org/blog-files/leaves/index.html
Bug occurs because BitmapTexture is larger than the content due to rounding to
NPOT, and its pixel data is never initialized.

Patch by Huang Dongsung <[email protected]> on 2011-10-17
Reviewed by Noam Rosenthal.

* platform/graphics/opengl/TextureMapperGL.cpp:
(WebCore::texImage2DResourceSafe):
(WebCore::BitmapTextureGL::reset):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97717 => 97718)


--- trunk/Source/WebCore/ChangeLog	2011-10-18 04:57:53 UTC (rev 97717)
+++ trunk/Source/WebCore/ChangeLog	2011-10-18 05:04:10 UTC (rev 97718)
@@ -1,3 +1,19 @@
+2011-10-17  Huang Dongsung  <[email protected]>
+
+        [TexMap][QT] TexMapGL renders a strange one-pixel border of BitmapTexture.
+        https://bugs.webkit.org/show_bug.cgi?id=70293
+
+        TextureMapperGL renders the strange border in
+        http://www.webkit.org/blog-files/leaves/index.html
+        Bug occurs because BitmapTexture is larger than the content due to rounding to
+        NPOT, and its pixel data is never initialized.
+
+        Reviewed by Noam Rosenthal.
+
+        * platform/graphics/opengl/TextureMapperGL.cpp:
+        (WebCore::texImage2DResourceSafe):
+        (WebCore::BitmapTextureGL::reset):
+
 2011-10-17  Jochen Eisinger  <[email protected]>
 
         Make NavigationAction wrap a ResourceRequest instead of a KURL.

Modified: trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp (97717 => 97718)


--- trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp	2011-10-18 04:57:53 UTC (rev 97717)
+++ trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp	2011-10-18 05:04:10 UTC (rev 97718)
@@ -25,6 +25,8 @@
 #include "Image.h"
 #include "Timer.h"
 #include <wtf/HashMap.h>
+#include <wtf/OwnArrayPtr.h>
+#include <wtf/PassOwnArrayPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -501,6 +503,19 @@
     return "OpenGL";
 }
 
+// This function is similar with GraphicsContext3D::texImage2DResourceSafe.
+static void texImage2DResourceSafe(size_t width, size_t height)
+{
+    const int pixelSize = 4; // RGBA
+    OwnArrayPtr<unsigned char> zero;
+    if (width && height) {
+        unsigned int size = width * height * pixelSize;
+        zero = adoptArrayPtr(new unsigned char[size]);
+        memset(zero.get(), 0, size);
+    }
+    GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, zero.get()))
+}
+
 void BitmapTextureGL::reset(const IntSize& newSize, bool opaque)
 {
     BitmapTexture::reset(newSize, opaque);
@@ -519,7 +534,7 @@
         GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR))
         GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE))
         GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE))
-        GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0))
+        texImage2DResourceSafe(m_textureSize.width(), m_textureSize.height());
     }
     m_actualSize = newSize;
     m_relativeSize = FloatSize(float(newSize.width()) / m_textureSize.width(), float(newSize.height()) / m_textureSize.height());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to