Title: [93615] trunk/Source/WebCore
Revision
93615
Author
[email protected]
Date
2011-08-23 11:08:46 -0700 (Tue, 23 Aug 2011)

Log Message

[chromium] Remove LayerRendererChromium references from TiledLayerChromium
https://bugs.webkit.org/show_bug.cgi?id=66433

Reviewed by James Robinson.

Covered by existing tests.

Updated TiledLayerChromium and the texture updater classes to not
access LayerRendererChromium or cache GraphicsContext3D. Some settings
like max texture size were moved from LayerRendererChromium to
CCLayerTreeHost in order to facilitate this refactoring.

LayerTextureUpdaterSkPicture has been #ifdef'd to only work when the
compositor is not threaded. It will need to be refactored more in
order to not own graphics resources from the main thread.

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::paintContentsIfDirty):
(WebCore::ContentLayerChromium::createTextureUpdater):
* platform/graphics/chromium/ContentLayerChromium.h:
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerTextureUpdater::create):
(WebCore::ImageLayerTextureUpdater::updateTextureRect):
(WebCore::ImageLayerTextureUpdater::ImageLayerTextureUpdater):
(WebCore::ImageLayerChromium::paintContentsIfDirty):
(WebCore::ImageLayerChromium::createTextureUpdater):
* platform/graphics/chromium/ImageLayerChromium.h:
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::setLayerRenderer):
(WebCore::LayerChromium::setLayerTreeHost):
* platform/graphics/chromium/LayerChromium.h:
* platform/graphics/chromium/LayerRendererChromium.cpp:
* platform/graphics/chromium/LayerRendererChromium.h:
* platform/graphics/chromium/LayerTextureUpdater.h:
(WebCore::LayerTextureUpdater::LayerTextureUpdater):
* platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
(WebCore::LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas):
(WebCore::LayerTextureUpdaterBitmap::create):
(WebCore::LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap):
(WebCore::LayerTextureUpdaterBitmap::updateTextureRect):
(WebCore::LayerTextureUpdaterSkPicture::create):
(WebCore::LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture):
(WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
* platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
(WebCore::LayerTextureUpdaterSkPicture::context):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::setLayerTreeHost):
(WebCore::TiledLayerChromium::updateCompositorResources):
(WebCore::TiledLayerChromium::invalidateRect):
(WebCore::TiledLayerChromium::prepareToUpdate):
* platform/graphics/chromium/TiledLayerChromium.h:
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::CCLayerTreeHost):
(WebCore::CCLayerTreeHost::initialize):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::CCLayerTreeHost::layerRenderer):
(WebCore::CCLayerTreeHost::contextSupportsMapSub):
(WebCore::CCLayerTreeHost::maxTextureSize):
(WebCore::CCLayerTreeHost::bestTextureFormat):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (93614 => 93615)


