Title: [87167] trunk/Source
Revision
87167
Author
al...@chromium.org
Date
2011-05-24 10:41:33 -0700 (Tue, 24 May 2011)

Log Message

2011-05-24  Alok Priyadarshi  <al...@chromium.org>

        Reviewed by James Robinson.

        Enable skia gpu rendering for content layers
        https://bugs.webkit.org/show_bug.cgi?id=56749

        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
        (WebKit::WebViewImpl::reallocateRenderer):
2011-05-24  Alok Priyadarshi  <al...@chromium.org>

        Reviewed by James Robinson.

        Enable skia gpu rendering for content layers
        https://bugs.webkit.org/show_bug.cgi?id=56749

        This patch adds gpu accelerated rendering for content and root layers.
        Layer textures are updated in two stages:
        1. Paint: The non-accelerated path paints the layer contents into a bitmap.
                  The accelerated path paints into an SkPicture, which is essentially a display list.
        2. Upload: The non-accelerated path uploads the pixels obtained in the first stage to a texture.
                   The accelerated path renders the picture directly into the texture.

        The accelerated path can be enabled by --enable-accelerated-drawing command-line flag in chromium.
        Note that this patch does not accelerate the CG path on mac. We have two options here - use skia or accelrate CG path.
        Any bugs should be caught by layout tests.

        * platform/graphics/chromium/ContentLayerChromium.cpp:
        (WebCore::ContentLayerChromium::createTextureUpdater):
        * platform/graphics/chromium/LayerRendererChromium.cpp:
        (WebCore::LayerRendererChromium::create):
        (WebCore::LayerRendererChromium::LayerRendererChromium):
        (WebCore::LayerRendererChromium::skiaContext):
        (WebCore::LayerRendererChromium::updateAndDrawLayers):
        (WebCore::LayerRendererChromium::createRootLayerTextureUpdater):
        * platform/graphics/chromium/LayerRendererChromium.h:
        (WebCore::LayerRendererChromium::acceleratedDrawing):
        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
        (WebCore::LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture):
        (WebCore::LayerTextureUpdaterSkPicture::~LayerTextureUpdaterSkPicture):
        (WebCore::LayerTextureUpdaterSkPicture::prepareToUpdate):
        (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
        (WebCore::LayerTextureUpdaterSkPicture::deleteFrameBuffer):
        (WebCore::LayerTextureUpdaterSkPicture::createFrameBuffer):
        (WebCore::LayerTextureUpdaterSkPicture::clearFrameBuffer):
        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
        (WebCore::LayerTextureUpdaterSkPicture::orientation):
        * platform/graphics/chromium/LayerTilerChromium.cpp:
        (WebCore::LayerTilerChromium::updateRect):
        (WebCore::LayerTilerChromium::draw):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87166 => 87167)


