[Chromium] Code cleanup: removing support for non-deferred 2d canvas rendering
authorjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 15:59:08 +0000 (15:59 +0000)
committerjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 15:59:08 +0000 (15:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112605

Reviewed by James Robinson.

Source/WebCore:

Deleting all the code that was used for propagating and supporting
the Chromium setting for disabling deferred 2d canvas rendering.

No new tests: Affected code paths covered by existing tests.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createImageBuffer):
* html/HTMLCanvasElement.h:
* page/Settings.in:
* platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::create):
(ImageBuffer):
* platform/graphics/blackberry/ImageBufferBlackBerry.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/chromium/Canvas2DLayerBridge.cpp:
(WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::prepareForDraw):
(WebCore::Canvas2DLayerBridge::storageAllocatedForRecordingChanged):
(WebCore::Canvas2DLayerBridge::storageAllocatedForRecording):
(WebCore::Canvas2DLayerBridge::freeMemoryIfPossible):
(WebCore::Canvas2DLayerBridge::flush):
(WebCore::Canvas2DLayerBridge::skCanvas):
(WebCore::Canvas2DLayerBridge::prepareTexture):
(WebCore::Canvas2DLayerBridge::contextAcquired):
* platform/graphics/chromium/Canvas2DLayerBridge.h:
(WebCore::Canvas2DLayerBridge::create):
(Canvas2DLayerBridge):
* platform/graphics/qt/ImageBufferQt.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::createAcceleratedCanvas):
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/wince/ImageBufferWinCE.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/wx/ImageBufferWx.cpp:
(WebCore::ImageBuffer::ImageBuffer):

Source/WebKit/chromium:

Deleting all the code that was used for propagating and supporting
the Chromium setting for disabling deferred 2d canvas rendering.

* public/WebSettings.h:
(WebKit::WebSettings::setDeferred2dCanvasEnabled):
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setDeferred2dCanvasEnabled):
* tests/Canvas2DLayerBridgeTest.cpp:
(Canvas2DLayerBridgeTest::fullLifecycleTest):
* tests/Canvas2DLayerManagerTest.cpp:
(FakeCanvas2DLayerBridge::FakeCanvas2DLayerBridge):

Tools:

Deleting all the code that was used for propagating and supporting
the Chromium setting for disabling deferred 2d canvas rendering.

* DumpRenderTree/chromium/DumpRenderTree.cpp:
(main):
* DumpRenderTree/chromium/TestRunner/public/WebPreferences.h:
* DumpRenderTree/chromium/TestRunner/src/WebPreferences.cpp:
(WebTestRunner::WebPreferences::reset):
(WebTestRunner::WebPreferences::applyTo):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::TestShell):
(TestShell::resetWebSettings):
(TestShell::runFileTest):
* DumpRenderTree/chromium/TestShell.h:
(TestShell):

LayoutTests:

Marked some 2d canvas tests as failing. These tests are using the
two point radial gradient API.  The bug was already present in
chromium. Starts getting detected in DRT with this change.
Related: crbug.com/222140

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

27 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h
Source/WebCore/page/Settings.in
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp
Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h
Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebSettings.h
Source/WebKit/chromium/src/WebSettingsImpl.cpp
Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp
Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp
Tools/ChangeLog
Tools/DumpRenderTree/chromium/DumpRenderTree.cpp
Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h
Tools/DumpRenderTree/chromium/TestRunner/src/WebPreferences.cpp
Tools/DumpRenderTree/chromium/TestShell.cpp
Tools/DumpRenderTree/chromium/TestShell.h

index dacf434..2aad9ef 100644 (file)
@@ -1,3 +1,15 @@
+2013-03-20  Justin Novosad  <junov@google.com>
+
+        [Chromium] Code cleanup: removing support for non-deferred 2d canvas rendering
+        https://bugs.webkit.org/show_bug.cgi?id=112605
+
+        Reviewed by James Robinson.
+
+        Marked some 2d canvas tests as failing. These tests are using the
+        two point radial gradient API.  The bug was already present in
+        chromium. Starts getting detected in DRT with this change.
+        Related: crbug.com/222140
+
 2013-03-20  Mike West  <mkwst@chromium.org>
 
         Drop full URLs from cross-domain access errors caused by 'document.domain' mismatches.