--- trunk/Source/WebCore/ChangeLog	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/ChangeLog	2011-08-23 18:08:46 UTC (rev 93615)
@@ -1,3 +1,65 @@
+2011-08-23  Adrienne Walker  <[email protected]>
+
+        [chromium] Remove LayerRendererChromium references from TiledLayerChromium
+        https://bugs.webkit.org/show_bug.cgi?id=66433
+
+        Reviewed by James Robinson.
+
+        Covered by existing tests.
+
+        Updated TiledLayerChromium and the texture updater classes to not
+        access LayerRendererChromium or cache GraphicsContext3D. Some settings
+        like max texture size were moved from LayerRendererChromium to
+        CCLayerTreeHost in order to facilitate this refactoring.
+
+        LayerTextureUpdaterSkPicture has been #ifdef'd to only work when the
+        compositor is not threaded. It will need to be refactored more in
+        order to not own graphics resources from the main thread.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::paintContentsIfDirty):
+        (WebCore::ContentLayerChromium::createTextureUpdater):
+        * platform/graphics/chromium/ContentLayerChromium.h:
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        (WebCore::ImageLayerTextureUpdater::create):
+        (WebCore::ImageLayerTextureUpdater::updateTextureRect):
+        (WebCore::ImageLayerTextureUpdater::ImageLayerTextureUpdater):
+        (WebCore::ImageLayerChromium::paintContentsIfDirty):
+        (WebCore::ImageLayerChromium::createTextureUpdater):
+        * platform/graphics/chromium/ImageLayerChromium.h:
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::setLayerRenderer):
+        (WebCore::LayerChromium::setLayerTreeHost):
+        * platform/graphics/chromium/LayerChromium.h:
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        * platform/graphics/chromium/LayerTextureUpdater.h:
+        (WebCore::LayerTextureUpdater::LayerTextureUpdater):
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
+        (WebCore::LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas):
+        (WebCore::LayerTextureUpdaterBitmap::create):
+        (WebCore::LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap):
+        (WebCore::LayerTextureUpdaterBitmap::updateTextureRect):
+        (WebCore::LayerTextureUpdaterSkPicture::create):
+        (WebCore::LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture):
+        (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
+        (WebCore::LayerTextureUpdaterSkPicture::context):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::setLayerTreeHost):
+        (WebCore::TiledLayerChromium::updateCompositorResources):
+        (WebCore::TiledLayerChromium::invalidateRect):
+        (WebCore::TiledLayerChromium::prepareToUpdate):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::CCLayerTreeHost):
+        (WebCore::CCLayerTreeHost::initialize):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::CCLayerTreeHost::layerRenderer):
+        (WebCore::CCLayerTreeHost::contextSupportsMapSub):
+        (WebCore::CCLayerTreeHost::maxTextureSize):
+        (WebCore::CCLayerTreeHost::bestTextureFormat):
+
 2011-08-23  Julien Chaffraix  <[email protected]>
 
         Reduce the amount of RenderLayer rectangles' update when scrolling

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


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-08-23 18:08:46 UTC (rev 93615)
@@ -38,6 +38,7 @@
 #include "LayerRendererChromium.h"
 #include "LayerTextureUpdaterCanvas.h"
 #include "PlatformBridge.h"