--- trunk/Source/WebCore/ChangeLog	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebCore/ChangeLog	2011-05-24 17:41:33 UTC (rev 87167)
@@ -1,3 +1,45 @@
+2011-05-24  Alok Priyadarshi  <al...@chromium.org>
+
+        Reviewed by James Robinson.
+
+        Enable skia gpu rendering for content layers
+        https://bugs.webkit.org/show_bug.cgi?id=56749
+
+        This patch adds gpu accelerated rendering for content and root layers.
+        Layer textures are updated in two stages:
+        1. Paint: The non-accelerated path paints the layer contents into a bitmap.
+                  The accelerated path paints into an SkPicture, which is essentially a display list.
+        2. Upload: The non-accelerated path uploads the pixels obtained in the first stage to a texture.
+                   The accelerated path renders the picture directly into the texture.
+
+        The accelerated path can be enabled by --enable-accelerated-drawing command-line flag in chromium.
+        Note that this patch does not accelerate the CG path on mac. We have two options here - use skia or accelrate CG path.
+        Any bugs should be caught by layout tests.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::createTextureUpdater):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::create):
+        (WebCore::LayerRendererChromium::LayerRendererChromium):
+        (WebCore::LayerRendererChromium::skiaContext):
+        (WebCore::LayerRendererChromium::updateAndDrawLayers):
+        (WebCore::LayerRendererChromium::createRootLayerTextureUpdater):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (WebCore::LayerRendererChromium::acceleratedDrawing):
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
+        (WebCore::LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture):
+        (WebCore::LayerTextureUpdaterSkPicture::~LayerTextureUpdaterSkPicture):
+        (WebCore::LayerTextureUpdaterSkPicture::prepareToUpdate):
+        (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
+        (WebCore::LayerTextureUpdaterSkPicture::deleteFrameBuffer):
+        (WebCore::LayerTextureUpdaterSkPicture::createFrameBuffer):
+        (WebCore::LayerTextureUpdaterSkPicture::clearFrameBuffer):
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
+        (WebCore::LayerTextureUpdaterSkPicture::orientation):
+        * platform/graphics/chromium/LayerTilerChromium.cpp:
+        (WebCore::LayerTilerChromium::updateRect):
+        (WebCore::LayerTilerChromium::draw):
+
 2011-05-24  Pavel Podivilov  <podivi...@chromium.org>
 
         Reviewed by Yury Semikhatsky.

Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp (87166 => 87167)


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-05-24 17:41:33 UTC (rev 87167)
@@ -128,6 +128,10 @@
 PassOwnPtr<LayerTextureUpdater> ContentLayerChromium::createTextureUpdater()
 {
     OwnPtr<LayerPainterChromium> painter = adoptPtr(new ContentLayerPainter(m_owner));
+#if USE(SKIA)
+    if (layerRenderer()->accelerateDrawing())
+        return adoptPtr(new LayerTextureUpdaterSkPicture(layerRendererContext(), painter.release(), layerRenderer()->skiaContext()));
+#endif
     return adoptPtr(new LayerTextureUpdaterBitmap(layerRendererContext(), painter.release(), layerRenderer()->contextSupportsMapSub()));
 }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (87166 => 87167)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-05-24 17:41:33 UTC (rev 87167)
@@ -51,6 +51,8 @@
 #include "WebGLLayerChromium.h"
 #include "cc/CCLayerImpl.h"
 #if USE(SKIA)
+#include "Extensions3D.h"
+#include "GrContext.h"
 #include "NativeImageSkia.h"
 #include "PlatformContextSkia.h"
 #elif USE(CG)
@@ -96,12 +98,12 @@
 
 }
 
-PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<LayerPainterChromium> contentPaint)
+PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing)
 {
     if (!context)
         return 0;
 
-    RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromium(context, contentPaint)));
+    RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromium(context, contentPaint, accelerateDrawing)));
     if (!layerRenderer->hardwareCompositing())
         return 0;
 
@@ -109,9 +111,11 @@
 }
 
 LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> context,
-                                             PassOwnPtr<LayerPainterChromium> contentPaint)
+                                             PassOwnPtr<LayerPainterChromium> contentPaint,
+                                             bool accelerateDrawing)
     : m_viewportScrollPosition(IntPoint(-1, -1))
     , m_rootLayer(0)
+    , m_accelerateDrawing(accelerateDrawing)
     , m_currentRenderSurface(0)
     , m_offscreenFramebufferId(0)
     , m_compositeOffscreen(false)
@@ -127,8 +131,7 @@
         m_context->getExtensions()->ensureEnabled("GL_CHROMIUM_map_sub");
     m_hardwareCompositing = initializeSharedObjects();
 