index 26c8d13..6eb4508 100644 (file)
@@ -1456,6 +1456,14 @@ webkit.org/b/75276 [ Android ] fast/repaint/shadow-multiple-horizontal.html [ Im
 webkit.org/b/75276 [ Android ] fast/repaint/shadow-multiple-strict-horizontal.html [ ImageOnlyFailure ]
 webkit.org/b/75276 [ Android ] fast/repaint/shadow-multiple-strict-vertical.html [ ImageOnlyFailure ]
 
+# These tests fail due to a bug with 2D canvas command deferral
+crbug.com/222140 platform/chromium/virtual/gpu/canvas/philip/tests/2d.gradient.radial.cone.beside.html [ Failure ]
+crbug.com/222140 platform/chromium/virtual/gpu/canvas/philip/tests/2d.gradient.radial.cone.shape1.html [ Failure ]
+crbug.com/222140 platform/chromium/virtual/gpu/canvas/philip/tests/2d.gradient.radial.cone.behind.html [ Failure ]
+crbug.com/222140 platform/chromium/virtual/gpu/canvas/philip/tests/2d.gradient.radial.cone.shape2.html [ Failure ]
+crbug.com/222140 platform/chromium/virtual/gpu/canvas/philip/tests/2d.gradient.radial.touch1.html [ Failure ]
+crbug.com/222140 platform/chromium/virtual/gpu/canvas/philip/tests/2d.gradient.radial.touch3.html [ Failure ]
+
 # -----------------------------------------------------------------
 # WebGL Tests
 # -----------------------------------------------------------------
index 48332a0..783fcd1 100644 (file)
@@ -1,3 +1,52 @@
+2013-03-20  Justin Novosad  <junov@google.com>
+
+        [Chromium] Code cleanup: removing support for non-deferred 2d canvas rendering
+        https://bugs.webkit.org/show_bug.cgi?id=112605
+
+        Reviewed by James Robinson.
+
+        Deleting all the code that was used for propagating and supporting
+        the Chromium setting for disabling deferred 2d canvas rendering.
+
+        No new tests: Affected code paths covered by existing tests.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createImageBuffer):
+        * html/HTMLCanvasElement.h:
+        * page/Settings.in:
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::create):
+        (ImageBuffer):
+        * platform/graphics/blackberry/ImageBufferBlackBerry.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/chromium/Canvas2DLayerBridge.cpp:
+        (WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
+        (WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
+        (WebCore::Canvas2DLayerBridge::prepareForDraw):
+        (WebCore::Canvas2DLayerBridge::storageAllocatedForRecordingChanged):
+        (WebCore::Canvas2DLayerBridge::storageAllocatedForRecording):
+        (WebCore::Canvas2DLayerBridge::freeMemoryIfPossible):
+        (WebCore::Canvas2DLayerBridge::flush):
+        (WebCore::Canvas2DLayerBridge::skCanvas):
+        (WebCore::Canvas2DLayerBridge::prepareTexture):
+        (WebCore::Canvas2DLayerBridge::contextAcquired):
+        * platform/graphics/chromium/Canvas2DLayerBridge.h:
+        (WebCore::Canvas2DLayerBridge::create):
+        (Canvas2DLayerBridge):
+        * platform/graphics/qt/ImageBufferQt.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::createAcceleratedCanvas):
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/wince/ImageBufferWinCE.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/wx/ImageBufferWx.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+
 2013-03-20  Mike West  <mkwst@chromium.org>
 
         Drop full URLs from cross-domain access errors caused by 'document.domain' mismatches.
index 3cc2c93..a3c0463 100644 (file)
@@ -520,22 +520,6 @@ bool HTMLCanvasElement::shouldAccelerate(const IntSize& size) const
 #endif
 }
 
