Title: [93013] trunk/Source/WebCore
Revision
93013
Author
[email protected]
Date
2011-08-12 20:26:43 -0700 (Fri, 12 Aug 2011)

Log Message

Ownership of canvas's GraphicsContext3D should be moved to PlatformContextSkia
https://bugs.webkit.org/show_bug.cgi?id=66154

Reviewed by Kenneth Russell.

Covered by existing tests in fast/canvas and canvas/philip.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::isAccelerated):
Plumb this call through GraphicsContext::isAcceleratedContext().
(WebCore::CanvasRenderingContext2D::paintsIntoCanvasBuffer):
For the ACCELERATED_2D_CANVAS path, plumb this call through
(the new) GraphicsContext::paintsIntoCanvasBuffer().
(WebCore::CanvasRenderingContext2D::clearAcceleration):
(WebCore::CanvasRenderingContext2D::resetAcceleration):
Remove the use of the m_context3D member; use a temporary instead.
* html/canvas/CanvasRenderingContext2D.h:
Remove the m_context3D member.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::isAcceleratedContext):
(WebCore::GraphicsContext::paintsIntoImageBuffer):
Implement stub versions of these functions for other platforms.
* platform/graphics/GraphicsContext.h:
Expose isAcceleratedContext() to all platforms.  Add
paintsIntoImageBuffer() member function.
* platform/graphics/gpu/SharedGraphicsContext3D.cpp:
(WebCore::SharedGraphicsContext3D::create):
* platform/graphics/gpu/SharedGraphicsContext3D.h:
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::setGraphicsContext3D):
(WebCore::GraphicsContext::isAcceleratedContext):
(WebCore::GraphicsContext::paintsIntoImageBuffer):
Basically gut this class leaving only a static creation function.
* platform/graphics/skia/ImageSkia.cpp:
(WebCore::paintSkBitmap):
(WebCore::Image::drawPattern):
Use isAccelerated() in place of useSkiaGpu().
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::isNativeFontRenderingAllowed):
(WebCore::PlatformContextSkia::paintsIntoImageBuffer):
* platform/graphics/skia/PlatformContextSkia.h:
(WebCore::PlatformContextSkia::isAccelerated):
Rename useSkiaGpu() to isAccelerated().  Plumb through 
paintsIntoImageBuffer() to GraphicsContext3D.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (93012 => 93013)


--- trunk/Source/WebCore/ChangeLog	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/ChangeLog	2011-08-13 03:26:43 UTC (rev 93013)
@@ -1,3 +1,50 @@
+2011-08-12  Stephen White  <[email protected]>
+
+        Ownership of canvas's GraphicsContext3D should be moved to PlatformContextSkia
+        https://bugs.webkit.org/show_bug.cgi?id=66154
+
+        Reviewed by Kenneth Russell.
+
+        Covered by existing tests in fast/canvas and canvas/philip.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::isAccelerated):
+        Plumb this call through GraphicsContext::isAcceleratedContext().
+        (WebCore::CanvasRenderingContext2D::paintsIntoCanvasBuffer):
+        For the ACCELERATED_2D_CANVAS path, plumb this call through
+        (the new) GraphicsContext::paintsIntoCanvasBuffer().
+        (WebCore::CanvasRenderingContext2D::clearAcceleration):
+        (WebCore::CanvasRenderingContext2D::resetAcceleration):
+        Remove the use of the m_context3D member; use a temporary instead.
+        * html/canvas/CanvasRenderingContext2D.h:
+        Remove the m_context3D member.
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::isAcceleratedContext):
+        (WebCore::GraphicsContext::paintsIntoImageBuffer):
+        Implement stub versions of these functions for other platforms.
+        * platform/graphics/GraphicsContext.h:
+        Expose isAcceleratedContext() to all platforms.  Add
+        paintsIntoImageBuffer() member function.
+        * platform/graphics/gpu/SharedGraphicsContext3D.cpp:
+        (WebCore::SharedGraphicsContext3D::create):
+        * platform/graphics/gpu/SharedGraphicsContext3D.h:
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::setGraphicsContext3D):
+        (WebCore::GraphicsContext::isAcceleratedContext):
+        (WebCore::GraphicsContext::paintsIntoImageBuffer):
+        Basically gut this class leaving only a static creation function.
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore::paintSkBitmap):
+        (WebCore::Image::drawPattern):
+        Use isAccelerated() in place of useSkiaGpu().
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        (WebCore::PlatformContextSkia::isNativeFontRenderingAllowed):
+        (WebCore::PlatformContextSkia::paintsIntoImageBuffer):
+        * platform/graphics/skia/PlatformContextSkia.h:
+        (WebCore::PlatformContextSkia::isAccelerated):
+        Rename useSkiaGpu() to isAccelerated().  Plumb through 
+        paintsIntoImageBuffer() to GraphicsContext3D.
+
 2011-08-12  Sam Weinig  <[email protected]>
 
         Use __builtin_trap() for CRASH when building with clang

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (93012 => 93013)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2011-08-13 03:26:43 UTC (rev 93013)
@@ -183,7 +183,7 @@
     ImageBuffer* buffer = canvas()->buffer();
     return buffer ? buffer->isAccelerated() : false;
 #elif ENABLE(ACCELERATED_2D_CANVAS)