+#include "cc/CCLayerTreeHost.h"
 #include <wtf/CurrentTime.h>
 
 namespace WebCore {
@@ -94,7 +95,6 @@
 void ContentLayerChromium::paintContentsIfDirty()
 {
     ASSERT(drawsContent());
-    ASSERT(layerRenderer());
 
     updateTileSizeAndTilingOption();
 
@@ -118,18 +118,18 @@
     return m_owner && m_owner->drawsContent() && TiledLayerChromium::drawsContent();
 }
 
-void ContentLayerChromium::createTextureUpdaterIfNeeded()
+void ContentLayerChromium::createTextureUpdater(const CCLayerTreeHost* host)
 {
-    if (m_textureUpdater)
-        return;
-
+#if !USE(THREADED_COMPOSITING)
 #if USE(SKIA)
-    if (layerRenderer()->settings().acceleratePainting) {
-        m_textureUpdater = LayerTextureUpdaterSkPicture::create(layerRendererContext(), ContentLayerPainter::create(m_owner), layerRenderer()->skiaContext());
+    if (host->settings().acceleratePainting) {
+        m_textureUpdater = LayerTextureUpdaterSkPicture::create(ContentLayerPainter::create(m_owner), host->layerRenderer()->skiaContext());
         return;
     }
-#endif
-    m_textureUpdater = LayerTextureUpdaterBitmap::create(layerRendererContext(), ContentLayerPainter::create(m_owner), layerRenderer()->contextSupportsMapSub());
+#endif // SKIA
+#endif // !THREADED_COMPOSITING
+
+    m_textureUpdater = LayerTextureUpdaterBitmap::create(ContentLayerPainter::create(m_owner), host->contextSupportsMapSub());
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h	2011-08-23 18:08:46 UTC (rev 93615)
@@ -58,7 +58,7 @@
 
     virtual void cleanupResources();
     virtual bool drawsContent() const;
-    virtual void createTextureUpdaterIfNeeded();
+    virtual void createTextureUpdater(const CCLayerTreeHost*);
     virtual LayerTextureUpdater* textureUpdater() const { return m_textureUpdater.get(); }
 
     OwnPtr<LayerTextureUpdater> m_textureUpdater;

Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-08-23 18:08:46 UTC (rev 93615)
@@ -34,22 +34,22 @@
 
 #include "ImageLayerChromium.h"
 
-#include "cc/CCLayerImpl.h"
 #include "Image.h"
-#include "LayerRendererChromium.h"
-#include "ManagedTexture.h"
 #include "LayerTextureSubImage.h"
 #include "LayerTextureUpdater.h"
+#include "ManagedTexture.h"
 #include "PlatformColor.h"
+#include "cc/CCLayerImpl.h"
+#include "cc/CCLayerTreeHost.h"
 
 namespace WebCore {
 
 class ImageLayerTextureUpdater : public LayerTextureUpdater {
     WTF_MAKE_NONCOPYABLE(ImageLayerTextureUpdater);
 public:
-    static PassOwnPtr<ImageLayerTextureUpdater> create(GraphicsContext3D* context, bool useMapTexSubImage)
+    static PassOwnPtr<ImageLayerTextureUpdater> create(bool useMapTexSubImage)
     {
-        return adoptPtr(new ImageLayerTextureUpdater(context, useMapTexSubImage));
+        return adoptPtr(new ImageLayerTextureUpdater(useMapTexSubImage));
     }
 
     virtual ~ImageLayerTextureUpdater() { }
@@ -67,9 +67,9 @@
         m_texSubImage.setSubImageSize(tileSize);
     }
 
-    virtual void updateTextureRect(ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
+    virtual void updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
     {
-        texture->bindTexture(context());
+        texture->bindTexture(context);
 
         // Source rect should never go outside the image pixels, even if this
         // is requested because the texture extends outside the image.
@@ -80,7 +80,7 @@
         clippedDestRect.move(clippedSourceRect.location() - sourceRect.location());
         clippedDestRect.setSize(clippedSourceRect.size());
 
-        m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, clippedDestRect, texture->format(), context());
+        m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, clippedDestRect, texture->format(), context);
     }
 
     void updateFromImage(NativeImagePtr nativeImage)
@@ -94,9 +94,8 @@
     }
 
 private:
-    ImageLayerTextureUpdater(GraphicsContext3D* context, bool useMapTexSubImage)
-        : LayerTextureUpdater(context)
-        , m_texSubImage(useMapTexSubImage)
+    explicit ImageLayerTextureUpdater(bool useMapTexSubImage)
+        : m_texSubImage(useMapTexSubImage)
     {
     }
 
@@ -147,8 +146,6 @@
 
 void ImageLayerChromium::paintContentsIfDirty()
 {
-    ASSERT(layerRenderer());
-
     if (!m_dirtyRect.isEmpty()) {
         m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame());
         updateTileSizeAndTilingOption();
@@ -182,10 +179,9 @@
     return m_contents && TiledLayerChromium::drawsContent();
 }
 
-void ImageLayerChromium::createTextureUpdaterIfNeeded()
+void ImageLayerChromium::createTextureUpdater(const CCLayerTreeHost* host)
 {
-    if (!m_textureUpdater)
-        m_textureUpdater = ImageLayerTextureUpdater::create(layerRendererContext(), layerRenderer()->contextSupportsMapSub());
+    m_textureUpdater = ImageLayerTextureUpdater::create(host->contextSupportsMapSub());
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h	2011-08-23 18:08:46 UTC (rev 93615)
@@ -64,7 +64,7 @@
     ImageLayerChromium(GraphicsLayerChromium* owner);
 
     virtual void cleanupResources();
-    virtual void createTextureUpdaterIfNeeded();
+    virtual void createTextureUpdater(const CCLayerTreeHost*);
     void setTilingOption(TilingOption);
 
     virtual LayerTextureUpdater* textureUpdater() const;

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2011-08-23 18:08:46 UTC (rev 93615)
@@ -105,8 +105,16 @@
         setNeedsDisplay();
     }
     m_layerRenderer = renderer;
+
+    // FIXME: Once setLayerRenderer is no longer needed on the LayerChromium
+    // tree, move this call to LayerRendererChromium::paintLayerContents.
+    setLayerTreeHost(renderer->owner());
 }
 
+void LayerChromium::setLayerTreeHost(CCLayerTreeHost*)
+{
+}
+
 void LayerChromium::setNeedsCommit()
 {
     // Call notifySyncRequired(), which for non-root layers plumbs through to

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2011-08-23 18:08:46 UTC (rev 93615)
@@ -53,6 +53,7 @@
 namespace WebCore {
 
 class CCLayerImpl;
+class CCLayerTreeHost;
 class GraphicsContext3D;
 class LayerRendererChromium;
 
@@ -157,6 +158,8 @@
     // FIXME, replace with CCLayerTreeHost.
     virtual void setLayerRenderer(LayerRendererChromium*);
 
+    virtual void setLayerTreeHost(CCLayerTreeHost*);
+
     void setOwner(GraphicsLayerChromium* owner) { m_owner = owner; }
 
     void setReplicaLayer(LayerChromium* layer) { m_replicaLayer = layer; }

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


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-08-23 18:08:46 UTC (rev 93615)
@@ -45,7 +45,6 @@
 #include "LayerTextureUpdaterCanvas.h"
 #include "NonCompositedContentHost.h"
 #include "NotImplemented.h"
-#include "PlatformColor.h"
 #include "RenderSurfaceChromium.h"
 #include "TextStream.h"
 #include "TextureManager.h"
@@ -534,11 +533,6 @@
     m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get());
 }
 
-GC3Denum LayerRendererChromium::bestTextureFormat()
-{
-    return PlatformColor::bestTextureFormat(context());
-}
-
 void LayerRendererChromium::viewportChanged()
 {
     if (m_context)

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h	2011-08-23 18:08:46 UTC (rev 93615)
@@ -42,6 +42,7 @@
 class LayerTextureUpdater {
     WTF_MAKE_NONCOPYABLE(LayerTextureUpdater);
 public:
+    LayerTextureUpdater() { }
     virtual ~LayerTextureUpdater() { }
 
     enum Orientation {
@@ -62,18 +63,7 @@
     // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red.
     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
-    virtual void updateTextureRect(ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
-
-protected:
-    explicit LayerTextureUpdater(GraphicsContext3D* context) : m_context(context) { }
-
-    GraphicsContext3D* context() const { return m_context; }
-
-private:
-    // The graphics context with which to update textures.
-    // It is assumed that the textures are either created in the same context
-    // or shared with this context.
-    GraphicsContext3D* m_context;
+    virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
 };
 
 } // namespace WebCore

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


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-08-23 18:08:46 UTC (rev 93615)
@@ -46,9 +46,8 @@
 
 namespace WebCore {
 
-LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter)
-    : LayerTextureUpdater(context)
-    , m_painter(painter)
+LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChromium> painter)
+    : m_painter(painter)
 {
 }
 
@@ -62,13 +61,13 @@
     m_contentRect = contentRect;
 }
 
-PassOwnPtr<LayerTextureUpdaterBitmap> LayerTextureUpdaterBitmap::create(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
+PassOwnPtr<LayerTextureUpdaterBitmap> LayerTextureUpdaterBitmap::create(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
 {
-    return adoptPtr(new LayerTextureUpdaterBitmap(context, painter, useMapTexSubImage));
+    return adoptPtr(new LayerTextureUpdaterBitmap(painter, useMapTexSubImage));
 }
 
-LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
-    : LayerTextureUpdaterCanvas(context, painter)
+LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
+    : LayerTextureUpdaterCanvas(painter)
     , m_texSubImage(useMapTexSubImage)
 {
 }
@@ -94,23 +93,25 @@
     paintContents(*canvasPainter.context(), contentRect);
 }
 
-void LayerTextureUpdaterBitmap::updateTextureRect(ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
+void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
 {
     PlatformCanvas::AutoLocker locker(&m_canvas);
 
-    texture->bindTexture(context());
-    m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context());
+    texture->bindTexture(context);
+    m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context);
 }
 
+#if !USE(THREADED_COMPOSITING)
 #if USE(SKIA)
-PassOwnPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
+PassOwnPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
 {
-    return adoptPtr(new LayerTextureUpdaterSkPicture(context, painter, skiaContext));
+    return adoptPtr(new LayerTextureUpdaterSkPicture(painter, skiaContext));
 }
 
-LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
-    : LayerTextureUpdaterCanvas(context, painter)
+LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
+    : LayerTextureUpdaterCanvas(painter)
     , m_skiaContext(skiaContext)
+    , m_context(0)
     , m_createFrameBuffer(false)
     , m_fbo(0)
     , m_depthStencilBuffer(0)
@@ -145,8 +146,11 @@
     m_picture.endRecording();
 }
 
