[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

zmo at google.com zmo at google.com
Wed Dec 22 11:53:29 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit eab0abae05b5fd1335a4cc6d6e306cb363fe1b76
Author: zmo at google.com <zmo at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 10 20:44:54 2010 +0000

    2010-08-06  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Dimitri Glazkov.
    
            texture functions should gen INVALID_OPERATION if no texture is bound
            https://bugs.webkit.org/show_bug.cgi?id=42907
    
            * html/canvas/WebGLRenderingContext.cpp:
            (WebCore::WebGLRenderingContext::copyTexImage2D): Check if a texture is bound to target.
            (WebCore::WebGLRenderingContext::copyTexSubImage2D): Ditto.
            (WebCore::WebGLRenderingContext::generateMipmap): Ditto.
            (WebCore::WebGLRenderingContext::getTexParameter): Ditto.
            (WebCore::WebGLRenderingContext::texImage2DBase): Ditto.
            (WebCore::WebGLRenderingContext::texParameter): Ditto.
            (WebCore::WebGLRenderingContext::texSubImage2DBase): Ditto.
            (WebCore::WebGLRenderingContext::validateTextureBinding): Check if target is valid and if a texture is bound to it.
            * html/canvas/WebGLRenderingContext.h: Declare validateTextureBinding().
    2010-08-06  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Dimitri Glazkov.
    
            texture functions should gen INVALID_OPERATION if no texture is bound
            https://bugs.webkit.org/show_bug.cgi?id=42907
    
            * fast/canvas/webgl/gl-enum-tests-expected.txt: Need to bind a texture before testing tex-functions.
            * fast/canvas/webgl/gl-enum-tests.html: Ditto.
            * fast/canvas/webgl/null-object-behaviour-expected.txt: Test tex-functions when no texture is bound.
            * fast/canvas/webgl/null-object-behaviour.html: Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65089 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 2d2c961..6f025dc 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-06  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        texture functions should gen INVALID_OPERATION if no texture is bound
+        https://bugs.webkit.org/show_bug.cgi?id=42907
+
+        * fast/canvas/webgl/gl-enum-tests-expected.txt: Need to bind a texture before testing tex-functions.
+        * fast/canvas/webgl/gl-enum-tests.html: Ditto.
+        * fast/canvas/webgl/null-object-behaviour-expected.txt: Test tex-functions when no texture is bound.
+        * fast/canvas/webgl/null-object-behaviour.html: Ditto.
+
 2010-08-10  Johnny Ding  <jnd at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt b/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt
index 1fa633d..50ec94a 100644
--- a/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt
@@ -19,13 +19,13 @@ PASS gl.bufferData(gl.ARRAY_BUFFER, 3, desktopGL['STATIC_READ']) should return I
 PASS gl.disable(desktopGL['CLIP_PLANE0']) should return INVALID_ENUM.
 PASS gl.disable(desktopGL['POINT_SPRITE']) should return INVALID_ENUM.
 PASS gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER']) should return INVALID_ENUM.
-PASS gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM.
-PASS gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM.
 PASS gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST) should return INVALID_ENUM.
 PASS gl.isEnabled(desktopGL['CLIP_PLANE0']) should return INVALID_ENUM.
 PASS gl.isEnabled(desktopGL['POINT_SPRITE']) should return INVALID_ENUM.
 PASS gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1) should return INVALID_ENUM.
 PASS gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.SHORT, buf) should return INVALID_ENUM.
+PASS gl.getError() is gl.NO_ERROR
+PASS gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM.
 PASS gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST) should return INVALID_ENUM.
 PASS gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1) should return INVALID_ENUM.
 