-bool HTMLCanvasElement::shouldDefer() const
-{
-#if USE(SKIA)
-    if (m_context && !m_context->is2d())
-        return false;
-
-    Settings* settings = document()->settings();
-    if (!settings || !settings->deferred2dCanvasEnabled())
-        return false;
-
-    return true;
-#else
-    return false;
-#endif
-}
-
 void HTMLCanvasElement::createImageBuffer() const
 {
     ASSERT(!m_imageBuffer);
@@ -565,8 +549,7 @@ void HTMLCanvasElement::createImageBuffer() const
 #else
         Unaccelerated;
 #endif
-    DeferralMode deferralMode = shouldDefer() ? Deferred : NonDeferred;
-    m_imageBuffer = ImageBuffer::create(size(), m_deviceScaleFactor, ColorSpaceDeviceRGB, renderingMode, deferralMode);
+    m_imageBuffer = ImageBuffer::create(size(), m_deviceScaleFactor, ColorSpaceDeviceRGB, renderingMode);
     if (!m_imageBuffer)
         return;
     m_imageBuffer->context()->setShadowsIgnoreTransforms(true);
index cd9821c..bf713d3 100644 (file)
@@ -160,8 +160,6 @@ private:
 
     void setSurfaceSize(const IntSize&);
 
-    bool shouldDefer() const;
-
     bool paintsIntoCanvasBuffer() const;
 
     HashSet<CanvasObserver*> m_observers;
index db7ca7a..f64f578 100644 (file)
@@ -113,7 +113,6 @@ webGLErrorsToConsoleEnabled initial=true
 openGLMultisamplingEnabled initial=true
 privilegedWebGLExtensionsEnabled initial=false
 accelerated2dCanvasEnabled initial=false
-deferred2dCanvasEnabled initial=false
 antialiased2dCanvasEnabled initial=true
 loadDeferringEnabled initial=true
 webAudioEnabled initial=false
index 9c5e63a..1e4e5d4 100644 (file)
@@ -70,11 +70,6 @@ namespace WebCore {
         DontCopyBackingStore // Subsequent draws may affect the copy.
     };
 
-    enum DeferralMode {
-        NonDeferred,
-        Deferred
-    };
-
     enum ScaleBehavior {
         Scaled,
         Unscaled
@@ -84,10 +79,10 @@ namespace WebCore {
         WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED;
     public:
         // Will return a null pointer on allocation failure.
-        static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated, DeferralMode deferralMode = NonDeferred)
+        static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated)
         {
             bool success = false;
-            OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, deferralMode, success));
+            OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, success));
             if (!success)
                 return nullptr;
             return buf.release();
@@ -160,7 +155,7 @@ namespace WebCore {
 
         // This constructor will place its success into the given out-variable
         // so that create() knows when it should return failure.
-        ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, RenderingMode, DeferralMode, bool& success);
+        ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, RenderingMode, bool& success);
 #if USE(SKIA)
         ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha, bool& success);
 #endif
index 5d8a245..fe72590 100644 (file)
@@ -153,7 +153,7 @@ void ImageBufferData::draw(GraphicsContext* thisContext, GraphicsContext* otherC
     }
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode renderingMode, DeferralMode deferralMode, HostWindow* window, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode renderingMode, HostWindow* window, bool& success)
     : m_size(size)
     , m_logicalSize(size)
     , m_resolutionScale(1)
index 6953932..9ebed9d 100644 (file)
@@ -54,7 +54,7 @@ ImageBufferData::ImageBufferData(const IntSize&)
 {
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, bool& success)
     : m_data(size)
     , m_size(size)
     , m_logicalSize(size)
index 7e0434c..e573732 100644 (file)
@@ -106,7 +106,7 @@ static void releaseImageData(void*, const void* data, size_t)
     fastFree(const_cast<void*>(data));
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool& success)
     : m_data(size) // NOTE: The input here isn't important as ImageBufferDataCG's constructor just ignores it.
     , m_logicalSize(size)
     , m_resolutionScale(resolutionScale)
index 66272fd..e406c30 100644 (file)
@@ -32,6 +32,7 @@
 #include "GraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
 #include "GraphicsLayerChromium.h"
+#include "SkDevice.h"
 #include "TraceEvent.h"
 #include <public/Platform.h>
 #include <public/WebCompositorSupport.h>
@@ -43,10 +44,8 @@ using WebKit::WebTextureUpdater;
 
 namespace WebCore {
 
-Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, ThreadMode threadMode, unsigned textureId)
-    : m_deferralMode(deferralMode)
-    , m_frontBufferTexture(0)
-    , m_backBufferTexture(textureId)
+Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, const IntSize& size, ThreadMode threadMode, unsigned textureId)
+    : m_backBufferTexture(textureId)
     , m_size(size)
     , m_canvas(0)
     , m_context(context)
@@ -59,30 +58,9 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context,
     // Used by browser tests to detect the use of a Canvas2DLayerBridge.
     TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation");
 
-    // FIXME: We currently turn off double buffering when canvas rendering is
-    // deferred. What we should be doing is to use a smarter heuristic based
-    // on GPU resource monitoring and other factors to chose between single
-    // and double buffering.
-    m_useDoubleBuffering = threadMode == Threaded && deferralMode == NonDeferred;
-
-    if (m_useDoubleBuffering) {
-        m_context->makeContextCurrent();
-        m_frontBufferTexture = m_context->createTexture();
-        m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_frontBufferTexture);
-        // Do basic linear filtering on resize.
-        m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
-        m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
-        // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
-        m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
-        m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
-        m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, size.width(), size.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE);
-        if (GrContext* grContext = m_context->grContext())
-            grContext->resetContext();
-    }
-
     m_layer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createExternalTextureLayer(this));
     m_layer->setTextureId(textureId);