-    return m_context3D;
+    return drawingContext() && drawingContext()->isAcceleratedContext();
 #else
     return false;
 #endif
@@ -192,8 +192,8 @@
 bool CanvasRenderingContext2D::paintsIntoCanvasBuffer() const
 {
 #if ENABLE(ACCELERATED_2D_CANVAS)
-    if (m_context3D)
-        return m_context3D->context()->paintsIntoCanvasBuffer();
+    if (drawingContext())
+        return drawingContext()->paintsIntoImageBuffer();
 #endif
     return true;
 }
@@ -2029,7 +2029,6 @@
         ctx->setGraphicsContext3D(0, 0, IntSize());
 
     m_drawingBuffer.clear();
-    m_context3D.clear();
 }
 
 void CanvasRenderingContext2D::resetAcceleration()
@@ -2046,13 +2045,11 @@
         return;
     }
 
-    if (!m_context3D) {
-        Page* page = canvas()->document()->page();
-        m_context3D = SharedGraphicsContext3D::create(page->chrome());
-        if (!m_context3D) {
-            clearAcceleration();
-            return;
-        }
+    Page* page = canvas()->document()->page();
+    GraphicsContext3D* context3D = SharedGraphicsContext3D::create(page->chrome());
+    if (!context3D) {
+        clearAcceleration();
+        return;
     }
 
     if (m_drawingBuffer) {
@@ -2061,14 +2058,14 @@
             return;
         }
     } else {
-        m_drawingBuffer = m_context3D->context()->createDrawingBuffer(canvas()->size());
+        m_drawingBuffer = context3D->createDrawingBuffer(canvas()->size());
         if (!m_drawingBuffer) {
             clearAcceleration();
             return;
         }
     }
 
-    ctx->setGraphicsContext3D(m_context3D->context(), m_drawingBuffer.get(), canvas()->size());
+    ctx->setGraphicsContext3D(context3D, m_drawingBuffer.get(), canvas()->size());
 }
 #endif
 

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (93012 => 93013)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2011-08-13 03:26:43 UTC (rev 93013)
@@ -307,7 +307,6 @@
 
 #if ENABLE(ACCELERATED_2D_CANVAS)
     RefPtr<DrawingBuffer> m_drawingBuffer;
-    RefPtr<SharedGraphicsContext3D> m_context3D;
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2011-08-13 03:26:43 UTC (rev 93013)
@@ -690,7 +690,20 @@
 }
 #endif
 
+#if !USE(SKIA) && !USE(CG)
+bool GraphicsContext::isAcceleratedContext() const
+{
+    return false;
+}
+#endif
 