-    OwnPtr<LayerTextureUpdater> textureUpdater = adoptPtr(new LayerTextureUpdaterBitmap(m_context.get(), contentPaint, m_contextSupportsMapSub));
-    m_rootLayerContentTiler = LayerTilerChromium::create(this, textureUpdater.release(), IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
+    m_rootLayerContentTiler = LayerTilerChromium::create(this, createRootLayerTextureUpdater(contentPaint), IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
     ASSERT(m_rootLayerContentTiler);
 
     m_headsUpDisplay = CCHeadsUpDisplay::create(this);
@@ -145,6 +148,25 @@
     return m_context.get();
 }
 
+#if USE(SKIA)
+GrContext* LayerRendererChromium::skiaContext()
+{
+    if (!m_skiaContext) {
+        WebCore::Extensions3D* extensions = m_context->getExtensions();
+        extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888");
+        extensions->ensureEnabled("GL_EXT_read_format_bgra");
+
+        m_skiaContext = adoptPtr(GrContext::CreateGLShaderContext());
+        // Limit the number of textures we hold in the bitmap->texture cache.
+        static const int maxTextureCacheCount = 512;
+        // Limit the bytes allocated toward textures in the bitmap->texture cache.
+        static const size_t maxTextureCacheBytes = 50 * 1024 * 1024;
+        m_skiaContext->setTextureCacheLimits(maxTextureCacheCount, maxTextureCacheBytes);
+    }
+    return m_skiaContext.get();
+}
+#endif
+
 void LayerRendererChromium::debugGLCall(GraphicsContext3D* context, const char* command, const char* file, int line)
 {
     unsigned long error = context->getError();
@@ -260,6 +282,15 @@
         copyOffscreenTextureToDisplay();
 }
 
+PassOwnPtr<LayerTextureUpdater> LayerRendererChromium::createRootLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
+{
+#if USE(SKIA)
+    if (accelerateDrawing())
+        return adoptPtr(new LayerTextureUpdaterSkPicture(context(), painter, skiaContext()));
+#endif
+    return adoptPtr(new LayerTextureUpdaterBitmap(context(), painter, contextSupportsMapSub()));
+}
+
 void LayerRendererChromium::updateLayers(LayerList& renderSurfaceLayerList)
 {
     TRACE_EVENT("LayerRendererChromium::updateLayers", this, 0);

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (87166 => 87167)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2011-05-24 17:41:33 UTC (rev 87167)
@@ -58,6 +58,10 @@
 #include <wtf/RetainPtr.h>
 #endif
 
+#if USE(SKIA)
+class GrContext;
+#endif
+
 namespace WebCore {
 
 class CCHeadsUpDisplay;
@@ -69,12 +73,15 @@
 // Class that handles drawing of composited render layers using GL.
 class LayerRendererChromium : public RefCounted<LayerRendererChromium> {
 public:
-    static PassRefPtr<LayerRendererChromium> create(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint);
+    static PassRefPtr<LayerRendererChromium> create(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing);
 
     ~LayerRendererChromium();
 
     GraphicsContext3D* context();
     bool contextSupportsMapSub() const { return m_contextSupportsMapSub; }
+#if USE(SKIA)
+    GrContext* skiaContext();
+#endif
 
     void invalidateRootLayerRect(const IntRect& dirtyRect);
 
@@ -101,6 +108,7 @@
     void transferRootLayer(LayerRendererChromium* other);
 
     bool hardwareCompositing() const { return m_hardwareCompositing; }
+    bool accelerateDrawing() const { return m_accelerateDrawing; } 
 
     void setCompositeOffscreen(bool);
     bool isCompositingOffscreen() const { return m_compositeOffscreen; }
@@ -150,8 +158,10 @@
     // FIXME: This needs to be moved to the CCViewImpl when that class exists.
     RefPtr<CCLayerImpl> m_rootCCLayerImpl;
 
-    LayerRendererChromium(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint);
+    LayerRendererChromium(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing);
 
+    PassOwnPtr<LayerTextureUpdater> createRootLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
+
     void updateLayers(LayerList& renderSurfaceLayerList);
     void updateRootLayerContents();
     void updatePropertiesAndRenderSurfaces(CCLayerImpl*, const TransformationMatrix& parentMatrix, LayerList& renderSurfaceLayerList, LayerList& layers);
@@ -193,9 +203,9 @@
     OwnPtr<LayerTilerChromium> m_rootLayerContentTiler;
 
     bool m_hardwareCompositing;
+    bool m_accelerateDrawing;
 
     RenderSurfaceChromium* m_currentRenderSurface;
-
     unsigned m_offscreenFramebufferId;
     bool m_compositeOffscreen;
 
@@ -222,8 +232,11 @@
     OwnPtr<CCHeadsUpDisplay> m_headsUpDisplay;
 
     RefPtr<GraphicsContext3D> m_context;
+#if USE(SKIA)
+    OwnPtr<GrContext> m_skiaContext;
+#endif
+
     ChildContextMap m_childContexts;
-
     // If true, the child contexts were copied to the compositor texture targets
     // and the compositor will need to wait on the proper latches before using
     // the target textures. If false, the compositor is reusing the textures

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp (87166 => 87167)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-05-24 17:41:33 UTC (rev 87167)
@@ -35,6 +35,14 @@
 #include "LayerTexture.h"
 #include "TraceEvent.h"
 
+#if USE(SKIA)
+#include "GrContext.h"
+#include "PlatformContextSkia.h"
+#include "SkCanvas.h"
+#include "SkGpuDevice.h"
+#include "SkGpuDeviceFactory.h"
+#endif // USE(SKIA)
+
 namespace WebCore {
 
 LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter)
@@ -81,6 +89,142 @@
     m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, context());
 }
 
+#if USE(SKIA)
+LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
+    : LayerTextureUpdaterCanvas(context, painter)
+    , m_skiaContext(skiaContext)
+    , m_createFrameBuffer(false)
+    , m_fbo(0)
+    , m_stencilBuffer(0)
+{
+}
+
+LayerTextureUpdaterSkPicture::~LayerTextureUpdaterSkPicture()
+{
+    deleteFrameBuffer();
+}
+
+void LayerTextureUpdaterSkPicture::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels)
+{
+    // Need to recreate FBO if tile-size changed.
+    // Note that we cannot create the framebuffer here because this function does not run in compositor thread
+    // and hence does not have access to compositor context.
+    if (m_bufferSize != tileSize) {
+        m_createFrameBuffer = true;
+        m_bufferSize = tileSize;
+    }
+
+    SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height());
+    PlatformContextSkia platformContext(canvas);
+    GraphicsContext graphicsContext(&platformContext);
+    paintContents(graphicsContext, contentRect);
+    m_picture.endRecording();
+}
+
+void LayerTextureUpdaterSkPicture::updateTextureRect(LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
+{
+    if (m_createFrameBuffer) {
+        deleteFrameBuffer();
+        createFrameBuffer();
+        m_createFrameBuffer = false;
+    }
+    if (!m_fbo)
+        return;
+
+    // Bind texture.
+    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+    texture->framebufferTexture2D();
+    ASSERT(context()->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE);
+
+    context()->viewport(0, 0, m_bufferSize.width(), m_bufferSize.height());
+    clearFrameBuffer();
+
+    // Notify SKIA to sync its internal GL state.
+    m_skiaContext->resetContext();
+    // Offset from source rectangle to this destination rectangle.
+    IntPoint offset(sourceRect.x() - contentRect().x(), sourceRect.y() - contentRect().y());
+    m_canvas->save();
+    m_canvas->translate(-offset.x(), -offset.y());
+    m_canvas->drawPicture(m_picture);
+    m_canvas->restore();
+    // Flush SKIA context so that all the rendered stuff appears on the texture.
+    m_skiaContext->flush(GrContext::kForceCurrentRenderTarget_FlushBit);
+
+    // Unbind texture.
+    context()->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, 0, 0);
+    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0);
+}
+
+void LayerTextureUpdaterSkPicture::deleteFrameBuffer()
+{
+    m_canvas.clear();
+
+    if (m_stencilBuffer)
+        context()->deleteRenderbuffer(m_stencilBuffer);
+    if (m_fbo)
+        context()->deleteFramebuffer(m_fbo);
+}
+
+bool LayerTextureUpdaterSkPicture::createFrameBuffer()
+{
+    ASSERT(!m_fbo);
+    ASSERT(!m_bufferSize.isEmpty());
+
+    // SKIA needs stencil buffer for path rendering.
+    // Make sure it is available.
+    GraphicsContext3D::Attributes contextAttribs = context()->getContextAttributes();
+    if (!contextAttribs.stencil)
+        return false;
+
+    // Create and bind a frame-buffer-object.
+    m_fbo = context()->createFramebuffer();
+    if (!m_fbo)
+        return false;
+    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+
+    // We just need to create a stencil buffer for FBO.
+    // The color buffer (texture) will be provided by tiles.
+    // SKIA does not need depth buffer.
+    m_stencilBuffer = context()->createRenderbuffer();
+    if (!m_stencilBuffer) {
+        context()->deleteFramebuffer(m_fbo);
+        m_fbo = 0;
+        return false;
+    }
+    context()->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer);
+    context()->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_bufferSize.width(), m_bufferSize.height());
+    context()->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_stencilBuffer);
+
+    // Create a skia gpu canvas.
+    GrPlatformSurfaceDesc targetDesc;
+    targetDesc.reset();
+    targetDesc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
+    targetDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit;
+    targetDesc.fWidth = m_bufferSize.width();
+    targetDesc.fHeight = m_bufferSize.height();
+    targetDesc.fConfig = kRGBA_8888_GrPixelConfig;
+    targetDesc.fStencilBits = 8;
+    targetDesc.fPlatformRenderTarget = m_fbo;
+    SkAutoTUnref<GrRenderTarget> target(static_cast<GrRenderTarget*>(m_skiaContext->createPlatformSurface(targetDesc)));
+    SkAutoTUnref<SkDeviceFactory> factory(new SkGpuDeviceFactory(m_skiaContext, target.get()));
+    SkAutoTUnref<SkDevice> device(factory.get()->newDevice(0, SkBitmap::kARGB_8888_Config, m_bufferSize.width(), m_bufferSize.height(), false, false));        
+    m_canvas = adoptPtr(new SkCanvas(factory.get()));
+    m_canvas->setDevice(device.get());
+
+    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0);
+    return true;
+}
+
+void LayerTextureUpdaterSkPicture::clearFrameBuffer()
+{
+#ifndef NDEBUG
+    // Clear to green to make it easier to spot unrendered regions.
+    context()->clearColor(0, 1, 0, 1);
+    context()->clear(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT);
+#endif
+}
+#endif // SKIA
+
 } // namespace WebCore
 #endif // USE(ACCELERATED_COMPOSITING)
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h (87166 => 87167)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-05-24 17:41:33 UTC (rev 87167)
@@ -29,11 +29,20 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
+#include "GraphicsTypes3D.h"
 #include "LayerTextureSubImage.h"
 #include "LayerTextureUpdater.h"
 #include "PlatformCanvas.h"
 #include <wtf/PassOwnPtr.h>
 
