[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 12:36:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 8849c7c05cc0bba565490373816033b090c0cdca
Author: zmo at google.com <zmo at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 25 23:40:58 2010 +0000

    2010-08-20  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Kenneth Russell.
    
            WebGL must enforce restrictions even if running on OpenGL ES 2.0
            https://bugs.webkit.org/show_bug.cgi?id=42908
    
            * public/WebGraphicsContext3D.h: Add two new flags.
            * src/GraphicsContext3D.cpp: Ditto.
            (WebCore::GraphicsContext3DInternal::isGLES2NPOTStrict):
            (WebCore::GraphicsContext3DInternal::isErrorGeneratedOnOutOfBoundsAccesses):
            (WebCore::GraphicsContext3D::isGLES2NPOTStrict):
            (WebCore::GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses):
            * src/WebGraphicsContext3DDefaultImpl.cpp: Ditto.
            (WebKit::WebGraphicsContext3DDefaultImpl::isGLES2NPOTStrict):
            (WebKit::WebGraphicsContext3DDefaultImpl::isErrorGeneratedOnOutOfBoundsAccesses):
            * src/WebGraphicsContext3DDefaultImpl.h: Ditto.
    2010-08-20  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Kenneth Russell.
    
            WebGL must enforce restrictions even if running on OpenGL ES 2.0
            https://bugs.webkit.org/show_bug.cgi?id=42908
    
            * html/canvas/WebGLFramebuffer.cpp:
            (WebCore::WebGLFramebuffer::getColorBufferFormat): Get format at given level instead of 0.
            * html/canvas/WebGLRenderingContext.cpp: Add two new flags and use them to replace the original isGLES2Compliant().
            (WebCore::WebGLRenderingContext::WebGLRenderingContext):
            (WebCore::WebGLRenderingContext::bindTexture):
            (WebCore::WebGLRenderingContext::blendEquation):
            (WebCore::WebGLRenderingContext::blendEquationSeparate):
            (WebCore::WebGLRenderingContext::bufferData):
            (WebCore::WebGLRenderingContext::bufferSubData):
            (WebCore::WebGLRenderingContext::checkFramebufferStatus):
            (WebCore::WebGLRenderingContext::clear):
            (WebCore::WebGLRenderingContext::copyTexImage2D):
            (WebCore::WebGLRenderingContext::copyTexSubImage2D):
            (WebCore::WebGLRenderingContext::disable):
            (WebCore::WebGLRenderingContext::drawArrays):
            (WebCore::WebGLRenderingContext::drawElements):
            (WebCore::WebGLRenderingContext::enable):
            (WebCore::WebGLRenderingContext::generateMipmap):
            (WebCore::WebGLRenderingContext::hint):
            (WebCore::WebGLRenderingContext::isEnabled):
            (WebCore::WebGLRenderingContext::texImage2DBase):
            (WebCore::WebGLRenderingContext::texParameter):
            (WebCore::WebGLRenderingContext::isGLES2NPOTStrict):
            (WebCore::WebGLRenderingContext::isErrorGeneratedOnOutOfBoundsAccesses):
            * html/canvas/WebGLRenderingContext.h: Declare two new flags.
            * html/canvas/WebGLTexture.cpp: Get format at given level instead of 0.
            (WebCore::WebGLTexture::getInternalFormat):
            * html/canvas/WebGLTexture.h: Ditto.
            * platform/graphics/GraphicsContext3D.h: Add three new flags.
            * platform/graphics/mac/GraphicsContext3DMac.mm: Ditto.
            (WebCore::GraphicsContext3D::isGLES2NPOTStrict):
            (WebCore::GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses):
            * platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
            (WebCore::GraphicsContext3D::isGLES2NPOTStrict):
            (WebCore::GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66055 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9b62cfd..3d5e548 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,46 @@
+2010-08-20  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        WebGL must enforce restrictions even if running on OpenGL ES 2.0
+        https://bugs.webkit.org/show_bug.cgi?id=42908
+
+        * html/canvas/WebGLFramebuffer.cpp:
+        (WebCore::WebGLFramebuffer::getColorBufferFormat): Get format at given level instead of 0.
+        * html/canvas/WebGLRenderingContext.cpp: Add two new flags and use them to replace the original isGLES2Compliant().
+        (WebCore::WebGLRenderingContext::WebGLRenderingContext):
+        (WebCore::WebGLRenderingContext::bindTexture):
+        (WebCore::WebGLRenderingContext::blendEquation):
+        (WebCore::WebGLRenderingContext::blendEquationSeparate):
+        (WebCore::WebGLRenderingContext::bufferData):
+        (WebCore::WebGLRenderingContext::bufferSubData):
+        (WebCore::WebGLRenderingContext::checkFramebufferStatus):
+        (WebCore::WebGLRenderingContext::clear):
+        (WebCore::WebGLRenderingContext::copyTexImage2D):
+        (WebCore::WebGLRenderingContext::copyTexSubImage2D):
+        (WebCore::WebGLRenderingContext::disable):
+        (WebCore::WebGLRenderingContext::drawArrays):
+        (WebCore::WebGLRenderingContext::drawElements):
+        (WebCore::WebGLRenderingContext::enable):
+        (WebCore::WebGLRenderingContext::generateMipmap):
+        (WebCore::WebGLRenderingContext::hint):
+        (WebCore::WebGLRenderingContext::isEnabled):
+        (WebCore::WebGLRenderingContext::texImage2DBase):
+        (WebCore::WebGLRenderingContext::texParameter):
+        (WebCore::WebGLRenderingContext::isGLES2NPOTStrict):
+        (WebCore::WebGLRenderingContext::isErrorGeneratedOnOutOfBoundsAccesses):
+        * html/canvas/WebGLRenderingContext.h: Declare two new flags.
+        * html/canvas/WebGLTexture.cpp: Get format at given level instead of 0.
+        (WebCore::WebGLTexture::getInternalFormat):
+        * html/canvas/WebGLTexture.h: Ditto.
+        * platform/graphics/GraphicsContext3D.h: Add three new flags.
+        * platform/graphics/mac/GraphicsContext3DMac.mm: Ditto.
+        (WebCore::GraphicsContext3D::isGLES2NPOTStrict):
+        (WebCore::GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses):
+        * platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
+        (WebCore::GraphicsContext3D::isGLES2NPOTStrict):
+        (WebCore::GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses):
+
 2010-08-25  Brent Fulgham  <bfulgham at webkit.org>
 
         Build correction, no review.
diff --git a/WebCore/html/canvas/WebGLFramebuffer.cpp b/WebCore/html/canvas/WebGLFramebuffer.cpp
index bfa08b7..6291705 100644
--- a/WebCore/html/canvas/WebGLFramebuffer.cpp
+++ b/WebCore/html/canvas/WebGLFramebuffer.cpp
@@ -101,7 +101,7 @@ unsigned long WebGLFramebuffer::getColorBufferFormat()
                 return GraphicsContext3D::RGB;
             }
         } else if (m_colorAttachment->isTexture())