-    m_layer->setRateLimitContext(threadMode == SingleThread || m_useDoubleBuffering);
+    m_layer->setRateLimitContext(threadMode == SingleThread);
     GraphicsLayerChromium::registerContentsLayer(m_layer->layer());
 }
 
@@ -90,21 +68,9 @@ Canvas2DLayerBridge::~Canvas2DLayerBridge()
 {
     GraphicsLayerChromium::unregisterContentsLayer(m_layer->layer());
     Canvas2DLayerManager::get().layerToBeDestroyed(this);
-    if (SkDeferredCanvas* deferred = deferredCanvas())
-        deferred->setNotificationClient(0);
+    if (m_canvas)
+        m_canvas->setNotificationClient(0);
     m_layer->setTextureId(0);
-    if (m_useDoubleBuffering) {
-        m_context->makeContextCurrent();
-        m_context->deleteTexture(m_frontBufferTexture);
-        m_context->flush();
-    }
-}
-
-SkDeferredCanvas* Canvas2DLayerBridge::deferredCanvas()
-{
-    if (m_deferralMode == Deferred)
-        return static_cast<SkDeferredCanvas*>(m_canvas);
-    return 0;
 }
 
 void Canvas2DLayerBridge::limitPendingFrames()
@@ -119,15 +85,12 @@ void Canvas2DLayerBridge::limitPendingFrames()
 
 void Canvas2DLayerBridge::prepareForDraw()
 {
-    ASSERT(deferredCanvas());
-    if (!m_useDoubleBuffering)
-        m_layer->willModifyTexture();
+    m_layer->willModifyTexture();
     m_context->makeContextCurrent();
 }
 
 void Canvas2DLayerBridge::storageAllocatedForRecordingChanged(size_t bytesAllocated)
 {
-    ASSERT(m_deferralMode == Deferred);
     intptr_t delta = (intptr_t)bytesAllocated - (intptr_t)m_bytesAllocated;
     m_bytesAllocated = bytesAllocated;
     Canvas2DLayerManager::get().layerAllocatedStorageChanged(this, delta);
@@ -135,7 +98,7 @@ void Canvas2DLayerBridge::storageAllocatedForRecordingChanged(size_t bytesAlloca
 
 size_t Canvas2DLayerBridge::storageAllocatedForRecording()
 {
-    return deferredCanvas()->storageAllocatedForRecording();
+    return m_canvas ? m_canvas->storageAllocatedForRecording() : 0;
 }
 
 void Canvas2DLayerBridge::flushedDrawCommands()
@@ -151,8 +114,7 @@ void Canvas2DLayerBridge::skippedPendingDrawCommands()
 
 size_t Canvas2DLayerBridge::freeMemoryIfPossible(size_t bytesToFree)
 {
-    ASSERT(deferredCanvas());
-    size_t bytesFreed = deferredCanvas()->freeMemoryIfPossible(bytesToFree);
+    size_t bytesFreed = m_canvas ? m_canvas->freeMemoryIfPossible(bytesToFree) : 0;
     if (bytesFreed)
         Canvas2DLayerManager::get().layerAllocatedStorageChanged(this, -((intptr_t)bytesFreed));
     m_bytesAllocated -= bytesFreed;
@@ -161,21 +123,15 @@ size_t Canvas2DLayerBridge::freeMemoryIfPossible(size_t bytesToFree)
 
 void Canvas2DLayerBridge::flush()
 {
-    ASSERT(deferredCanvas());
-    if (deferredCanvas()->hasPendingCommands())
+    if (m_canvas && m_canvas->hasPendingCommands())
         m_canvas->flush();
 }
 
 SkCanvas* Canvas2DLayerBridge::skCanvas(SkDevice* device)
 {
     ASSERT(!m_canvas);
-    if (m_deferralMode == Deferred) {
-        SkDeferredCanvas* deferred = new SkDeferredCanvas(device);
-        deferred->setNotificationClient(this);
-        m_canvas = deferred;
-    } else
-        m_canvas = new SkCanvas(device);
-
+    m_canvas = new SkDeferredCanvas(device);
+    m_canvas->setNotificationClient(this);
     return m_canvas;
 }
 
@@ -191,11 +147,6 @@ unsigned Canvas2DLayerBridge::prepareTexture(WebTextureUpdater& updater)
 
     m_context->flush();
 
-    if (m_useDoubleBuffering) {
-        updater.appendCopy(m_backBufferTexture, m_frontBufferTexture, m_size);
-        return m_frontBufferTexture;
-    }
-
     if (m_canvas) {
         // Notify skia that the state of the backing store texture object will be touched by the compositor
         GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_canvas->getDevice()->accessRenderTarget());
@@ -217,12 +168,8 @@ WebKit::WebLayer* Canvas2DLayerBridge::layer()
 
 void Canvas2DLayerBridge::contextAcquired()
 {
-    if (m_deferralMode == NonDeferred && !m_useDoubleBuffering)
-        m_layer->willModifyTexture();
-    else if (m_deferralMode == Deferred) {
-        Canvas2DLayerManager::get().layerDidDraw(this);
-        m_didRecordDrawCommand = true;
-    }
+    Canvas2DLayerManager::get().layerDidDraw(this);
+    m_didRecordDrawCommand = true;
 }
 
 unsigned Canvas2DLayerBridge::backBufferTexture()
index 8e442fd..b386304 100644 (file)
@@ -27,7 +27,6 @@
 #define Canvas2DLayerBridge_h
 
 #include "GraphicsContext3D.h"
-#include "ImageBuffer.h" // For DeferralMode enum.
 #include "IntSize.h"
 #include "SkDeferredCanvas.h"
 #include <public/WebExternalTextureLayer.h>
@@ -50,9 +49,9 @@ public:
         Threaded
     };
 
-    static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, ThreadMode threading, unsigned textureId)
+    static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, ThreadMode threading, unsigned textureId)
     {
-        return adoptPtr(new Canvas2DLayerBridge(context, size, deferralMode, threading, textureId));
+        return adoptPtr(new Canvas2DLayerBridge(context, size, threading, textureId));
     }
 
     virtual ~Canvas2DLayerBridge();
