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

jamesr at google.com jamesr at google.com
Wed Dec 22 11:47:50 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit adc38860db12c9b124baf4d0efb9382c0a9c036f
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 6 23:29:27 2010 +0000

    2010-08-06  James Robinson  <jamesr at chromium.org>
    
            Reviewed by Simon Fraser.
    
            Accelerated 2d canvases should get compositing layers
            https://bugs.webkit.org/show_bug.cgi?id=43362
    
            Allows for 2d canvas rendering contexts to use a GraphicsContext3D for
            accelerated rendering.  The rendering context holds the GraphicsContext3D
            alive and exposes it to the compositor.  The 3d context itself is passed
            down through the GraphicsContext to use for actual rendering:
            https://bug-43362-attachments.webkit.org/attachment.cgi?id=63557
    
            This approach will let us simultaneously prototype accelerated techniques
            for canvas 2d and revise the design of canvas elements without destabilizing
            all ports.
    
            * html/HTMLCanvasElement.cpp:
            (WebCore::HTMLCanvasElement::getContext):
            (WebCore::HTMLCanvasElement::willDraw):
            (WebCore::HTMLCanvasElement::makeRenderingResultsAvailable):
            * html/canvas/CanvasRenderingContext.h:
            (WebCore::CanvasRenderingContext::paintRenderingResultsToCanvas):
            * html/canvas/CanvasRenderingContext2D.cpp:
            (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
            (WebCore::CanvasRenderingContext2D::isAccelerated):
            (WebCore::CanvasRenderingContext2D::reset):
            (WebCore::CanvasRenderingContext2D::willDraw):
            (WebCore::CanvasRenderingContext2D::paintRenderingResultsToCanvas):
            * html/canvas/CanvasRenderingContext2D.h:
            (WebCore::CanvasRenderingContext2D::graphicsContext3D):
            * html/canvas/WebGLRenderingContext.cpp:
            (WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas):
            * html/canvas/WebGLRenderingContext.h:
            * platform/graphics/GraphicsContext.h:
            * platform/graphics/skia/GraphicsContextSkia.cpp:
            (WebCore::GraphicsContext::syncSoftwareCanvas):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64881 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4c82a7f..2b756d6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2010-08-06  James Robinson  <jamesr at chromium.org>
+
+        Reviewed by Simon Fraser.
+
+        Accelerated 2d canvases should get compositing layers
+        https://bugs.webkit.org/show_bug.cgi?id=43362
+
+        Allows for 2d canvas rendering contexts to use a GraphicsContext3D for
+        accelerated rendering.  The rendering context holds the GraphicsContext3D
+        alive and exposes it to the compositor.  The 3d context itself is passed
+        down through the GraphicsContext to use for actual rendering:
+        https://bug-43362-attachments.webkit.org/attachment.cgi?id=63557
+
+        This approach will let us simultaneously prototype accelerated techniques
+        for canvas 2d and revise the design of canvas elements without destabilizing
+        all ports.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::getContext):
+        (WebCore::HTMLCanvasElement::willDraw):
+        (WebCore::HTMLCanvasElement::makeRenderingResultsAvailable):
+        * html/canvas/CanvasRenderingContext.h:
+        (WebCore::CanvasRenderingContext::paintRenderingResultsToCanvas):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
+        (WebCore::CanvasRenderingContext2D::isAccelerated):
+        (WebCore::CanvasRenderingContext2D::reset):
+        (WebCore::CanvasRenderingContext2D::willDraw):
+        (WebCore::CanvasRenderingContext2D::paintRenderingResultsToCanvas):
+        * html/canvas/CanvasRenderingContext2D.h:
+        (WebCore::CanvasRenderingContext2D::graphicsContext3D):
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas):
+        * html/canvas/WebGLRenderingContext.h:
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::syncSoftwareCanvas):
+
 2010-08-06  Eric Seidel  <eric at webkit.org>
 
         Reviewed by Chris Fleizach.
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp
index 6b5a3a3..ef5574a 100644
--- a/WebCore/html/HTMLCanvasElement.cpp
+++ b/WebCore/html/HTMLCanvasElement.cpp
@@ -169,6 +169,12 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
                 usesDashbardCompatibilityMode = settings->usesDashboardBackwardCompatibilityMode();
 #endif
             m_context = new CanvasRenderingContext2D(this, document()->inCompatMode(), usesDashbardCompatibilityMode);
+#if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
+            if (m_context) {
+                // Need to make sure a RenderLayer and compositing layer get created for the Canvas
+                setNeedsStyleRecalc(SyntheticStyleChange);
+            }
+#endif
         }
         return m_context.get();
     }