-void LayerTextureUpdaterSkPicture::updateTextureRect(ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
+void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* compositorContext, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
 {
+    ASSERT(!m_context || m_context == compositorContext);
+    m_context = compositorContext;
+
     if (m_createFrameBuffer) {
         deleteFrameBuffer();
         createFrameBuffer();
@@ -250,7 +254,7 @@
     return true;
 }
 #endif // SKIA
+#endif // !THREADED_COMPOSITING
 
 } // namespace WebCore
 #endif // USE(ACCELERATED_COMPOSITING)
-

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


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-08-23 18:08:46 UTC (rev 93615)
@@ -51,11 +51,8 @@
 // A LayerTextureUpdater with an internal canvas.
 class LayerTextureUpdaterCanvas : public LayerTextureUpdater {
     WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterCanvas);
-public:
-    virtual ~LayerTextureUpdaterCanvas() { }
-
 protected:
-    LayerTextureUpdaterCanvas(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>);
+    explicit LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChromium>);
 
     void paintContents(GraphicsContext&, const IntRect& contentRect);
     const IntRect& contentRect() const { return m_contentRect; }
@@ -70,38 +67,40 @@
 class LayerTextureUpdaterBitmap : public LayerTextureUpdaterCanvas {
     WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterBitmap);
 public:
-    static PassOwnPtr<LayerTextureUpdaterBitmap> create(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
-    virtual ~LayerTextureUpdaterBitmap() { }
+    static PassOwnPtr<LayerTextureUpdaterBitmap> create(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
 
     virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
-    virtual void updateTextureRect(ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
+    virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
 
 private:
-    LayerTextureUpdaterBitmap(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
+    LayerTextureUpdaterBitmap(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
     PlatformCanvas m_canvas;
     LayerTextureSubImage m_texSubImage;
 };
 
+#if !USE(THREADED_COMPOSITING)
 #if USE(SKIA)
 class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas {
     WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterSkPicture);
 public:
-    static PassOwnPtr<LayerTextureUpdaterSkPicture> create(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, GrContext*);
+    static PassOwnPtr<LayerTextureUpdaterSkPicture> create(PassOwnPtr<LayerPainterChromium>, GrContext*);
     virtual ~LayerTextureUpdaterSkPicture();
 
     virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; }
     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
-    virtual void updateTextureRect(ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
+    virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
 
 private:
-    LayerTextureUpdaterSkPicture(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, GrContext*);
+    LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium>, GrContext*);
     void deleteFrameBuffer();
     bool createFrameBuffer();
+    GraphicsContext3D* context() { return m_context; }
 
     GrContext* m_skiaContext; // SKIA graphics context.
+    GraphicsContext3D* m_context;
 
     bool m_createFrameBuffer; // Need to create FBO if true.
     SkPicture m_picture; // Recording canvas.
@@ -111,8 +110,8 @@
     OwnPtr<SkCanvas> m_canvas; // GPU accelerated canvas.
 };
 #endif // SKIA
+#endif // !THREADED_COMPOSITING
 
 } // namespace WebCore
 #endif // USE(ACCELERATED_COMPOSITING)
 #endif // LayerTextureUpdaterCanvas_h
-

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-08-23 18:08:46 UTC (rev 93615)
@@ -92,12 +92,6 @@
     m_updateRect = IntRect();
 }
 
-void TiledLayerChromium::setLayerRenderer(LayerRendererChromium* layerRenderer)
-{
-    LayerChromium::setLayerRenderer(layerRenderer);
-    createTilerIfNeeded();
-}
-
 void TiledLayerChromium::updateTileSizeAndTilingOption()
 {
     if (!m_tiler)
@@ -140,17 +134,16 @@
     return !m_skipsDraw;
 }
 
-void TiledLayerChromium::createTilerIfNeeded()
+void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
 {
     if (m_tiler)
         return;
 
-    createTextureUpdaterIfNeeded();
+    createTextureUpdater(host);
 
-    m_textureFormat = layerRenderer()->bestTextureFormat();
+    m_textureFormat = host->bestTextureFormat();
     m_textureOrientation = textureUpdater()->orientation();
     m_sampledTexelFormat = textureUpdater()->sampledTexelFormat(m_textureFormat);
-
     m_tiler = CCLayerTilingData::create(
         IntSize(defaultTileSize, defaultTileSize),
         isRootLayer() ? CCLayerTilingData::NoBorderTexels : CCLayerTilingData::HasBorderTexels);
@@ -208,7 +201,7 @@
             GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
             GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0));
 
