WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-72752-20120206174447.patch (text/plain), 119.85 KB, created by
David Reveman
on 2012-02-06 14:44:48 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
David Reveman
Created:
2012-02-06 14:44:48 PST
Size:
119.85 KB
patch
obsolete
>Subversion Revision: 106846 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b7bb15b2e1e718caa148594faea7682f3a827523..aaed4c626d5dab3601041e15c8f8684af5e81660 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,149 @@ >+2012-02-06 David Reveman <reveman@chromium.org> >+ >+ [Chromium] Upload textures in parallel with painting contents. >+ https://bugs.webkit.org/show_bug.cgi?id=72752 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Start uploading texture resources as soon as enough contents has >+ been painted for one texture to be updated. >+ LayerChromium::updateCompositorResources is replaced by >+ LayerChromium::forEachCompositorResource which allows us to >+ repeatedly go through compositor resources for various purposes. >+ >+ Update unit test: TiledLayerChromiumTest.pushDirtyTiles. >+ >+ * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp: >+ (WebCore::BitmapCanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore::BitmapCanvasLayerTextureUpdater::paintContents): >+ * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h: >+ (BitmapCanvasLayerTextureUpdater): >+ * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp: >+ (WebCore::BitmapSkPictureCanvasLayerTextureUpdater::paintContents): >+ * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h: >+ (BitmapSkPictureCanvasLayerTextureUpdater): >+ * platform/graphics/chromium/Canvas2DLayerChromium.cpp: >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::UpdaterTexture): >+ (WebCore): >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::~UpdaterTexture): >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::updateRect): >+ (WebCore::Canvas2DLayerChromium::Canvas2DLayerChromium): >+ (WebCore::Canvas2DLayerChromium::prepareToUpdateIfDirty): >+ (WebCore::Canvas2DLayerChromium::updateCompositorResources): >+ (WebCore::Canvas2DLayerChromium::forEachCompositorResource): >+ * platform/graphics/chromium/Canvas2DLayerChromium.h: >+ (UpdaterTexture): >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::create): >+ (Canvas2DLayerChromium): >+ * platform/graphics/chromium/CanvasLayerTextureUpdater.cpp: >+ (WebCore::CanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore): >+ (WebCore::CanvasLayerTextureUpdater::Texture::~Texture): >+ * platform/graphics/chromium/CanvasLayerTextureUpdater.h: >+ (Texture): >+ (WebCore::CanvasLayerTextureUpdater::Texture::texture): >+ (CanvasLayerTextureUpdater): >+ * platform/graphics/chromium/ContentLayerChromium.cpp: >+ (WebCore::ContentLayerChromium::prepareToUpdateIfDirty): >+ (WebCore::ContentLayerChromium::idlePrepareToUpdateIfDirty): >+ (WebCore::ContentLayerChromium::paintContentsIfDirty): >+ (WebCore): >+ * platform/graphics/chromium/ContentLayerChromium.h: >+ (ContentLayerChromium): >+ * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp: >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture): >+ * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h: >+ * platform/graphics/chromium/ImageLayerChromium.cpp: >+ (WebCore::ImageLayerTextureUpdater::Texture::Texture): >+ (WebCore::ImageLayerTextureUpdater::paintContents): >+ (WebCore::ImageLayerChromium::prepareToUpdateIfDirty): >+ * platform/graphics/chromium/ImageLayerChromium.h: >+ (ImageLayerChromium): >+ * platform/graphics/chromium/LayerChromium.h: >+ (WebCore): >+ (WebCore::LayerChromium::prepareToUpdateIfDirty): >+ (WebCore::LayerChromium::idlePrepareToUpdateIfDirty): >+ (WebCore::LayerChromium::paintContentsIfDirty): >+ (WebCore::LayerChromium::forEachCompositorResource): >+ * platform/graphics/chromium/LayerTextureUpdater.h: >+ (WebCore::LayerTextureUpdater::Texture::texture): >+ (LayerTextureUpdater): >+ (Handler): >+ (WebCore::LayerTextureUpdater::Handler::~Handler): >+ * platform/graphics/chromium/PluginLayerChromium.cpp: >+ (WebCore::PluginLayerChromium::prepareToUpdateIfDirty): >+ * platform/graphics/chromium/PluginLayerChromium.h: >+ (PluginLayerChromium): >+ * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp: >+ (WebCore::SkPictureCanvasLayerTextureUpdater::paintContents): >+ * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h: >+ (SkPictureCanvasLayerTextureUpdater): >+ * platform/graphics/chromium/TiledLayerChromium.cpp: >+ (WebCore::TiledLayerChromium::forEachCompositorResource): >+ (WebCore::TiledLayerChromium::prepareToUpdateTiles): >+ (WebCore::TiledLayerChromium::prepareToUpdate): >+ (WebCore::TiledLayerChromium::paintContents): >+ (WebCore): >+ * platform/graphics/chromium/TiledLayerChromium.h: >+ (TiledLayerChromium): >+ * platform/graphics/chromium/WebGLLayerChromium.cpp: >+ (WebCore::WebGLLayerChromium::UpdaterTexture::UpdaterTexture): >+ (WebCore): >+ (WebCore::WebGLLayerChromium::UpdaterTexture::~UpdaterTexture): >+ (WebCore::WebGLLayerChromium::UpdaterTexture::updateRect): >+ (WebCore::WebGLLayerChromium::WebGLLayerChromium): >+ (WebCore::WebGLLayerChromium::updateCompositorResources): >+ (WebCore::WebGLLayerChromium::forEachCompositorResource): >+ * platform/graphics/chromium/WebGLLayerChromium.h: >+ (UpdaterTexture): >+ (WebCore::WebGLLayerChromium::UpdaterTexture::create): >+ (WebGLLayerChromium): >+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: >+ (WebCore::CCLayerTreeHost::UpdateHandler::UpdateHandler): >+ (WebCore): >+ (WebCore::CCLayerTreeHost::UpdateHandler::~UpdateHandler): >+ (WebCore::CCLayerTreeHost::UpdateHandler::handle): >+ (WebCore::CCLayerTreeHost::prepareToUpdate): >+ (WebCore::CCLayerTreeHost::updateLayers): >+ (WebCore::CCLayerTreeHost::reserveTextures): >+ (WebCore::CCLayerTreeHost::appendVisibleLayer): >+ (WebCore::CCLayerTreeHost::appendMaskAndReplicaForRenderSurface): >+ (WebCore::CCLayerTreeHost::appendVisibleLayers): >+ (WebCore::CCLayerTreeHost::clearPendingUpdate): >+ * platform/graphics/chromium/cc/CCLayerTreeHost.h: >+ (WebCore): >+ (WebCore::CCSettings::CCSettings): >+ (CCSettings): >+ (CCLayerTreeHost): >+ (UpdateHandler): >+ * platform/graphics/chromium/cc/CCProxy.h: >+ (CCProxy): >+ * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: >+ (WebCore::CCSingleThreadProxy::doCommit): >+ (WebCore::CCSingleThreadProxy::update): >+ (WebCore): >+ (WebCore::CCSingleThreadProxy::commitIfNeeded): >+ * platform/graphics/chromium/cc/CCSingleThreadProxy.h: >+ (WebCore): >+ (CCSingleThreadProxy): >+ * platform/graphics/chromium/cc/CCTextureUpdater.cpp: >+ (WebCore::CCTextureUpdater::CCTextureUpdater): >+ (WebCore::CCTextureUpdater::update): >+ (WebCore::CCTextureUpdater::clear): >+ * platform/graphics/chromium/cc/CCTextureUpdater.h: >+ (CCTextureUpdater): >+ * platform/graphics/chromium/cc/CCThreadProxy.cpp: >+ (WebCore::CCThreadProxy::update): >+ (WebCore): >+ (WebCore::CCThreadProxy::beginFrameAndCommit): >+ (WebCore::CCThreadProxy::updateTextureOnImplThread): >+ (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread): >+ (WebCore::CCThreadProxy::scheduledActionUpdateMoreResources): >+ (WebCore::CCThreadProxy::scheduledActionCommit): >+ * platform/graphics/chromium/cc/CCThreadProxy.h: >+ (CCThreadProxy): >+ (UpdateEntry): >+ > 2012-02-06 Jochen Eisinger <jochen@chromium.org> > > Before accessing a frame's script controller in V8 bindings, first check that the frame actually exists >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 6235c0c2102321ab647d9653aa08ec60f4b6dbe0..f01996ffba66d867f7cb41da38069fa6736faad6 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,85 @@ >+2012-02-06 David Reveman <reveman@chromium.org> >+ >+ [Chromium] Upload textures in parallel with painting contents. >+ https://bugs.webkit.org/show_bug.cgi?id=72752 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add delayTextureUpdates setting that is used by compositor to determine >+ if texture uploads should be delayed until all painting has completed. >+ Update unit tests: CCLayerTreeHostTestOpacityChange and >+ TiledLayerChromiumTest. >+ >+ * public/WebSettings.h: >+ * src/WebSettingsImpl.cpp: >+ (WebKit::WebSettingsImpl::WebSettingsImpl): >+ (WebKit::WebSettingsImpl::setDelayTextureUpdates): >+ (WebKit): >+ * src/WebSettingsImpl.h: >+ (WebSettingsImpl): >+ (WebKit::WebSettingsImpl::delayTextureUpdates): >+ * src/WebViewImpl.cpp: >+ (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): >+ * tests/CCLayerTreeHostTest.cpp: >+ (MockLayerDelegate): >+ (WTF::MockLayerDelegate::paintContents): >+ (WTF::MockLayerDelegate::drawsContent): >+ (WTF::MockLayerDelegate::preserves3D): >+ (WTF::MockLayerDelegate::notifySyncRequired): >+ (WTF): >+ (ContentLayerTextureUpdater): >+ (Texture): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::Texture): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::texture): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::prepareRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::updateRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::create): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::createTexture): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::sampledTexelFormat): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::paintContents): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::layer): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::ContentLayerTextureUpdater): >+ (ContentLayerChromiumWithUpdateTracking): >+ (WTF::ContentLayerChromiumWithUpdateTracking::create): >+ (WTF::ContentLayerChromiumWithUpdateTracking::createTextureUpdaterIfNeeded): >+ (WTF::ContentLayerChromiumWithUpdateTracking::textureUpdater): >+ (WTF::ContentLayerChromiumWithUpdateTracking::prepareToUpdateIfDirty): >+ (WTF::ContentLayerChromiumWithUpdateTracking::idlePrepareToUpdateIfDirty): >+ (WTF::ContentLayerChromiumWithUpdateTracking::prepareToUpdate): >+ (WTF::ContentLayerChromiumWithUpdateTracking::prepareToUpdateCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::idlePrepareToUpdate): >+ (WTF::ContentLayerChromiumWithUpdateTracking::idlePrepareToUpdateCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::paintContents): >+ (WTF::ContentLayerChromiumWithUpdateTracking::paintContentsCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::prepareRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::prepareRectCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::updateRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::updateRectCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerChromiumWithUpdateTracking): >+ (WTF::CCLayerTreeHostTestOpacityChange::afterTest): >+ (WTF::CCLayerTreeHostTestSetViewportSize::beginTest): >+ (WTF::TestLayerChromium::prepareToUpdateIfDirty): >+ (WTF::CCLayerTreeHostTestLayerOcclusion::beginTest): >+ * tests/Canvas2DLayerChromiumTest.cpp: >+ (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): >+ * tests/LayerTextureUpdaterTest.cpp: >+ (WebCore::TEST): >+ * tests/TiledLayerChromiumTest.cpp: >+ (WTF::FakeHandler::handle): >+ (WTF::FakeLayerTextureUpdater::Texture::Texture): >+ (WTF::FakeLayerTextureUpdater::Texture::texture): >+ (Texture): >+ (WTF::FakeLayerTextureUpdater::FakeLayerTextureUpdater): >+ (FakeLayerTextureUpdater): >+ (WTF::FakeLayerTextureUpdater::paintCount): >+ (WTF::FakeLayerTextureUpdater::clearPaintCount): >+ (WTF::FakeTiledLayerChromium::paintContents): >+ (FakeTiledLayerChromium): >+ (WTF::FakeTiledLayerChromium::prepareToUpdateIfDirty): >+ (WTF::FakeTiledLayerChromium::paintContentsIfDirty): >+ (WTF::FakeLayerTextureUpdater::paintContents): >+ (WTF::TEST): >+ > 2012-02-03 James Robinson <jamesr@chromium.org> > > [chromium] Support detaching TextureManager from ManagedTexture >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >index 0d97e52aede0f980ada15de0a14a1d28d86a1e88..dd0353d163cdbf399d781bf36f9dfb57ee6c5e74 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >@@ -37,7 +37,7 @@ > namespace WebCore { > > BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >- : LayerTextureUpdater::Texture(texture) >+ : CanvasLayerTextureUpdater::Texture(texture) > , m_textureUpdater(textureUpdater) > { > } >@@ -78,7 +78,7 @@ LayerTextureUpdater::SampledTexelFormat BitmapCanvasLayerTextureUpdater::sampled > LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; > } > >-void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect) >+void BitmapCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect) > { > m_texSubImage.setSubImageSize(tileSize); > >@@ -92,7 +92,7 @@ void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect > borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText; > PlatformCanvas::Painter canvasPainter(&m_canvas, textOption); > canvasPainter.skiaContext()->setTrackOpaqueRegion(!layerIsOpaque); >- paintContents(*canvasPainter.context(), contentRect, contentsScale); >+ CanvasLayerTextureUpdater::paintContents(*canvasPainter.context(), contentRect, contentsScale); > > if (!layerIsOpaque) > *resultingOpaqueRect = canvasPainter.skiaContext()->opaqueRegion().asRect(); >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >index 4e162295b86e00893c33ef03d4b62d2c1e52bd5f..2abac96a030db09284943cf38b494cd80ec90c52 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >@@ -42,7 +42,7 @@ class LayerPainterChromium; > // possible. > class BitmapCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater { > public: >- class Texture : public LayerTextureUpdater::Texture { >+ class Texture : public CanvasLayerTextureUpdater::Texture { > public: > Texture(BitmapCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>); > virtual ~Texture(); >@@ -60,7 +60,7 @@ public: > > virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*); > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect); >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect); > void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); > > virtual void setOpaque(bool); >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp >index e2ab798386fccf07013d66bb3f28fe7d8f4ec27c..34ad2609531ca1f04497f14b5372e6205a222aee 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp >@@ -86,10 +86,10 @@ LayerTextureUpdater::SampledTexelFormat BitmapSkPictureCanvasLayerTextureUpdater > LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; > } > >-void BitmapSkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect) >+void BitmapSkPictureCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect) > { > m_texSubImage.setSubImageSize(tileSize); >- SkPictureCanvasLayerTextureUpdater::prepareToUpdate(contentRect, tileSize, borderTexels, contentsScale, resultingOpaqueRect); >+ SkPictureCanvasLayerTextureUpdater::paintContents(contentRect, tileSize, borderTexels, contentsScale, resultingOpaqueRect); > } > > void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canvas, const IntRect& sourceRect) >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h >index 1c564cdc183ea49591f6906efebd3a8d9b5f80cc..6d7225f322d6a5a0b662cc182f0e9157bf6641af 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h >@@ -59,7 +59,7 @@ public: > > virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*); > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect); >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect); > void paintContentsRect(SkCanvas*, const IntRect& sourceRect); > void updateTextureRect(GraphicsContext3D*, GC3Denum format, const IntRect& destRect, const uint8_t* pixels); > >diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp >index 1666b618e11b2feb136d075bfe227928e0d33ecc..65cd7864b55fe1f2f8a3c2ae0d1eb0450d3ec7e7 100644 >--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp >@@ -45,6 +45,20 @@ > > namespace WebCore { > >+Canvas2DLayerChromium::UpdaterTexture::UpdaterTexture(Canvas2DLayerChromium* layer) >+ : m_layer(layer) >+{ >+} >+ >+Canvas2DLayerChromium::UpdaterTexture::~UpdaterTexture() >+{ >+} >+ >+void Canvas2DLayerChromium::UpdaterTexture::updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ m_layer->updateCompositorResources(context, allocator); >+} >+ > PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(GraphicsContext3D* context, const IntSize& size) > { > return adoptRef(new Canvas2DLayerChromium(context, size)); >@@ -58,6 +72,7 @@ Canvas2DLayerChromium::Canvas2DLayerChromium(GraphicsContext3D* context, const I > , m_fbo(0) > , m_useDoubleBuffering(CCProxy::hasImplThread()) > , m_canvas(0) >+ , m_updaterTexture(UpdaterTexture::create(this)) > { > if (m_useDoubleBuffering) > GLC(m_context, m_fbo = m_context->createFramebuffer()); >@@ -95,7 +110,7 @@ void Canvas2DLayerChromium::setCanvas(SkCanvas* canvas) > m_canvas = canvas; > } > >-void Canvas2DLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenSpace */) >+void Canvas2DLayerChromium::prepareToUpdateIfDirty(const Region& /* occludedScreenSpace */) > { > if (!drawsContent()) > return; >@@ -133,12 +148,12 @@ void Canvas2DLayerChromium::setTextureManager(TextureManager* textureManager) > m_frontTexture.clear(); > } > >-void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >+void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator *allocator) > { > if (!m_backTextureId || !m_frontTexture || !m_frontTexture->isValid(m_size, GraphicsContext3D::RGBA)) > return; > >- m_frontTexture->bindTexture(context, updater.allocator()); >+ m_frontTexture->bindTexture(context, allocator); > > GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo)); > GLC(context, context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_backTextureId, 0)); >@@ -149,6 +164,11 @@ void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D* context > GLC(context, context->flush()); > } > >+void Canvas2DLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) >+{ >+ handler.handle(m_updaterTexture.get(), IntRect(), IntRect()); >+} >+ > void Canvas2DLayerChromium::pushPropertiesTo(CCLayerImpl* layer) > { > CanvasLayerChromium::pushPropertiesTo(layer); >diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h >index 877224f41ea1b55ce9e020a08f2e841423768d4f..dd97cb40d8ed8eaa71745969e23b609bab364494 100644 >--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h >@@ -47,6 +47,23 @@ class Region; > // A layer containing an accelerated 2d canvas > class Canvas2DLayerChromium : public CanvasLayerChromium { > public: >+ class UpdaterTexture : public LayerTextureUpdater::Texture { >+ public: >+ static PassOwnPtr<UpdaterTexture> create(Canvas2DLayerChromium* layer) >+ { >+ return adoptPtr(new UpdaterTexture(layer)); >+ } >+ >+ virtual ~UpdaterTexture(); >+ >+ virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ explicit UpdaterTexture(Canvas2DLayerChromium*); >+ >+ Canvas2DLayerChromium* m_layer; >+ }; >+ > static PassRefPtr<Canvas2DLayerChromium> create(GraphicsContext3D*, const IntSize&); > virtual ~Canvas2DLayerChromium(); > >@@ -55,10 +72,11 @@ public: > virtual void contentChanged(); > > virtual bool drawsContent() const; >- virtual void paintContentsIfDirty(const Region& occludedScreenSpace); >+ virtual void prepareToUpdateIfDirty(const Region& occludedScreenSpace); > > virtual void setLayerTreeHost(CCLayerTreeHost*); >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ void updateCompositorResources(GraphicsContext3D*, TextureAllocator*); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > virtual void pushPropertiesTo(CCLayerImpl*); > virtual void unreserveContentsTexture(); > virtual void cleanupResources(); >@@ -82,6 +100,7 @@ private: > bool m_useDoubleBuffering; > OwnPtr<ManagedTexture> m_frontTexture; > SkCanvas* m_canvas; >+ OwnPtr<UpdaterTexture> m_updaterTexture; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >index 5fa67854c6bd7f5382b52b0eefba103166fc08fe..1f3b644ee66bbd07517ac485c95cb28dd01e22a3 100644 >--- a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >@@ -36,6 +36,14 @@ > > namespace WebCore { > >+CanvasLayerTextureUpdater::Texture::Texture(PassOwnPtr<ManagedTexture> texture) : m_texture(texture) >+{ >+} >+ >+CanvasLayerTextureUpdater::Texture::~Texture() >+{ >+} >+ > CanvasLayerTextureUpdater::CanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter) > : m_painter(painter) > { >diff --git a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >index 4415f6986533bb85d69e7cf64782b26af11135ac..7f8d3d59d999e368a5a8ea2b6410d6652fe4f6fb 100644 >--- a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >@@ -41,6 +41,19 @@ class LayerPainterChromium; > // their respective paintContents implementations. > class CanvasLayerTextureUpdater : public LayerTextureUpdater { > public: >+ class Texture : public LayerTextureUpdater::Texture { >+ public: >+ virtual ~Texture(); >+ >+ virtual ManagedTexture* texture() { return m_texture.get(); } >+ >+ protected: >+ explicit Texture(PassOwnPtr<ManagedTexture>); >+ >+ private: >+ OwnPtr<ManagedTexture> m_texture; >+ }; >+ > virtual ~CanvasLayerTextureUpdater(); > > protected: >diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >index aa7fb5cf46b06257ff5bf235fb3bf0784535499f..ff47e272b6ac19f8e07d5ceaa75d93ddc5f7a57e 100644 >--- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >@@ -93,7 +93,7 @@ bool ContentLayerChromium::drawsContent() const > return TiledLayerChromium::drawsContent() && m_delegate; > } > >-void ContentLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenSpace */) >+void ContentLayerChromium::prepareToUpdateIfDirty(const Region& /* occludedScreenSpace */) > { > updateTileSizeAndTilingOption(); > createTextureUpdaterIfNeeded(); >@@ -109,7 +109,7 @@ void ContentLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenS > m_needsDisplay = false; > } > >-void ContentLayerChromium::idlePaintContentsIfDirty() >+void ContentLayerChromium::idlePrepareToUpdateIfDirty() > { > if (!drawsContent()) > return; >@@ -123,6 +123,20 @@ void ContentLayerChromium::idlePaintContentsIfDirty() > setNeedsCommit(); > } > >+void ContentLayerChromium::paintContentsIfDirty() >+{ >+ ASSERT(drawsContent()); >+ >+ const IntRect& layerRect = visibleLayerRect(); >+ if (layerRect.isEmpty()) >+ return; >+ >+ if (!drawsContent()) >+ return; >+ >+ paintContents(layerRect); >+} >+ > void ContentLayerChromium::createTextureUpdaterIfNeeded() > { > if (m_textureUpdater) >diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h >index 3e8686d0a0dbce2c1e8c61b6018140263766bf23..6803099611ba599fce52aba6a6ea37d722529502 100644 >--- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h >@@ -59,8 +59,9 @@ public: > void clearDelegate() { m_delegate = 0; } > > virtual bool drawsContent() const; >- virtual void paintContentsIfDirty(const Region& occludedScreenSpace); >- virtual void idlePaintContentsIfDirty(); >+ virtual void prepareToUpdateIfDirty(const Region& occludedScreenSpace); >+ virtual void idlePrepareToUpdateIfDirty(); >+ virtual void paintContentsIfDirty(); > > virtual void setOpaque(bool); > >diff --git a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp >index 19dfa2f006c9884770e676c4585be9467134f3b3..8f2de8a0e893d41daf30b651f153654cd35a710b 100644 >--- a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp >@@ -58,7 +58,7 @@ static PassOwnPtr<SkCanvas> createAcceleratedCanvas(GraphicsContext3D* context, > } > > FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture(FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >- : LayerTextureUpdater::Texture(texture) >+ : CanvasLayerTextureUpdater::Texture(texture) > , m_textureUpdater(textureUpdater) > { > } >diff --git a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >index 4a10c858e4cda8c252ac16dfa07d09a5d908eec3..743ed6ebafbc827e627448441ad3f998379ab59f 100644 >--- a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >@@ -39,7 +39,7 @@ namespace WebCore { > // intermediate framebuffer and then is copied to the destination texture once done. > class FrameBufferSkPictureCanvasLayerTextureUpdater : public SkPictureCanvasLayerTextureUpdater { > public: >- class Texture : public LayerTextureUpdater::Texture { >+ class Texture : public CanvasLayerTextureUpdater::Texture { > public: > Texture(FrameBufferSkPictureCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>); > virtual ~Texture(); >diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >index 1e44e87023fed5f46935df7c3fbd362e54ab0429..f7366246a498b56f7c3158fd2a0cd0069cddcda8 100644 >--- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >@@ -34,9 +34,9 @@ > > #include "ImageLayerChromium.h" > >+#include "CanvasLayerTextureUpdater.h" > #include "Image.h" > #include "LayerTextureSubImage.h" >-#include "LayerTextureUpdater.h" > #include "ManagedTexture.h" > #include "PlatformColor.h" > #include "cc/CCLayerImpl.h" >@@ -46,10 +46,10 @@ namespace WebCore { > > class ImageLayerTextureUpdater : public LayerTextureUpdater { > public: >- class Texture : public LayerTextureUpdater::Texture { >+ class Texture : public CanvasLayerTextureUpdater::Texture { > public: > Texture(ImageLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >- : LayerTextureUpdater::Texture(texture) >+ : CanvasLayerTextureUpdater::Texture(texture) > , m_textureUpdater(textureUpdater) > { > } >@@ -83,7 +83,7 @@ public: > LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; > } > >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int /* borderTexels */, float /* contentsScale */, IntRect* /* resultingOpaqueRect */) >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int /* borderTexels */, float /* contentsScale */, IntRect* /* resultingOpaqueRect */) > { > m_texSubImage.setSubImageSize(tileSize); > } >@@ -158,7 +158,7 @@ void ImageLayerChromium::setContents(Image* contents) > setNeedsDisplay(); > } > >-void ImageLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenSpace */) >+void ImageLayerChromium::prepareToUpdateIfDirty(const Region& /* occludedScreenSpace */) > { > createTextureUpdaterIfNeeded(); > if (m_needsDisplay) { >diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h >index 2127b857c5c0c9e1ef0c4ee1904eab7ab1c7f21e..9c7d65d17dc09df20c40a05151caafd325303cf3 100644 >--- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h >@@ -54,7 +54,7 @@ public: > virtual ~ImageLayerChromium(); > > virtual bool drawsContent() const; >- virtual void paintContentsIfDirty(const Region& occludedScreenSpace); >+ virtual void prepareToUpdateIfDirty(const Region& occludedScreenSpace); > virtual bool needsContentsScale() const; > > void setContents(Image* image); >diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h >index 764f730155b54537cda4c7381b3fd3bcb796064d..57c7166253631ccc97e7598aff874b1bf0024316 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.h >@@ -36,6 +36,7 @@ > > #include "FloatPoint.h" > #include "GraphicsContext.h" >+#include "LayerTextureUpdater.h" > #include "PlatformString.h" > #include "ProgramBinding.h" > #include "RenderSurfaceChromium.h" >@@ -53,7 +54,6 @@ namespace WebCore { > > class CCLayerImpl; > class CCLayerTreeHost; >-class CCTextureUpdater; > class GraphicsContext3D; > class Region; > >@@ -154,9 +154,10 @@ public: > > // These methods typically need to be overwritten by derived classes. > virtual bool drawsContent() const { return m_isDrawable; } >- virtual void paintContentsIfDirty(const Region& /* occludedScreenSpace */) { } >- virtual void idlePaintContentsIfDirty() { } >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) { } >+ virtual void prepareToUpdateIfDirty(const Region& /* occludedScreenSpace */) { } >+ virtual void idlePrepareToUpdateIfDirty() { } >+ virtual void paintContentsIfDirty() { } >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&) { } > virtual void setIsMask(bool) { } > virtual void unreserveContentsTexture() { } > virtual void bindContentsTexture() { } >diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >index 179fea6e12bf103c5b07435cf24a3a48f8cd9323..5e1e8e260f30b3e8755ddf9b97d08bbd11bbd6f6 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >@@ -48,14 +48,16 @@ public: > public: > virtual ~Texture() { } > >- ManagedTexture* texture() { return m_texture.get(); } >+ virtual ManagedTexture* texture() { return 0; } > virtual void prepareRect(const IntRect& /* sourceRect */) { } > virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect) = 0; >- protected: >- explicit Texture(PassOwnPtr<ManagedTexture> texture) : m_texture(texture) { } >+ }; >+ >+ class Handler { >+ public: >+ virtual ~Handler() { } > >- private: >- OwnPtr<ManagedTexture> m_texture; >+ virtual void handle(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect) = 0; > }; > > virtual ~LayerTextureUpdater() { } >@@ -73,8 +75,7 @@ public: > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0; > // The |resultingOpaqueRect| gives back a region of the layer that was painted opaque. If the layer is marked opaque in the updater, > // then this region should be ignored in preference for the entire layer's area. >- virtual void prepareToUpdate(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */, >- IntRect* /* resultingOpaqueRect */) { } >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */, IntRect* /* resultingOpaqueRect */) = 0; > > // Set true by the layer when it is known that the entire output is going to be opaque. > virtual void setOpaque(bool) { } >diff --git a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp >index 079ad2ede95475582b870729a71a5d61bd28ab4b..9fa67d41023e4519c79e57ab672cfde997aaed60 100644 >--- a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp >@@ -52,7 +52,7 @@ PluginLayerChromium::PluginLayerChromium() > { > } > >-void PluginLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, CCTextureUpdater&) >+void PluginLayerChromium::prepareToUpdateIfDirty() > { > if (!m_needsDisplay) > return; >diff --git a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h >index 84365695bb1ddc65231add04f6f0d8300091e0d0..5a038b2bf74373b7d112f64dab1dda3b232e90cf 100644 >--- a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h >@@ -37,7 +37,7 @@ namespace WebCore { > class PluginLayerChromium : public LayerChromium { > public: > static PassRefPtr<PluginLayerChromium> create(); >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ virtual void prepareToUpdateIfDirty(); > > virtual PassRefPtr<CCLayerImpl> createCCLayerImpl(); > >diff --git a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp >index 0d974fa63a4457d9eac7c8b873f7e91a4d26843b..64d460e27d79d8d7a827ce20523068a49f1fbb59 100644 >--- a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp >@@ -49,14 +49,14 @@ SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater() > { > } > >-void SkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */, float contentsScale, IntRect* resultingOpaqueRect) >+void SkPictureCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */, float contentsScale, IntRect* resultingOpaqueRect) > { > SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height()); > PlatformContextSkia platformContext(canvas); > platformContext.setDeferred(true); > platformContext.setTrackOpaqueRegion(!m_layerIsOpaque); > GraphicsContext graphicsContext(&platformContext); >- paintContents(graphicsContext, contentRect, contentsScale); >+ CanvasLayerTextureUpdater::paintContents(graphicsContext, contentRect, contentsScale); > m_picture.endRecording(); > > if (!m_layerIsOpaque) >diff --git a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >index 7fcc6059f90e7d9d1c301bf2a70f5152a4927b00..465542e57a203b6945026505e058e9d4d389f04f 100644 >--- a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >@@ -51,7 +51,7 @@ public: > protected: > explicit SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>); > >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect); >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect); > void drawPicture(SkCanvas*); > > virtual void setOpaque(bool); >diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >index e97936196ac416ea36de2b070e7fe88bdeb58d7c..dbe53e894a2edb9e4addce2cf5875282551f38d8 100644 >--- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >@@ -174,10 +174,10 @@ IntSize TiledLayerChromium::contentBounds() const > return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds().height() * contentsScale())); > } > >-void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater& updater) >+void TiledLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) > { > // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. >- if (m_skipsDraw || m_requestedUpdateTilesRect.isEmpty() || m_tiler->isEmpty()) >+ if (m_skipsDraw || m_requestedUpdateTilesRect.isEmpty() || m_tiler->isEmpty() || m_paintRect.isEmpty()) > return; > > int left = m_requestedUpdateTilesRect.x(); >@@ -219,15 +219,9 @@ void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTexture > if (paintOffset.y() + destRect.height() > m_paintRect.height()) > CRASH(); > >- updater.append(tile->texture(), sourceRect, destRect); >+ handler.handle(tile->texture(), sourceRect, destRect); > } > } >- >- // The updateRect should be in layer space. So we have to convert the paintRect from content space to layer space. >- m_updateRect = FloatRect(m_paintRect); >- float widthScale = bounds().width() / static_cast<float>(contentBounds().width()); >- float heightScale = bounds().height() / static_cast<float>(contentBounds().height()); >- m_updateRect.scale(widthScale, heightScale); > } > > void TiledLayerChromium::setTilingOption(TilingOption tilingOption) >@@ -350,12 +344,6 @@ void TiledLayerChromium::protectTileTextures(const IntRect& layerRect) > > void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int right, int bottom) > { >- // Reset m_updateRect for all tiles. >- for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { >- UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); >- tile->m_updateRect = IntRect(); >- } >- > createTextureUpdaterIfNeeded(); > > // Create tiles as needed, expanding a dirty rect to contain all >@@ -404,30 +392,14 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int > if (!m_paintRect.isEmpty()) > m_requestedUpdateTilesRect = IntRect(left, top, right - left + 1, bottom - top + 1); > >- // Calling prepareToUpdate() calls into WebKit to paint, which may have the side >- // effect of disabling compositing, which causes our reference to the texture updater to be deleted. >- // However, we can't free the memory backing the GraphicsContext until the paint finishes, >- // so we grab a local reference here to hold the updater alive until the paint completes. >- RefPtr<LayerTextureUpdater> protector(textureUpdater()); >- IntRect paintedOpaqueRect; >- textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale(), &paintedOpaqueRect); > for (int j = top; j <= bottom; ++j) { > for (int i = left; i <= right; ++i) { > UpdatableTile* tile = tileAt(i, j); > >- // Tiles are created before prepareToUpdate() is called. >+ // Tiles are created above. > if (!tile) > CRASH(); > >- IntRect tileRect = m_tiler->tileBounds(i, j); >- >- // Save what was painted opaque in the tile. If everything painted in the tile was opaque, and the area is a subset of an >- // already opaque area, keep the old area. >- IntRect tilePaintedRect = intersection(tileRect, m_paintRect); >- IntRect tilePaintedOpaqueRect = intersection(tileRect, paintedOpaqueRect); >- if (tilePaintedOpaqueRect != tilePaintedRect || !tile->m_opaqueRect.contains(tilePaintedOpaqueRect)) >- tile->m_opaqueRect = tilePaintedOpaqueRect; >- > // Use m_updateRect as copyAndClearDirty above moved the existing dirty rect to m_updateRect. > const IntRect& dirtyRect = tile->m_updateRect; > if (dirtyRect.isEmpty()) >@@ -441,10 +413,6 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int > sourceRect.intersect(m_paintRect); > > tile->m_updateRect = sourceRect; >- if (sourceRect.isEmpty()) >- continue; >- >- tile->texture()->prepareRect(sourceRect); > } > } > } >@@ -512,6 +480,12 @@ void TiledLayerChromium::prepareToUpdate(const IntRect& layerRect) > m_requestedUpdateTilesRect = IntRect(); > m_paintRect = IntRect(); > >+ // Reset m_updateRect for all tiles. >+ for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { >+ UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); >+ tile->m_updateRect = IntRect(); >+ } >+ > updateBounds(); > > if (layerRect.isEmpty() || !m_tiler->numTiles()) >@@ -608,5 +582,47 @@ IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleLayerRect) > return prepaintRect; > } > >+void TiledLayerChromium::paintContents(const IntRect& layerRect) >+{ >+ if (m_skipsDraw || m_requestedUpdateTilesRect.isEmpty() || !m_tiler->numTiles() || m_paintRect.isEmpty()) >+ return; >+ >+ // Calling prepareToUpdate() calls into WebKit to paint, which may have the side >+ // effect of disabling compositing, which causes our reference to the texture updater to be deleted. >+ // However, we can't free the memory backing the GraphicsContext until the paint finishes, >+ // so we grab a local reference here to hold the updater alive until the paint completes. >+ RefPtr<LayerTextureUpdater> protector(textureUpdater()); >+ IntRect paintedOpaqueRect; >+ textureUpdater()->paintContents(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale(), &paintedOpaqueRect); >+ int left = m_requestedUpdateTilesRect.x(); >+ int top = m_requestedUpdateTilesRect.y(); >+ int right = m_requestedUpdateTilesRect.maxX() - 1; >+ int bottom = m_requestedUpdateTilesRect.maxY() - 1; >+ for (int j = top; j <= bottom; ++j) { >+ for (int i = left; i <= right; ++i) { >+ UpdatableTile* tile = tileAt(i, j); >+ >+ // Tiles are created in prepareToUpdateTiles(). >+ if (!tile) >+ CRASH(); >+ >+ IntRect tileRect = m_tiler->tileBounds(i, j); >+ >+ // Save what was painted opaque in the tile. If everything painted in the tile was opaque, and the area is a subset of an >+ // already opaque area, keep the old area. >+ IntRect tilePaintedRect = intersection(tileRect, m_paintRect); >+ IntRect tilePaintedOpaqueRect = intersection(tileRect, paintedOpaqueRect); >+ if (tilePaintedOpaqueRect != tilePaintedRect || !tile->m_opaqueRect.contains(tilePaintedOpaqueRect)) >+ tile->m_opaqueRect = tilePaintedOpaqueRect; >+ } >+ } >+ >+ // The updateRect should be in layer space. So we have to convert the paintRect from content space to layer space. >+ m_updateRect = FloatRect(m_paintRect); >+ float widthScale = bounds().width() / static_cast<float>(contentBounds().width()); >+ float heightScale = bounds().height() / static_cast<float>(contentBounds().height()); >+ m_updateRect.scale(widthScale, heightScale); >+} >+ > } > #endif // USE(ACCELERATED_COMPOSITING) >diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h >index 29fecfe4cbf959070089edcbea5a44c38f80d44c..a26ede24252dceeb8cb1057c22005504fe951c58 100644 >--- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h >@@ -44,7 +44,7 @@ public: > > virtual ~TiledLayerChromium(); > >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > virtual void setIsMask(bool); > > virtual void pushPropertiesTo(CCLayerImpl*); >@@ -85,7 +85,7 @@ protected: > // Set invalidations to be potentially repainted during update(). > void invalidateRect(const IntRect& layerRect); > >- // Prepare data needed to update textures that intersect with layerRect. >+ // Prepare to update textures that intersect with layerRect. > void prepareToUpdate(const IntRect& layerRect); > > // Same as above, but this will try to paint additional surrounding content if idle. >@@ -96,6 +96,9 @@ protected: > > bool skipsDraw() const { return m_skipsDraw; } > >+ // Paint contents needed to update textures that intersect with layerRect. >+ void paintContents(const IntRect& layerRect); >+ > virtual void protectVisibleTileTextures(); > > virtual TextureManager* textureManager() const; >@@ -112,7 +115,7 @@ private: > UpdatableTile* tileAt(int, int) const; > UpdatableTile* createTile(int, int); > >- // Temporary state held between prepareToUpdate() and updateCompositorResources(). >+ // Temporary state held between prepareToUpdate() and paintContents(). > IntRect m_requestedUpdateTilesRect; > > // State held between prepareToUpdate() and pushPropertiesTo(). This represents the area >diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp >index 74db7f13ec4f8f4caaf68e5ad74745be93b72f3b..7f0ff6f42dc04379bdcfeab102f43fb490f0b624 100644 >--- a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp >@@ -39,9 +39,24 @@ > #include "GraphicsContext3D.h" > #include "LayerRendererChromium.h" > #include "TraceEvent.h" >+#include "cc/CCTextureUpdater.h" > > namespace WebCore { > >+WebGLLayerChromium::UpdaterTexture::UpdaterTexture(WebGLLayerChromium* layer) >+ : m_layer(layer) >+{ >+} >+ >+WebGLLayerChromium::UpdaterTexture::~UpdaterTexture() >+{ >+} >+ >+void WebGLLayerChromium::UpdaterTexture::updateRect(GraphicsContext3D* context, TextureAllocator*, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ m_layer->updateCompositorResources(context); >+} >+ > PassRefPtr<WebGLLayerChromium> WebGLLayerChromium::create() > { > return adoptRef(new WebGLLayerChromium()); >@@ -55,6 +70,7 @@ WebGLLayerChromium::WebGLLayerChromium() > , m_textureChanged(true) > , m_textureUpdated(false) > , m_drawingBuffer(0) >+ , m_updaterTexture(UpdaterTexture::create(this)) > { > } > >@@ -69,7 +85,7 @@ bool WebGLLayerChromium::drawsContent() const > return LayerChromium::drawsContent() && context() && (context()->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR); > } > >-void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, CCTextureUpdater&) >+void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext) > { > if (!drawsContent()) > return; >@@ -98,6 +114,11 @@ void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererCo > } > } > >+void WebGLLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) >+{ >+ handler.handle(m_updaterTexture.get(), IntRect(), IntRect()); >+} >+ > void WebGLLayerChromium::pushPropertiesTo(CCLayerImpl* layer) > { > CanvasLayerChromium::pushPropertiesTo(layer); >diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h >index 4dc68a3308e3f2337b4b265c465d75db2dc6a7fa..7a7416fb655857736cdddc80afd99371a510244f 100644 >--- a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h >@@ -36,6 +36,7 @@ > > #include "CanvasLayerChromium.h" > #include "DrawingBuffer.h" >+#include "LayerTextureUpdater.h" > > namespace WebCore { > >@@ -45,6 +46,23 @@ class WebGLLayerChromiumRateLimitTask; > // A Layer containing a WebGL canvas > class WebGLLayerChromium : public CanvasLayerChromium { > public: >+ class UpdaterTexture : public LayerTextureUpdater::Texture { >+ public: >+ static PassOwnPtr<UpdaterTexture> create(WebGLLayerChromium* layer) >+ { >+ return adoptPtr(new UpdaterTexture(layer)); >+ } >+ >+ virtual ~UpdaterTexture(); >+ >+ virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ explicit UpdaterTexture(WebGLLayerChromium*); >+ >+ WebGLLayerChromium* m_layer; >+ }; >+ > static PassRefPtr<WebGLLayerChromium> create(); > > virtual ~WebGLLayerChromium(); >@@ -53,7 +71,8 @@ public: > void setTextureId(unsigned textureId) { m_textureId = textureId; } > > virtual bool drawsContent() const; >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ void updateCompositorResources(GraphicsContext3D*); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > virtual void pushPropertiesTo(CCLayerImpl*); > virtual void contentChanged(); > bool paintRenderedResultsToCanvas(ImageBuffer*); >@@ -78,6 +97,8 @@ private: > // A reference is not held here, because the DrawingBuffer already holds > // a reference to the WebGLLayerChromium. > DrawingBuffer* m_drawingBuffer; >+ >+ OwnPtr<UpdaterTexture> m_updaterTexture; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >index 50d76a5e8c542d760b1c690050d66834fb798518..51ca9f62201529da31d8e08afc0e6859316afc85 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >@@ -36,9 +36,12 @@ > #include "cc/CCLayerTreeHostCommon.h" > #include "cc/CCLayerTreeHostImpl.h" > #include "cc/CCSingleThreadProxy.h" >+#include "cc/CCTextureUpdater.h" > #include "cc/CCThread.h" > #include "cc/CCThreadProxy.h" > >+using namespace std; >+ > namespace { > static int numLayerTreeInstances; > } >@@ -50,6 +53,21 @@ bool CCLayerTreeHost::anyLayerTreeHostInstanceExists() > return numLayerTreeInstances > 0; > } > >+CCLayerTreeHost::UpdateHandler::UpdateHandler(CCProxy* proxy) >+ : m_proxy(proxy) >+{ >+} >+ >+CCLayerTreeHost::UpdateHandler::~UpdateHandler() >+{ >+} >+ >+void CCLayerTreeHost::UpdateHandler::handle(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ texture->prepareRect(sourceRect); >+ m_proxy->update(texture, sourceRect, destRect); >+} >+ > PassRefPtr<CCLayerTreeHost> CCLayerTreeHost::create(CCLayerTreeHostClient* client, const CCSettings& settings) > { > RefPtr<CCLayerTreeHost> layerTreeHost = adoptRef(new CCLayerTreeHost(client, settings)); >@@ -371,7 +389,7 @@ void CCLayerTreeHost::composite() > static_cast<CCSingleThreadProxy*>(m_proxy.get())->compositeImmediately(); > } > >-void CCLayerTreeHost::updateLayers() >+void CCLayerTreeHost::prepareToUpdate() > { > if (!m_layerRendererInitialized) { > initializeLayerRenderer(); >@@ -386,12 +404,12 @@ void CCLayerTreeHost::updateLayers() > if (viewportSize().isEmpty()) > return; > >- updateLayers(rootLayer()); >+ prepareToUpdate(rootLayer()); > } > >-void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer) >+void CCLayerTreeHost::prepareToUpdate(LayerChromium* rootLayer) > { >- TRACE_EVENT("CCLayerTreeHost::updateLayers", this, 0); >+ TRACE_EVENT("CCLayerTreeHost::prepareToUpdate", this, 0); > > if (!rootLayer->renderSurface()) > rootLayer->createRenderSurface(); >@@ -400,38 +418,36 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer) > IntRect rootClipRect(IntPoint(), viewportSize()); > rootLayer->setClipRect(rootClipRect); > >- // This assert fires if updateCompositorResources wasn't called after >- // updateLayers. Only one update can be pending at any given time. >- ASSERT(!m_updateList.size()); >- m_updateList.append(rootLayer); >+ // This assert fires if commitComplete wasn't called after >+ // prepareToUpdate. Only one update can be pending at any given time. >+ ASSERT(!m_renderSurfaceUpdateList.size() && !m_layerUpdateList.size()); >+ m_renderSurfaceUpdateList.append(rootLayer); > > RenderSurfaceChromium* rootRenderSurface = rootLayer->renderSurface(); > rootRenderSurface->clearLayerList(); > > TransformationMatrix identityMatrix; > { >- TRACE_EVENT("CCLayerTreeHost::updateLayers::calcDrawEtc", this, 0); >- CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, identityMatrix, identityMatrix, m_updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize); >+ TRACE_EVENT("CCLayerTreeHost::prepareToUpdate::calcDrawEtc", this, 0); >+ CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, identityMatrix, identityMatrix, m_renderSurfaceUpdateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize); > } > > reserveTextures(); > >- paintLayerContents(m_updateList, PaintVisible); >- if (!m_triggerIdlePaints) >+ appendVisibleLayers(m_renderSurfaceUpdateList, m_layerUpdateList); >+} >+ >+void CCLayerTreeHost::updateLayers() >+{ >+ if (!rootLayer()) > return; > > size_t preferredLimitBytes = TextureManager::reclaimLimitBytes(m_viewportSize); >- size_t maxLimitBytes = TextureManager::highLimitBytes(m_viewportSize); > m_contentsTextureManager->reduceMemoryToLimit(preferredLimitBytes); > if (m_contentsTextureManager->currentMemoryUseBytes() >= preferredLimitBytes) > return; > >- // Idle painting should fail when we hit the preferred memory limit, >- // otherwise it will always push us towards the maximum limit. >- m_contentsTextureManager->setMaxMemoryLimitBytes(preferredLimitBytes); >- // The second (idle) paint will be a no-op in layers where painting already occured above. >- paintLayerContents(m_updateList, PaintIdle); >- m_contentsTextureManager->setMaxMemoryLimitBytes(maxLimitBytes); >+ updateLayers(rootLayer()); > } > > void CCLayerTreeHost::reserveTextures() >@@ -439,26 +455,61 @@ void CCLayerTreeHost::reserveTextures() > // Use BackToFront since it's cheap and this isn't order-dependent. > typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType; > >- CCLayerIteratorType end = CCLayerIteratorType::end(&m_updateList); >- for (CCLayerIteratorType it = CCLayerIteratorType::begin(&m_updateList); it != end; ++it) { >+ CCLayerIteratorType end = CCLayerIteratorType::end(&m_renderSurfaceUpdateList); >+ for (CCLayerIteratorType it = CCLayerIteratorType::begin(&m_renderSurfaceUpdateList); it != end; ++it) { > if (it.representsTargetRenderSurface() || !it->alwaysReserveTextures()) > continue; > it->reserveTextures(); > } > } > >-// static >-void CCLayerTreeHost::paintContentsIfDirty(LayerChromium* layer, PaintType paintType, const Region& occludedScreenSpace) >+void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer) > { >- ASSERT(layer); >- ASSERT(PaintVisible == paintType || PaintIdle == paintType); >- if (PaintVisible == paintType) >- layer->paintContentsIfDirty(occludedScreenSpace); >- else >- layer->idlePaintContentsIfDirty(); >+ TRACE_EVENT("CCLayerTreeHost::updateLayers", this, 0); >+ >+ for (int layerIndex = m_layerUpdateList.size() - 1; layerIndex >= 0 ; --layerIndex) { >+ LayerChromium* layer = m_layerUpdateList[layerIndex].first.get(); >+ layer->prepareToUpdateIfDirty(m_layerUpdateList[layerIndex].second); >+ } >+ >+ if (m_triggerIdlePaints) { >+ size_t preferredLimitBytes = TextureManager::reclaimLimitBytes(m_viewportSize); >+ size_t maxLimitBytes = TextureManager::highLimitBytes(m_viewportSize); >+ m_contentsTextureManager->reduceMemoryToLimit(preferredLimitBytes); >+ if (m_contentsTextureManager->currentMemoryUseBytes() < preferredLimitBytes) { >+ // Idle painting should fail when we hit the preferred memory limit, >+ // otherwise it will always push us towards the maximum limit. >+ m_contentsTextureManager->setMaxMemoryLimitBytes(preferredLimitBytes); >+ // The second (idle) paint will be a no-op in layers where painting already occured above. >+ >+ for (int layerIndex = m_layerUpdateList.size() - 1; layerIndex >= 0 ; --layerIndex) { >+ LayerChromium* layer = m_layerUpdateList[layerIndex].first.get(); >+ layer->idlePrepareToUpdateIfDirty(); >+ } >+ >+ m_contentsTextureManager->setMaxMemoryLimitBytes(maxLimitBytes); >+ } >+ } >+ >+ UpdateHandler handler(m_proxy.get()); >+ for (int layerIndex = m_layerUpdateList.size() - 1; layerIndex >= 0 ; --layerIndex) { >+ LayerChromium* layer = m_layerUpdateList[layerIndex].first.get(); >+ layer->paintContentsIfDirty(); >+ layer->forEachCompositorResource(handler); >+ } >+} >+ >+void CCLayerTreeHost::appendVisibleLayer(LayerChromium* layer, const Region& occludedScreenSpace, LayerUpdateList& updateList) >+{ >+ // For normal layers, these conditions should have already been checked while creating the render surface layer lists. >+ // For masks and replicas however, we may still need to check them here. >+ if (layer->bounds().isEmpty() || !layer->opacity() || !layer->drawsContent()) >+ return; >+ >+ updateList.append(pair<RefPtr<LayerChromium>, Region>(layer, occludedScreenSpace)); > } > >-void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderSurfaceLayer, PaintType paintType) >+void CCLayerTreeHost::appendMaskAndReplicaForRenderSurface(LayerChromium* renderSurfaceLayer, LayerUpdateList& updateList) > { > // Note: Masks and replicas only exist for layers that own render surfaces. If we reach this point > // in code, we already know that at least something will be drawn into this render surface, so the >@@ -469,16 +520,16 @@ void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderS > > if (renderSurfaceLayer->maskLayer()) { > renderSurfaceLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), renderSurfaceLayer->contentBounds())); >- paintContentsIfDirty(renderSurfaceLayer->maskLayer(), paintType, noOcclusion); >+ appendVisibleLayer(renderSurfaceLayer->maskLayer(), noOcclusion, updateList); > } > > LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer(); > if (replicaLayer) { >- paintContentsIfDirty(replicaLayer, paintType, noOcclusion); >+ appendVisibleLayer(replicaLayer, noOcclusion, updateList); > > if (replicaLayer->maskLayer()) { > replicaLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds())); >- paintContentsIfDirty(replicaLayer->maskLayer(), paintType, noOcclusion); >+ appendVisibleLayer(replicaLayer->maskLayer(), noOcclusion, updateList); > } > } > } >@@ -518,7 +569,7 @@ static void leaveTargetRenderSurface(Vector<RenderSurfaceRegion>& stack, RenderS > } > } > >-void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, PaintType paintType) >+void CCLayerTreeHost::appendVisibleLayers(const LayerList& renderSurfaceUpdateList, LayerUpdateList& updateList) > { > // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk. > typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; >@@ -532,13 +583,13 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList > // We merge the occlusion at the top of the stack with the new current subtree. This new target is pushed onto the stack if not already there. > Vector<RenderSurfaceRegion> targetSurfaceStack; > >- CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); >- for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { >+ CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceUpdateList); >+ for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceUpdateList); it != end; ++it) { > if (it.representsTargetRenderSurface()) { > ASSERT(it->renderSurface()->drawOpacity()); > > enterTargetRenderSurface(targetSurfaceStack, it->renderSurface()); >- paintMaskAndReplicaForRenderSurface(*it, paintType); >+ appendMaskAndReplicaForRenderSurface(*it, updateList); > // FIXME: add the replica layer to the current occlusion > > if (it->maskLayer() || it->renderSurface()->drawOpacity() < 1) >@@ -547,7 +598,7 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList > ASSERT(!it->bounds().isEmpty()); > > enterTargetRenderSurface(targetSurfaceStack, it->targetRenderSurface()); >- paintContentsIfDirty(*it, paintType, targetSurfaceStack.last().occludedInScreen); >+ appendVisibleLayer(*it, targetSurfaceStack.last().occludedInScreen, updateList); > it->addSelfToOccludedScreenSpace(targetSurfaceStack.last().occludedInScreen); > } else { > leaveTargetRenderSurface(targetSurfaceStack, it.targetRenderSurfaceLayer()->renderSurface()); >@@ -555,36 +606,16 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList > } > } > >-void CCLayerTreeHost::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >-{ >- // Use BackToFront since it's cheap and this isn't order-dependent. >- typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType; >- >- CCLayerIteratorType end = CCLayerIteratorType::end(&m_updateList); >- for (CCLayerIteratorType it = CCLayerIteratorType::begin(&m_updateList); it != end; ++it) { >- if (it.representsTargetRenderSurface()) { >- ASSERT(it->renderSurface()->drawOpacity()); >- if (it->maskLayer()) >- it->maskLayer()->updateCompositorResources(context, updater); >- >- if (it->replicaLayer()) { >- it->replicaLayer()->updateCompositorResources(context, updater); >- if (it->replicaLayer()->maskLayer()) >- it->replicaLayer()->maskLayer()->updateCompositorResources(context, updater); >- } >- } else if (it.representsItself()) >- it->updateCompositorResources(context, updater); >- } >-} >- > void CCLayerTreeHost::clearPendingUpdate() > { >- for (size_t surfaceIndex = 0; surfaceIndex < m_updateList.size(); ++surfaceIndex) { >- LayerChromium* layer = m_updateList[surfaceIndex].get(); >+ m_layerUpdateList.clear(); >+ >+ for (size_t surfaceIndex = 0; surfaceIndex < m_renderSurfaceUpdateList.size(); ++surfaceIndex) { >+ LayerChromium* layer = m_renderSurfaceUpdateList[surfaceIndex].get(); > ASSERT(layer->renderSurface()); > layer->clearRenderSurface(); > } >- m_updateList.clear(); >+ m_renderSurfaceUpdateList.clear(); > } > > void CCLayerTreeHost::applyScrollAndScale(const CCScrollAndScaleSet& info) >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >index 2224f7cc16082906210dbdd1bd42b11eb0ca771d..d510e3a186404b9f23c9b46ff4e0335859ada090 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >@@ -41,7 +41,6 @@ > namespace WebCore { > > class CCLayerTreeHostImpl; >-class CCTextureUpdater; > class GraphicsContext3D; > class LayerPainterChromium; > class Region; >@@ -74,7 +73,8 @@ struct CCSettings { > , refreshRate(0) > , perTilePainting(false) > , partialSwapEnabled(false) >- , partialTextureUpdates(true) { } >+ , partialTextureUpdates(true) >+ , delayTextureUpdates(false) { } > > bool acceleratePainting; > bool compositeOffscreen; >@@ -84,6 +84,7 @@ struct CCSettings { > bool perTilePainting; > bool partialSwapEnabled; > bool partialTextureUpdates; >+ bool delayTextureUpdates; > }; > > // Provides information on an Impl's rendering capabilities back to the CCLayerTreeHost >@@ -184,9 +185,9 @@ public: > > void setHaveWheelEventHandlers(bool); > >+ void prepareToUpdate(); > void updateLayers(); > >- void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); > void applyScrollAndScale(const CCScrollAndScaleSet&); > void startRateLimiter(GraphicsContext3D*); > void stopRateLimiter(GraphicsContext3D*); >@@ -198,16 +199,28 @@ protected: > bool initialize(); > > private: >+ class UpdateHandler : public LayerTextureUpdater::Handler { >+ public: >+ UpdateHandler(CCProxy*); >+ virtual ~UpdateHandler(); >+ >+ virtual void handle(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ CCProxy* m_proxy; >+ }; >+ > typedef Vector<RefPtr<LayerChromium> > LayerList; >+ typedef Vector<std::pair<RefPtr<LayerChromium>, Region> > LayerUpdateList; > typedef Vector<OwnPtr<ManagedTexture> > TextureList; > > void initializeLayerRenderer(); > >- enum PaintType { PaintVisible, PaintIdle }; >- static void paintContentsIfDirty(LayerChromium*, PaintType, const Region& occludedScreenSpace); >- void paintLayerContents(const LayerList&, PaintType); >- void paintMaskAndReplicaForRenderSurface(LayerChromium*, PaintType); >+ void appendVisibleLayer(LayerChromium*, const Region& occludedScreenSpace, LayerUpdateList&); >+ void appendMaskAndReplicaForRenderSurface(LayerChromium*, LayerUpdateList&); >+ void appendVisibleLayers(const LayerList& renderSurfaceUpdateList, LayerUpdateList&); > >+ void prepareToUpdate(LayerChromium*); > void updateLayers(LayerChromium*); > // Pre-reserve textures for any layer marked "always reserve textures" > void reserveTextures(); >@@ -227,7 +240,8 @@ private: > RefPtr<LayerChromium> m_rootLayer; > OwnPtr<TextureManager> m_contentsTextureManager; > >- LayerList m_updateList; >+ LayerList m_renderSurfaceUpdateList; >+ LayerUpdateList m_layerUpdateList; > > CCSettings m_settings; > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h >index a3aa716071c342ab698e3e0e93d22982373e75fa..06563bb392ee1d21f67487141be8ebb18f51a6c5 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h >@@ -26,6 +26,7 @@ > #define CCProxy_h > > #include "IntRect.h" >+#include "LayerTextureUpdater.h" > #include <wtf/Noncopyable.h> > #include <wtf/PassOwnPtr.h> > #include <wtf/PassRefPtr.h> >@@ -84,6 +85,8 @@ public: > // updates are required. > virtual bool partialTextureUpdateCapability() const = 0; > >+ virtual void update(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect) = 0; >+ > // Debug hooks > #ifndef NDEBUG > static bool isMainThread(); >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >index 70dec054c5252163d3df0d7f9345f374168dff2a..a82fb64c17d64b7df87ba60bfb980e191388b286 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >@@ -161,15 +161,15 @@ void CCSingleThreadProxy::setNeedsAnimate() > void CCSingleThreadProxy::doCommit() > { > ASSERT(CCProxy::isMainThread()); >+ > // Commit immediately > { > DebugScopedSetImplThread impl; > m_layerTreeHostImpl->beginCommit(); > >+ if (m_currentTextureUpdater) >+ while (m_currentTextureUpdater->update(m_layerTreeHostImpl->context(), 1)) { } > m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); >- CCTextureUpdater updater(m_layerTreeHostImpl->contentsTextureAllocator()); >- m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), updater); >- while (updater.update(m_layerTreeHostImpl->context(), 1)) { } > m_layerTreeHostImpl->setVisible(m_layerTreeHost->visible()); > m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); > >@@ -184,6 +184,8 @@ void CCSingleThreadProxy::doCommit() > } > m_layerTreeHost->commitComplete(); > m_nextFrameIsNewlyCommittedFrame = true; >+ >+ ASSERT(!m_currentTextureUpdater || !m_currentTextureUpdater->hasMoreUpdates()); > } > > void CCSingleThreadProxy::setNeedsCommit() >@@ -222,6 +224,17 @@ void CCSingleThreadProxy::stop() > m_layerTreeHost = 0; > } > >+void CCSingleThreadProxy::update(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ if (!m_currentTextureUpdater) >+ m_currentTextureUpdater = adoptPtr(new CCTextureUpdater(m_layerTreeHostImpl->contentsTextureAllocator())); >+ >+ if (m_layerTreeHostImpl->settings().delayTextureUpdates) >+ m_currentTextureUpdater->append(texture, sourceRect, destRect); >+ else >+ texture->updateRect(m_layerTreeHostImpl->context(), m_currentTextureUpdater->allocator(), sourceRect, destRect); >+} >+ > // Called by the legacy scheduling path (e.g. where render_widget does the scheduling) > void CCSingleThreadProxy::compositeImmediately() > { >@@ -286,6 +299,7 @@ void CCSingleThreadProxy::commitIfNeeded() > { > ASSERT(CCProxy::isMainThread()); > >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > > doCommit(); >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >index 4345ed62f604b7bc0b8e1b6171eb842b2dff6d06..36a58fa811c306ccab97dbe5e6cb57c3cb368605 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >@@ -33,6 +33,7 @@ > namespace WebCore { > > class CCLayerTreeHost; >+class CCTextureUpdater; > > class CCSingleThreadProxy : public CCProxy, CCLayerTreeHostImplClient { > public: >@@ -56,6 +57,7 @@ public: > virtual void start(); > virtual void stop(); > virtual bool partialTextureUpdateCapability() const { return true; } >+ virtual void update(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); > > // CCLayerTreeHostImplClient implementation > virtual void onSwapBuffersCompleteOnImplThread() { ASSERT_NOT_REACHED(); } >@@ -89,6 +91,8 @@ private: > bool m_graphicsContextLost; > int m_timesRecreateShouldFail; // Used during testing. > bool m_nextFrameIsNewlyCommittedFrame; >+ >+ OwnPtr<CCTextureUpdater> m_currentTextureUpdater; > }; > > // For use in the single-threaded case. In debug builds, it pretends that the >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp >index 8745c4ea0a710bde18ede1820f314fdb8cc872ab..df7724413d173c180628d4f89b40ce89d3a11a7c 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp >@@ -29,6 +29,7 @@ > > #include "cc/CCTextureUpdater.h" > >+#include "cc/CCProxy.h" > #include "GraphicsContext3D.h" > #include "LayerTextureUpdater.h" > #include "ManagedTexture.h" >@@ -39,7 +40,6 @@ namespace WebCore { > > CCTextureUpdater::CCTextureUpdater(TextureAllocator* allocator) > : m_allocator(allocator) >- , m_entryIndex(0) > { > ASSERT(m_allocator); > } >@@ -66,23 +66,20 @@ bool CCTextureUpdater::hasMoreUpdates() const > > bool CCTextureUpdater::update(GraphicsContext3D* context, size_t count) > { >- size_t maxIndex = min(m_entryIndex + count, m_entries.size()); >- for (; m_entryIndex < maxIndex; ++m_entryIndex) { >- UpdateEntry& entry = m_entries[m_entryIndex]; >+ while (count--) { >+ if (!m_entries.size()) >+ return false; >+ >+ UpdateEntry& entry = m_entries.last(); > entry.m_texture->updateRect(context, m_allocator, entry.m_sourceRect, entry.m_destRect); >+ m_entries.removeLast(); > } > >- if (maxIndex < m_entries.size()) >- return true; >- >- // If no entries left to process, auto-clear. >- clear(); >- return false; >+ return m_entries.size() > 0; > } > > void CCTextureUpdater::clear() > { >- m_entryIndex = 0; > m_entries.clear(); > } > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h >index bf79ac9c2e22efc5eda9a64829e2efccec15bb30..c37af34bee64f7c0af5b1036953114023c566683 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h >@@ -59,7 +59,6 @@ private: > }; > > TextureAllocator* m_allocator; >- size_t m_entryIndex; > Vector<UpdateEntry> m_entries; > }; > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >index 4b203f354b993f6331306bec2c0eaeabd83f48f3..335509f20f7f157b79e47f97f1de696f72130ae5 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >@@ -311,6 +311,20 @@ void CCThreadProxy::stop() > m_started = false; > } > >+void CCThreadProxy::update(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ TRACE_EVENT("CCThreadProxy::update", this, 0); >+ ASSERT(isMainThread()); >+ ASSERT(m_started); >+ >+ OwnPtr<UpdateEntry> entry = adoptPtr(new UpdateEntry); >+ entry->m_texture = texture; >+ entry->m_sourceRect = sourceRect; >+ entry->m_destRect = destRect; >+ >+ CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::updateTextureOnImplThread, entry.release())); >+} >+ > void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion) > { > TRACE_EVENT("CCThreadProxy::finishAllRenderingOnImplThread", this, 0); >@@ -397,6 +411,7 @@ void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim > // updateLayers. > m_commitRequested = false; > >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > > // Before applying scrolls and calling animate, we set m_animateRequested to false. >@@ -421,13 +436,25 @@ void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim > ASSERT(m_lastExecutedBeginFrameAndCommitSequenceNumber == sequenceNumber); > } > >+void CCThreadProxy::updateTextureOnImplThread(PassOwnPtr<UpdateEntry> entry) >+{ >+ ASSERT(!m_commitCompletionEventOnImplThread); >+ ASSERT(isImplThread()); >+ if (!m_layerTreeHostImpl) >+ return; >+ >+ if (!m_currentTextureUpdaterOnImplThread) >+ m_currentTextureUpdaterOnImplThread = adoptPtr(new CCTextureUpdater(m_layerTreeHostImpl->contentsTextureAllocator())); >+ >+ m_currentTextureUpdaterOnImplThread->append(entry->m_texture, entry->m_sourceRect, entry->m_destRect); >+} >+ > void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion) > { > TRACE_EVENT("CCThreadProxy::beginFrameCompleteOnImplThread", this, 0); > ASSERT(!m_commitCompletionEventOnImplThread); > ASSERT(isImplThread()); > ASSERT(m_schedulerOnImplThread); >- ASSERT(m_schedulerOnImplThread->commitPending()); > if (!m_layerTreeHostImpl) { > completion->signal(); > return; >@@ -435,10 +462,6 @@ void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion > > m_commitCompletionEventOnImplThread = completion; > >- ASSERT(!m_currentTextureUpdaterOnImplThread); >- m_currentTextureUpdaterOnImplThread = adoptPtr(new CCTextureUpdater(m_layerTreeHostImpl->contentsTextureAllocator())); >- m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), *m_currentTextureUpdaterOnImplThread); >- > m_schedulerOnImplThread->beginFrameComplete(); > } > >@@ -460,19 +483,20 @@ bool CCThreadProxy::canDraw() > void CCThreadProxy::scheduledActionUpdateMoreResources() > { > TRACE_EVENT("CCThreadProxy::scheduledActionUpdateMoreResources", this, 0); >- ASSERT(m_currentTextureUpdaterOnImplThread); >+ if (!m_currentTextureUpdaterOnImplThread) >+ return; > m_currentTextureUpdaterOnImplThread->update(m_layerTreeHostImpl->context(), textureUpdatesPerFrame > 0 ? textureUpdatesPerFrame : 99999); > } > > void CCThreadProxy::scheduledActionCommit() > { > TRACE_EVENT("CCThreadProxy::scheduledActionCommit", this, 0); >- ASSERT(m_currentTextureUpdaterOnImplThread); >- ASSERT(!m_currentTextureUpdaterOnImplThread->hasMoreUpdates()); > ASSERT(m_commitCompletionEventOnImplThread); > >- m_currentTextureUpdaterOnImplThread.clear(); >- >+ if (m_currentTextureUpdaterOnImplThread) { >+ ASSERT(!m_currentTextureUpdaterOnImplThread->hasMoreUpdates()); >+ m_currentTextureUpdaterOnImplThread.clear(); >+ } > > m_layerTreeHostImpl->beginCommit(); > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >index b65a6c604e2923fc8f09cf9ac7f5596d0ab0cdd0..f56d32a7c5a87378c0dffef3301a844e449c4135 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >@@ -64,6 +64,7 @@ public: > virtual void start(); > virtual void stop(); > virtual bool partialTextureUpdateCapability() const; >+ virtual void update(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); > > // CCLayerTreeHostImplClient implementation > virtual void onSwapBuffersCompleteOnImplThread(); >@@ -81,6 +82,12 @@ public: > private: > explicit CCThreadProxy(CCLayerTreeHost*); > >+ struct UpdateEntry { >+ LayerTextureUpdater::Texture* m_texture; >+ IntRect m_sourceRect; >+ IntRect m_destRect; >+ }; >+ > // Called on main thread > void beginFrameAndCommit(int sequenceNumber, double frameBeginTime, PassOwnPtr<CCScrollAndScaleSet>); > void didCommitAndDrawFrame(); >@@ -95,6 +102,7 @@ private: > }; > PassOwnPtr<CCThread::Task> createBeginFrameAndCommitTaskOnImplThread(); > void obtainBeginFrameAndCommitTaskFromCCThread(CCCompletionEvent*, CCThread::Task**); >+ void updateTextureOnImplThread(PassOwnPtr<UpdateEntry>); > void beginFrameCompleteOnImplThread(CCCompletionEvent*); > void requestReadbackOnImplThread(ReadbackRequest*); > void finishAllRenderingOnImplThread(CCCompletionEvent*); >diff --git a/Source/WebKit/chromium/public/WebSettings.h b/Source/WebKit/chromium/public/WebSettings.h >index b5da4e6ba678fe29d8a8d5997d512d5626c8ca9b..e51cbaeab1c13ba435644e5fb07c5615d38df124 100644 >--- a/Source/WebKit/chromium/public/WebSettings.h >+++ b/Source/WebKit/chromium/public/WebSettings.h >@@ -138,6 +138,8 @@ public: > virtual void setAcceleratedPaintingEnabled(bool) = 0; > virtual void setPerTilePaintingEnabled(bool) = 0; > virtual void setPartialSwapEnabled(bool) = 0; >+ virtual void setDelayTextureUpdates(bool) = 0; >+ virtual bool delayTextureUpdates() const = 0; > > protected: > ~WebSettings() { } >diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.cpp b/Source/WebKit/chromium/src/WebSettingsImpl.cpp >index 2723ca78bf472f5d57ed46ce1e6be8140433dc2f..a684117853c98344f24ff53447094e080fdcdc5a 100644 >--- a/Source/WebKit/chromium/src/WebSettingsImpl.cpp >+++ b/Source/WebKit/chromium/src/WebSettingsImpl.cpp >@@ -50,6 +50,7 @@ WebSettingsImpl::WebSettingsImpl(Settings* settings) > , m_compositeToTextureEnabled(false) > , m_showFPSCounter(false) > , m_showPlatformLayerTree(false) >+ , m_delayTextureUpdates(false) > { > ASSERT(settings); > } >@@ -522,4 +523,9 @@ void WebSettingsImpl::setPartialSwapEnabled(bool enabled) > m_settings->setPartialSwapEnabled(enabled); > } > >+void WebSettingsImpl::setDelayTextureUpdates(bool enabled) >+{ >+ m_delayTextureUpdates = enabled; >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.h b/Source/WebKit/chromium/src/WebSettingsImpl.h >index 63a00a0999e32d094cc785da58f5f55afa2a0a43..8a5f67a65b627f98a082115d3acfd7e18e907319 100644 >--- a/Source/WebKit/chromium/src/WebSettingsImpl.h >+++ b/Source/WebKit/chromium/src/WebSettingsImpl.h >@@ -133,12 +133,15 @@ public: > virtual void setAcceleratedPaintingEnabled(bool); > virtual void setPerTilePaintingEnabled(bool); > virtual void setPartialSwapEnabled(bool); >+ virtual void setDelayTextureUpdates(bool); >+ virtual bool delayTextureUpdates() const { return m_delayTextureUpdates; } > > private: > WebCore::Settings* m_settings; > bool m_compositeToTextureEnabled; > bool m_showFPSCounter; > bool m_showPlatformLayerTree; >+ bool m_delayTextureUpdates; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp >index 4629cbb32abe5b4324e56a097fe37d685755ea04..957c63b9dc03133c6176966288ad044df5611534 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.cpp >+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp >@@ -3010,6 +3010,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) > > ccSettings.perTilePainting = page()->settings()->perTileDrawingEnabled(); > ccSettings.partialSwapEnabled = page()->settings()->partialSwapEnabled(); >+ ccSettings.delayTextureUpdates = settings()->delayTextureUpdates(); > > m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this)); > m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders()); >diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >index 2008613cd89d53fa59dcea95f52e6f357f3ac86b..93d7c0b11def404bbd4ae80cbb851a22332b2fe4 100644 >--- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >@@ -976,6 +976,14 @@ TEST_F(CCLayerTreeHostTestSetVisible, runMultiThread) > runTest(true); > } > >+class MockLayerDelegate : public ContentLayerDelegate { >+public: >+ virtual void paintContents(GraphicsContext&, const IntRect&) { } >+ virtual bool drawsContent() const { return true; } >+ virtual bool preserves3D() { return false; } >+ virtual void notifySyncRequired() { } >+}; >+ > class TestOpacityChangeLayerDelegate : public ContentLayerDelegate { > public: > TestOpacityChangeLayerDelegate(CCLayerTreeHostTest* test) >@@ -997,47 +1005,127 @@ private: > > class ContentLayerChromiumWithUpdateTracking : public ContentLayerChromium { > public: >- static PassRefPtr<ContentLayerChromiumWithUpdateTracking> create(ContentLayerDelegate *delegate) { return adoptRef(new ContentLayerChromiumWithUpdateTracking(delegate)); } >+ class ContentLayerTextureUpdater : public LayerTextureUpdater { >+ public: >+ class Texture : public LayerTextureUpdater::Texture { >+ public: >+ Texture(ContentLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >+ : m_texture(texture) >+ , m_textureUpdater(textureUpdater) >+ { >+ } > >- int paintContentsCount() { return m_paintContentsCount; } >- int idlePaintContentsCount() { return m_idlePaintContentsCount; } >- void resetPaintContentsCount() { m_paintContentsCount = 0; m_idlePaintContentsCount = 0;} >+ virtual ManagedTexture* texture() { return m_texture.get(); } >+ >+ virtual void prepareRect(const IntRect& /* sourceRect */) >+ { >+ m_textureUpdater->layer()->prepareRect(); >+ } >+ >+ virtual void updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+ { >+ m_texture->bindTexture(context, allocator); >+ m_textureUpdater->layer()->updateRect(); >+ } >+ >+ private: >+ OwnPtr<ManagedTexture> m_texture; >+ ContentLayerTextureUpdater* m_textureUpdater; >+ }; >+ >+ static PassRefPtr<ContentLayerTextureUpdater> create(ContentLayerChromiumWithUpdateTracking *layer) >+ { >+ return adoptRef(new ContentLayerTextureUpdater(layer)); >+ } >+ >+ virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) >+ { >+ return adoptPtr(new Texture(this, ManagedTexture::create(manager))); >+ } >+ >+ virtual SampledTexelFormat sampledTexelFormat(GC3Denum /* textureFormat */) >+ { >+ return LayerTextureUpdater::SampledTexelFormatRGBA; >+ } > >- int updateCount() { return m_updateCount; } >- void resetUpdateCount() { m_updateCount = 0; } >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */, IntRect* /* resultingOpaqueRect */) >+ { >+ m_layer->paintContents(); >+ } >+ >+ ContentLayerChromiumWithUpdateTracking* layer() { return m_layer; } > >- virtual void paintContentsIfDirty(const Region& occludedScreenSpace) >+ private: >+ explicit ContentLayerTextureUpdater(ContentLayerChromiumWithUpdateTracking* layer) : m_layer(layer) { } >+ >+ ContentLayerChromiumWithUpdateTracking* m_layer; >+ }; >+ >+ static PassRefPtr<ContentLayerChromiumWithUpdateTracking> create(ContentLayerDelegate* delegate) > { >- ContentLayerChromium::paintContentsIfDirty(occludedScreenSpace); >- m_paintContentsCount++; >+ return adoptRef(new ContentLayerChromiumWithUpdateTracking(delegate)); >+ } >+ >+ virtual void createTextureUpdaterIfNeeded() >+ { >+ if (m_contentLayerTextureUpdater) >+ return; >+ >+ m_contentLayerTextureUpdater = ContentLayerTextureUpdater::create(this); >+ m_contentLayerTextureUpdater->setOpaque(opaque()); >+ >+ GC3Denum textureFormat = layerTreeHost()->layerRendererCapabilities().bestTextureFormat; >+ setTextureFormat(textureFormat); >+ setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat)); > } >+ virtual LayerTextureUpdater* textureUpdater() const { return m_contentLayerTextureUpdater.get(); } > >- virtual void idlePaintContentsIfDirty() >+ virtual void prepareToUpdateIfDirty(const Region& occludedScreenSpace) > { >- ContentLayerChromium::idlePaintContentsIfDirty(); >- m_idlePaintContentsCount++; >+ ContentLayerChromium::prepareToUpdateIfDirty(occludedScreenSpace); >+ prepareToUpdate(); > } > >- virtual void updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >+ virtual void idlePrepareToUpdateIfDirty() > { >- ContentLayerChromium::updateCompositorResources(context, updater); >- m_updateCount++; >+ ContentLayerChromium::idlePrepareToUpdateIfDirty(); >+ idlePrepareToUpdate(); > } > >+ void prepareToUpdate() { m_prepareToUpdateCount++; } >+ int prepareToUpdateCount() { return m_prepareToUpdateCount; } >+ >+ void idlePrepareToUpdate() { m_idlePrepareToUpdateCount++; } >+ int idlePrepareToUpdateCount() { return m_idlePrepareToUpdateCount; } >+ >+ void paintContents() { m_paintContentsCount++; } >+ int paintContentsCount() { return m_paintContentsCount; } >+ >+ void prepareRect() { m_prepareRectCount++; } >+ int prepareRectCount() { return m_prepareRectCount; } >+ >+ void updateRect() { m_updateRectCount++; } >+ int updateRectCount() { return m_updateRectCount; } >+ > private: > explicit ContentLayerChromiumWithUpdateTracking(ContentLayerDelegate* delegate) > : ContentLayerChromium(delegate) >+ , m_prepareToUpdateCount(0) >+ , m_idlePrepareToUpdateCount(0) > , m_paintContentsCount(0) >- , m_idlePaintContentsCount(0) >- , m_updateCount(0) >+ , m_prepareRectCount(0) >+ , m_updateRectCount(0) > { > setBounds(IntSize(10, 10)); > setIsDrawable(true); > } > >+ RefPtr<ContentLayerTextureUpdater> m_contentLayerTextureUpdater; >+ int m_prepareToUpdateCount; >+ int m_idlePrepareToUpdateCount; > int m_paintContentsCount; >- int m_idlePaintContentsCount; >- int m_updateCount; >+ int m_prepareRectCount; >+ int m_updateRectCount; > }; > > // Layer opacity change during paint should not prevent compositor resources from being updated during commit. >@@ -1064,16 +1152,19 @@ public: > > virtual void afterTest() > { >- // paintContentsIfDirty() should have been called once. >- EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount()); >+ // prepareToUpdate() should have been called once. >+ EXPECT_EQ(1, m_updateCheckLayer->prepareToUpdateCount()); > >- // idlePaintContentsIfDirty() should have been called once >- EXPECT_EQ(1, m_updateCheckLayer->idlePaintContentsCount()); >+ // idlePrepareToUpdate() should have been called once. >+ EXPECT_EQ(1, m_updateCheckLayer->idlePrepareToUpdateCount()); >+ >+ // paintContents() should have been called once. >+ EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount()); > >- // updateCompositorResources() should have been called the same >- // amout of times as paintContentsIfDirty(). >- EXPECT_EQ(m_updateCheckLayer->paintContentsCount(), >- m_updateCheckLayer->updateCount()); >+ // paintContentsRect() should have been called the same >+ // amount of times as prepareRect(). >+ EXPECT_EQ(m_updateCheckLayer->prepareRectCount(), >+ m_updateCheckLayer->updateRectCount()); > > // clear m_updateCheckLayer so CCLayerTreeHost dies. > m_updateCheckLayer.clear(); >@@ -1103,6 +1194,7 @@ public: > IntSize viewportSize(10, 10); > layerTreeHost()->setViewportSize(viewportSize); > >+ layerTreeHost()->prepareToUpdate(); > layerTreeHost()->updateLayers(); > > EXPECT_EQ(viewportSize, layerTreeHost()->viewportSize()); >@@ -1242,7 +1334,7 @@ class TestLayerChromium : public LayerChromium { > public: > static PassRefPtr<TestLayerChromium> create() { return adoptRef(new TestLayerChromium()); } > >- virtual void paintContentsIfDirty(const Region& occludedScreenSpace) >+ virtual void prepareToUpdateIfDirty(const Region& occludedScreenSpace) > { > m_occludedScreenSpace = occludedScreenSpace; > } >@@ -1301,6 +1393,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >@@ -1318,6 +1411,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >@@ -1336,6 +1430,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >@@ -1356,6 +1451,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >@@ -1378,6 +1474,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >@@ -1400,6 +1497,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >@@ -1423,6 +1521,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >@@ -1446,6 +1545,7 @@ public: > > m_layerTreeHost->setRootLayer(rootLayer); > m_layerTreeHost->setViewportSize(rootLayer->bounds()); >+ m_layerTreeHost->prepareToUpdate(); > m_layerTreeHost->updateLayers(); > m_layerTreeHost->commitComplete(); > >diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp >index 1df27c01119b2657e82e2a0797b1c01b50d305eb..b2327d35e950251526a8e950caf3923810409466 100644 >--- a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp >+++ b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp >@@ -33,7 +33,6 @@ > #include "TextureManager.h" > #include "cc/CCCanvasLayerImpl.h" > #include "cc/CCSingleThreadProxy.h" >-#include "cc/CCTextureUpdater.h" > > #include <gmock/gmock.h> > #include <gtest/gtest.h> >@@ -69,6 +68,21 @@ public: > MOCK_METHOD3(deleteTexture, void(unsigned, const IntSize&, GC3Denum)); > }; > >+class MockUpdateHandler : public LayerTextureUpdater::Handler { >+public: >+ MockUpdateHandler(GraphicsContext3D* context, TextureAllocator* allocator) : m_context(context), m_allocator(allocator) { } >+ >+ virtual void handle(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+ { >+ texture->prepareRect(sourceRect); >+ texture->updateRect(m_context, m_allocator, sourceRect, destRect); >+ } >+ >+private: >+ GraphicsContext3D* m_context; >+ TextureAllocator* m_allocator; >+}; >+ > } // namespace > > namespace WebCore { >@@ -92,7 +106,7 @@ protected: > MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get())); > > MockTextureAllocator allocatorMock; >- CCTextureUpdater updater(&allocatorMock); >+ MockUpdateHandler updateHandlerMock(implContext.get(), &allocatorMock); > > const IntSize size(300, 150); > const size_t maxTextureSize = size.width() * size.height() * 4; >@@ -140,7 +154,8 @@ protected: > canvas->contentChanged(); > EXPECT_TRUE(canvas->needsDisplay()); > Region occludedScreenSpace; >- canvas->paintContentsIfDirty(occludedScreenSpace); >+ canvas->prepareToUpdateIfDirty(occludedScreenSpace); >+ canvas->paintContentsIfDirty(); > EXPECT_FALSE(canvas->needsDisplay()); > { > DebugScopedSetImplThread scopedImplThread; >@@ -148,7 +163,7 @@ protected: > RefPtr<CCLayerImpl> layerImpl = canvas->createCCLayerImpl(); > EXPECT_EQ(0u, static_cast<CCCanvasLayerImpl*>(layerImpl.get())->textureId()); > >- canvas->updateCompositorResources(implContext.get(), updater); >+ canvas->forEachCompositorResource(updateHandlerMock); > canvas->pushPropertiesTo(layerImpl.get()); > > if (threaded) >diff --git a/Source/WebKit/chromium/tests/LayerTextureUpdaterTest.cpp b/Source/WebKit/chromium/tests/LayerTextureUpdaterTest.cpp >index bdbf7bb093018bd6a6b307ff8be381415f58a673..0f7ed570ed6fe4278967fe3b1e5eadb7444e0919 100644 >--- a/Source/WebKit/chromium/tests/LayerTextureUpdaterTest.cpp >+++ b/Source/WebKit/chromium/tests/LayerTextureUpdaterTest.cpp >@@ -95,19 +95,19 @@ TEST(LayerTextureUpdaterTest, testOpaqueRectPresentAfterOpaquePaint) > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillOpaque)); > updater = BitmapCanvasLayerTextureUpdater::create(painter.release(), false); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 400, 400), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillOpaque)); > updater = BitmapSkPictureCanvasLayerTextureUpdater::create(painter.release(), false); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 400, 400), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillOpaque)); > updater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(painter.release()); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 400, 400), opaqueRect); > } > >@@ -121,19 +121,19 @@ TEST(LayerTextureUpdaterTest, testOpaqueRectNotPresentAfterNonOpaquePaint) > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillAlpha)); > updater = BitmapCanvasLayerTextureUpdater::create(painter.release(), false); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillAlpha)); > updater = BitmapSkPictureCanvasLayerTextureUpdater::create(painter.release(), false); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillAlpha)); > updater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(painter.release()); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > } > >@@ -148,21 +148,21 @@ TEST(LayerTextureUpdaterTest, testOpaqueRectNotPresentForOpaqueLayerWithOpaquePa > painter = adoptPtr(new TestLayerPainterChromium(fillOpaque)); > updater = BitmapCanvasLayerTextureUpdater::create(painter.release(), false); > updater->setOpaque(true); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillOpaque)); > updater = BitmapSkPictureCanvasLayerTextureUpdater::create(painter.release(), false); > updater->setOpaque(true); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillOpaque)); > updater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(painter.release()); > updater->setOpaque(true); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > } > >@@ -177,21 +177,21 @@ TEST(LayerTextureUpdaterTest, testOpaqueRectNotPresentForOpaqueLayerWithNonOpaqu > painter = adoptPtr(new TestLayerPainterChromium(fillAlpha)); > updater = BitmapCanvasLayerTextureUpdater::create(painter.release(), false); > updater->setOpaque(true); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillAlpha)); > updater = BitmapSkPictureCanvasLayerTextureUpdater::create(painter.release(), false); > updater->setOpaque(true); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > > opaqueRect = IntRect(); > painter = adoptPtr(new TestLayerPainterChromium(fillAlpha)); > updater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(painter.release()); > updater->setOpaque(true); >- updater->prepareToUpdate(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); >+ updater->paintContents(IntRect(0, 0, 400, 400), IntSize(400, 400), 0, 1, &opaqueRect); > EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), opaqueRect); > } > >diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp >index 0c55090062c0f6fad603cf44a0113eafc190b7ab..4f152956ba343f54240148073c356f28f909a9a4 100644 >--- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp >+++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp >@@ -29,11 +29,11 @@ > #include "CCLayerTreeTestCommon.h" > #include "FakeCCLayerTreeHostClient.h" > #include "LayerTextureUpdater.h" >+#include "ManagedTexture.h" > #include "Region.h" > #include "TextureManager.h" > #include "WebCompositor.h" > #include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread >-#include "cc/CCTextureUpdater.h" > #include "cc/CCTiledLayerImpl.h" > #include <gtest/gtest.h> > >@@ -48,10 +48,9 @@ using namespace WTF; > > namespace { > >-class FakeTextureAllocator : public TextureAllocator { >+class FakeHandler : public LayerTextureUpdater::Handler { > public: >- virtual unsigned createTexture(const IntSize&, GC3Denum) { return 0; } >- virtual void deleteTexture(unsigned, const IntSize&, GC3Denum) { } >+ virtual void handle(LayerTextureUpdater::Texture*, const IntRect&, const IntRect&) { } > }; > > class FakeTiledLayerChromium; >@@ -60,22 +59,26 @@ class FakeLayerTextureUpdater : public LayerTextureUpdater { > public: > class Texture : public LayerTextureUpdater::Texture { > public: >- Texture(PassOwnPtr<ManagedTexture> texture) : LayerTextureUpdater::Texture(texture) { } >+ Texture(PassOwnPtr<ManagedTexture> texture) : m_texture(texture) { } > virtual ~Texture() { } > >+ virtual ManagedTexture* texture() { return m_texture.get(); } > virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect&, const IntRect&) { } >+ >+ private: >+ OwnPtr<ManagedTexture> m_texture; > }; > >- FakeLayerTextureUpdater() : m_prepareCount(0) { } >+ FakeLayerTextureUpdater() : m_paintCount(0) { } > virtual ~FakeLayerTextureUpdater() { } > > // Sets the rect to invalidate during the next call to prepareToUpdate(). After the next > // call to prepareToUpdate() the rect is reset. > void setRectToInvalidate(const IntRect&, FakeTiledLayerChromium*); > >- // Number of times prepareToUpdate has been invoked. >- int prepareCount() const { return m_prepareCount; } >- void clearPrepareCount() { m_prepareCount = 0; } >+ // Number of times paintContents has been invoked. >+ int paintCount() const { return m_paintCount; } >+ void clearPaintCount() { m_paintCount = 0; } > > void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; } > >@@ -84,10 +87,10 @@ public: > > virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(ManagedTexture::create(manager))); } > virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; } >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect); >+ virtual void paintContents(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect); > > private: >- int m_prepareCount; >+ int m_paintCount; > IntRect m_rectToInvalidate; > IntRect m_lastUpdateRect; > IntRect m_opaquePaintRect; >@@ -145,15 +148,25 @@ public: > return TiledLayerChromium::skipsDraw(); > } > >+ void paintContents(const IntRect& rect) >+ { >+ TiledLayerChromium::paintContents(rect); >+ } >+ > FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpdater.get(); } > > virtual TextureManager* textureManager() const { return m_textureManager; } > >- virtual void paintContentsIfDirty(const Region& /* occludedScreenSpace */) >+ virtual void prepareToUpdateIfDirty(const Region& /* occludedScreenSpace */) > { > prepareToUpdate(visibleLayerRect()); > } > >+ virtual void paintContentsIfDirty() >+ { >+ paintContents(visibleLayerRect()); >+ } >+ > private: > virtual void createTextureUpdater(const CCLayerTreeHost*) { } > >@@ -190,9 +203,9 @@ void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiled > m_layer = layer; > } > >-void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect) >+void FakeLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect) > { >- m_prepareCount++; >+ m_paintCount++; > m_lastUpdateRect = contentRect; > if (!m_rectToInvalidate.isEmpty()) { > m_layer->invalidateRect(m_rectToInvalidate); >@@ -209,14 +222,14 @@ TEST(TiledLayerChromiumTest, pushDirtyTiles) > DebugScopedSetImplThread implThread; > RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); > >- FakeTextureAllocator textureAllocator; >- CCTextureUpdater updater(&textureAllocator); >+ FakeHandler handler; > > // The tile size is 100x100, so this invalidates and then paints two tiles. > layer->setBounds(IntSize(100, 200)); > layer->invalidateRect(IntRect(0, 0, 100, 200)); > layer->prepareToUpdate(IntRect(0, 0, 100, 200)); >- layer->updateCompositorResources(0, updater); >+ layer->paintContents(IntRect(0, 0, 100, 200)); >+ layer->forEachCompositorResource(handler); > layer->pushPropertiesTo(layerImpl.get()); > > // We should have both tiles on the impl side. >@@ -229,7 +242,8 @@ TEST(TiledLayerChromiumTest, pushDirtyTiles) > layer->invalidateRect(IntRect(0, 0, 100, 200)); > // ....but then only update one of them. > layer->prepareToUpdate(IntRect(0, 0, 100, 100)); >- layer->updateCompositorResources(0, updater); >+ layer->paintContents(IntRect(0, 0, 100, 100)); >+ layer->forEachCompositorResource(handler); > layer->pushPropertiesTo(layerImpl.get()); > > // We should only have the first tile since the other tile was invalidated but not painted. >@@ -244,8 +258,7 @@ TEST(TiledLayerChromiumTest, pushIdlePaintTiles) > DebugScopedSetImplThread implThread; > RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); > >- FakeTextureAllocator textureAllocator; >- CCTextureUpdater updater(&textureAllocator); >+ FakeHandler handler; > > // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center. > IntSize contentBounds(500, 500); >@@ -261,7 +274,7 @@ TEST(TiledLayerChromiumTest, pushIdlePaintTiles) > // We should need idle-painting for 3x3 tiles in the center. > EXPECT_TRUE(layer->needsIdlePaint(visibleRect)); > >- layer->updateCompositorResources(0, updater); >+ layer->forEachCompositorResource(handler); > layer->pushPropertiesTo(layerImpl.get()); > > // We should have one tile on the impl side. >@@ -274,7 +287,7 @@ TEST(TiledLayerChromiumTest, pushIdlePaintTiles) > layer->prepareToUpdate(visibleRect); > EXPECT_TRUE(layer->needsIdlePaint(visibleRect)); > layer->prepareToUpdateIdle(visibleRect); >- layer->updateCompositorResources(0, updater); >+ layer->forEachCompositorResource(handler); > layer->pushPropertiesTo(layerImpl.get()); > textureManager->unprotectAllTextures(); > } >@@ -310,8 +323,7 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) > DebugScopedSetImplThread implThread; > RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); > >- FakeTextureAllocator textureAllocator; >- CCTextureUpdater updater(&textureAllocator); >+ FakeHandler handler; > > // This invalidates 9 tiles and then paints one visible tile. > layer->setBounds(contentBounds); >@@ -322,7 +334,7 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) > // We should need idle-painting for 3x3 tiles surounding visible tile. > EXPECT_TRUE(layer->needsIdlePaint(visibleRect)); > >- layer->updateCompositorResources(0, updater); >+ layer->forEachCompositorResource(handler); > layer->pushPropertiesTo(layerImpl.get()); > > // We should have one tile on the impl side. >@@ -335,7 +347,7 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) > // We shouldn't signal we need another idle paint after we run out of memory. > EXPECT_FALSE(layer->needsIdlePaint(visibleRect)); > >- layer->updateCompositorResources(0, updater); >+ layer->forEachCompositorResource(handler); > layer->pushPropertiesTo(layerImpl.get()); > } > >@@ -346,14 +358,14 @@ TEST(TiledLayerChromiumTest, invalidateFromPrepare) > DebugScopedSetImplThread implThread; > RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); > >- FakeTextureAllocator textureAllocator; >- CCTextureUpdater updater(&textureAllocator); >+ FakeHandler handler; > > // The tile size is 100x100, so this invalidates and then paints two tiles. > layer->setBounds(IntSize(100, 200)); > layer->invalidateRect(IntRect(0, 0, 100, 200)); > layer->prepareToUpdate(IntRect(0, 0, 100, 200)); >- layer->updateCompositorResources(0, updater); >+ layer->paintContents(IntRect(0, 0, 100, 200)); >+ layer->forEachCompositorResource(handler); > layer->pushPropertiesTo(layerImpl.get()); > > // We should have both tiles on the impl side. >@@ -362,22 +374,24 @@ TEST(TiledLayerChromiumTest, invalidateFromPrepare) > > textureManager->unprotectAllTextures(); > >- layer->fakeLayerTextureUpdater()->clearPrepareCount(); >+ layer->fakeLayerTextureUpdater()->clearPaintCount(); > // Invoke prepareToUpdate again. As the layer is valid prepareToUpdate shouldn't be invoked on > // the LayerTextureUpdater. > layer->prepareToUpdate(IntRect(0, 0, 100, 200)); >- EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount()); >+ EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->paintCount()); > > layer->invalidateRect(IntRect(0, 0, 50, 50)); > // setRectToInvalidate triggers invalidateRect() being invoked from prepareToUpdate. > layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), layer.get()); >- layer->fakeLayerTextureUpdater()->clearPrepareCount(); >+ layer->fakeLayerTextureUpdater()->clearPaintCount(); > layer->prepareToUpdate(IntRect(0, 0, 100, 200)); >- EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); >- layer->fakeLayerTextureUpdater()->clearPrepareCount(); >+ layer->paintContents(IntRect(0, 0, 100, 200)); >+ EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->paintCount()); >+ layer->fakeLayerTextureUpdater()->clearPaintCount(); > // The layer should still be invalid as prepareToUpdate invoked invalidate. > layer->prepareToUpdate(IntRect(0, 0, 100, 200)); >- EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); >+ layer->paintContents(IntRect(0, 0, 100, 200)); >+ EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->paintCount()); > } > > TEST(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) >@@ -388,8 +402,7 @@ TEST(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) > OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); > RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWithScaledBounds(textureManager.get())); > >- FakeTextureAllocator textureAllocator; >- CCTextureUpdater updater(&textureAllocator); >+ FakeHandler handler; > > IntRect layerBounds(0, 0, 300, 200); > IntRect contentBounds(0, 0, 200, 250); >@@ -402,20 +415,23 @@ TEST(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) > // However, it should still be in layer space, not content space. > layer->invalidateRect(contentBounds); > layer->prepareToUpdate(contentBounds); >- layer->updateCompositorResources(0, updater); >+ layer->paintContents(contentBounds); >+ layer->forEachCompositorResource(handler); > EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect()); > > // After the tiles are updated once, another invalidate only needs to update the bounds of the layer. > layer->invalidateRect(contentBounds); > layer->prepareToUpdate(contentBounds); >- layer->updateCompositorResources(0, updater); >+ layer->paintContents(contentBounds); >+ layer->forEachCompositorResource(handler); > EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect()); > > // Partial re-paint should also be represented by the updateRect in layer space, not content space. > IntRect partialDamage(30, 100, 10, 10); > layer->invalidateRect(partialDamage); > layer->prepareToUpdate(contentBounds); >- layer->updateCompositorResources(0, updater); >+ layer->paintContents(contentBounds); >+ layer->forEachCompositorResource(handler); > EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); > } > >@@ -445,24 +461,22 @@ TEST(TiledLayerChromiumTest, skipsDrawGetsReset) > rootLayer->invalidateRect(contentRect); > childLayer->invalidateRect(contentRect); > >- FakeTextureAllocator textureAllocator; >- CCTextureUpdater updater(&textureAllocator); >- > ccLayerTreeHost->setRootLayer(rootLayer); > ccLayerTreeHost->setViewportSize(IntSize(300, 300)); > textureManager->setMaxMemoryLimitBytes(memoryLimit); >+ ccLayerTreeHost->prepareToUpdate(); > ccLayerTreeHost->updateLayers(); >- ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater); > >- // We'll skip the root layer. >- EXPECT_TRUE(rootLayer->skipsDraw()); >- EXPECT_FALSE(childLayer->skipsDraw()); >+ EXPECT_FALSE(rootLayer->skipsDraw()); >+ // We'll skip the child layer. >+ EXPECT_TRUE(childLayer->skipsDraw()); > > ccLayerTreeHost->commitComplete(); > > // Remove the child layer. > rootLayer->removeAllChildren(); > >+ ccLayerTreeHost->prepareToUpdate(); > ccLayerTreeHost->updateLayers(); > EXPECT_FALSE(rootLayer->skipsDraw()); > >@@ -494,6 +508,7 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) > layer->setOpaque(true); > layer->invalidateRect(contentBounds); > layer->prepareToUpdate(contentBounds); >+ layer->paintContents(contentBounds); > > occluded = Region(); > layer->addSelfToOccludedScreenSpace(occluded); >@@ -504,6 +519,7 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) > layer->setOpaque(false); > layer->invalidateRect(contentBounds); > layer->prepareToUpdate(contentBounds); >+ layer->paintContents(contentBounds); > > occluded = Region(); > layer->addSelfToOccludedScreenSpace(occluded); >@@ -515,6 +531,7 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) > layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); > layer->invalidateRect(contentBounds); > layer->prepareToUpdate(contentBounds); >+ layer->paintContents(contentBounds); > > occluded = Region(); > layer->addSelfToOccludedScreenSpace(occluded); >@@ -524,6 +541,7 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) > // If we paint again without invalidating, the same stuff should be occluded. > layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); > layer->prepareToUpdate(contentBounds); >+ layer->paintContents(contentBounds); > > occluded = Region(); > layer->addSelfToOccludedScreenSpace(occluded); >@@ -541,6 +559,7 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) > screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); > layer->setScreenSpaceTransform(screenSpaceTransform); > layer->prepareToUpdate(contentBounds); >+ layer->paintContents(contentBounds); > > occluded = Region(); > layer->addSelfToOccludedScreenSpace(occluded); >@@ -556,6 +575,7 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) > screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); > layer->setScreenSpaceTransform(screenSpaceTransform); > layer->prepareToUpdate(contentBounds); >+ layer->paintContents(contentBounds); > > occluded = Region(); > layer->addSelfToOccludedScreenSpace(occluded);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 72752
:
115869
|
115886
|
116005
|
117073
|
117218
|
117624
|
117646
|
118058
|
118207
|
118412
|
118442
|
118593
|
118710
|
120668
|
121160
|
122406
|
123459
|
123557
|
124307
|
125025
|
125710
|
125962
|
126645
|
129331