-            return (reinterpret_cast<WebGLTexture*>(m_colorAttachment))->getInternalFormat();
+            return (reinterpret_cast<WebGLTexture*>(m_colorAttachment))->getInternalFormat(0);
     }
     return 0;
 }
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 4ee87fd..44d3e08 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -130,10 +130,10 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
     m_context->getIntegerv(GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSize);
     m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextureSize, m_maxCubeMapTextureSize);
 
-    if (!isGLES2Compliant()) {
+    if (!isGLES2NPOTStrict())
         createFallbackBlackTextures1x1();
+    if (!isGLES2Compliant())
         initVertexAttrib0();
-    }
     m_context->reshape(canvas()->width(), canvas()->height());
     m_context->viewport(0, 0, canvas()->width(), canvas()->height());
 }
@@ -306,7 +306,7 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text
         return;
     }
     m_context->bindTexture(target, objectOrZero(texture));
-    if (!isGLES2Compliant() && texture)
+    if (texture)
         texture->setTarget(target, maxLevel);
 
     // FIXME: do we want to do this on all platforms?
@@ -338,20 +338,16 @@ void WebGLRenderingContext::blendColor(double red, double green, double blue, do
 
 void WebGLRenderingContext::blendEquation(unsigned long mode)
 {
-    if (!isGLES2Compliant()) {
-        if (!validateBlendEquation(mode))
-            return;
-    }
+    if (!validateBlendEquation(mode))
+        return;
     m_context->blendEquation(mode);
     cleanupAfterGraphicsCall(false);
 }
 
 void WebGLRenderingContext::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha)
 {
-    if (!isGLES2Compliant()) {
-        if (!validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha))
-            return;
-    }
+    if (!validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha))
+        return;
     m_context->blendEquationSeparate(modeRGB, modeAlpha);
     cleanupAfterGraphicsCall(false);
 }