@@ -216,7 +222,7 @@ void HTMLCanvasElement::willDraw(const FloatRect& rect)
         m_dirtyRect.unite(r);
         ro->repaintRectangle(enclosingIntRect(m_dirtyRect));
     }
-    
+
     if (m_observer)
         m_observer->canvasChanged(this, rect);
 }
@@ -299,12 +305,8 @@ bool HTMLCanvasElement::is3D() const
 
 void HTMLCanvasElement::makeRenderingResultsAvailable()
 {
-#if ENABLE(3D_CANVAS)
-    if (is3D()) {
-        WebGLRenderingContext* context3d = reinterpret_cast<WebGLRenderingContext*>(renderingContext());
-        context3d->paintRenderingResultsToCanvas();
-    }
-#endif
+    if (m_context)
+        m_context->paintRenderingResultsToCanvas();
 }
 
 void HTMLCanvasElement::recalcStyle(StyleChange change)
diff --git a/WebCore/html/canvas/CanvasRenderingContext.h b/WebCore/html/canvas/CanvasRenderingContext.h
index b8a7ca2..cb26363 100644
--- a/WebCore/html/canvas/CanvasRenderingContext.h
+++ b/WebCore/html/canvas/CanvasRenderingContext.h
@@ -53,6 +53,8 @@ namespace WebCore {
         // For non accelerated canvases returns 0.
         virtual GraphicsContext3D* graphicsContext3D() const { return 0; }
 
+        virtual void paintRenderingResultsToCanvas() {}
+
     private:
         HTMLCanvasElement* m_canvas;
     };
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 3b05348..0dac6af 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -58,7 +58,13 @@
 #include "StrokeStyleApplier.h"
 #include "TextMetrics.h"
 
-#include <stdio.h>
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include "FrameView.h"
+#include "GraphicsContext3D.h"
+#if USE(ACCELERATED_COMPOSITING)
+#include "RenderLayer.h"
+#endif
+#endif
 
 #include <wtf/ByteArray.h>
 #include <wtf/MathExtras.h>
@@ -100,6 +106,9 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo
 #if ENABLE(DASHBOARD_SUPPORT)
     , m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode)
 #endif
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    , m_context3D(0)
+#endif
 {
 #if !ENABLE(DASHBOARD_SUPPORT)
     ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMode);
@@ -108,17 +117,53 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo
     // Make sure that even if the drawingContext() has a different default
     // thickness, it is in sync with the canvas thickness.
     setLineWidth(lineWidth());
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    Page* p = canvas->document()->page();
+    if (!p)
+        return;
+    if (!p->settings()->accelerated2dCanvasEnabled())
+        return;
+    if (FrameView* view = canvas->document()->view()) {
+        if (ScrollView* rootView = view->root()) {
+            if (HostWindow* hostWindow = view->root()->hostWindow()) {
+                // Set up our context
+                GraphicsContext3D::Attributes attr;
+                attr.stencil = true;
+                m_context3D = GraphicsContext3D::create(attr, hostWindow);
+                if (m_context3D)
+                    if (GraphicsContext* c = drawingContext())
+                        c->setGraphicsContext3D(m_context3D.get(), IntSize(canvas->width(), canvas->height()));
+            }
+        }
+    }
+#endif
 }
 
 CanvasRenderingContext2D::~CanvasRenderingContext2D()
 {
 }
 
+bool CanvasRenderingContext2D::isAccelerated() const
+{
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    return m_context3D;
+#else
+    return false;
+#endif
+}
+
 void CanvasRenderingContext2D::reset()
 {
     m_stateStack.resize(1);
     m_stateStack.first() = State();
     m_path.clear();
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    if (m_context3D) {
+        if (GraphicsContext* c = drawingContext())
+            c->setGraphicsContext3D(m_context3D.get(), IntSize(canvas()->width(), canvas()->height()));
+    }
+#endif
 }
 
 CanvasRenderingContext2D::State::State()
@@ -1434,7 +1479,14 @@ void CanvasRenderingContext2D::willDraw(const FloatRect& r, unsigned options)
         // we'd have to keep the clip path around.
     }
 
-    canvas()->willDraw(dirtyRect);
+#if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
+    // If we are drawing to hardware and we have a composited layer, just call rendererContentChanged().
+    RenderBox* renderBox = canvas()->renderBox();
+    if (m_context3D && renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing())
+        renderBox->layer()->rendererContentChanged();
+    else
+#endif
+        canvas()->willDraw(dirtyRect);
 }
 
 GraphicsContext* CanvasRenderingContext2D::drawingContext() const