@@ -81,15 +80,11 @@ public:
     unsigned backBufferTexture();
 
 protected:
-    Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, DeferralMode, ThreadMode, unsigned textureId);
-    SkDeferredCanvas* deferredCanvas();
+    Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, ThreadMode, unsigned textureId);
 
-    DeferralMode m_deferralMode;
-    bool m_useDoubleBuffering;
-    unsigned m_frontBufferTexture;
     unsigned m_backBufferTexture;
     IntSize m_size;
-    SkCanvas* m_canvas;
+    SkDeferredCanvas* m_canvas;
     OwnPtr<WebKit::WebExternalTextureLayer> m_layer;
     RefPtr<GraphicsContext3D> m_context;
     size_t m_bytesAllocated;
index 43859ca..1bcdee9 100644 (file)
@@ -94,7 +94,7 @@ QImage ImageBufferData::toQImage() const
     return image;
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, bool& success)
     : m_data(size)
     , m_size(size)
     , m_logicalSize(size)
index 742b011..61309fa 100644 (file)
@@ -72,7 +72,7 @@ ImageBufferData::ImageBufferData(const IntSize& size)
 {
 }
 
-static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* data, DeferralMode deferralMode)
+static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* data)
 {
     RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get();
     if (!context3D)
@@ -94,7 +94,7 @@ static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* d
     SkAutoTUnref<SkDevice> device(new SkGpuDevice(gr, texture.get()));
 #if USE(ACCELERATED_COMPOSITING)
     Canvas2DLayerBridge::ThreadMode threadMode = WebKit::Platform::current()->isThreadedCompositingEnabled() ? Canvas2DLayerBridge::Threaded : Canvas2DLayerBridge::SingleThread;
-    data->m_layerBridge = Canvas2DLayerBridge::create(context3D.release(), size, deferralMode, threadMode, texture.get()->getTextureHandle());
+    data->m_layerBridge = Canvas2DLayerBridge::create(context3D.release(), size, threadMode, texture.get()->getTextureHandle());
     canvas = data->m_layerBridge->skCanvas(device.get());
 #else
     canvas = new SkCanvas(device.get());
@@ -151,7 +151,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace,
     success = true;
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, DeferralMode deferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, bool& success)
     : m_data(size)
     , m_size(size)
     , m_logicalSize(size)
@@ -160,7 +160,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace,
     OwnPtr<SkCanvas> canvas;
 
     if (renderingMode == Accelerated)
-        canvas = adoptPtr(createAcceleratedCanvas(size, &m_data, deferralMode));
+        canvas = adoptPtr(createAcceleratedCanvas(size, &m_data));
     else if (renderingMode == UnacceleratedNonPlatformBuffer)
         canvas = adoptPtr(createNonPlatformCanvas(size));
 
index c3c4119..fd41e12 100644 (file)
@@ -71,7 +71,7 @@ ImageBufferData::ImageBufferData(const IntSize& size)
     m_bitmap->setHasAlpha(true);
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, bool& success)
     : m_data(size)
     , m_size(size)
     , m_logicalSize(size)