+#if !USE(SKIA)
+bool GraphicsContext::paintsIntoImageBuffer() const
+{
+    return true;
+}
+#endif
+
 void GraphicsContext::adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle penStyle)
 {
     // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2011-08-13 03:26:43 UTC (rev 93013)
@@ -273,8 +273,9 @@
         bool isCALayerContext() const;
 
         void setIsAcceleratedContext(bool);
+#endif
         bool isAcceleratedContext() const;
-#endif
+        bool paintsIntoImageBuffer() const;
 
         void save();
         void restore();

Modified: trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp	2011-08-13 03:26:43 UTC (rev 93013)
@@ -30,36 +30,16 @@
 
 namespace WebCore {
 
-SharedGraphicsContext3D* SharedGraphicsContext3D::s_instance = 0;
-
-PassRefPtr<SharedGraphicsContext3D> SharedGraphicsContext3D::create(HostWindow* window)
+GraphicsContext3D* SharedGraphicsContext3D::create(HostWindow* window)
 {
-    if (s_instance) {
-        s_instance->ref(); // Manually increment refcount for this caller since adoptRef() does not increase the refcount.
-        return adoptRef(s_instance);
-    }
     GraphicsContext3D::Attributes attributes;
     attributes.depth = false;
     attributes.stencil = true;
     attributes.antialias = false;
     attributes.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts.
-    RefPtr<GraphicsContext3D> context = GraphicsContext3D::create(attributes, window);
-    if (!context)
-        return PassRefPtr<SharedGraphicsContext3D>();
-    RefPtr<SharedGraphicsContext3D> sharedContext = adoptRef(new SharedGraphicsContext3D(context.release()));
-    s_instance = sharedContext.get();
-    return sharedContext;
+    static RefPtr<GraphicsContext3D> context = GraphicsContext3D::create(attributes, window);
+    return context.get();
 }
 
-SharedGraphicsContext3D::SharedGraphicsContext3D(PassRefPtr<GraphicsContext3D> context)
-    : m_context(context)
-{
 }
 
-SharedGraphicsContext3D::~SharedGraphicsContext3D()
-{
-    s_instance = 0;
-}
-
-}
-

Modified: trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h	2011-08-13 03:26:43 UTC (rev 93013)
@@ -32,18 +32,9 @@
 
 namespace WebCore {
 
-class SharedGraphicsContext3D : public RefCounted<SharedGraphicsContext3D> {
+class SharedGraphicsContext3D {
 public:
-    static PassRefPtr<SharedGraphicsContext3D> create(HostWindow*);
-    ~SharedGraphicsContext3D();
-
-    GraphicsContext3D* context() const { return m_context.get(); }
-
-private:
-    explicit SharedGraphicsContext3D(PassRefPtr<GraphicsContext3D>);
-
-    RefPtr<GraphicsContext3D> m_context;
-    static SharedGraphicsContext3D* s_instance;
+    static GraphicsContext3D* create(HostWindow*);
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2011-08-13 03:26:43 UTC (rev 93013)
@@ -1203,11 +1203,21 @@
                                            WebCoreFloatToSkScalar(h));
 }
 
-void GraphicsContext::setGraphicsContext3D(GraphicsContext3D* context, DrawingBuffer* framebuffer, const IntSize& size)
+void GraphicsContext::setGraphicsContext3D(GraphicsContext3D* context, DrawingBuffer* drawingBuffer, const IntSize& size)
 {
-    platformContext()->setGraphicsContext3D(context, framebuffer, size);
+    platformContext()->setGraphicsContext3D(context, drawingBuffer, size);
 }
 
+bool GraphicsContext::isAcceleratedContext() const
+{
+    return platformContext()->isAccelerated();
+}
+
+bool GraphicsContext::paintsIntoImageBuffer() const
+{
+    return platformContext()->paintsIntoImageBuffer();
+}
+
 #if PLATFORM(CHROMIUM) && OS(DARWIN)
 CGColorSpaceRef deviceRGBColorSpaceRef()
 {

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp	2011-08-13 03:26:43 UTC (rev 93013)
@@ -265,7 +265,7 @@
     SkCanvas* canvas = platformContext->canvas();
 
     ResamplingMode resampling;
-    if (platformContext->useSkiaGPU())
+    if (platformContext->isAccelerated())
         resampling = RESAMPLE_LINEAR;
     else
         resampling = platformContext->printing() ? RESAMPLE_NONE :
@@ -365,7 +365,7 @@
 
     // Compute the resampling mode.
     ResamplingMode resampling;
-    if (context->platformContext()->useSkiaGPU())
+    if (context->platformContext()->isAccelerated())
         resampling = RESAMPLE_LINEAR;
     else {
         if (context->platformContext()->printing())

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2011-08-13 03:26:43 UTC (rev 93013)
@@ -575,7 +575,7 @@
 #if ENABLE(SKIA_TEXT)
     return false;
 #else
-    if (useSkiaGPU())
+    if (isAccelerated())
         return false;
     return skia::SupportsPlatformPaint(m_canvas);
 #endif
@@ -682,4 +682,9 @@
         m_gpuContext->makeContextCurrent();
 }
 
+bool PlatformContextSkia::paintsIntoImageBuffer() const
+{
+    return m_gpuContext ? m_gpuContext->paintsIntoCanvasBuffer() : true;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h (93012 => 93013)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2011-08-13 02:40:51 UTC (rev 93012)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2011-08-13 03:26:43 UTC (rev 93013)
@@ -177,8 +177,9 @@
     void clearImageResamplingHint();
     bool hasImageResamplingHint() const;
 
-    bool useSkiaGPU() const { return m_gpuContext; }
+    bool isAccelerated() const { return m_gpuContext; }
     void setGraphicsContext3D(GraphicsContext3D*, DrawingBuffer*, const IntSize&);
+    bool paintsIntoImageBuffer() const;
     void makeGrContextCurrent();
 
 private:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to