+#if USE(SKIA)
+#include "SkPicture.h"
+
+class GrContext;
+class SkCanvas;
+class SkPicture;
+#endif
+
 namespace WebCore {
 
 class GraphicsContext3D;
@@ -69,6 +78,32 @@
     LayerTextureSubImage m_texSubImage;
 };
 
+#if USE(SKIA)
+class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas {
+public:
+    LayerTextureUpdaterSkPicture(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, GrContext*);
+    virtual ~LayerTextureUpdaterSkPicture();
+
+    virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; }
+    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
+    virtual void updateTextureRect(LayerTexture*, const IntRect& sourceRect, const IntRect& destRect);
+
+private:
+    void deleteFrameBuffer();
+    bool createFrameBuffer();
+    void clearFrameBuffer();
+
+    GrContext* m_skiaContext; // SKIA graphics context.
+
+    bool m_createFrameBuffer; // Need to create FBO if true.
+    SkPicture m_picture; // Recording canvas.
+    IntSize m_bufferSize; // Frame buffer size.
+    Platform3DObject m_fbo; // Frame buffer id.
+    Platform3DObject m_stencilBuffer;
+    OwnPtr<SkCanvas> m_canvas; // GPU accelerated canvas.
+};
+#endif // SKIA
+
 } // namespace WebCore
 #endif // USE(ACCELERATED_COMPOSITING)
 #endif // LayerTextureUpdaterCanvas_h

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp (87166 => 87167)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp	2011-05-24 17:41:33 UTC (rev 87167)
@@ -318,6 +318,7 @@
             const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
             GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
             GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