index 4f41ed1..9f01ea2 100644 (file)
@@ -94,7 +94,7 @@ ImageBufferData::~ImageBufferData()
     delete m_memDC;
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, bool& success)
     : m_data(size)
     , m_size(size)
     , m_logicalSize(size)
index 3504380..ec0ff93 100644 (file)
@@ -1,3 +1,22 @@
+2013-03-20  Justin Novosad  <junov@google.com>
+
+        [Chromium] Code cleanup: removing support for non-deferred 2d canvas rendering
+        https://bugs.webkit.org/show_bug.cgi?id=112605
+
+        Reviewed by James Robinson.
+
+        Deleting all the code that was used for propagating and supporting
+        the Chromium setting for disabling deferred 2d canvas rendering.
+
+        * public/WebSettings.h:
+        (WebKit::WebSettings::setDeferred2dCanvasEnabled):
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setDeferred2dCanvasEnabled):
+        * tests/Canvas2DLayerBridgeTest.cpp:
+        (Canvas2DLayerBridgeTest::fullLifecycleTest):
+        * tests/Canvas2DLayerManagerTest.cpp:
+        (FakeCanvas2DLayerBridge::FakeCanvas2DLayerBridge):
+
 2013-03-20  Ken Kania  <kkania@chromium.org>
 
         Web Inspector: Add promptText param to Page.handleJavaScriptDialog
index e92b6c8..725c61c 100644 (file)
@@ -87,7 +87,7 @@ public:
     virtual void setDefaultFontSize(int) = 0;
     virtual void setDefaultTextEncodingName(const WebString&) = 0;
     virtual void setDefaultVideoPosterURL(const WebString&) = 0;
-    virtual void setDeferred2dCanvasEnabled(bool) = 0;
+    void setDeferred2dCanvasEnabled(bool) { } // temporary stub
     virtual void setDeferredImageDecodingEnabled(bool) = 0;
     virtual void setDeveloperExtrasEnabled(bool) = 0;
     virtual void setDeviceSupportsMouse(bool) = 0;
index 0c0d2fd..9f34901 100644 (file)
@@ -514,7 +514,6 @@ void WebSettingsImpl::setAntialiased2dCanvasEnabled(bool enabled)
 
 void WebSettingsImpl::setDeferred2dCanvasEnabled(bool enabled)
 {
-    m_settings->setDeferred2dCanvasEnabled(enabled);
 }
 
 void WebSettingsImpl::setDeferredImageDecodingEnabled(bool enabled)
index c44f330..6f261ba 100644 (file)
@@ -63,7 +63,7 @@ public:
 
 class Canvas2DLayerBridgeTest : public Test {
 protected:
-    void fullLifecycleTest(Canvas2DLayerBridge::ThreadMode threadMode, DeferralMode deferralMode)
+    void fullLifecycleTest(Canvas2DLayerBridge::ThreadMode threadMode)
     {
         RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext));
 
@@ -76,52 +76,29 @@ protected:
         WebGLId backTextureId = 1;
         WebGLId frontTextureId = 1;
 
-        // Threaded and non deferred canvases are double buffered.
-        if (threadMode == Canvas2DLayerBridge::Threaded && deferralMode == NonDeferred) {
-            frontTextureId = 2;
-            // Create texture (on the main thread) and do the copy (on the impl thread).
-            EXPECT_CALL(mainMock, createTexture()).WillOnce(Return(frontTextureId));
-        }
-
-        OwnPtr<Canvas2DLayerBridge> bridge = Canvas2DLayerBridge::create(mainContext.get(), size, deferralMode, threadMode, backTextureId);
+        OwnPtr<Canvas2DLayerBridge> bridge = Canvas2DLayerBridge::create(mainContext.get(), size, threadMode, backTextureId);
 
         ::testing::Mock::VerifyAndClearExpectations(&mainMock);
 
         EXPECT_CALL(mainMock, flush());
-        if (threadMode == Canvas2DLayerBridge::Threaded && deferralMode == NonDeferred)
-            EXPECT_CALL(updater, appendCopy(backTextureId, frontTextureId, WebSize(300, 150)));
         EXPECT_EQ(frontTextureId, bridge->prepareTexture(updater));
         ::testing::Mock::VerifyAndClearExpectations(&mainMock);
         ::testing::Mock::VerifyAndClearExpectations(&updater);
 