@@ -375,9 +371,11 @@ void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned
     WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
     if (!buffer)
         return;
-    if (!buffer->associateBufferData(size)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
-        return;
+    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+        if (!buffer->associateBufferData(size)) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+            return;
+        }
     }
 
     m_context->bufferData(target, size, usage);
@@ -390,9 +388,11 @@ void WebGLRenderingContext::bufferData(unsigned long target, ArrayBuffer* data,
     WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
     if (!buffer)
         return;
-    if (!buffer->associateBufferData(data)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
-        return;
+    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+        if (!buffer->associateBufferData(data)) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+            return;
+        }
     }
 
     m_context->bufferData(target, data->byteLength(), data->data(), usage);
@@ -405,9 +405,11 @@ void WebGLRenderingContext::bufferData(unsigned long target, ArrayBufferView* da
     WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
     if (!buffer)
         return;
-    if (!buffer->associateBufferData(data)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
-        return;
+    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+        if (!buffer->associateBufferData(data)) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+            return;
+        }
     }
 
     m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage);
@@ -420,9 +422,11 @@ void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, Arr
     WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW);
     if (!buffer)
         return;
-    if (!buffer->associateBufferSubData(offset, data)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
-        return;
+    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+        if (!buffer->associateBufferSubData(offset, data)) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+            return;
+        }
     }
 
     m_context->bufferSubData(target, offset, data->byteLength(), data->data());
@@ -435,9 +439,11 @@ void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, Arr
     WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW);
     if (!buffer)
         return;
-    if (!buffer->associateBufferSubData(offset, data)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
-        return;
+    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+        if (!buffer->associateBufferSubData(offset, data)) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+            return;
+        }
     }
 
     m_context->bufferSubData(target, offset, data->byteLength(), data->baseAddress());
@@ -446,11 +452,9 @@ void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, Arr
 
 unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target)
 {
-    if (!isGLES2Compliant()) {
-        if (target != GraphicsContext3D::FRAMEBUFFER) {
-            m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
-            return 0;
-        }
+    if (target != GraphicsContext3D::FRAMEBUFFER) {
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+        return 0;
     }
     if (!m_framebufferBinding || !m_framebufferBinding->object())
         return GraphicsContext3D::FRAMEBUFFER_COMPLETE;
@@ -460,11 +464,9 @@ unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target
 
 void WebGLRenderingContext::clear(unsigned long mask)
 {
-    if (!isGLES2Compliant()) {
-        if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) {
-            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
-            return;
-        }
+    if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) {
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+        return;
     }
     m_context->clear(mask);
     cleanupAfterGraphicsCall(true);
@@ -525,15 +527,14 @@ void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, uns
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
             return;
         }
-        if (level && WebGLTexture::isNPOT(width, height)) {
-            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
-            return;
-        }
+    }
+    if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) {
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+        return;
     }
     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.
-    if (!isGLES2Compliant())
-        tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
+    tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
     if (m_framebufferBinding)
         m_framebufferBinding->onAttachedObjectChange(tex);
     cleanupAfterGraphicsCall(false);
@@ -546,7 +547,7 @@ void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level,
         return;
     if (!isGLES2Compliant()) {
         if (m_framebufferBinding && m_framebufferBinding->object()
-            && !isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(),
+            && !isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(level),
                                                                m_framebufferBinding->getColorBufferFormat())) {
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
             return;
@@ -716,10 +717,8 @@ void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
 
 void WebGLRenderingContext::disable(unsigned long cap)
 {
-    if (!isGLES2Compliant()) {
-        if (!validateCapability(cap))
-            return;
-    }
+    if (!validateCapability(cap))
+        return;
     m_context->disable(cap);
     cleanupAfterGraphicsCall(false);
 }
@@ -919,26 +918,27 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun
         return;
     }
 
