Title: [164744] trunk/Source/WebCore
Revision
164744
Author
d...@apple.com
Date
2014-02-26 13:31:38 -0800 (Wed, 26 Feb 2014)

Log Message

[WebGL] Protect more WebGL entry points for pending contexts
https://bugs.webkit.org/show_bug.cgi?id=129386

Reviewed by Tim Horton.

There are entry points into a WebGLRenderingContext that don't
come from the web-exposed API directly, such as drawImage with
the WebGL canvas. Protect these by returning early if we're
a pending context.

Also a bunch of drive-by 0 -> nullptr changes.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::markLayerComposited):
(WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas):
(WebCore::WebGLRenderingContext::paintRenderingResultsToImageData):
(WebCore::WebGLRenderingContext::reshape):
(WebCore::WebGLRenderingContext::createBuffer):
(WebCore::WebGLRenderingContext::createFramebuffer):
(WebCore::WebGLRenderingContext::createTexture):
(WebCore::WebGLRenderingContext::createProgram):
(WebCore::WebGLRenderingContext::createRenderbuffer):
(WebCore::WebGLRenderingContext::createShader):
(WebCore::WebGLRenderingContext::getActiveAttrib):
(WebCore::WebGLRenderingContext::getActiveUniform):
(WebCore::WebGLRenderingContext::getContextAttributes):
(WebCore::WebGLRenderingContext::getError):
(WebCore::WebGLRenderingContext::getExtension):
(WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
(WebCore::WebGLRenderingContext::getUniformLocation):
(WebCore::WebGLRenderingContext::drawImageIntoBuffer):
(WebCore::WebGLRenderingContext::videoFrameToImage):
(WebCore::WebGLRenderingContext::validateBufferDataParameters):
(WebCore::WebGLRenderingContext::LRUImageBufferCache::imageBuffer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164743 => 164744)


--- trunk/Source/WebCore/ChangeLog	2014-02-26 21:27:10 UTC (rev 164743)
+++ trunk/Source/WebCore/ChangeLog	2014-02-26 21:31:38 UTC (rev 164744)
@@ -1,3 +1,40 @@
+2014-02-26  Dean Jackson  <d...@apple.com>
+
+        [WebGL] Protect more WebGL entry points for pending contexts
+        https://bugs.webkit.org/show_bug.cgi?id=129386
+
+        Reviewed by Tim Horton.
+
+        There are entry points into a WebGLRenderingContext that don't
+        come from the web-exposed API directly, such as drawImage with
+        the WebGL canvas. Protect these by returning early if we're
+        a pending context.
+
+        Also a bunch of drive-by 0 -> nullptr changes.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::markLayerComposited):
+        (WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas):
+        (WebCore::WebGLRenderingContext::paintRenderingResultsToImageData):
+        (WebCore::WebGLRenderingContext::reshape):
+        (WebCore::WebGLRenderingContext::createBuffer):
+        (WebCore::WebGLRenderingContext::createFramebuffer):
+        (WebCore::WebGLRenderingContext::createTexture):
+        (WebCore::WebGLRenderingContext::createProgram):
+        (WebCore::WebGLRenderingContext::createRenderbuffer):
+        (WebCore::WebGLRenderingContext::createShader):
+        (WebCore::WebGLRenderingContext::getActiveAttrib):
+        (WebCore::WebGLRenderingContext::getActiveUniform):
+        (WebCore::WebGLRenderingContext::getContextAttributes):
+        (WebCore::WebGLRenderingContext::getError):
+        (WebCore::WebGLRenderingContext::getExtension):
+        (WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
+        (WebCore::WebGLRenderingContext::getUniformLocation):
+        (WebCore::WebGLRenderingContext::drawImageIntoBuffer):
+        (WebCore::WebGLRenderingContext::videoFrameToImage):
+        (WebCore::WebGLRenderingContext::validateBufferDataParameters):
+        (WebCore::WebGLRenderingContext::LRUImageBufferCache::imageBuffer):
+
 2014-02-26  Bem Jones-Bey  <bjone...@adobe.com>
 
         [CSS Shapes] inset and inset-rectangle trigger assert with replaced element and large percentage dimension

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (164743 => 164744)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2014-02-26 21:27:10 UTC (rev 164743)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2014-02-26 21:31:38 UTC (rev 164744)
@@ -764,11 +764,16 @@
 
 void WebGLRenderingContext::markLayerComposited()
 {
+    if (isContextLostOrPending())
+        return;
     m_context->markLayerComposited();
 }
 
 void WebGLRenderingContext::paintRenderingResultsToCanvas()
 {
+    if (isContextLostOrPending())
+        return;
+
     if (canvas()->document().printing())
         canvas()->clearPresentationCopy();
 
@@ -802,6 +807,8 @@
 
 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData()
 {
+    if (isContextLostOrPending())
+        return nullptr;
     clearIfComposited();
     if (m_drawingBuffer)
         m_drawingBuffer->commit();
@@ -819,6 +826,9 @@
 
 void WebGLRenderingContext::reshape(int width, int height)
 {
+    if (isContextLostOrPending())
+        return;
+
     // This is an approximation because at WebGLRenderingContext level we don't
     // know if the underlying FBO uses textures or renderbuffers.
     GC3Dint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize);
@@ -1508,7 +1518,7 @@
 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer()
 {
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     RefPtr<WebGLBuffer> o = WebGLBuffer::create(this);
     addSharedObject(o.get());
     return o;
@@ -1517,7 +1527,7 @@
 PassRefPtr<WebGLFramebuffer> WebGLRenderingContext::createFramebuffer()
 {
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this);
     addContextObject(o.get());
     return o;
@@ -1526,7 +1536,7 @@
 PassRefPtr<WebGLTexture> WebGLRenderingContext::createTexture()
 {
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     RefPtr<WebGLTexture> o = WebGLTexture::create(this);
     addSharedObject(o.get());
     return o;
@@ -1535,7 +1545,7 @@
 PassRefPtr<WebGLProgram> WebGLRenderingContext::createProgram()
 {
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     RefPtr<WebGLProgram> o = WebGLProgram::create(this);
     addSharedObject(o.get());
     return o;
@@ -1544,7 +1554,7 @@
 PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer()
 {
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this);
     addSharedObject(o.get());
     return o;
@@ -1554,10 +1564,10 @@
 {
     UNUSED_PARAM(ec);
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::FRAGMENT_SHADER) {
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "createShader", "invalid shader type");
-        return 0;
+        return nullptr;
     }
 
     RefPtr<WebGLShader> o = WebGLShader::create(this, type);
@@ -2266,10 +2276,10 @@
 {
     UNUSED_PARAM(ec);
     if (isContextLostOrPending() || !validateWebGLObject("getActiveAttrib", program))
-        return 0;
+        return nullptr;
     ActiveInfo info;
     if (!m_context->getActiveAttrib(objectOrZero(program), index, info))
-        return 0;
+        return nullptr;
 
     LOG(WebGL, "Returning active attribute %d: %s", index, info.name.utf8().data());
 
@@ -2283,7 +2293,7 @@
         return 0;
     ActiveInfo info;
     if (!m_context->getActiveUniform(objectOrZero(program), index, info))
-        return 0;
+        return nullptr;
     if (!isGLES2Compliant())
         if (info.size > 1 && !info.name.endsWith("[0]"))
             info.name.append("[0]");
@@ -2354,7 +2364,7 @@
 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes()
 {
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     // We always need to return a new WebGLContextAttributes object to
     // prevent the user from mutating any cached version.
 
@@ -2376,13 +2386,15 @@
 
 GC3Denum WebGLRenderingContext::getError()
 {
+    if (isContextLostOrPending())
+        return GraphicsContext3D::NO_ERROR;
     return m_context->getError();
 }
 
 WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
 {
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
 
     if (equalIgnoringCase(name, "WEBKIT_EXT_texture_filter_anisotropic")
         && m_context->getExtensions()->supports("GL_EXT_texture_filter_anisotropic")) {
@@ -2506,7 +2518,7 @@
         }
     }
 
-    return 0;
+    return nullptr;
 }
 
 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode& ec)
@@ -2938,14 +2950,14 @@
 {
     UNUSED_PARAM(ec);
     if (isContextLostOrPending())
-        return 0;
+        return nullptr;
     switch (shaderType) {
     case GraphicsContext3D::VERTEX_SHADER:
     case GraphicsContext3D::FRAGMENT_SHADER:
         break;
     default:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type");
-        return 0;
+        return nullptr;
     }
     switch (precisionType) {
     case GraphicsContext3D::LOW_FLOAT:
@@ -2957,7 +2969,7 @@
         break;
     default:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFormat", "invalid precision type");
-        return 0;
+        return nullptr;
     }
 
     GC3Dint range[2] = {0, 0};
@@ -3199,7 +3211,7 @@
     for (GC3Dint i = 0; i < activeUniforms; i++) {
         ActiveInfo info;
         if (!m_context->getActiveUniform(objectOrZero(program), i, info))
-            return 0;
+            return nullptr;
         // Strip "[0]" from the name if it's an array.
         if (info.name.endsWith("[0]"))
             info.name = info.name.left(info.name.length() - 3);
@@ -3860,7 +3872,7 @@
     ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
     if (!buf) {
         synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out of memory");
-        return 0;
+        return nullptr;
     }
 
     IntRect srcRect(IntPoint(), image->size());
@@ -3922,7 +3934,7 @@
     ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
     if (!buf) {
         synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out of memory");
-        return 0;
+        return nullptr;
     }
     IntRect destRect(0, 0, size.width(), size.height());
     // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback.
@@ -5612,11 +5624,11 @@
         break;
     default:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target");
-        return 0;
+        return nullptr;
     }
     if (!buffer) {
         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no buffer");
-        return 0;
+        return nullptr;
     }
     switch (usage) {
     case GraphicsContext3D::STREAM_DRAW:
@@ -5625,7 +5637,7 @@
         return buffer;
     }
     synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid usage");
-    return 0;
+    return nullptr;
 }
 
 bool WebGLRenderingContext::validateHTMLImageElement(const char* functionName, HTMLImageElement* image, ExceptionCode& ec)
@@ -5953,7 +5965,7 @@
 
     std::unique_ptr<ImageBuffer> temp = ImageBuffer::create(size, 1);
     if (!temp)
-        return 0;
+        return nullptr;
     i = std::min(m_capacity - 1, i);
     m_buffers[i] = std::move(temp);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to