-        if (threadMode == Canvas2DLayerBridge::Threaded && deferralMode == NonDeferred) {
-            EXPECT_CALL(mainMock, deleteTexture(frontTextureId));
-            EXPECT_CALL(mainMock, flush());
-        }
         bridge.clear();
     }
 };
 
 namespace {
 
-TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreadedDeferred)
-{
-    fullLifecycleTest(Canvas2DLayerBridge::SingleThread, NonDeferred);
-}
-
-TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreadedNonDeferred)
-{
-    fullLifecycleTest(Canvas2DLayerBridge::SingleThread, Deferred);
-}
-
-TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleThreadedNonDeferred)
+TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded)
 {
-    fullLifecycleTest(Canvas2DLayerBridge::Threaded, NonDeferred);
+    fullLifecycleTest(Canvas2DLayerBridge::SingleThread);
 }
 
-TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleThreadedDeferred)
+TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleThreaded)
 {
-    fullLifecycleTest(Canvas2DLayerBridge::Threaded, Deferred);
+    fullLifecycleTest(Canvas2DLayerBridge::Threaded);
 }
 
 } // namespace
index feb31b2..29773ae 100644 (file)
@@ -42,7 +42,7 @@ using testing::Test;
 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge {
 public:
     FakeCanvas2DLayerBridge() 
-        : Canvas2DLayerBridge(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new WebKit::FakeWebGraphicsContext3D)), IntSize(1, 1), Deferred, SingleThread, 0)
+        : Canvas2DLayerBridge(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new WebKit::FakeWebGraphicsContext3D)), IntSize(1, 1), SingleThread, 0)
         , m_freeableBytes(0)
         , m_freeMemoryIfPossibleCount(0)
         , m_flushCount(0)
index 564bf1e..892b79e 100644 (file)
@@ -1,3 +1,26 @@
+2013-03-20  Justin Novosad  <junov@google.com>
+
+        [Chromium] Code cleanup: removing support for non-deferred 2d canvas rendering
+        https://bugs.webkit.org/show_bug.cgi?id=112605
+
+        Reviewed by James Robinson.
+
+        Deleting all the code that was used for propagating and supporting
+        the Chromium setting for disabling deferred 2d canvas rendering.
+
+        * DumpRenderTree/chromium/DumpRenderTree.cpp:
+        (main):
+        * DumpRenderTree/chromium/TestRunner/public/WebPreferences.h:
+        * DumpRenderTree/chromium/TestRunner/src/WebPreferences.cpp:
+        (WebTestRunner::WebPreferences::reset):
+        (WebTestRunner::WebPreferences::applyTo):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::TestShell):
+        (TestShell::resetWebSettings):
+        (TestShell::runFileTest):
+        * DumpRenderTree/chromium/TestShell.h:
+        (TestShell):
+
 2013-03-20  Ádám Kallai  <kadam@inf.u-szeged.hu>
 
         [Qt] Qt 4.8 tool related stuff removal from webkitpy.
index 4cfbd15..8038040 100644 (file)
@@ -59,7 +59,6 @@ static const char optionEnableSoftwareCompositing[] = "--enable-software-composi
 static const char optionEnableThreadedCompositing[] = "--enable-threaded-compositing";
 static const char optionForceCompositingMode[] = "--force-compositing-mode";
 static const char optionEnableAccelerated2DCanvas[] = "--enable-accelerated-2d-canvas";
-static const char optionEnableDeferred2DCanvas[] = "--enable-deferred-2d-canvas";
 static const char optionEnableAcceleratedCompositingForVideo[] = "--enable-accelerated-video";
 static const char optionEnableAcceleratedFixedPosition[] = "--enable-accelerated-fixed-position";
 static const char optionEnableAcceleratedOverflowScroll[] = "--enable-accelerated-overflow-scroll";
@@ -138,7 +137,6 @@ int main(int argc, char* argv[])
     bool forceCompositingMode = false;
     bool threadedHTMLParser = true;
     bool accelerated2DCanvasEnabled = false;
-    bool deferred2DCanvasEnabled = false;
     bool perTilePaintingEnabled = false;
     bool deferredImageDecodingEnabled = false;
     bool stressOpt = false;
@@ -183,8 +181,6 @@ int main(int argc, char* argv[])
             threadedHTMLParser = false;
         else if (argument == optionEnableAccelerated2DCanvas)
             accelerated2DCanvasEnabled = true;
-        else if (argument == optionEnableDeferred2DCanvas)
-            deferred2DCanvasEnabled = true;
         else if (argument == optionEnablePerTilePainting)
             perTilePaintingEnabled = true;
         else if (argument == optionEnableDeferredImageDecoding)
@@ -228,7 +224,6 @@ int main(int argc, char* argv[])
         shell.setForceCompositingMode(forceCompositingMode);
         shell.setThreadedHTMLParser(threadedHTMLParser);
         shell.setAccelerated2dCanvasEnabled(accelerated2DCanvasEnabled);