-    // Ensure we have a valid rendering state
-    CheckedInt<int32_t> checkedFirst(first);
-    CheckedInt<int32_t> checkedCount(count);
-    CheckedInt<int32_t> checkedSum = checkedFirst + checkedCount;
-    if (!checkedSum.valid() || !validateRenderingState(checkedSum.value())) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
-        return;
+    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+        // Ensure we have a valid rendering state
+        CheckedInt<int32_t> checkedFirst(first);
+        CheckedInt<int32_t> checkedCount(count);
+        CheckedInt<int32_t> checkedSum = checkedFirst + checkedCount;
+        if (!checkedSum.valid() || !validateRenderingState(checkedSum.value())) {
+            m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+            return;
+        }
     }
 
     bool vertexAttrib0Simulated = false;
-    if (!isGLES2Compliant()) {
+    if (!isGLES2Compliant())
         vertexAttrib0Simulated = simulateVertexAttrib0(first + count - 1);
+    if (!isGLES2NPOTStrict())
         handleNPOTTextures(true);
-    }
     m_context->drawArrays(mode, first, count);
-    if (!isGLES2Compliant()) {
+    if (!isGLES2Compliant() && vertexAttrib0Simulated)
+        restoreStatesAfterVertexAttrib0Simulation();
+    if (!isGLES2NPOTStrict())
         handleNPOTTextures(false);
-        if (vertexAttrib0Simulated)
-            restoreStatesAfterVertexAttrib0Simulation();
-    }
     cleanupAfterGraphicsCall(true);
 }
 
@@ -963,40 +963,41 @@ void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigne
         return;
     }
 
-    // Ensure we have a valid rendering state
-    long numElements;
-    
-    if (!validateElementArraySize(count, type, offset)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
-        return;
-    }
-
-    if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements))
-        if (!validateIndexArrayPrecise(count, type, offset, numElements) || !validateRenderingState(numElements)) {
+    long numElements = 0;
+    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+        // Ensure we have a valid rendering state
+        if (!validateElementArraySize(count, type, offset)) {
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
             return;
         }
+        if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements)) {
+            if (!validateIndexArrayPrecise(count, type, offset, numElements) || !validateRenderingState(numElements)) {
+                m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+                return;
+            }
+        }
+    }
 
     bool vertexAttrib0Simulated = false;
     if (!isGLES2Compliant()) {
+        if (!numElements)
+            validateIndexArrayPrecise(count, type, offset, numElements);
         vertexAttrib0Simulated = simulateVertexAttrib0(numElements);
-        handleNPOTTextures(true);
     }
+    if (!isGLES2NPOTStrict())
+        handleNPOTTextures(true);
     m_context->drawElements(mode, count, type, offset);
-    if (!isGLES2Compliant()) {
+    if (!isGLES2Compliant() && vertexAttrib0Simulated)
+        restoreStatesAfterVertexAttrib0Simulation();
+    if (!isGLES2NPOTStrict())
         handleNPOTTextures(false);
-        if (vertexAttrib0Simulated)
-            restoreStatesAfterVertexAttrib0Simulation();
-    }
     cleanupAfterGraphicsCall(true);
 }
 
 void WebGLRenderingContext::enable(unsigned long cap)
 {
-    if (!isGLES2Compliant()) {
-        if (!validateCapability(cap))
-            return;
-    }
+    if (!validateCapability(cap))
+        return;
     m_context->enable(cap);
     cleanupAfterGraphicsCall(false);
 }
@@ -1119,15 +1120,12 @@ void WebGLRenderingContext::generateMipmap(unsigned long target)
     WebGLTexture* tex = validateTextureBinding(target, false);
     if (!tex)
         return;
-    if (!isGLES2Compliant()) {
-        if (!tex->canGenerateMipmaps()) {
-            m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
-            return;
-        }
+    if (!tex->canGenerateMipmaps()) {
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+        return;
     }
     m_context->generateMipmap(target);
-    if (!isGLES2Compliant())
-        tex->generateMipmapLevelInfo();
+    tex->generateMipmapLevelInfo();
     cleanupAfterGraphicsCall(false);
 }
 
