Skip to content
Permalink
Browse files
[chromium] Remove LayerRendererChromium references from TiledLayerChr…
…omium

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):

Canonical link: https://commits.webkit.org/82592@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
quisquous committed Aug 23, 2011
1 parent a705cf6 commit 303fa3efbc81cd9cd57f0502e271f1259915c536
Showing 15 changed files with 157 additions and 87 deletions.
@@ -1,3 +1,65 @@
2011-08-23 Adrienne Walker <enne@google.com>

[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 <jchaffraix@webkit.org>

Reduce the amount of RenderLayer rectangles' update when scrolling
@@ -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::cleanupResources()
void ContentLayerChromium::paintContentsIfDirty()
{
ASSERT(drawsContent());
ASSERT(layerRenderer());

updateTileSizeAndTilingOption();

@@ -118,18 +118,18 @@ bool ContentLayerChromium::drawsContent() const
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());
}

}
@@ -58,7 +58,7 @@ class ContentLayerChromium : public TiledLayerChromium {

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;
@@ -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 @@ class ImageLayerTextureUpdater : public LayerTextureUpdater {
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 @@ class ImageLayerTextureUpdater : public LayerTextureUpdater {
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 @@ class ImageLayerTextureUpdater : public LayerTextureUpdater {
}

private:
ImageLayerTextureUpdater(GraphicsContext3D* context, bool useMapTexSubImage)
: LayerTextureUpdater(context)
, m_texSubImage(useMapTexSubImage)
explicit ImageLayerTextureUpdater(bool useMapTexSubImage)
: m_texSubImage(useMapTexSubImage)
{
}

@@ -147,8 +146,6 @@ void ImageLayerChromium::setContents(Image* contents)

void ImageLayerChromium::paintContentsIfDirty()
{
ASSERT(layerRenderer());

if (!m_dirtyRect.isEmpty()) {
m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame());
updateTileSizeAndTilingOption();
@@ -182,10 +179,9 @@ bool ImageLayerChromium::drawsContent() const
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());
}

}
@@ -64,7 +64,7 @@ class ImageLayerChromium : public TiledLayerChromium {
ImageLayerChromium(GraphicsLayerChromium* owner);

virtual void cleanupResources();
virtual void createTextureUpdaterIfNeeded();
virtual void createTextureUpdater(const CCLayerTreeHost*);
void setTilingOption(TilingOption);

virtual LayerTextureUpdater* textureUpdater() const;
@@ -105,6 +105,14 @@ void LayerChromium::setLayerRenderer(LayerRendererChromium* renderer)
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()
@@ -53,6 +53,7 @@
namespace WebCore {

class CCLayerImpl;
class CCLayerTreeHost;
class GraphicsContext3D;
class LayerRendererChromium;

@@ -157,6 +158,8 @@ class LayerChromium : public RefCounted<LayerChromium> {
// 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; }
@@ -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 @@ void LayerRendererChromium::releaseTextures()
m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get());
}

GC3Denum LayerRendererChromium::bestTextureFormat()
{
return PlatformColor::bestTextureFormat(context());
}

void LayerRendererChromium::viewportChanged()
{
if (m_context)
@@ -42,6 +42,7 @@ class ManagedTexture;
class LayerTextureUpdater {
WTF_MAKE_NONCOPYABLE(LayerTextureUpdater);
public:
LayerTextureUpdater() { }
virtual ~LayerTextureUpdater() { }

enum Orientation {
@@ -62,18 +63,7 @@ class LayerTextureUpdater {
// 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
@@ -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 @@ void LayerTextureUpdaterCanvas::paintContents(GraphicsContext& context, const In
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 @@ void LayerTextureUpdaterBitmap::prepareToUpdate(const IntRect& contentRect, cons
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 @@ void LayerTextureUpdaterSkPicture::prepareToUpdate(const IntRect& contentRect, c
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 @@ bool LayerTextureUpdaterSkPicture::createFrameBuffer()
return true;
}
#endif // SKIA
#endif // !THREADED_COMPOSITING

} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)

0 comments on commit 303fa3e

Please sign in to comment.