2011-04-08 Jeff Timanus <twiz@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 23:01:29 +0000 (23:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 23:01:29 +0000 (23:01 +0000)
        Reviewed by Kenneth Russell.

        Fall back to software rendering for Canvas2D when requesting a DrawingBuffer larger than supported by the GL environment.
        https://bugs.webkit.org/show_bug.cgi?id=57768

        * platform/chromium/test_expectations.txt:
2011-04-08  Jeff Timanus  <twiz@chromium.org>

        Reviewed by Kenneth Russell.

        Fall back to software rendering for Canvas2D when requesting a DrawingBuffer larger than supported by the GL environment.
        https://bugs.webkit.org/show_bug.cgi?id=57768

        * html/canvas/CanvasRenderingContext2D.cpp:
        (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
        (WebCore::CanvasRenderingContext2D::reset):
        * platform/graphics/gpu/DrawingBuffer.cpp:
        (WebCore::DrawingBuffer::reset):
        * platform/graphics/gpu/DrawingBuffer.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83355 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
Source/WebCore/platform/graphics/gpu/DrawingBuffer.h

index 2feccfd..6ab96d8 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-08  Jeff Timanus  <twiz@chromium.org>
+
+        Reviewed by Kenneth Russell.
+
+        Fall back to software rendering for Canvas2D when requesting a DrawingBuffer larger than supported by the GL environment.
+        https://bugs.webkit.org/show_bug.cgi?id=57768
+
+        * platform/chromium/test_expectations.txt:
+
 2011-04-08  Daniel Cheng  <dcheng@chromium.org>
 
         Reviewed by Dmitry Titov.
index 52d83d3..a4e175a 100644 (file)
@@ -2914,9 +2914,6 @@ BUGCR60965 GPU WIN LINUX : fast/canvas/setWidthResetAfterForcedRender.html = IMA
 
 BUGNONE SLOW GPU DEBUG WIN : fast/canvas/canvas-getImageData.html = PASS
 
-// Started failing after r75648 on everything except Snow Leopard
-BUGWK52341 GPU : fast/canvas/canvas-large-dimensions.html = TEXT
-
 BUGWK53469 GPU MAC : compositing/scroll-painted-composited-content.html = CRASH
 
 BUGCR74979 GPU MAC: media/video-canvas-alpha.html = IMAGE
index f7d1fc6..13e3a4c 100644 (file)
@@ -1,3 +1,17 @@
+2011-04-08  Jeff Timanus  <twiz@chromium.org>
+
+        Reviewed by Kenneth Russell.
+
+        Fall back to software rendering for Canvas2D when requesting a DrawingBuffer larger than supported by the GL environment.
+        https://bugs.webkit.org/show_bug.cgi?id=57768
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
+        (WebCore::CanvasRenderingContext2D::reset):
+        * platform/graphics/gpu/DrawingBuffer.cpp:
+        (WebCore::DrawingBuffer::reset):
+        * platform/graphics/gpu/DrawingBuffer.h:
+
 2011-04-08  Daniel Cheng  <dcheng@chromium.org>
 
         Reviewed by Dmitry Titov.
index f22da37..0ca15b9 100644 (file)
@@ -133,7 +133,11 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo
         m_context3D = p->sharedGraphicsContext3D();
         if (m_context3D) {
             m_drawingBuffer = m_context3D->graphicsContext3D()->createDrawingBuffer(IntSize(canvas->width(), canvas->height()));
-            c->setSharedGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), IntSize(canvas->width(), canvas->height()));
+            if (!m_drawingBuffer) {
+                c->setSharedGraphicsContext3D(0, 0, IntSize());
+                m_context3D.clear();
+            } else
+                c->setSharedGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), IntSize(canvas->width(), canvas->height()));
         }
     }
 #endif
@@ -173,13 +177,18 @@ void CanvasRenderingContext2D::reset()
 #if ENABLE(ACCELERATED_2D_CANVAS)
     if (GraphicsContext* c = drawingContext()) {
         if (m_context3D && m_drawingBuffer) {
-            m_drawingBuffer->reset(IntSize(canvas()->width(), canvas()->height()));
-            c->setSharedGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), IntSize(canvas()->width(), canvas()->height()));
+            if (m_drawingBuffer->reset(IntSize(canvas()->width(), canvas()->height()))) {
+                c->setSharedGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), IntSize(canvas()->width(), canvas()->height()));
 #if USE(ACCELERATED_COMPOSITING)
-            RenderBox* renderBox = canvas()->renderBox();
-            if (renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing())
-                renderBox->layer()->contentChanged(RenderLayer::CanvasChanged);
+                RenderBox* renderBox = canvas()->renderBox();
+                if (renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing())
+                    renderBox->layer()->contentChanged(RenderLayer::CanvasChanged);
 #endif
+            } else {
+                c->setSharedGraphicsContext3D(0, 0, IntSize());
+                m_drawingBuffer.clear();
+                m_context3D.clear();
+            }
         }
     }
 #endif
index 2a83fcf..f58380b 100644 (file)
@@ -144,15 +144,22 @@ void DrawingBuffer::resizeDepthStencil(int sampleCount)
     m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0);
 }
 
-void DrawingBuffer::reset(const IntSize& newSize)
+bool DrawingBuffer::reset(const IntSize& newSize)
 {
-    m_size = newSize;
-
     if (!m_context)
-        return;
-        
+        return false;
+
     m_context->makeContextCurrent();
-    
+
+    int maxTextureSize = 0;
+    m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
+    if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) {
+      clear();
+      return false;
+    }
+
+    m_size = newSize;
+
     const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes();
     unsigned long internalColorFormat, colorFormat, internalRenderbufferFormat;
     if (attributes.alpha) {
@@ -182,7 +189,7 @@ void DrawingBuffer::reset(const IntSize& newSize)
         if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
             // Cleanup
             clear();
-            return;
+            return false;
         }
     }
 
@@ -190,15 +197,18 @@ void DrawingBuffer::reset(const IntSize& newSize)
     m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
 
     m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
+    
     m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE);
+
     m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
     m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+
     if (!multisample())
         resizeDepthStencil(0);
     if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
         // Cleanup
         clear();
-        return;
+        return false;
     }
 
     if (multisample())
@@ -250,6 +260,8 @@ void DrawingBuffer::reset(const IntSize& newSize)
     m_context->flush();
     
     didReset();
+
+    return true;
 }
 
 void DrawingBuffer::commit(long x, long y, long width, long height)
index 606484e..ed0c9cb 100644 (file)
@@ -60,7 +60,8 @@ public:
     
     ~DrawingBuffer();
 
-    void reset(const IntSize&);
+    // Returns true if the buffer was successfully resized.
+    bool reset(const IntSize&);
     void bind();
     IntSize size() const { return m_size; }
     Platform3DObject colorBuffer() const { return m_colorBuffer; }