diff --git a/LayoutTests/fast/canvas/webgl/gl-enum-tests.html b/LayoutTests/fast/canvas/webgl/gl-enum-tests.html
index 0b6018b..ec46c31 100644
--- a/LayoutTests/fast/canvas/webgl/gl-enum-tests.html
+++ b/LayoutTests/fast/canvas/webgl/gl-enum-tests.html
@@ -33,6 +33,7 @@ if (!gl) {
   var tex = gl.createTexture();
   gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
   shouldBe("gl.getError()", "gl.NO_ERROR");
+
   var tests = [
     "gl.bindTexture(desktopGL['TEXTURE_3D'], tex)",
     "gl.blendEquation(desktopGL['MIN'])",
@@ -45,21 +46,31 @@ if (!gl) {
     "gl.disable(desktopGL['CLIP_PLANE0'])",
     "gl.disable(desktopGL['POINT_SPRITE'])",
     "gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER'])",
-    "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])",
-    "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])",
     "gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST)",
     "gl.isEnabled(desktopGL['CLIP_PLANE0'])",
     "gl.isEnabled(desktopGL['POINT_SPRITE'])",
     "gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1)",
     "gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.SHORT, buf)",
+  ];
+  for (var ii = 0; ii < tests.length; ++ii) {
+    eval(tests[ii]);
+    assertMsg(gl.getError() == gl.INVALID_ENUM,
+              tests[ii] + " should return INVALID_ENUM.");
+  }
+
+  gl.bindTexture(gl.TEXTURE_2D, tex);
+  shouldBe("gl.getError()", "gl.NO_ERROR");
+
+  tests = [
+    "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])",
     "gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST)",
     "gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1)"
-   ];
-   for (var ii = 0; ii < tests.length; ++ii) {
-     eval(tests[ii]);
-     assertMsg(gl.getError() == gl.INVALID_ENUM,
-               tests[ii] + " should return INVALID_ENUM.");
-   }
+  ];
+  for (var ii = 0; ii < tests.length; ++ii) {
+    eval(tests[ii]);
+    assertMsg(gl.getError() == gl.INVALID_ENUM,
+              tests[ii] + " should return INVALID_ENUM.");
+  }
 }
 
 debug("");
diff --git a/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt b/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
index b2f24c2..f8f14f7 100644
--- a/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
@@ -18,6 +18,14 @@ PASS context.bindBuffer(context.ARRAY_BUFFER, 0) was expected value: NO_ERROR.
 PASS context.bindFramebuffer(context.FRAMEBUFFER, 0) was expected value: NO_ERROR.
 PASS context.bindRenderbuffer(context.RENDERBUFFER, 0) was expected value: NO_ERROR.
 PASS context.bindTexture(context.TEXTURE_2D, 0) was expected value: NO_ERROR.
+PASS context.bindBuffer(context.ARRAY_BUFFER, null) was expected value: NO_ERROR.
+PASS context.bindFramebuffer(context.FRAMEBUFFER, null) was expected value: NO_ERROR.
+PASS context.bindRenderbuffer(context.RENDERBUFFER, null) was expected value: NO_ERROR.
+PASS context.bindTexture(context.TEXTURE_2D, null) was expected value: NO_ERROR.
+PASS context.bindBuffer(context.ARRAY_BUFFER, undefined) was expected value: NO_ERROR.
+PASS context.bindFramebuffer(context.FRAMEBUFFER, undefined) was expected value: NO_ERROR.
+PASS context.bindRenderbuffer(context.RENDERBUFFER, undefined) was expected value: NO_ERROR.
+PASS context.bindTexture(context.TEXTURE_2D, undefined) was expected value: NO_ERROR.
 PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) was expected value: INVALID_OPERATION.
 PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) was expected value: INVALID_OPERATION.
 PASS context.getProgramParameter(undefined, 0) was expected value: INVALID_VALUE.
@@ -27,6 +35,20 @@ PASS context.getShaderInfoLog(undefined, 0) was expected value: INVALID_VALUE.
 PASS context.getShaderSource(undefined) was expected value: INVALID_VALUE.
 PASS context.getUniform(undefined, 0) was expected value: INVALID_VALUE.
 PASS context.getUniformLocation(undefined, 'foo') was expected value: INVALID_VALUE.
+
+check with bindings
+PASS context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW) was expected value: NO_ERROR.
+PASS context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE) was expected value: NO_ERROR.
+PASS context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0])) was expected value: NO_ERROR.
+PASS context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST) was expected value: NO_ERROR.
+PASS context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER) was expected value: NO_ERROR.
+
+check without bindings
+PASS context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW) was expected value: INVALID_OPERATION.
+PASS context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE) was expected value: INVALID_OPERATION.
+PASS context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0])) was expected value: INVALID_OPERATION.
+PASS context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST) was expected value: INVALID_OPERATION.
+PASS context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER) was expected value: INVALID_OPERATION.
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/canvas/webgl/null-object-behaviour.html b/LayoutTests/fast/canvas/webgl/null-object-behaviour.html
index dc84278..2bb9801 100644
--- a/LayoutTests/fast/canvas/webgl/null-object-behaviour.html
+++ b/LayoutTests/fast/canvas/webgl/null-object-behaviour.html
@@ -34,6 +34,14 @@ shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, 0)");
 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, 0)");
 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, 0)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, null)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, null)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, null)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, null)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, undefined)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, undefined)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, undefined)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, undefined)");
 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
@@ -44,6 +52,27 @@ shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(u
 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, 0)");
 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
 