@@ -1772,4 +1824,11 @@ const Font& CanvasRenderingContext2D::accessFont()
     return state().m_font;
 }
 
+void CanvasRenderingContext2D::paintRenderingResultsToCanvas()
+{
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    drawingContext()->syncSoftwareCanvas();
+#endif
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h
index 22ed7fc..f610250 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.h
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.h
@@ -42,6 +42,10 @@
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
+#if USE(ACCELERATED_COMPOSITING)
+#include "GraphicsLayer.h"
+#endif
+
 namespace WebCore {
 
 class CanvasGradient;
@@ -56,6 +60,10 @@ class ImageData;
 class KURL;
 class TextMetrics;
 
+#if ENABLE(ACCELERATED_2D_CANVAS)
+class GraphicsContext3D;
+#endif
+
 typedef int ExceptionCode;
 
 class CanvasRenderingContext2D : public CanvasRenderingContext {
@@ -65,6 +73,7 @@ public:
     virtual ~CanvasRenderingContext2D();
 
     virtual bool is2d() const { return true; }
+    virtual bool isAccelerated() const;
 
     CanvasStyle* strokeStyle() const;
     void setStrokeStyle(PassRefPtr<CanvasStyle>);
@@ -212,6 +221,12 @@ public:
     LineCap getLineCap() const { return state().m_lineCap; }
     LineJoin getLineJoin() const { return state().m_lineJoin; }
 
+    virtual void paintRenderingResultsToCanvas();
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    virtual GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); }
+#endif
+
 private:
     struct State {
         State();
@@ -281,6 +296,10 @@ private:
 #if ENABLE(DASHBOARD_SUPPORT)
     bool m_usesDashboardCompatibilityMode;
 #endif
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    OwnPtr<GraphicsContext3D> m_context3D;
+#endif
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 5f9ad91..ffe17b6 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -156,7 +156,7 @@ void WebGLRenderingContext::markContextChanged()
     m_markedCanvasDirty = true;
 }
 
-bool WebGLRenderingContext::paintRenderingResultsToCanvas()
+void WebGLRenderingContext::paintRenderingResultsToCanvas()
 {
     if (m_markedCanvasDirty) {
         // FIXME: It should not be necessary to clear the image before doing a readback.
@@ -164,9 +164,7 @@ bool WebGLRenderingContext::paintRenderingResultsToCanvas()
         canvas()->buffer()->clearImage();
         m_markedCanvasDirty = false;
         m_context->paintRenderingResultsToCanvas(this);
-        return true;
     }
-    return false;
 }
 
 void WebGLRenderingContext::beginPaint()
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index b5a6343..5371305 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -307,9 +307,7 @@ public:
 
     void reshape(int width, int height);
 
-    // Return value true indicates canvas is updated during the call,
-    // false indicates no updates.
-    bool paintRenderingResultsToCanvas();
+    virtual void paintRenderingResultsToCanvas();
 
     // Helpers for notification about paint events.
     void beginPaint();
diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h
index d3535b4..a2e018a 100644
--- a/WebCore/platform/graphics/GraphicsContext.h
+++ b/WebCore/platform/graphics/GraphicsContext.h
@@ -116,6 +116,7 @@ namespace WebCore {
     class Font;
     class Generator;
     class Gradient;
+    class GraphicsContext3D;
     class GraphicsContextPlatformPrivate;
     class GraphicsContextPrivate;
     class ImageBuffer;
@@ -393,6 +394,11 @@ namespace WebCore {
         pattern getHaikuStrokeStyle();
 #endif
 
+#if PLATFORM(SKIA)
+        void setGraphicsContext3D(GraphicsContext3D*, const IntSize&);
+        void syncSoftwareCanvas();
+#endif
+
     private:
         void savePlatformState();
         void restorePlatformState();
diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
index ae088b6..7bcd84b 100644
--- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
@@ -1276,4 +1276,21 @@ void GraphicsContext::translate(float w, float h)
                                            WebCoreFloatToSkScalar(h));
 }
 
+void GraphicsContext::setGraphicsContext3D(GraphicsContext3D* context3D, const IntSize& size)
+{
+#if USE(GLES2_RENDERING)
+    platformContext()->setGraphicsContext3D(context3D, size);
+#else
+    UNUSED_PARAM(context3D);
+    UNUSED_PARAM(size);
+#endif
+}
+
+void GraphicsContext::syncSoftwareCanvas()
+{
+#if USE(GLES2_RENDERING)
+    platformContext()->syncSoftwareCanvas();
+#endif
+}
+
 }  // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list