@@ -1807,11 +1805,9 @@ long WebGLRenderingContext::getVertexAttribOffset(unsigned long index, unsigned
 
 void WebGLRenderingContext::hint(unsigned long target, unsigned long mode)
 {
-    if (!isGLES2Compliant()) {
-        if (target != GraphicsContext3D::GENERATE_MIPMAP_HINT) {
-            m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
-            return;
-        }
+    if (target != GraphicsContext3D::GENERATE_MIPMAP_HINT) {
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+        return;
     }
     m_context->hint(target, mode);
     cleanupAfterGraphicsCall(false);
@@ -1827,10 +1823,8 @@ bool WebGLRenderingContext::isBuffer(WebGLBuffer* buffer)
 
 bool WebGLRenderingContext::isEnabled(unsigned long cap)
 {
-    if (!isGLES2Compliant()) {
-        if (!validateCapability(cap))
-            return false;
-    }
+    if (!validateCapability(cap))
+        return false;
     return m_context->isEnabled(cap);
 }
 
@@ -2089,7 +2083,7 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
     WebGLTexture* tex = validateTextureBinding(target, true);
     if (!tex)
         return;
-    if (!isGLES2Compliant()) {
+    if (!isGLES2NPOTStrict()) {
         if (level && WebGLTexture::isNPOT(width, height)) {
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
             return;
@@ -2097,8 +2091,7 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
     }
     m_context->texImage2D(target, level, internalformat, width, height,
                           border, format, type, pixels);
-    if (!isGLES2Compliant())
-        tex->setLevelInfo(target, level, internalformat, width, height, type);
+    tex->setLevelInfo(target, level, internalformat, width, height, type);
     if (m_framebufferBinding)
         m_framebufferBinding->onAttachedObjectChange(tex);
     cleanupAfterGraphicsCall(false);
@@ -2224,32 +2217,29 @@ void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pna
     WebGLTexture* tex = validateTextureBinding(target, false);
     if (!tex)
         return;
-    if (!isGLES2Compliant()) {
-        switch (pname) {
-        case GraphicsContext3D::TEXTURE_MIN_FILTER:
-        case GraphicsContext3D::TEXTURE_MAG_FILTER:
-            break;
-        case GraphicsContext3D::TEXTURE_WRAP_S:
-        case GraphicsContext3D::TEXTURE_WRAP_T:
-            if (isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT
-                || !isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT) {
-                m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
-                return;
-            }
-            break;
-        default:
+    switch (pname) {
+    case GraphicsContext3D::TEXTURE_MIN_FILTER:
+    case GraphicsContext3D::TEXTURE_MAG_FILTER:
+        break;
+    case GraphicsContext3D::TEXTURE_WRAP_S:
+    case GraphicsContext3D::TEXTURE_WRAP_T:
+        if (isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT
+            || !isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT) {
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
             return;
         }
-        if (isFloat)
-            tex->setParameterf(pname, paramf);
-        else
-            tex->setParameteri(pname, parami);
+        break;
+    default:
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+        return;
     }
-    if (isFloat)
+    if (isFloat) {
+        tex->setParameterf(pname, paramf);
         m_context->texParameterf(target, pname, paramf);
-    else
+    } else {
+        tex->setParameteri(pname, parami);
         m_context->texParameteri(target, pname, parami);
+    }
     cleanupAfterGraphicsCall(false);
 }
 
@@ -3010,6 +3000,16 @@ bool WebGLRenderingContext::isGLES2Compliant()
     return m_context->isGLES2Compliant();
 }
 
+bool WebGLRenderingContext::isGLES2NPOTStrict()
+{
+    return m_context->isGLES2NPOTStrict();
+}
+
+bool WebGLRenderingContext::isErrorGeneratedOnOutOfBoundsAccesses()
+{
+    return m_context->isErrorGeneratedOnOutOfBoundsAccesses();
+}
+
 void WebGLRenderingContext::handleNPOTTextures(bool prepareToDraw)
 {
     bool resetActiveUnit = false;
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index 0cb78ae..66ec8d8 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -305,6 +305,8 @@ public:
     }
 
     bool isGLES2Compliant();
+    bool isGLES2NPOTStrict();
+    bool isErrorGeneratedOnOutOfBoundsAccesses();
 
     // Helper to return the size in bytes of OpenGL data types
     // like GL_FLOAT, GL_INT, etc.
diff --git a/WebCore/html/canvas/WebGLTexture.cpp b/WebCore/html/canvas/WebGLTexture.cpp
index e6dfd0a..7b2869f 100644
--- a/WebCore/html/canvas/WebGLTexture.cpp
+++ b/WebCore/html/canvas/WebGLTexture.cpp
@@ -169,11 +169,12 @@ void WebGLTexture::generateMipmapLevelInfo()
     m_needToUseBlackTexture = false;
 }
 
-unsigned long WebGLTexture::getInternalFormat() const
+unsigned long WebGLTexture::getInternalFormat(int level) const
 {
     if (!object() || !m_target)
         return 0;
-    return m_info[0][0].internalFormat;
+    // We assume level has been validated already.
+    return m_info[0][level].internalFormat;
 }
 
 bool WebGLTexture::isNPOT(unsigned width, unsigned height)
diff --git a/WebCore/html/canvas/WebGLTexture.h b/WebCore/html/canvas/WebGLTexture.h
index 64bd6e0..a1ce348 100644
--- a/WebCore/html/canvas/WebGLTexture.h
+++ b/WebCore/html/canvas/WebGLTexture.h
@@ -60,7 +60,7 @@ public:
     // Generate all level information.
     void generateMipmapLevelInfo();
 
-    unsigned long getInternalFormat() const;
+    unsigned long getInternalFormat(int level) const;
 
     // Whether width/height is NotPowerOfTwo.
     static bool isNPOT(unsigned, unsigned);
diff --git a/WebCore/platform/graphics/GraphicsContext3D.h b/WebCore/platform/graphics/GraphicsContext3D.h
index aa75fd8..b583813 100644
--- a/WebCore/platform/graphics/GraphicsContext3D.h
+++ b/WebCore/platform/graphics/GraphicsContext3D.h
@@ -463,6 +463,8 @@ public:
     int sizeInBytes(int type);
 
     bool isGLES2Compliant() const;
+    bool isGLES2NPOTStrict() const;
+    bool isErrorGeneratedOnOutOfBoundsAccesses() const;
 
     //----------------------------------------------------------------------
     // Helpers for texture uploading and pixel readback.
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
index 69299b1..ab4ef4b 100644
--- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
+++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
@@ -312,6 +312,16 @@ bool GraphicsContext3D::isGLES2Compliant() const
     return false;
 }
 
+bool GraphicsContext3D::isGLES2NPOTStrict() const
+{
+    return false;
+}
+
+bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
+{
+    return false;
+}
+
 void GraphicsContext3D::reshape(int width, int height)
 {
     if (width == m_currentWidth && height == m_currentHeight || !m_contextObj)
diff --git a/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 3ea5704..7918378 100644
--- a/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -274,6 +274,18 @@ bool GraphicsContext3D::isGLES2Compliant() const
 #endif
 }
 
+// Even with underlying GLES2 driver, the below flags should still be set to
+// false if extentions exist (and they almost always do).
+bool GraphicsContext3D::isGLES2NPOTStrict() const
+{
+    return false;
+}
+
+bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
+{
+    return false;
+}
+
  
 GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
     : m_attrs(attrs)
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 2824511..6783864 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-20  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        WebGL must enforce restrictions even if running on OpenGL ES 2.0
+        https://bugs.webkit.org/show_bug.cgi?id=42908
+
+        * public/WebGraphicsContext3D.h: Add two new flags.
+        * src/GraphicsContext3D.cpp: Ditto.
+        (WebCore::GraphicsContext3DInternal::isGLES2NPOTStrict):
+        (WebCore::GraphicsContext3DInternal::isErrorGeneratedOnOutOfBoundsAccesses):
+        (WebCore::GraphicsContext3D::isGLES2NPOTStrict):
+        (WebCore::GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses):
+        * src/WebGraphicsContext3DDefaultImpl.cpp: Ditto.
+        (WebKit::WebGraphicsContext3DDefaultImpl::isGLES2NPOTStrict):
+        (WebKit::WebGraphicsContext3DDefaultImpl::isErrorGeneratedOnOutOfBoundsAccesses):
+        * src/WebGraphicsContext3DDefaultImpl.h: Ditto.
+
 2010-08-24  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/WebKit/chromium/public/WebGraphicsContext3D.h b/WebKit/chromium/public/WebGraphicsContext3D.h
index 4c18076..44a0498 100644
--- a/WebKit/chromium/public/WebGraphicsContext3D.h
+++ b/WebKit/chromium/public/WebGraphicsContext3D.h
@@ -103,6 +103,11 @@ public:
 
     // Query whether it is built on top of compliant GLES2 implementation.
     virtual bool isGLES2Compliant() = 0;
+    // Query whether it is built on top of GLES2 NPOT strict implementation.
+    virtual bool isGLES2NPOTStrict() = 0;
+    // Query whether it is built on top of implementation that generates errors
+    // on out-of-bounds buffer accesses.
+    virtual bool isErrorGeneratedOnOutOfBoundsAccesses() = 0;
 
     // Helper for software compositing path. Reads back the frame buffer into
     // the memory region pointed to by "pixels" with size "bufferSize". It is
diff --git a/WebKit/chromium/src/GraphicsContext3D.cpp b/WebKit/chromium/src/GraphicsContext3D.cpp
index 22e4ef6..6bc5ffe 100644
--- a/WebKit/chromium/src/GraphicsContext3D.cpp
+++ b/WebKit/chromium/src/GraphicsContext3D.cpp
@@ -106,6 +106,8 @@ public:
     CanvasLayerChromium* platformLayer() const;
 #endif
     bool isGLES2Compliant() const;
+    bool isGLES2NPOTStrict() const;
+    bool isErrorGeneratedOnOutOfBoundsAccesses() const;
 
     //----------------------------------------------------------------------
     // Entry points for WebGL.
@@ -581,6 +583,16 @@ bool GraphicsContext3DInternal::isGLES2Compliant() const
     return m_impl->isGLES2Compliant();
 }
 
+bool GraphicsContext3DInternal::isGLES2NPOTStrict() const
+{
+    return m_impl->isGLES2NPOTStrict();
+}
+
+bool GraphicsContext3DInternal::isErrorGeneratedOnOutOfBoundsAccesses() const
+{
+    return m_impl->isErrorGeneratedOnOutOfBoundsAccesses();
+}
+
 DELEGATE_TO_IMPL_1(activeTexture, unsigned long)
 DELEGATE_TO_IMPL_2(attachShader, Platform3DObject, Platform3DObject)
 
@@ -1227,6 +1239,16 @@ bool GraphicsContext3D::isGLES2Compliant() const
     return m_internal->isGLES2Compliant();
 }
 
+bool GraphicsContext3D::isGLES2NPOTStrict() const
+{
+    return m_internal->isGLES2NPOTStrict();
+}
+
+bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
+{
+    return m_internal->isErrorGeneratedOnOutOfBoundsAccesses();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp
index 0153ba3..6e1adca 100644
--- a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp
+++ b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp
@@ -182,6 +182,16 @@ bool WebGraphicsContext3DDefaultImpl::isGLES2Compliant()
     return false;
 }
 
+bool WebGraphicsContext3DDefaultImpl::isGLES2NPOTStrict()
+{
+    return false;
+}
+
+bool WebGraphicsContext3DDefaultImpl::isErrorGeneratedOnOutOfBoundsAccesses()
+{
+    return false;
+}
+
 unsigned int WebGraphicsContext3DDefaultImpl::getPlatformTextureId()
 {
     ASSERT_NOT_REACHED();
diff --git a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h
index cf5f5b4..a4c5b4b 100644
--- a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h
+++ b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h
@@ -68,6 +68,8 @@ public:
     virtual int sizeInBytes(int type);
 
     virtual bool isGLES2Compliant();
+    virtual bool isGLES2NPOTStrict();
+    virtual bool isErrorGeneratedOnOutOfBoundsAccesses();
 
     virtual void reshape(int width, int height);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list