-            textureUpdater()->updateTextureRect(tile->texture(), sourceRect, destRect);
+            textureUpdater()->updateTextureRect(context, tile->texture(), sourceRect, destRect);
             tile->clearDirty();
         }
     }
@@ -327,7 +320,7 @@
 
 void TiledLayerChromium::invalidateRect(const IntRect& contentRect)
 {
-    if (contentRect.isEmpty() || m_skipsDraw)
+    if (!m_tiler || contentRect.isEmpty() || m_skipsDraw)
         return;
 
     m_tiler->growLayerToContain(contentRect);
@@ -376,6 +369,8 @@
 
 void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect)
 {
+    ASSERT(m_tiler);
+
     m_skipsDraw = false;
 
     if (contentRect.isEmpty()) {

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2011-08-23 18:08:46 UTC (rev 93615)
@@ -60,7 +60,7 @@
     virtual void cleanupResources();
     void updateTileSizeAndTilingOption();
 
-    virtual void createTextureUpdaterIfNeeded() = 0;
+    virtual void createTextureUpdater(const CCLayerTreeHost*) = 0;
     virtual LayerTextureUpdater* textureUpdater() const = 0;
 
     // Set invalidations to be potentially repainted during update().
@@ -76,7 +76,7 @@
 
     virtual void dumpLayerProperties(TextStream&, int indent) const;
 
-    virtual void setLayerRenderer(LayerRendererChromium*);
+    virtual void setLayerTreeHost(CCLayerTreeHost*);
 
     void createTilerIfNeeded();
     void setTilingOption(TilingOption);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2011-08-23 18:08:46 UTC (rev 93615)
@@ -30,6 +30,7 @@
 #include "LayerPainterChromium.h"
 #include "LayerRendererChromium.h"
 #include "NonCompositedContentHost.h"
+#include "PlatformColor.h"
 #include "TraceEvent.h"
 #include "cc/CCLayerTreeHostCommitter.h"
 #include "cc/CCLayerTreeHostImpl.h"
@@ -46,6 +47,8 @@
 
 CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCSettings& settings)
     : m_recreatingGraphicsContext(false)
+    , m_maxTextureSize(0)
+    , m_contextSupportsMapSub(false)
     , m_animating(false)
     , m_client(client)
     , m_frameNumber(0)
@@ -60,6 +63,12 @@
     if (!m_layerRenderer)
         return false;
 
+    // FIXME: In the threaded case, these values will need to be initialized
+    // by something other than m_layerRenderer.
+    m_maxTextureSize = m_layerRenderer->maxTextureSize();
+    m_bestTextureFormat = PlatformColor::bestTextureFormat(m_layerRenderer->context());
+    m_contextSupportsMapSub = m_layerRenderer->contextSupportsMapSub();
+
     m_rootLayer = GraphicsLayer::create(0);
 #ifndef NDEBUG
     m_rootLayer->setName("root layer");

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (93614 => 93615)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-08-23 18:02:43 UTC (rev 93614)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-08-23 18:08:46 UTC (rev 93615)
@@ -25,6 +25,7 @@
 #ifndef CCLayerTreeHost_h
 #define CCLayerTreeHost_h
 
+#include "GraphicsTypes3D.h"
 #include "IntRect.h"
 #include "cc/CCLayerTreeHostCommitter.h"
 #include "cc/CCLayerTreeHostImplProxy.h"
@@ -113,10 +114,15 @@
     // Temporary home for the non-threaded rendering path.
 #if !USE(THREADED_COMPOSITING)
     void composite(bool finish);
+    LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); }
 #endif
 
     NonCompositedContentHost* nonCompositedContentHost() const { return m_nonCompositedContentHost.get(); }
 
+    bool contextSupportsMapSub() const { return m_contextSupportsMapSub; }
+    int maxTextureSize() const { return m_maxTextureSize; }
+    GC3Denum bestTextureFormat() { return m_bestTextureFormat; }
+
 protected:
     CCLayerTreeHost(CCLayerTreeHostClient*, const CCSettings&);
 
@@ -134,6 +140,10 @@
     RefPtr<LayerRendererChromium> m_layerRenderer;
 #endif
 
+    int m_maxTextureSize;
+    GC3Denum m_bestTextureFormat;
+    bool m_contextSupportsMapSub;
+
     bool m_animating;
 
     CCLayerTreeHostClient* m_client;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to