-        shell.setDeferred2dCanvasEnabled(deferred2DCanvasEnabled);
         shell.setPerTilePaintingEnabled(perTilePaintingEnabled);
         shell.setDeferredImageDecodingEnabled(deferredImageDecodingEnabled);
         shell.setJavaScriptFlags(javaScriptFlags);
index 5644d09..bfce5af 100644 (file)
@@ -94,7 +94,6 @@ struct WEBTESTRUNNER_EXPORT WebPreferences {
     bool forceCompositingMode;
     bool threadedHTMLParser;
     bool accelerated2dCanvasEnabled;
-    bool deferred2dCanvasEnabled;
     bool perTilePaintingEnabled;
     bool acceleratedAnimationEnabled;
     bool deferredImageDecodingEnabled;
index a687773..5d882ae 100644 (file)
@@ -119,7 +119,6 @@ void WebPreferences::reset()
     acceleratedCompositingForOverflowScrollEnabled = false;
     acceleratedCompositingEnabled = false;
     accelerated2dCanvasEnabled = false;
-    deferred2dCanvasEnabled = false;
     forceCompositingMode = false;
     threadedHTMLParser = true;
     perTilePaintingEnabled = false;
@@ -189,7 +188,6 @@ void WebPreferences::applyTo(WebView* webView)
     settings->setForceCompositingMode(forceCompositingMode);
     settings->setThreadedHTMLParser(threadedHTMLParser);
     settings->setAccelerated2dCanvasEnabled(accelerated2dCanvasEnabled);
-    settings->setDeferred2dCanvasEnabled(deferred2dCanvasEnabled);
     settings->setPerTilePaintingEnabled(perTilePaintingEnabled);
     settings->setDeferredImageDecodingEnabled(deferredImageDecodingEnabled);
     settings->setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
index d3db65e..66f1c40 100644 (file)
@@ -115,7 +115,6 @@ TestShell::TestShell()
     , m_forceCompositingMode(false)
     , m_threadedHTMLParser(true)
     , m_accelerated2dCanvasEnabled(false)
-    , m_deferred2dCanvasEnabled(false)
     , m_perTilePaintingEnabled(false)
     , m_deferredImageDecodingEnabled(false)
     , m_stressOpt(false)
@@ -215,7 +214,6 @@ void TestShell::resetWebSettings(WebView& webView)
     m_prefs.acceleratedCompositingForOverflowScrollEnabled = m_acceleratedCompositingForOverflowScrollEnabled;
     m_prefs.forceCompositingMode = m_forceCompositingMode;
     m_prefs.accelerated2dCanvasEnabled = m_accelerated2dCanvasEnabled;
-    m_prefs.deferred2dCanvasEnabled = m_deferred2dCanvasEnabled;
     m_prefs.perTilePaintingEnabled = m_perTilePaintingEnabled;
     m_prefs.deferredImageDecodingEnabled = m_deferredImageDecodingEnabled;
     m_prefs.threadedHTMLParser = m_threadedHTMLParser;
@@ -236,7 +234,6 @@ void TestShell::runFileTest(const TestParams& params, bool shouldDumpPixels)
         if (!m_softwareCompositingEnabled)
             m_prefs.accelerated2dCanvasEnabled = true;
         m_prefs.acceleratedCompositingForVideoEnabled = true;
-        m_prefs.deferred2dCanvasEnabled = true;
         m_prefs.mockScrollbarsEnabled = true;
         m_prefs.applyTo(m_webView);
     }
index ed7eafc..1cb34ac 100644 (file)
@@ -121,7 +121,6 @@ public:
     void setForceCompositingMode(bool enabled) { m_forceCompositingMode = enabled; }
     void setThreadedHTMLParser(bool enabled) { m_threadedHTMLParser = enabled; }
     void setAccelerated2dCanvasEnabled(bool enabled) { m_accelerated2dCanvasEnabled = enabled; }
-    void setDeferred2dCanvasEnabled(bool enabled) { m_deferred2dCanvasEnabled = enabled; }
     void setPerTilePaintingEnabled(bool enabled) { m_perTilePaintingEnabled = enabled; }
     void setDeferredImageDecodingEnabled(bool enabled) { m_deferredImageDecodingEnabled = enabled; }
 #if defined(OS_WIN)
@@ -216,7 +215,6 @@ private:
     bool m_forceCompositingMode;
     bool m_threadedHTMLParser;
     bool m_accelerated2dCanvasEnabled;
-    bool m_deferred2dCanvasEnabled;
     bool m_perTilePaintingEnabled;
     bool m_deferredImageDecodingEnabled;
     WebTestRunner::WebPreferences m_prefs;