+debug("");
+debug("check with bindings");
+context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer());
+context.bindTexture(context.TEXTURE_2D, context.createTexture());
+shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))");
+shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)");
+
+debug("");
+debug("check without bindings");
+context.bindBuffer(context.ARRAY_BUFFER, 0);
+context.bindTexture(context.TEXTURE_2D, 0);
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)");
+
+
 successfullyParsed = true;
 </script>
 
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fd31224..e43be11 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-06  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        texture functions should gen INVALID_OPERATION if no texture is bound
+        https://bugs.webkit.org/show_bug.cgi?id=42907
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::copyTexImage2D): Check if a texture is bound to target.
+        (WebCore::WebGLRenderingContext::copyTexSubImage2D): Ditto.
+        (WebCore::WebGLRenderingContext::generateMipmap): Ditto.
+        (WebCore::WebGLRenderingContext::getTexParameter): Ditto.
+        (WebCore::WebGLRenderingContext::texImage2DBase): Ditto.
+        (WebCore::WebGLRenderingContext::texParameter): Ditto.
+        (WebCore::WebGLRenderingContext::texSubImage2DBase): Ditto.
+        (WebCore::WebGLRenderingContext::validateTextureBinding): Check if target is valid and if a texture is bound to it.
+        * html/canvas/WebGLRenderingContext.h: Declare validateTextureBinding().
+
 2010-08-10  Patrick Gansterer  <paroga at paroga.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 0284ec6..89e9510 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -521,6 +521,9 @@ void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, uns
 {
     if (!validateTexFuncParameters(target, level, internalformat, width, height, border, internalformat, GraphicsContext3D::UNSIGNED_BYTE))
         return;
+    WebGLTexture* tex = validateTextureBinding(target, true);
+    if (!tex)
+        return;
     if (!isGLES2Compliant()) {
         if (m_framebufferBinding && m_framebufferBinding->object()
             && !isTexInternalFormatColorBufferCombinationValid(internalformat,
@@ -535,21 +538,20 @@ void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, uns
     }
     m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
     // FIXME: if the framebuffer is not complete, none of the below should be executed.
-    WebGLTexture* tex = getTextureBinding(target);
-    if (!isGLES2Compliant()) {
-        if (tex)
-            tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
-    }
-    if (m_framebufferBinding && tex)
+    if (!isGLES2Compliant())
+        tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
+    if (m_framebufferBinding)
         m_framebufferBinding->onAttachedObjectChange(tex);
     cleanupAfterGraphicsCall(false);
 }
 
 void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height)
 {
+    WebGLTexture* tex = validateTextureBinding(target, true);
+    if (!tex)
+        return;
     if (!isGLES2Compliant()) {
-        WebGLTexture* tex = getTextureBinding(target);
-        if (m_framebufferBinding && m_framebufferBinding->object() && tex
+        if (m_framebufferBinding && m_framebufferBinding->object()
             && !isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(),
                                                                m_framebufferBinding->getColorBufferFormat())) {
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -1110,22 +1112,18 @@ void WebGLRenderingContext::frontFace(unsigned long mode)
 
 void WebGLRenderingContext::generateMipmap(unsigned long target)
 {
-    RefPtr<WebGLTexture> tex;
+    WebGLTexture* tex = validateTextureBinding(target, false);
+    if (!tex)
+        return;
     if (!isGLES2Compliant()) {
-        if (target == GraphicsContext3D::TEXTURE_2D)
-            tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
-        else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
-            tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
-        if (tex && !tex->canGenerateMipmaps()) {
+        if (!tex->canGenerateMipmaps()) {
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
             return;
         }
     }
     m_context->generateMipmap(target);
-    if (!isGLES2Compliant()) {
-        if (tex)
-            tex->generateMipmapLevelInfo();
-    }
+    if (!isGLES2Compliant())
+        tex->generateMipmapLevelInfo();
     cleanupAfterGraphicsCall(false);
 }
 
@@ -1574,11 +1572,9 @@ String WebGLRenderingContext::getString(unsigned long name)
 WebGLGetInfo WebGLRenderingContext::getTexParameter(unsigned long target, unsigned long pname, ExceptionCode& ec)
 {
     UNUSED_PARAM(ec);
-    if (target != GraphicsContext3D::TEXTURE_2D
-        && target != GraphicsContext3D::TEXTURE_CUBE_MAP) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+    WebGLTexture* tex = validateTextureBinding(target, false);
+    if (!tex)
         return WebGLGetInfo();
-    }
     WebGLStateRestorer(this, false);
     int value = 0;
     switch (pname) {
@@ -2100,6 +2096,9 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
     ec = 0;
     if (!validateTexFuncParameters(target, level, internalformat, width, height, border, format, type))
         return;
+    WebGLTexture* tex = validateTextureBinding(target, true);
+    if (!tex)
+        return;
     if (!isGLES2Compliant()) {
         if (level && WebGLTexture::isNPOT(width, height)) {
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
@@ -2108,12 +2107,9 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
     }
     m_context->texImage2D(target, level, internalformat, width, height,
                           border, format, type, pixels);
-    WebGLTexture* tex = getTextureBinding(target);
-    if (!isGLES2Compliant()) {
-        if (tex)
-            tex->setLevelInfo(target, level, internalformat, width, height, type);
-    }
-    if (m_framebufferBinding && tex)
+    if (!isGLES2Compliant())
+        tex->setLevelInfo(target, level, internalformat, width, height, type);
+    if (m_framebufferBinding)
         m_framebufferBinding->onAttachedObjectChange(tex);
     cleanupAfterGraphicsCall(false);
 }
@@ -2330,19 +2326,10 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLVide
 
 void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pname, float paramf, int parami, bool isFloat)
 {
+    WebGLTexture* tex = validateTextureBinding(target, false);
+    if (!tex)
+        return;
     if (!isGLES2Compliant()) {
-        RefPtr<WebGLTexture> tex = 0;
-        switch (target) {
-        case GraphicsContext3D::TEXTURE_2D:
-            tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
-            break;
-        case GraphicsContext3D::TEXTURE_CUBE_MAP:
-            tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
-            break;
-        default:
-            m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
-            return;
-        }
         switch (pname) {
         case GraphicsContext3D::TEXTURE_MIN_FILTER:
         case GraphicsContext3D::TEXTURE_MAG_FILTER:
@@ -2359,12 +2346,10 @@ void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pna
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
             return;
         }
-        if (tex) {
-            if (isFloat)
-                tex->setParameterf(pname, paramf);
-            else
-                tex->setParameteri(pname, parami);
-        }
+        if (isFloat)
+            tex->setParameterf(pname, paramf);
+        else
+            tex->setParameteri(pname, parami);
     }
     if (isFloat)
         m_context->texParameterf(target, pname, paramf);
@@ -2391,7 +2376,8 @@ void WebGLRenderingContext::texSubImage2DBase(unsigned target, unsigned level, u
     ec = 0;
     if (!validateTexFuncFormatAndType(format, type))
         return;
-
+    if (!validateTextureBinding(target, true))
+        return;
     m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
     cleanupAfterGraphicsCall(false);
 }
@@ -3309,12 +3295,12 @@ bool WebGLRenderingContext::isTexInternalFormatColorBufferCombinationValid(unsig
     return false;
 }
 
-WebGLTexture* WebGLRenderingContext::getTextureBinding(unsigned long target)
+WebGLTexture* WebGLRenderingContext::validateTextureBinding(unsigned long target, bool useSixEnumsForCubeMap)
 {
-    RefPtr<WebGLTexture> tex = 0;
+    WebGLTexture* tex = 0;
     switch (target) {
     case GraphicsContext3D::TEXTURE_2D:
-        tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+        tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get();
         break;
     case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
     case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
@@ -3322,12 +3308,26 @@ WebGLTexture* WebGLRenderingContext::getTextureBinding(unsigned long target)
     case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
     case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
     case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
-        tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+        if (!useSixEnumsForCubeMap) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+            return 0;
+        }
+        tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get();
+        break;
+    case GraphicsContext3D::TEXTURE_CUBE_MAP:
+        if (useSixEnumsForCubeMap) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+            return 0;
+        }
+        tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get();
         break;
+    default:
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+        return 0;
     }
-    if (tex && tex->object())
-        return tex.get();
-    return 0;
+    if (!tex)
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+    return tex;
 }
 
 bool WebGLRenderingContext::validateTexFuncFormatAndType(unsigned long format, unsigned long type)
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index 608797f..6fb8ce4 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -460,8 +460,10 @@ public:
     bool isTexInternalFormatColorBufferCombinationValid(unsigned long texInternalFormat,
                                                         unsigned long colorBufferFormat);
 
-    // Helper function to get the current bound texture.
-    WebGLTexture* getTextureBinding(unsigned long target);
+    // Helper function to check target and texture bound to the target.
+    // Generate GL errors and return 0 if target is invalid or texture bound is
+    // null.  Otherwise, return the texture bound to the target.
+    WebGLTexture* validateTextureBinding(unsigned long target, bool useSixEnumsForCubeMap);
 
     // Helper function to check input format/type for functions {copy}Tex{Sub}Image.
     // Generates GL error and returns false if parameters are invalid.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list