+            GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0));
 
             m_textureUpdater->updateTextureRect(tile->texture(), sourceRect, destRect);
             tile->clearDirty();
@@ -339,6 +340,7 @@
     const LayerTilerChromium::Program* program = layerRenderer()->tilerProgram();
     GLC(context, context->useProgram(program->program()));
     GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
+    GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
 
     int left, top, right, bottom;
     contentRectToTileIndices(contentRect, left, top, right, bottom);

Modified: trunk/Source/WebKit/chromium/ChangeLog (87166 => 87167)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-05-24 17:41:33 UTC (rev 87167)
@@ -1,3 +1,14 @@
+2011-05-24  Alok Priyadarshi  <al...@chromium.org>
+
+        Reviewed by James Robinson.
+
+        Enable skia gpu rendering for content layers
+        https://bugs.webkit.org/show_bug.cgi?id=56749
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+        (WebKit::WebViewImpl::reallocateRenderer):
+
 2011-05-24  Mikhail Naganov  <mnaga...@chromium.org>
 
         Reviewed by Yury Semikhatsky.

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (87166 => 87167)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-05-24 17:36:47 UTC (rev 87166)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-05-24 17:41:33 UTC (rev 87167)
@@ -2478,7 +2478,7 @@
         }
 
 
-        m_layerRenderer = LayerRendererChromium::create(context.release(), WebViewImplContentPainter::create(this));
+        m_layerRenderer = LayerRendererChromium::create(context.release(), WebViewImplContentPainter::create(this), m_page->settings()->acceleratedDrawingEnabled());
         if (m_layerRenderer) {
             m_client->didActivateAcceleratedCompositing(true);
             m_isAcceleratedCompositingActive = true;
@@ -2522,7 +2522,7 @@
         newContext = GraphicsContext3D::create(
             getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow);
     // GraphicsContext3D::create might fail and return 0, in that case LayerRendererChromium::create will also return 0.
-    RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(newContext, WebViewImplContentPainter::create(this));
+    RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(newContext, WebViewImplContentPainter::create(this), m_page->settings()->acceleratedDrawingEnabled());
 
     // Reattach the root layer.  Child layers will get reattached as a side effect of updateLayersRecursive.
     if (layerRenderer) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to