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-20111208130233.patch (text/plain), 146.89 KB, created by
David Reveman
on 2011-12-08 10:02:35 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
David Reveman
Created:
2011-12-08 10:02:35 PST
Size:
146.89 KB
patch
obsolete
>Subversion Revision: 102342 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3688934ba66b1a110502dd289d646ad8b5cfe96b..0fdf37e92c9fbcee8fb196e4f65da097107312d4 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,184 @@ >+2011-12-08 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. >+ >+ Split layer updates into two steps. Step one calculates transforms >+ and visible layer areas. Step two paints layer contents. This >+ allows us to perform a compositor resource preparation step after >+ visible layer areas have been computed but before any painting >+ has occurred. LayerChromium::updateCompositorResources is replaced >+ by LayerChromium::forEachCompositorResource which allows us to iterate >+ over compositor resources for various purposes. >+ >+ Add new unit test: CCLayerTreeHostTestNoPrepareRect. >+ >+ * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp: >+ (WebCore::BitmapCanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore::BitmapCanvasLayerTextureUpdater::Texture::updateRect): >+ (WebCore::BitmapCanvasLayerTextureUpdater::paintContents): >+ (WebCore::BitmapCanvasLayerTextureUpdater::updateTextureRect): >+ * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h: >+ * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp: >+ (WebCore::BitmapSkPictureCanvasLayerTextureUpdater::Texture::paintContentsRect): >+ (WebCore::BitmapSkPictureCanvasLayerTextureUpdater::Texture::updateRect): >+ (WebCore::BitmapSkPictureCanvasLayerTextureUpdater::paintContents): >+ * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h: >+ * platform/graphics/chromium/Canvas2DLayerChromium.cpp: >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::UpdaterTexture): >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::~UpdaterTexture): >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::updateRect): >+ (WebCore::Canvas2DLayerChromium::Canvas2DLayerChromium): >+ (WebCore::Canvas2DLayerChromium::updateCompositorResources): >+ (WebCore::Canvas2DLayerChromium::forEachCompositorResource): >+ * platform/graphics/chromium/Canvas2DLayerChromium.h: >+ (WebCore::Canvas2DLayerChromium::UpdaterTexture::create): >+ * platform/graphics/chromium/CanvasLayerTextureUpdater.cpp: >+ (WebCore::CanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore::CanvasLayerTextureUpdater::Texture::~Texture): >+ (WebCore::CanvasLayerTextureUpdater::Texture::needPrepareRect): >+ (WebCore::CanvasLayerTextureUpdater::Texture::prepareRect): >+ (WebCore::CanvasLayerTextureUpdater::paint): >+ * platform/graphics/chromium/CanvasLayerTextureUpdater.h: >+ (WebCore::CanvasLayerTextureUpdater::Texture::texture): >+ * platform/graphics/chromium/ContentLayerChromium.cpp: >+ (WebCore::ContentLayerChromium::prepareToUpdateIfDirty): >+ (WebCore::ContentLayerChromium::paintContentsIfDirty): >+ * platform/graphics/chromium/ContentLayerChromium.h: >+ * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp: >+ (WebCore::FrameBuffer::FrameBuffer::initialize): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect): >+ * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h: >+ * platform/graphics/chromium/ImageLayerChromium.cpp: >+ (WebCore::ImageLayerTextureUpdater::Texture::Texture): >+ (WebCore::ImageLayerTextureUpdater::Texture::texture): >+ (WebCore::ImageLayerTextureUpdater::Texture::needPrepareRect): >+ (WebCore::ImageLayerTextureUpdater::Texture::prepareRect): >+ (WebCore::ImageLayerTextureUpdater::Texture::updateRect): >+ (WebCore::ImageLayerTextureUpdater::paintContents): >+ (WebCore::ImageLayerTextureUpdater::updateTextureRect): >+ (WebCore::ImageLayerChromium::prepareToUpdateIfDirty): >+ * platform/graphics/chromium/ImageLayerChromium.h: >+ * platform/graphics/chromium/LayerChromium.h: >+ (WebCore::LayerChromium::prepareToUpdateIfDirty): >+ (WebCore::LayerChromium::forEachCompositorResource): >+ * platform/graphics/chromium/LayerTextureUpdater.h: >+ (WebCore::LayerTextureUpdater::Texture::texture): >+ (WebCore::LayerTextureUpdater::Texture::needPrepareRect): >+ (WebCore::LayerTextureUpdater::Texture::prepareRect): >+ (WebCore::LayerTextureUpdater::Texture::paintContentsRect): >+ (WebCore::LayerTextureUpdater::Handler::~Handler): >+ (WebCore::LayerTextureUpdater::paintContents): >+ * platform/graphics/chromium/ManagedTexture.cpp: >+ (WebCore::ManagedTexture::allocateTexture): >+ (WebCore::ManagedTexture::bindTexture): >+ * platform/graphics/chromium/ManagedTexture.h: >+ * platform/graphics/chromium/PluginLayerChromium.cpp: >+ (WebCore::PluginLayerChromium::prepareToUpdateIfDirty): >+ * platform/graphics/chromium/PluginLayerChromium.h: >+ * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp: >+ (WebCore::SkPictureCanvasLayerTextureUpdater::paintContents): >+ * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h: >+ * platform/graphics/chromium/TiledLayerChromium.cpp: >+ (WebCore::TiledLayerChromium::forEachCompositorResource): >+ (WebCore::TiledLayerChromium::prepareToUpdate): >+ (WebCore::TiledLayerChromium::paintContents): >+ * platform/graphics/chromium/TiledLayerChromium.h: >+ * platform/graphics/chromium/VideoLayerChromium.cpp: >+ (WebCore::VideoLayerChromium::UpdaterTexture::UpdaterTexture): >+ (WebCore::VideoLayerChromium::UpdaterTexture::~UpdaterTexture): >+ (WebCore::VideoLayerChromium::UpdaterTexture::prepareRect): >+ (WebCore::VideoLayerChromium::UpdaterTexture::dataRect): >+ (WebCore::VideoLayerChromium::UpdaterTexture::updateRect): >+ (WebCore::VideoLayerChromium::VideoLayerChromium): >+ (WebCore::VideoLayerChromium::cleanupResources): >+ (WebCore::VideoLayerChromium::prepareToUpdateIfDirty): >+ (WebCore::VideoLayerChromium::paintContentsIfDirty): >+ (WebCore::VideoLayerChromium::forEachCompositorResource): >+ (WebCore::VideoLayerChromium::pushPropertiesTo): >+ (WebCore::VideoLayerChromium::setLayerTreeHost): >+ (WebCore::VideoLayerChromium::texturesValid): >+ (WebCore::VideoLayerChromium::reserveTextures): >+ * platform/graphics/chromium/VideoLayerChromium.h: >+ (WebCore::VideoLayerChromium::UpdaterTexture::create): >+ (WebCore::VideoLayerChromium::UpdaterTexture::texture): >+ (WebCore::VideoLayerChromium::UpdaterTexture::needPrepareRect): >+ (WebCore::VideoLayerChromium::UpdaterTexture::setVisibleSize): >+ (WebCore::VideoLayerChromium::UpdaterTexture::visibleSize): >+ * platform/graphics/chromium/WebGLLayerChromium.cpp: >+ (WebCore::WebGLLayerChromium::UpdaterTexture::UpdaterTexture): >+ (WebCore::WebGLLayerChromium::UpdaterTexture::~UpdaterTexture): >+ (WebCore::WebGLLayerChromium::UpdaterTexture::updateRect): >+ (WebCore::WebGLLayerChromium::WebGLLayerChromium): >+ (WebCore::WebGLLayerChromium::updateCompositorResources): >+ (WebCore::WebGLLayerChromium::forEachCompositorResource): >+ * platform/graphics/chromium/WebGLLayerChromium.h: >+ (WebCore::WebGLLayerChromium::UpdaterTexture::create): >+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: >+ (WebCore::CCLayerTreeHost::NeedResourceHandler::NeedResourceHandler): >+ (WebCore::CCLayerTreeHost::NeedResourceHandler::~NeedResourceHandler): >+ (WebCore::CCLayerTreeHost::NeedResourceHandler::handle): >+ (WebCore::CCLayerTreeHost::PrepareResourceHandler::PrepareResourceHandler): >+ (WebCore::CCLayerTreeHost::PrepareResourceHandler::~PrepareResourceHandler): >+ (WebCore::CCLayerTreeHost::PrepareResourceHandler::handle): >+ (WebCore::CCLayerTreeHost::PaintHandler::PaintHandler): >+ (WebCore::CCLayerTreeHost::PaintHandler::~PaintHandler): >+ (WebCore::CCLayerTreeHost::PaintHandler::handle): >+ (WebCore::CCLayerTreeHost::prepareToUpdate): >+ (WebCore::CCLayerTreeHost::needsCompositorResources): >+ (WebCore::CCLayerTreeHost::prepareCompositorResources): >+ (WebCore::CCLayerTreeHost::paintContents): >+ (WebCore::CCLayerTreeHost::appendVisibleLayer): >+ (WebCore::CCLayerTreeHost::appendMaskAndReplicaForRenderSurface): >+ (WebCore::CCLayerTreeHost::appendVisibleLayers): >+ (WebCore::CCLayerTreeHost::forEachCompositorResource): >+ (WebCore::CCLayerTreeHost::clearPendingUpdate): >+ * platform/graphics/chromium/cc/CCLayerTreeHost.h: >+ (WebCore::CCSettings::CCSettings): >+ (WebCore::CCLayerTreeHost::NeedResourceHandler::resources): >+ * platform/graphics/chromium/cc/CCProxy.h: >+ * platform/graphics/chromium/cc/CCScheduler.cpp: >+ (WebCore::CCScheduler::setResourceUpdatesPending): >+ (WebCore::CCScheduler::beginFrame): >+ (WebCore::CCScheduler::updateMoreResourcesComplete): >+ (WebCore::CCScheduler::processScheduledActions): >+ * platform/graphics/chromium/cc/CCScheduler.h: >+ * platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp: >+ (WebCore::CCSchedulerStateMachine::CCSchedulerStateMachine): >+ (WebCore::CCSchedulerStateMachine::nextAction): >+ (WebCore::CCSchedulerStateMachine::updateState): >+ (WebCore::CCSchedulerStateMachine::setResourceUpdatesPending): >+ (WebCore::CCSchedulerStateMachine::beginFrameComplete): >+ (WebCore::CCSchedulerStateMachine::updateMoreResourcesComplete): >+ * platform/graphics/chromium/cc/CCSchedulerStateMachine.h: >+ * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: >+ (WebCore::CCSingleThreadProxy::doCommit): >+ (WebCore::CCSingleThreadProxy::update): >+ (WebCore::CCSingleThreadProxy::commitIfNeeded): >+ * platform/graphics/chromium/cc/CCSingleThreadProxy.h: >+ * platform/graphics/chromium/cc/CCTextureUpdater.cpp: >+ (WebCore::CCTextureUpdater::CCTextureUpdater): >+ (WebCore::CCTextureUpdater::update): >+ (WebCore::CCTextureUpdater::clear): >+ * platform/graphics/chromium/cc/CCTextureUpdater.h: >+ * platform/graphics/chromium/cc/CCThreadProxy.cpp: >+ (WebCore::CCThreadProxy::update): >+ (WebCore::CCThreadProxy::beginFrameAndCommit): >+ (WebCore::CCThreadProxy::prepareFrameResourcesOnImplThread): >+ (WebCore::CCThreadProxy::updateTextureOnImplThread): >+ (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread): >+ (WebCore::CCThreadProxy::hasMoreResourceUpdates): >+ (WebCore::CCThreadProxy::scheduledActionUpdateMoreResources): >+ (WebCore::CCThreadProxy::scheduledActionCommit): >+ * platform/graphics/chromium/cc/CCThreadProxy.h: >+ > 2011-12-08 Takashi Toyoshima <toyoshim@chromium.org> > > Provide more specific error description for SocketStreamError. >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 569bbb876af2c28f4b6c08d6b5d910ce6567dddd..9c8af8fdece3eba569bff2f5f757b8376e53f194 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,76 @@ >+2011-12-08 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 CCLayerTreeHostTestNoPrepareRect test. Track changes to scheduler >+ and texture uploads. >+ >+ * public/WebSettings.h: >+ * src/WebSettingsImpl.cpp: >+ (WebKit::WebSettingsImpl::WebSettingsImpl): >+ (WebKit::WebSettingsImpl::setDelayTextureUpdates): >+ * src/WebSettingsImpl.h: >+ (WebKit::WebSettingsImpl::delayTextureUpdates): >+ * src/WebViewImpl.cpp: >+ (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): >+ * tests/CCLayerTreeHostTest.cpp: >+ (WTF::MockLayerDelegate::paintContents): >+ (WTF::MockLayerDelegate::drawsContent): >+ (WTF::MockLayerDelegate::preserves3D): >+ (WTF::MockLayerDelegate::notifySyncRequired): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::Texture): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::texture): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::needPrepareRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::prepareRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::paintContentsRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::Texture::updateRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::create): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::createTexture): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::orientation): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::sampledTexelFormat): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::paintContents): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::layer): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerTextureUpdater::ContentLayerTextureUpdater): >+ (WTF::ContentLayerChromiumWithUpdateTracking::create): >+ (WTF::ContentLayerChromiumWithUpdateTracking::createTextureUpdater): >+ (WTF::ContentLayerChromiumWithUpdateTracking::textureUpdater): >+ (WTF::ContentLayerChromiumWithUpdateTracking::paintContents): >+ (WTF::ContentLayerChromiumWithUpdateTracking::paintContentsCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::prepareRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::prepareRectCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::paintContentsRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::paintContentsRectCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::updateRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::updateRectCount): >+ (WTF::ContentLayerChromiumWithUpdateTracking::needPrepareRect): >+ (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerChromiumWithUpdateTracking): >+ (WTF::CCLayerTreeHostTestOpacityChange::CCLayerTreeHostTestOpacityChange): >+ (WTF::CCLayerTreeHostTestOpacityChange::afterTest): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::CCLayerTreeHostTestNoPrepareRect): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::beginTest): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::commitCompleteOnCCThread): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::afterTest): >+ (WTF::TEST_F): >+ * tests/CCSchedulerStateMachineTest.cpp: >+ (WebCore::StateMachine::setResourceUpdatesPending): >+ (WebCore::StateMachine::resourceUpdatesPending): >+ (WebCore::StateMachine::setFrameComplete): >+ (WebCore::StateMachine::frameComplete): >+ (WebCore::TEST): >+ * tests/CCSchedulerTest.cpp: >+ (WebKitTests::TEST): >+ * tests/TiledLayerChromiumTest.cpp: >+ (WTF::FakeHandler::handle): >+ (WTF::FakeLayerTextureUpdater::Texture::Texture): >+ (WTF::FakeLayerTextureUpdater::Texture::texture): >+ (WTF::FakeLayerTextureUpdater::Texture::updateRect): >+ (WTF::FakeLayerTextureUpdater::paintContents): >+ (WTF::FakeTiledLayerChromium::paintContents): >+ (WTF::TEST): >+ > 2011-12-07 Alexandre Elias <aelias@google.com> > > [chromium] Add page-scale animation support to Impl thread >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >index dd931913f7097762635fe6419d38751aff86179d..07905c1897074804b55d81065e0e6e0a39965325 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >@@ -36,7 +36,7 @@ > namespace WebCore { > > BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >- : LayerTextureUpdater::Texture(texture) >+ : CanvasLayerTextureUpdater::Texture(texture) > , m_textureUpdater(textureUpdater) > { > } >@@ -45,9 +45,11 @@ BitmapCanvasLayerTextureUpdater::Texture::~Texture() > { > } > >-void BitmapCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect) >+void BitmapCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, const IntRect& sourceRect, const IntRect& destRect) > { >- textureUpdater()->updateTextureRect(context, allocator, texture(), sourceRect, destRect); >+ ASSERT(texture()->textureId()); >+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture()->textureId()); >+ textureUpdater()->updateTextureRect(context, texture()->format(), sourceRect, destRect); > } > > PassRefPtr<BitmapCanvasLayerTextureUpdater> BitmapCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage) >@@ -77,7 +79,7 @@ LayerTextureUpdater::SampledTexelFormat BitmapCanvasLayerTextureUpdater::sampled > LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; > } > >-void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale) >+void BitmapCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale) > { > m_texSubImage.setSubImageSize(tileSize); > >@@ -88,15 +90,13 @@ void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect > PlatformCanvas::Painter::TextOption textOption = > borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText; > PlatformCanvas::Painter canvasPainter(&m_canvas, textOption); >- paintContents(*canvasPainter.context(), contentRect, contentsScale); >+ paint(*canvasPainter.context(), contentRect, contentsScale); > } > >-void BitmapCanvasLayerTextureUpdater::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) >+void BitmapCanvasLayerTextureUpdater::updateTextureRect(GraphicsContext3D* context, unsigned format, const IntRect& sourceRect, const IntRect& destRect) > { > PlatformCanvas::AutoLocker locker(&m_canvas); >- >- texture->bindTexture(context, allocator); >- m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context); >+ m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, format, context); > } > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >index 975522cbaaa341475856db6cbeda312c149d87ba..2e91dba04e30d810216c66698ffa9cedff4a6889 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >@@ -40,12 +40,12 @@ class LayerPainterChromium; > // A CanvasLayerTextureUpdater with an internal bitmap. > class BitmapCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater { > public: >- class Texture : public LayerTextureUpdater::Texture { >+ class Texture : public CanvasLayerTextureUpdater::Texture { > public: > Texture(BitmapCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>); > virtual ~Texture(); > >- virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect); >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect); > > private: > BitmapCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } >@@ -59,8 +59,8 @@ public: > virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*); > virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale); >- void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale); >+ void updateTextureRect(GraphicsContext3D*, unsigned format, const IntRect& sourceRect, const IntRect& destRect); > > private: > BitmapCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage); >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp >index 8221dd2e521bd63fe0e6f0f9d6224e38dfb34298..df00e4a9eaee9495f65a0a6d7a56611ca698ebdf 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp >@@ -43,7 +43,7 @@ BitmapSkPictureCanvasLayerTextureUpdater::Texture::Texture(BitmapSkPictureCanvas > { > } > >-void BitmapSkPictureCanvasLayerTextureUpdater::Texture::prepareRect(const IntRect& sourceRect) >+void BitmapSkPictureCanvasLayerTextureUpdater::Texture::paintContentsRect(const IntRect& sourceRect) > { > size_t bufferSize = TextureManager::memoryUseBytes(sourceRect.size(), texture()->format()); > m_pixelData = adoptArrayPtr(new uint8_t[bufferSize]); >@@ -51,9 +51,10 @@ void BitmapSkPictureCanvasLayerTextureUpdater::Texture::prepareRect(const IntRec > textureUpdater()->paintContentsRect(canvas.get(), sourceRect); > } > >-void BitmapSkPictureCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect) >+void BitmapSkPictureCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, const IntRect& sourceRect, const IntRect& destRect) > { >- texture()->bindTexture(context, allocator); >+ ASSERT(texture()->textureId()); >+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture()->textureId()); > ASSERT(m_pixelData.get()); > textureUpdater()->updateTextureRect(context, texture()->format(), destRect, m_pixelData.get()); > m_pixelData.clear(); >@@ -86,10 +87,10 @@ LayerTextureUpdater::SampledTexelFormat BitmapSkPictureCanvasLayerTextureUpdater > LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; > } > >-void BitmapSkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale) >+void BitmapSkPictureCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale) > { > m_texSubImage.setSubImageSize(tileSize); >- SkPictureCanvasLayerTextureUpdater::prepareToUpdate(contentRect, tileSize, borderTexels, contentsScale); >+ SkPictureCanvasLayerTextureUpdater::paintContents(contentRect, tileSize, borderTexels, contentsScale); > } > > 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 c30f307555bd3721b114ffb8b7b0d6c86d5f442b..ec7ac6c9264d92510a2a5f9d08d20f16de74947d 100644 >--- a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h >@@ -42,8 +42,8 @@ public: > public: > Texture(BitmapSkPictureCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>); > >- virtual void prepareRect(const IntRect& sourceRect); >- virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect); >+ virtual void paintContentsRect(const IntRect& sourceRect); >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect); > > private: > BitmapSkPictureCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } >@@ -58,7 +58,7 @@ public: > virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*); > virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale); >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale); > 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 b0c4e073946ba5e51e3dc6a253736a0eca38cacc..e04f18d0062f7e4a69384bb84a1039203f3fe0f8 100644 >--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp >@@ -44,6 +44,20 @@ > > namespace WebCore { > >+Canvas2DLayerChromium::UpdaterTexture::UpdaterTexture(Canvas2DLayerChromium* layer) >+ : m_layer(layer) >+{ >+} >+ >+Canvas2DLayerChromium::UpdaterTexture::~UpdaterTexture() >+{ >+} >+ >+void Canvas2DLayerChromium::UpdaterTexture::updateRect(GraphicsContext3D*, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ m_layer->updateCompositorResources(); >+} >+ > PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(GraphicsContext3D* context) > { > return adoptRef(new Canvas2DLayerChromium(context)); >@@ -52,6 +66,7 @@ PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(GraphicsContext3 > Canvas2DLayerChromium::Canvas2DLayerChromium(GraphicsContext3D* context) > : CanvasLayerChromium(0) > , m_context(context) >+ , m_updaterTexture(UpdaterTexture::create(this)) > { > } > >@@ -65,7 +80,7 @@ bool Canvas2DLayerChromium::drawsContent() const > && (m_context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR)); > } > >-void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) >+void Canvas2DLayerChromium::updateCompositorResources() > { > if (!m_needsDisplay || !drawsContent()) > return; >@@ -85,6 +100,11 @@ void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, CCText > m_needsDisplay = false; > } > >+void Canvas2DLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) >+{ >+ handler.handle(m_updaterTexture.get(), IntRect(), IntRect()); >+} >+ > void Canvas2DLayerChromium::contentChanged() > { > if (layerTreeHost()) >diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h >index 457bd564d778dab94ac99113f81ebfe75defdd4f..e86a61a4eee4520aba686c4193a6f78f0fc50f09 100644 >--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h >@@ -43,16 +43,36 @@ class GraphicsContext3D; > // 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*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ explicit UpdaterTexture(Canvas2DLayerChromium*); >+ >+ Canvas2DLayerChromium* m_layer; >+ }; >+ > static PassRefPtr<Canvas2DLayerChromium> create(GraphicsContext3D*); > virtual ~Canvas2DLayerChromium(); > virtual bool drawsContent() const; >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ void updateCompositorResources(); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > > virtual void contentChanged(); > > private: > explicit Canvas2DLayerChromium(GraphicsContext3D*); > GraphicsContext3D* m_context; >+ >+ OwnPtr<UpdaterTexture> m_updaterTexture; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >index 5fa67854c6bd7f5382b52b0eefba103166fc08fe..c61ec33d67e653712d2b92113fb79babf839b5d4 100644 >--- a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >@@ -36,6 +36,24 @@ > > namespace WebCore { > >+CanvasLayerTextureUpdater::Texture::Texture(PassOwnPtr<ManagedTexture> texture) : m_texture(texture) >+{ >+} >+ >+CanvasLayerTextureUpdater::Texture::~Texture() >+{ >+} >+ >+bool CanvasLayerTextureUpdater::Texture::needPrepareRect() >+{ >+ return !m_texture->textureId(); >+} >+ >+void CanvasLayerTextureUpdater::Texture::prepareRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ m_texture->allocateTexture(context, allocator); >+} >+ > CanvasLayerTextureUpdater::CanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter) > : m_painter(painter) > { >@@ -45,7 +63,7 @@ CanvasLayerTextureUpdater::~CanvasLayerTextureUpdater() > { > } > >-void CanvasLayerTextureUpdater::paintContents(GraphicsContext& context, const IntRect& contentRect, float contentsScale) >+void CanvasLayerTextureUpdater::paint(GraphicsContext& context, const IntRect& contentRect, float contentsScale) > { > context.translate(-contentRect.x(), -contentRect.y()); > { >diff --git a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >index a8feff3422b1b8530b8f689ff2c5667660bed5cf..886d1012d8e53279ce74e51a10349db81a89fe9e 100644 >--- a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >@@ -30,6 +30,7 @@ > #if USE(ACCELERATED_COMPOSITING) > > #include "LayerTextureUpdater.h" >+#include "ManagedTexture.h" > > namespace WebCore { > >@@ -39,12 +40,28 @@ class LayerPainterChromium; > // A LayerTextureUpdater with an internal canvas. > class CanvasLayerTextureUpdater : public LayerTextureUpdater { > public: >+ class Texture : public LayerTextureUpdater::Texture { >+ public: >+ virtual ~Texture(); >+ >+ virtual ManagedTexture* texture() { return m_texture.get(); } >+ >+ virtual bool needPrepareRect(); >+ virtual void prepareRect(GraphicsContext3D*, TextureAllocator*, const IntRect& /* sourceRect */, const IntRect& /* destRect */); >+ >+ protected: >+ explicit Texture(PassOwnPtr<ManagedTexture>); >+ >+ private: >+ OwnPtr<ManagedTexture> m_texture; >+ }; >+ > virtual ~CanvasLayerTextureUpdater(); > > protected: > explicit CanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>); > >- void paintContents(GraphicsContext&, const IntRect& contentRect, float contentsScale); >+ void paint(GraphicsContext&, const IntRect& contentRect, float contentsScale); > const IntRect& contentRect() const { return m_contentRect; } > > private: >diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >index 2a2466d9129aec364093229cb935af82d50724b6..dd749677cb712d04f7de20511032ce7735929d31 100644 >--- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >@@ -94,7 +94,7 @@ void ContentLayerChromium::cleanupResources() > TiledLayerChromium::cleanupResources(); > } > >-void ContentLayerChromium::paintContentsIfDirty() >+void ContentLayerChromium::prepareToUpdateIfDirty() > { > updateTileSizeAndTilingOption(); > >@@ -109,6 +109,20 @@ void ContentLayerChromium::paintContentsIfDirty() > m_needsDisplay = false; > } > >+void ContentLayerChromium::paintContentsIfDirty() >+{ >+ ASSERT(drawsContent()); >+ >+ const IntRect& layerRect = visibleLayerRect(); >+ if (layerRect.isEmpty()) >+ return; >+ >+ if (!drawsContent()) >+ return; >+ >+ paintContents(layerRect); >+} >+ > bool ContentLayerChromium::drawsContent() const > { > return m_delegate && m_delegate->drawsContent() && TiledLayerChromium::drawsContent(); >diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h >index b834e676bd63445aa453b365eee280240f3809c1..c5e9fccebf476eb7d02bc9822170b6653a513bb5 100644 >--- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h >@@ -49,6 +49,7 @@ public: > > virtual ~ContentLayerChromium(); > >+ virtual void prepareToUpdateIfDirty(); > virtual void paintContentsIfDirty(); > > protected: >diff --git a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp >index f2d7e2dddaa6fd99fbe603c3b8e373e998a33835..9eefb46b5e524f7ee23598378505b4f2e4a29ea8 100644 >--- a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp >@@ -44,7 +44,7 @@ public: > FrameBuffer(); > ~FrameBuffer(); > >- SkCanvas* initialize(GraphicsContext3D*, TextureAllocator*, ManagedTexture*); >+ SkCanvas* initialize(GraphicsContext3D*, ManagedTexture*); > > private: > GraphicsContext3D* m_context; >@@ -66,12 +66,12 @@ FrameBuffer::~FrameBuffer() > m_context->deleteFramebuffer(m_fbo); > } > >-SkCanvas* FrameBuffer::initialize(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture) >+SkCanvas* FrameBuffer::initialize(GraphicsContext3D* context, ManagedTexture* texture) > { > m_context = context; > m_fbo = m_context->createFramebuffer(); > m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >- texture->framebufferTexture2D(m_context, allocator); >+ context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->textureId(), 0); > > // Create a skia gpu canvas. > GrContext* grContext = m_context->grContext(); >@@ -96,7 +96,7 @@ SkCanvas* FrameBuffer::initialize(GraphicsContext3D* context, TextureAllocator* > } // namespace > > FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture(FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >- : LayerTextureUpdater::Texture(texture) >+ : CanvasLayerTextureUpdater::Texture(texture) > , m_textureUpdater(textureUpdater) > { > } >@@ -105,9 +105,23 @@ FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture() > { > } > >-void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect) >+void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, const IntRect& sourceRect, const IntRect& destRect) > { >- textureUpdater()->updateTextureRect(context, allocator, texture(), sourceRect, destRect); >+ // Make sure SKIA uses the correct GL context. >+ context->makeContextCurrent(); >+ // Notify SKIA to sync its internal GL state. >+ context->grContext()->resetContext(); >+ >+ ASSERT(texture()->textureId()); >+ >+ // Create an accelerated canvas to draw on. >+ FrameBuffer buffer; >+ SkCanvas* canvas = buffer.initialize(context, texture()); >+ >+ textureUpdater()->updateTextureRect(context, canvas, sourceRect, destRect); >+ >+ // Flush SKIA context so that all the rendered stuff appears on the texture. >+ context->grContext()->flush(); > } > > PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> FrameBufferSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter) >@@ -135,26 +149,14 @@ LayerTextureUpdater::SampledTexelFormat FrameBufferSkPictureCanvasLayerTextureUp > return LayerTextureUpdater::SampledTexelFormatRGBA; > } > >-void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) >+void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(GraphicsContext3D* context, SkCanvas* canvas, const IntRect& sourceRect, const IntRect& destRect) > { >- // Make sure SKIA uses the correct GL context. >- context->makeContextCurrent(); >- // Notify SKIA to sync its internal GL state. >- context->grContext()->resetContext(); >- >- // Create an accelerated canvas to draw on. >- FrameBuffer buffer; >- SkCanvas* canvas = buffer.initialize(context, allocator, texture); >- > canvas->clipRect(SkRect(destRect)); > // Translate the origin of contentRect to that of destRect. > // Note that destRect is defined relative to sourceRect. > canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(), > contentRect().y() - sourceRect.y() + destRect.y()); > drawPicture(canvas); >- >- // Flush SKIA context so that all the rendered stuff appears on the texture. >- context->grContext()->flush(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >index 06b62d1999b56235041cc0dbb222491051f959eb..a8ff85ff5bbe478a2d585dfa675ced38ca049409 100644 >--- a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >@@ -32,16 +32,18 @@ > > #include "SkPictureCanvasLayerTextureUpdater.h" > >+class SkCanvas; >+ > namespace WebCore { > > class FrameBufferSkPictureCanvasLayerTextureUpdater : public SkPictureCanvasLayerTextureUpdater { > public: >- class Texture : public LayerTextureUpdater::Texture { >+ class Texture : public CanvasLayerTextureUpdater::Texture { > public: > Texture(FrameBufferSkPictureCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>); > virtual ~Texture(); > >- virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect); >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect); > > private: > FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } >@@ -55,7 +57,7 @@ public: > virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*); > virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; } > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >- void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); >+ void updateTextureRect(GraphicsContext3D*, SkCanvas*, const IntRect& sourceRect, const IntRect& destRect); > > private: > explicit FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>); >diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >index 4fb9574d48ee0028728e922e14e316709a604dda..1e33c6d2697bf010206de41383133172d69fc320 100644 >--- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >@@ -49,19 +49,34 @@ public: > class Texture : public LayerTextureUpdater::Texture { > public: > Texture(ImageLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >- : LayerTextureUpdater::Texture(texture) >+ : m_texture(texture) > , m_textureUpdater(textureUpdater) > { > } > >- virtual void updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect) >+ virtual ManagedTexture* texture() { return m_texture.get(); } >+ >+ virtual bool needPrepareRect() >+ { >+ return !m_texture->textureId(); >+ } >+ >+ virtual void prepareRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& /* sourceRect */, const IntRect& /* destRect */) > { >- textureUpdater()->updateTextureRect(context, allocator, texture(), sourceRect, destRect); >+ m_texture->allocateTexture(context, allocator); >+ } >+ >+ virtual void updateRect(GraphicsContext3D* context, const IntRect& sourceRect, const IntRect& destRect) >+ { >+ ASSERT(texture()->textureId()); >+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture()->textureId()); >+ textureUpdater()->updateTextureRect(context, texture()->format(), sourceRect, destRect); > } > > private: > ImageLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } > >+ OwnPtr<ManagedTexture> m_texture; > ImageLayerTextureUpdater* m_textureUpdater; > }; > >@@ -85,15 +100,13 @@ public: > LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; > } > >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int /* borderTexels */, float /* contentsScale */) >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& tileSize, int /* borderTexels */, float /* contentsScale */) > { > m_texSubImage.setSubImageSize(tileSize); > } > >- virtual void updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) >+ virtual void updateTextureRect(GraphicsContext3D* context, unsigned format, const IntRect& sourceRect, const IntRect& destRect) > { >- texture->bindTexture(context, allocator); >- > // Source rect should never go outside the image pixels, even if this > // is requested because the texture extends outside the image. > IntRect clippedSourceRect = sourceRect; >@@ -103,7 +116,7 @@ public: > clippedDestRect.move(clippedSourceRect.location() - sourceRect.location()); > clippedDestRect.setSize(clippedSourceRect.size()); > >- m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, clippedDestRect, texture->format(), context); >+ m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, clippedDestRect, format, context); > } > > void updateFromImage(NativeImagePtr nativeImage) >@@ -166,7 +179,7 @@ void ImageLayerChromium::setContents(Image* contents) > setNeedsDisplay(); > } > >-void ImageLayerChromium::paintContentsIfDirty() >+void ImageLayerChromium::prepareToUpdateIfDirty() > { > if (m_needsDisplay) { > m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame()); >diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h >index 5fe4f26668bdcc3e29f04cffcda882a73c31e327..f6ebc8a7e8b907318cf5206c4fb4e87faea1e07b 100644 >--- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h >@@ -53,7 +53,7 @@ public: > virtual ~ImageLayerChromium(); > > virtual bool drawsContent() const; >- virtual void paintContentsIfDirty(); >+ virtual void prepareToUpdateIfDirty(); > 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 5e05c157c795ce1e064df2df964407adbfe550b0..fd043f095d1a6023f5d66db8e877dc3f747c5470 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 CCLayerDelegate { >@@ -160,8 +160,9 @@ public: > > // These methods typically need to be overwritten by derived classes. > virtual bool drawsContent() const { return false; } >+ virtual void prepareToUpdateIfDirty() { } > virtual void paintContentsIfDirty() { } >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) { } >+ 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 bf75cf29a89e389e27677b119206ef29a4e30146..226bc2181d316480db990c63082d55889ac7b182 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >@@ -29,7 +29,6 @@ > > #if USE(ACCELERATED_COMPOSITING) > >-#include "ManagedTexture.h" > #include "GraphicsTypes3D.h" > #include <wtf/RefCounted.h> > >@@ -38,6 +37,7 @@ namespace WebCore { > class GraphicsContext3D; > class IntRect; > class IntSize; >+class ManagedTexture; > class TextureAllocator; > class TextureManager; > >@@ -48,14 +48,23 @@ public: > public: > virtual ~Texture() { } > >- ManagedTexture* texture() { return m_texture.get(); } >- 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) { } >+ virtual ManagedTexture* texture() { return 0; } > >- private: >- OwnPtr<ManagedTexture> m_texture; >+ // prepareRect() will only be called if this returns true. >+ virtual bool needPrepareRect() { return false; } >+ // This runs synchronously on the impl thread with safe access to main thread resources. >+ virtual void prepareRect(GraphicsContext3D*, TextureAllocator*, const IntRect& /* sourceRect */, const IntRect& /* destRect */) { } >+ // This runs on the main thread after calls to needPrepareRect() and prepareRect() but before updateRect(). >+ virtual void paintContentsRect(const IntRect& /* sourceRect */) { } >+ // This runs asynchronously on the impl thread. Access to main thread resources is unsafe. >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect) = 0; >+ }; >+ >+ class Handler { >+ public: >+ virtual ~Handler() { } >+ >+ virtual void handle(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect) = 0; > }; > > virtual ~LayerTextureUpdater() { } >@@ -78,7 +87,7 @@ public: > // This format specifies the component order in the sampled texel. > // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red. > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0; >- virtual void prepareToUpdate(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */) { } >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */) { } > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp >index cbdfe03c2c5443bceaf43ca6af02a73c571d0333..ee18025faa1de5b0f06250317d889da8d69ad7d4 100644 >--- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp >@@ -80,11 +80,16 @@ void ManagedTexture::unreserve() > m_textureManager->unprotectTexture(m_token); > } > >-void ManagedTexture::bindTexture(GraphicsContext3D* context, TextureAllocator* allocator) >+void ManagedTexture::allocateTexture(GraphicsContext3D* context, TextureAllocator* allocator) > { > ASSERT(m_textureManager->hasTexture(m_token)); > if (!m_textureId) > m_textureId = m_textureManager->allocateTexture(allocator, m_token); >+} >+ >+void ManagedTexture::bindTexture(GraphicsContext3D* context, TextureAllocator* allocator) >+{ >+ allocateTexture(context, allocator); > context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); > } > >diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h >index 4d43809595340f5d733d5679291a92064c7b1ae5..d73c8742d7840e229014e01afed2566d7c99bc0a 100644 >--- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h >+++ b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h >@@ -55,6 +55,7 @@ public: > return m_textureManager->isProtected(m_token); > } > >+ void allocateTexture(GraphicsContext3D*, TextureAllocator*); > void bindTexture(GraphicsContext3D*, TextureAllocator*); > void framebufferTexture2D(GraphicsContext3D*, TextureAllocator*); > >diff --git a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp >index e3c5c48f7920feec708e4dac7aef64e23e8aaf00..603268a62e3f2d04709b6cdb629dabec376fcbd2 100644 >--- a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp >@@ -52,7 +52,7 @@ PluginLayerChromium::PluginLayerChromium(CCLayerDelegate* delegate) > { > } > >-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 277a969c58cc3f5834587e0778ffd1c6277d66f6..16f3fc1b3ce82542fdf40706da608872935c3e63 100644 >--- a/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h >@@ -38,7 +38,7 @@ class PluginLayerChromium : public LayerChromium { > public: > static PassRefPtr<PluginLayerChromium> create(CCLayerDelegate* = 0); > virtual bool drawsContent() const { return true; } >- 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 537e137e8d8ec518b934aa5cd2d700c74b19fe4b..55a1db8fb603e6d04902aacfcfff8709e895eb4f 100644 >--- a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp >+++ b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp >@@ -48,13 +48,13 @@ SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater() > { > } > >-void SkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */, float contentsScale) >+void SkPictureCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */, float contentsScale) > { > SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height()); > PlatformContextSkia platformContext(canvas); > platformContext.setDeferred(true); > GraphicsContext graphicsContext(&platformContext); >- paintContents(graphicsContext, contentRect, contentsScale); >+ paint(graphicsContext, contentRect, contentsScale); > m_picture.endRecording(); > } > >diff --git a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >index 440f8b03ea4f2739a97543867ac7eb154030d0c2..aefbfc3f6a4a2a3aa71a5b1fb43edeaf1cbf6de8 100644 >--- a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >@@ -46,7 +46,7 @@ public: > protected: > explicit SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>); > >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale); >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale); > void drawPicture(SkCanvas*); > > private: >diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >index 5c55f59bf3e7372fe9ec512ef6361101ac5a05e5..2a681582b365f4c4aead1f23bef6cd916ca747a8 100644 >--- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >@@ -172,14 +172,14 @@ void TiledLayerChromium::createTiler(CCLayerTilingData::BorderTexelOption border > m_tiler = CCLayerTilingData::create(m_tileSize, borderTexelOption); > } > >-void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater& updater) >+void TiledLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) > { > // If this assert is hit, it means that paintContentsIfDirty hasn't been > // called on this layer. Any layer that is updated should be painted first. > ASSERT(m_tiler); > > // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. >- if (m_skipsDraw || m_requestedUpdateRect.isEmpty() || !m_tiler || !m_tiler->numTiles()) >+ if (m_skipsDraw || m_requestedUpdateRect.isEmpty() || !m_tiler || !m_tiler->numTiles() || m_paintRect.isEmpty()) > return; > > int left, top, right, bottom; >@@ -219,11 +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); > } > } >- >- m_updateRect = FloatRect(m_tiler->contentRectToLayerRect(m_paintRect)); > } > > void TiledLayerChromium::setTilingOption(TilingOption tilingOption) >@@ -399,15 +397,9 @@ void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect) > m_requestedUpdateRect = contentRect; > > m_paintRect = m_tiler->layerRectToContentRect(dirtyLayerRect); >- if (dirtyLayerRect.isEmpty()) >+ if (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()); >- textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale()); > m_tiler->contentRectToTileIndices(m_requestedUpdateRect, left, top, right, bottom); > for (int j = top; j <= bottom; ++j) { > for (int i = left; i <= right; ++i) { >@@ -432,13 +424,25 @@ void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect) > tile->clearDirty(); > > tile->m_updateRect = sourceRect; >- if (sourceRect.isEmpty()) >- continue; >- >- tile->texture()->prepareRect(sourceRect); > } > } > } > >+void TiledLayerChromium::paintContents(const IntRect& contentRect) >+{ >+ if (m_skipsDraw || m_requestedUpdateRect.isEmpty() || !m_tiler->numTiles() || m_paintRect.isEmpty()) >+ return; >+ >+ // Calling paintContents() 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()); >+ textureUpdater()->paintContents(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale()); >+ >+ m_updateRect = FloatRect(m_tiler->contentRectToLayerRect(m_paintRect)); >+} >+ >+ > } > #endif // USE(ACCELERATED_COMPOSITING) >diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h >index 28e7d1d0c5696800f3d6212408dd8d18bcedbec2..e47818f64206617317fe95a331917c77f840ec5e 100644 >--- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h >@@ -43,7 +43,7 @@ public: > > virtual ~TiledLayerChromium(); > >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > virtual void setIsMask(bool); > > virtual void pushPropertiesTo(CCLayerImpl*); >@@ -75,8 +75,10 @@ protected: > > // Set invalidations to be potentially repainted during update(). > void invalidateRect(const IntRect& contentRect); >- // Prepare data needed to update textures that intersect with contentRect. >+ // Prepare to update textures that intersect with contentRect. > void prepareToUpdate(const IntRect& contentRect); >+ // Paint contents needed to update textures that intersect with contentRect. >+ void paintContents(const IntRect& contentRect); > > virtual void protectVisibleTileTextures(); > >@@ -93,7 +95,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_requestedUpdateRect; > // State held between prepareToUpdate() and pushPropertiesTo(). This represents the area > // of the layer that is actually re-painted by WebKit. >diff --git a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp >index ec93f168da14ea41e3c16df6d7c49bee4513eace..7bec7c0a18003dc91e1d4cbaadde9d3b2d41fec1 100644 >--- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp >@@ -40,11 +40,61 @@ > #include "VideoFrameChromium.h" > #include "VideoFrameProvider.h" > #include "cc/CCLayerImpl.h" >-#include "cc/CCTextureUpdater.h" > #include "cc/CCVideoLayerImpl.h" > > namespace WebCore { > >+VideoLayerChromium::UpdaterTexture::UpdaterTexture(PassOwnPtr<ManagedTexture> texture) >+ : m_texture(texture) >+ , m_mappedBuffer(0) >+{ >+} >+ >+VideoLayerChromium::UpdaterTexture::~UpdaterTexture() >+{ >+ ASSERT(!m_mappedBuffer); >+} >+ >+void VideoLayerChromium::UpdaterTexture::prepareRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ IntSize dimensions = m_texture->size(); >+ >+ Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions()); >+ m_mappedBuffer = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, dimensions.width(), dimensions.height(), m_texture->format(), GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY)); >+ >+ if (!m_mappedBuffer) { >+ size_t bufferSize = TextureManager::memoryUseBytes(dimensions, m_texture->format()); >+ m_buffer = adoptArrayPtr(new uint8_t[bufferSize]); >+ } >+ >+ m_texture->allocateTexture(context, allocator); >+} >+ >+void VideoLayerChromium::UpdaterTexture::dataRect(const void* data) >+{ >+ size_t bufferSize = TextureManager::memoryUseBytes(m_texture->size(), m_texture->format()); >+ >+ if (m_mappedBuffer) >+ memcpy(m_mappedBuffer, data, bufferSize); >+ else >+ memcpy(m_buffer.get(), data, bufferSize); >+} >+ >+void VideoLayerChromium::UpdaterTexture::updateRect(GraphicsContext3D* context, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ ASSERT(m_texture->textureId()); >+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_texture->textureId()); >+ if (m_mappedBuffer) { >+ Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions()); >+ GLC(context, extensions->unmapTexSubImage2DCHROMIUM(m_mappedBuffer)); >+ m_mappedBuffer = 0; >+ } else { >+ IntSize dimensions = m_texture->size(); >+ GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, dimensions.width(), dimensions.height(), m_texture->format(), GraphicsContext3D::UNSIGNED_BYTE, m_buffer.get())); >+ m_buffer.clear(); >+ } >+} >+ > PassRefPtr<VideoLayerChromium> VideoLayerChromium::create(CCLayerDelegate* delegate, > VideoFrameProvider* provider) > { >@@ -58,6 +108,7 @@ VideoLayerChromium::VideoLayerChromium(CCLayerDelegate* delegate, VideoFrameProv > , m_provider(provider) > , m_planes(0) > , m_nativeTextureId(0) >+ , m_frame(0) > { > } > >@@ -75,17 +126,19 @@ void VideoLayerChromium::cleanupResources() > { > LayerChromium::cleanupResources(); > for (unsigned i = 0; i < MaxPlanes; ++i) >- m_textures[i].m_texture.clear(); >+ m_textures[i].clear(); > } > >-void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >+void VideoLayerChromium::prepareToUpdateIfDirty() > { >+ m_frame = 0; >+ > if (!m_delegate || !m_provider || !drawsContent()) > return; > > if (!m_needsDisplay && texturesValid()) { > for (unsigned plane = 0; plane < m_planes; plane++) { >- ManagedTexture* tex = m_textures[plane].m_texture.get(); >+ ManagedTexture* tex = m_textures[plane]->texture(); > if (!tex->reserve(tex->size(), tex->format())) { > m_skipsDraw = true; > break; >@@ -123,8 +176,10 @@ void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, C > return; > } > >- // Allocate textures for planes if they are not allocated already, or >- // reallocate textures that are the wrong size for the frame. >+ if (frame->planes() > MaxPlanes) >+ CRASH(); >+ >+ // Reserve textures for planes if they are not reserved already. > bool texturesReserved = reserveTextures(frame, textureFormat); > if (!texturesReserved) { > m_skipsDraw = true; >@@ -132,21 +187,34 @@ void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, C > return; > } > >- // Update texture planes. >- for (unsigned plane = 0; plane < frame->planes(); plane++) { >- Texture& texture = m_textures[plane]; >- ASSERT(texture.m_texture); >- ASSERT(frame->requiredTextureSize(plane) == texture.m_texture->size()); >- updateTexture(context, updater.allocator(), texture, frame->data(plane)); >- } >- >+ m_frame = frame; > m_planes = frame->planes(); >- ASSERT(m_planes <= MaxPlanes); > > m_updateRect = FloatRect(FloatPoint(), bounds()); > m_needsDisplay = false; >+} >+ >+void VideoLayerChromium::paintContentsIfDirty() >+{ >+ if (!m_frame) >+ return; > >- m_provider->putCurrentFrame(frame); >+ // Copy planes to mapped buffers. >+ for (unsigned plane = 0; plane < m_frame->planes(); plane++) >+ m_textures[plane]->dataRect(m_frame->data(plane)); >+ >+ m_provider->putCurrentFrame(m_frame); >+} >+ >+void VideoLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) >+{ >+ if (!m_frame) >+ return; >+ >+ for (unsigned plane = 0; plane < m_planes; plane++) { >+ IntRect rect(IntPoint(), m_textures[plane]->visibleSize()); >+ handler.handle(m_textures[plane].get(), rect, rect); >+ } > } > > void VideoLayerChromium::pushPropertiesTo(CCLayerImpl* layer) >@@ -157,11 +225,11 @@ void VideoLayerChromium::pushPropertiesTo(CCLayerImpl* layer) > videoLayer->setSkipsDraw(m_skipsDraw); > videoLayer->setFrameFormat(m_frameFormat); > for (unsigned i = 0; i < m_planes; ++i) { >- if (!m_textures[i].m_texture) { >+ if (!m_textures[i]) { > videoLayer->setSkipsDraw(true); > break; > } >- videoLayer->setTexture(i, m_textures[i].m_texture->textureId(), m_textures[i].m_texture->size(), m_textures[i].m_visibleSize); >+ videoLayer->setTexture(i, m_textures[i]->texture()->textureId(), m_textures[i]->texture()->size(), m_textures[i]->visibleSize()); > } > for (unsigned i = m_planes; i < MaxPlanes; ++i) > videoLayer->setTexture(i, 0, IntSize(), IntSize()); >@@ -172,10 +240,8 @@ void VideoLayerChromium::pushPropertiesTo(CCLayerImpl* layer) > void VideoLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) > { > if (host && layerTreeHost() != host) { >- for (unsigned i = 0; i < MaxPlanes; ++i) { >- m_textures[i].m_visibleSize = IntSize(); >- m_textures[i].m_texture = ManagedTexture::create(host->contentsTextureManager()); >- } >+ for (unsigned i = 0; i < MaxPlanes; ++i) >+ m_textures[i] = UpdaterTexture::create(ManagedTexture::create(host->contentsTextureManager())); > } > > LayerChromium::setLayerTreeHost(host); >@@ -199,8 +265,10 @@ GC3Denum VideoLayerChromium::determineTextureFormat(const VideoFrameChromium* fr > > bool VideoLayerChromium::texturesValid() > { >+ ASSERT(layerTreeHost()); >+ > for (unsigned plane = 0; plane < m_planes; plane++) { >- ManagedTexture* tex = m_textures[plane].m_texture.get(); >+ ManagedTexture* tex = m_textures[plane]->texture(); > if (!tex->isValid(tex->size(), tex->format())) > return false; > } >@@ -217,19 +285,20 @@ bool VideoLayerChromium::reserveTextures(const VideoFrameChromium* frame, GC3Den > > for (unsigned plane = 0; plane < frame->planes(); plane++) { > IntSize requiredTextureSize = frame->requiredTextureSize(plane); >+ ASSERT(m_textures[plane]); >+ ASSERT(m_textures[plane]->texture()); > > // If the renderer cannot handle this large of a texture, return false. > // FIXME: Remove this test when tiled layers are implemented. > if (requiredTextureSize.isZero() || requiredTextureSize.width() > maxTextureSize || requiredTextureSize.height() > maxTextureSize) > return false; > >- if (!m_textures[plane].m_texture) >- return false; >- >- if (m_textures[plane].m_texture->size() != requiredTextureSize) >- m_textures[plane].m_visibleSize = computeVisibleSize(frame, plane); >+ if (m_textures[plane]->texture()->size() != requiredTextureSize) { >+ IntSize visibleSize = computeVisibleSize(frame, plane); >+ m_textures[plane]->setVisibleSize(visibleSize); >+ } > >- m_textures[plane].m_texture->reserve(requiredTextureSize, textureFormat); >+ m_textures[plane]->texture()->reserve(requiredTextureSize, textureFormat); > } > > return true; >@@ -259,28 +328,6 @@ IntSize VideoLayerChromium::computeVisibleSize(const VideoFrameChromium* frame, > return IntSize(visibleWidth, visibleHeight); > } > >-void VideoLayerChromium::updateTexture(GraphicsContext3D* context, TextureAllocator* allocator, Texture& texture, const void* data) const >-{ >- ASSERT(context); >- ASSERT(texture.m_texture); >- >- texture.m_texture->bindTexture(context, allocator); >- >- GC3Denum format = texture.m_texture->format(); >- IntSize dimensions = texture.m_texture->size(); >- >- void* mem = static_cast<Extensions3DChromium*>(context->getExtensions())->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, dimensions.width(), dimensions.height(), format, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY); >- if (mem) { >- memcpy(mem, data, dimensions.width() * dimensions.height()); >- GLC(context, static_cast<Extensions3DChromium*>(context->getExtensions())->unmapTexSubImage2DCHROMIUM(mem)); >- } else { >- // If mapTexSubImage2DCHROMIUM fails, then do the slower texSubImage2D >- // upload. This does twice the copies as mapTexSubImage2DCHROMIUM, one >- // in the command buffer and another to the texture. >- GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, dimensions.width(), dimensions.height(), format, GraphicsContext3D::UNSIGNED_BYTE, data)); >- } >-} >- > void VideoLayerChromium::releaseProvider() > { > m_provider = 0; >diff --git a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h >index 516c8d3847c2adb64c5bbefb7c99cab5f5afaba3..351f8f8d156131720f3e6b384eb342f8074e508d 100644 >--- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h >@@ -43,6 +43,33 @@ namespace WebCore { > // A Layer that contains a Video element. > class VideoLayerChromium : public LayerChromium { > public: >+ class UpdaterTexture : public LayerTextureUpdater::Texture { >+ public: >+ static PassOwnPtr<UpdaterTexture> create(PassOwnPtr<ManagedTexture> texture) >+ { >+ return adoptPtr(new UpdaterTexture(texture)); >+ } >+ >+ virtual ~UpdaterTexture(); >+ >+ virtual ManagedTexture* texture() { return m_texture.get(); } >+ >+ virtual bool needPrepareRect() { return true; } >+ virtual void prepareRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect); >+ void dataRect(const void*); >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ void setVisibleSize(IntSize& size) { m_visibleSize = size; } >+ IntSize& visibleSize() { return m_visibleSize; } >+ >+ private: >+ explicit UpdaterTexture(PassOwnPtr<ManagedTexture>); >+ >+ OwnPtr<ManagedTexture> m_texture; >+ IntSize m_visibleSize; >+ uint8_t* m_mappedBuffer; >+ OwnArrayPtr<uint8_t> m_buffer; >+ }; > > static PassRefPtr<VideoLayerChromium> create(CCLayerDelegate* = 0, > VideoFrameProvider* = 0); >@@ -50,7 +77,9 @@ public: > > virtual PassRefPtr<CCLayerImpl> createCCLayerImpl(); > >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ virtual void prepareToUpdateIfDirty(); >+ virtual void paintContentsIfDirty(); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > virtual bool drawsContent() const { return true; } > > void releaseProvider(); >@@ -63,18 +92,12 @@ protected: > virtual void cleanupResources(); > > private: >- struct Texture { >- IntSize m_visibleSize; >- OwnPtr<ManagedTexture> m_texture; >- }; >- > VideoLayerChromium(CCLayerDelegate*, VideoFrameProvider*); > > static GC3Denum determineTextureFormat(const VideoFrameChromium*); > static IntSize computeVisibleSize(const VideoFrameChromium*, unsigned plane); > bool texturesValid(); > bool reserveTextures(const VideoFrameChromium*, GC3Denum textureFormat); >- void updateTexture(GraphicsContext3D*, TextureAllocator*, Texture&, const void*) const; > > void resetFrameParameters(); > >@@ -83,12 +106,14 @@ private: > VideoFrameProvider* m_provider; > > enum { MaxPlanes = 3 }; >- Texture m_textures[MaxPlanes]; >+ OwnPtr<UpdaterTexture> m_textures[MaxPlanes]; > unsigned m_planes; > > unsigned m_nativeTextureId; > IntSize m_nativeTextureSize; > IntSize m_nativeTextureVisibleSize; >+ >+ VideoFrameChromium* m_frame; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp >index deb8c947422a13e1f1745daaf46380a803fbd65d..3f4b05b6a4972a4d56e7fed1b4bac97232849785 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, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ m_layer->updateCompositorResources(context); >+} >+ > PassRefPtr<WebGLLayerChromium> WebGLLayerChromium::create(CCLayerDelegate* delegate) > { > return adoptRef(new WebGLLayerChromium(delegate)); >@@ -52,6 +67,7 @@ WebGLLayerChromium::WebGLLayerChromium(CCLayerDelegate* delegate) > , m_textureChanged(true) > , m_textureUpdated(false) > , m_drawingBuffer(0) >+ , m_updaterTexture(UpdaterTexture::create(this)) > { > } > >@@ -66,7 +82,7 @@ bool WebGLLayerChromium::drawsContent() const > return (context() && context()->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR); > } > >-void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, CCTextureUpdater&) >+void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext) > { > if (!drawsContent()) > return; >@@ -95,6 +111,11 @@ void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererCo > } > } > >+void WebGLLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) >+{ >+ handler.handle(m_updaterTexture.get(), IntRect(), IntRect()); >+} >+ > bool WebGLLayerChromium::paintRenderedResultsToCanvas(ImageBuffer* imageBuffer) > { > if (m_textureUpdated || !layerRendererContext() || !drawsContent()) >diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h >index 6374b9ef6b117ad2355a1fadb69ddb4107a69310..54b27d47665511d703fe666aab3d5c1bcabf6de2 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,12 +46,30 @@ 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*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ explicit UpdaterTexture(WebGLLayerChromium*); >+ >+ WebGLLayerChromium* m_layer; >+ }; >+ > static PassRefPtr<WebGLLayerChromium> create(CCLayerDelegate* = 0); > > virtual ~WebGLLayerChromium(); > > virtual bool drawsContent() const; >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ void updateCompositorResources(GraphicsContext3D*); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > virtual void contentChanged(); > bool paintRenderedResultsToCanvas(ImageBuffer*); > >@@ -71,6 +90,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 27d956a7c7afbd095db945b934a166efa55f374f..c6584528c80d303ea5ea666050f5b69adf67e34d 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >@@ -34,6 +34,7 @@ > #include "cc/CCLayerTreeHostCommon.h" > #include "cc/CCLayerTreeHostImpl.h" > #include "cc/CCSingleThreadProxy.h" >+#include "cc/CCTextureUpdater.h" > #include "cc/CCThread.h" > #include "cc/CCThreadProxy.h" > >@@ -48,6 +49,52 @@ bool CCLayerTreeHost::anyLayerTreeHostInstanceExists() > return numLayerTreeInstances > 0; > } > >+CCLayerTreeHost::NeedResourceHandler::NeedResourceHandler() >+ : m_resources(0) >+{ >+} >+ >+CCLayerTreeHost::NeedResourceHandler::~NeedResourceHandler() >+{ >+} >+ >+void CCLayerTreeHost::NeedResourceHandler::handle(LayerTextureUpdater::Texture* texture, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ if (texture->needPrepareRect()) >+ m_resources++; >+} >+ >+CCLayerTreeHost::PrepareResourceHandler::PrepareResourceHandler(GraphicsContext3D* context, TextureAllocator* allocator) >+ : m_context(context) >+ , m_allocator(allocator) >+{ >+} >+ >+CCLayerTreeHost::PrepareResourceHandler::~PrepareResourceHandler() >+{ >+} >+ >+void CCLayerTreeHost::PrepareResourceHandler::handle(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ if (texture->needPrepareRect()) >+ texture->prepareRect(m_context, m_allocator, sourceRect, destRect); >+} >+ >+CCLayerTreeHost::PaintHandler::PaintHandler(CCProxy* proxy) >+ : m_proxy(proxy) >+{ >+} >+ >+CCLayerTreeHost::PaintHandler::~PaintHandler() >+{ >+} >+ >+void CCLayerTreeHost::PaintHandler::handle(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ texture->paintContentsRect(sourceRect); >+ m_proxy->update(texture, sourceRect, destRect); >+} >+ > PassRefPtr<CCLayerTreeHost> CCLayerTreeHost::create(CCLayerTreeHostClient* client, const CCSettings& settings) > { > RefPtr<CCLayerTreeHost> layerTreeHost = adoptRef(new CCLayerTreeHost(client, settings)); >@@ -314,7 +361,7 @@ void CCLayerTreeHost::composite() > static_cast<CCSingleThreadProxy*>(m_proxy.get())->compositeImmediately(); > } > >-void CCLayerTreeHost::updateLayers() >+void CCLayerTreeHost::prepareToUpdate() > { > if (!rootLayer()) > return; >@@ -322,12 +369,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(); >@@ -336,24 +383,77 @@ 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); >+ } >+ >+ appendVisibleLayers(m_renderSurfaceUpdateList, m_layerUpdateList); >+ >+ for (int layerIndex = m_layerUpdateList.size() - 1; layerIndex >= 0 ; --layerIndex) { >+ LayerChromium* layer = m_layerUpdateList[layerIndex].get(); >+ layer->prepareToUpdateIfDirty(); >+ } >+} >+ >+bool CCLayerTreeHost::needsCompositorResources() >+{ >+ NeedResourceHandler handler; >+ forEachCompositorResource(handler); >+ return handler.resources(); >+} >+ >+void CCLayerTreeHost::prepareCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator) >+{ >+ TRACE_EVENT("CCLayerTreeHost::prepareCompositorResources", this, 0); >+ PrepareResourceHandler handler(context, allocator); >+ forEachCompositorResource(handler); >+} >+ >+void CCLayerTreeHost::paintContents() >+{ >+ if (!rootLayer()) >+ return; >+ >+ if (viewportSize().isEmpty()) >+ return; >+ >+ paintContents(rootLayer()); >+} >+ >+void CCLayerTreeHost::paintContents(LayerChromium* rootLayer) >+{ >+ TRACE_EVENT("CCLayerTreeHost::paintContents", this, 0); >+ >+ for (int layerIndex = m_layerUpdateList.size() - 1; layerIndex >= 0 ; --layerIndex) { >+ LayerChromium* layer = m_layerUpdateList[layerIndex].get(); >+ layer->paintContentsIfDirty(); >+ >+ PaintHandler handler(m_proxy.get()); >+ layer->forEachCompositorResource(handler); > } >+} > >- paintLayerContents(m_updateList); >+void CCLayerTreeHost::appendVisibleLayer(LayerChromium* layer, LayerList& 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(layer); > } > >-void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderSurfaceLayer) >+void CCLayerTreeHost::appendMaskAndReplicaForRenderSurface(LayerChromium* renderSurfaceLayer, LayerList& 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 >@@ -362,33 +462,33 @@ void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderS > if (renderSurfaceLayer->maskLayer()) { > renderSurfaceLayer->maskLayer()->setLayerTreeHost(this); > renderSurfaceLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), renderSurfaceLayer->contentBounds())); >- renderSurfaceLayer->maskLayer()->paintContentsIfDirty(); >+ appendVisibleLayer(renderSurfaceLayer->maskLayer(), updateList); > } > > LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer(); > if (replicaLayer) { > > replicaLayer->setLayerTreeHost(this); >- replicaLayer->paintContentsIfDirty(); >+ appendVisibleLayer(replicaLayer, updateList); > > if (replicaLayer->maskLayer()) { > replicaLayer->maskLayer()->setLayerTreeHost(this); > replicaLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds())); >- replicaLayer->maskLayer()->paintContentsIfDirty(); >+ appendVisibleLayer(replicaLayer->maskLayer(), updateList); > } > } > } > >-void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList) >+void CCLayerTreeHost::appendVisibleLayers(const LayerList& renderSurfaceUpdateList, LayerList& updateList) > { >- for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { >- LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get(); >+ for (int surfaceIndex = renderSurfaceUpdateList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { >+ LayerChromium* renderSurfaceLayer = renderSurfaceUpdateList[surfaceIndex].get(); > RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface(); > ASSERT(renderSurface); > ASSERT(renderSurface->drawOpacity()); > > renderSurfaceLayer->setLayerTreeHost(this); >- paintMaskAndReplicaForRenderSurface(renderSurfaceLayer); >+ appendMaskAndReplicaForRenderSurface(renderSurfaceLayer, updateList); > > const LayerList& layerList = renderSurface->layerList(); > for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { >@@ -404,49 +504,29 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList > ASSERT(layer->opacity()); > ASSERT(!layer->bounds().isEmpty()); > >- layer->paintContentsIfDirty(); >+ appendVisibleLayer(layer, updateList); > } > } > } > >-void CCLayerTreeHost::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >+void CCLayerTreeHost::forEachCompositorResource(LayerTextureUpdater::Handler& handler) > { >- for (int surfaceIndex = m_updateList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { >- LayerChromium* renderSurfaceLayer = m_updateList[surfaceIndex].get(); >- RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface(); >- ASSERT(renderSurface); >- ASSERT(renderSurface->drawOpacity()); >- >- if (renderSurfaceLayer->maskLayer()) >- renderSurfaceLayer->maskLayer()->updateCompositorResources(context, updater); >- >- if (renderSurfaceLayer->replicaLayer()) { >- renderSurfaceLayer->replicaLayer()->updateCompositorResources(context, updater); >- >- if (renderSurfaceLayer->replicaLayer()->maskLayer()) >- renderSurfaceLayer->replicaLayer()->maskLayer()->updateCompositorResources(context, updater); >- } >- >- const LayerList& layerList = renderSurface->layerList(); >- for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { >- LayerChromium* layer = layerList[layerIndex].get(); >- >- if (CCLayerTreeHostCommon::renderSurfaceContributesToTarget<LayerChromium>(layer, renderSurfaceLayer->id())) >- continue; >- >- layer->updateCompositorResources(context, updater); >- } >+ for (int layerIndex = m_layerUpdateList.size() - 1; layerIndex >= 0 ; --layerIndex) { >+ LayerChromium* layer = m_layerUpdateList[layerIndex].get(); >+ layer->forEachCompositorResource(handler); > } > } > > 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 aaad14229d3510ee191021c764c75b4fb473ab55..c32e210bfa47f8fa9ab11551803c2edab87cc9ef 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >@@ -45,7 +45,6 @@ class GrContext; > namespace WebCore { > > class CCLayerTreeHostImpl; >-class CCTextureUpdater; > class GraphicsContext3D; > class LayerPainterChromium; > class TextureAllocator; >@@ -74,7 +73,8 @@ struct CCSettings { > , showFPSCounter(false) > , showPlatformLayerTree(false) > , refreshRate(0) >- , perTilePainting(false) { } >+ , perTilePainting(false) >+ , delayTextureUpdates(false) { } > > bool acceleratePainting; > bool compositeOffscreen; >@@ -82,6 +82,7 @@ struct CCSettings { > bool showPlatformLayerTree; > double refreshRate; > bool perTilePainting; >+ bool delayTextureUpdates; > }; > > // Provides information on an Impl's rendering capabilities back to the CCLayerTreeHost >@@ -186,9 +187,12 @@ public: > > void setHaveWheelEventHandlers(bool); > >- void updateLayers(); >+ void prepareToUpdate(); >+ bool needsCompositorResources(); >+ void prepareCompositorResources(GraphicsContext3D*, TextureAllocator*); >+ void paintContents(); > >- void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ void forEachCompositorResource(LayerTextureUpdater::Handler&); > void applyScrollAndScale(const CCScrollAndScaleSet&); > void startRateLimiter(GraphicsContext3D*); > void stopRateLimiter(GraphicsContext3D*); >@@ -198,12 +202,50 @@ protected: > bool initialize(); > > private: >+ class NeedResourceHandler : public LayerTextureUpdater::Handler { >+ public: >+ NeedResourceHandler(); >+ virtual ~NeedResourceHandler(); >+ >+ virtual void handle(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ int resources() { return m_resources; } >+ >+ private: >+ int m_resources; >+ }; >+ >+ class PrepareResourceHandler : public LayerTextureUpdater::Handler { >+ public: >+ PrepareResourceHandler(GraphicsContext3D*, TextureAllocator*); >+ virtual ~PrepareResourceHandler(); >+ >+ virtual void handle(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ GraphicsContext3D* m_context; >+ TextureAllocator* m_allocator; >+ }; >+ >+ class PaintHandler : public LayerTextureUpdater::Handler { >+ public: >+ PaintHandler(CCProxy*); >+ virtual ~PaintHandler(); >+ >+ virtual void handle(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ CCProxy* m_proxy; >+ }; >+ > typedef Vector<RefPtr<LayerChromium> > LayerList; > >- void paintLayerContents(const LayerList&); >- void paintMaskAndReplicaForRenderSurface(LayerChromium*); >+ void appendVisibleLayer(LayerChromium*, LayerList&); >+ void appendMaskAndReplicaForRenderSurface(LayerChromium*, LayerList& updateList); >+ void appendVisibleLayers(const LayerList& renderSurfaceUpdateList, LayerList& updateList); > >- void updateLayers(LayerChromium*); >+ void prepareToUpdate(LayerChromium*); >+ void paintContents(LayerChromium*); > void clearPendingUpdate(); > > int m_compositorIdentifier; >@@ -219,7 +261,8 @@ private: > RefPtr<LayerChromium> m_rootLayer; > OwnPtr<TextureManager> m_contentsTextureManager; > >- LayerList m_updateList; >+ LayerList m_renderSurfaceUpdateList; >+ LayerList 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 bb3780147b16c26b75a7ccd22aa8b8fe84e76bbd..eee6d18c1e8008d83f953cab45bf4d44169e48e9 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> >@@ -79,6 +80,8 @@ public: > virtual void start() = 0; // Must be called before using the proxy. > virtual void stop() = 0; // Must be called before deleting the proxy. > >+ 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/CCScheduler.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp >index 501a00c2b09a0df90dc61dcafcfca7d7c667b185..c895a516d3f63cf4701d1f7cbb8390358ef824b6 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp >@@ -68,6 +68,12 @@ void CCScheduler::setNeedsForcedRedraw() > processScheduledActions(); > } > >+void CCScheduler::setResourceUpdatesPending() >+{ >+ m_stateMachine.setResourceUpdatesPending(); >+ processScheduledActions(); >+} >+ > void CCScheduler::beginFrameComplete() > { > TRACE_EVENT("CCScheduler::beginFrameComplete", this, 0); >@@ -96,7 +102,7 @@ void CCScheduler::beginFrame() > { > if (m_updateMoreResourcesPending) { > m_updateMoreResourcesPending = false; >- m_stateMachine.beginUpdateMoreResourcesComplete(m_client->hasMoreResourceUpdates()); >+ m_stateMachine.updateMoreResourcesComplete(m_client->hasMoreResourceUpdates()); > } > TRACE_EVENT("CCScheduler::beginFrame", this, 0); > >@@ -105,6 +111,14 @@ void CCScheduler::beginFrame() > m_stateMachine.didLeaveVSync(); > } > >+void CCScheduler::updateMoreResourcesComplete() >+{ >+ ASSERT(m_updateMoreResourcesPending); >+ m_updateMoreResourcesPending = false; >+ m_stateMachine.updateMoreResourcesComplete(m_client->hasMoreResourceUpdates()); >+ processScheduledActions(); >+} >+ > void CCScheduler::processScheduledActions() > { > // Early out so we don't spam TRACE_EVENTS with useless processScheduledActions. >@@ -125,6 +139,7 @@ void CCScheduler::processScheduledActions() > m_client->scheduledActionBeginFrame(); > break; > case CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES: >+ ASSERT(m_client->hasMoreResourceUpdates()); > m_client->scheduledActionUpdateMoreResources(); > if (!m_client->hasMoreResourceUpdates()) { > // If we were just told to update resources, but there are no >@@ -132,7 +147,7 @@ void CCScheduler::processScheduledActions() > // beginUpdateMoreResources completed. If more are pending, > // then we will ack the update at the next draw. > m_updateMoreResourcesPending = false; >- m_stateMachine.beginUpdateMoreResourcesComplete(false); >+ m_stateMachine.updateMoreResourcesComplete(false); > } else > m_updateMoreResourcesPending = true; > break; >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h b/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h >index 95e995f4518ed67cf34f4c788874f6922e7e26dd..82822812e901b9abc38649c6f1b4abaf70dec7c1 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h >@@ -66,11 +66,12 @@ public: > // As setNeedsRedraw(), but ensures the draw will definitely happen even if we are not visible. > void setNeedsForcedRedraw(); > >+ void setResourceUpdatesPending(); > void beginFrameComplete(); >- > void setMaxFramesPending(int); > void didSwapBuffersComplete(); > void didSwapBuffersAbort(); >+ void updateMoreResourcesComplete(); > > bool commitPending() const { return m_stateMachine.commitPending(); } > bool redrawPending() const { return m_stateMachine.redrawPending(); } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp >index 4cff6730b87ce1429cab0d21907f286da86ba47b..ff65fe50a2575069ebe64b5be4bbd6bd4c6df8e7 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp >@@ -37,7 +37,9 @@ CCSchedulerStateMachine::CCSchedulerStateMachine() > , m_needsCommit(false) > , m_updateMoreResourcesPending(false) > , m_insideVSync(false) >- , m_visible(false) { } >+ , m_visible(false) >+ , m_resourceUpdatesPending(false) >+ , m_frameComplete(false) { } > > CCSchedulerStateMachine::Action CCSchedulerStateMachine::nextAction() const > { >@@ -51,15 +53,10 @@ CCSchedulerStateMachine::Action CCSchedulerStateMachine::nextAction() const > return ACTION_BEGIN_FRAME; > return ACTION_NONE; > >- case COMMIT_STATE_FRAME_IN_PROGRESS: >- if (shouldDraw) >- return ACTION_DRAW; >- return ACTION_NONE; >- > case COMMIT_STATE_UPDATING_RESOURCES: > if (shouldDraw) > return ACTION_DRAW; >- if (!m_updateMoreResourcesPending) >+ if (!m_updateMoreResourcesPending && m_resourceUpdatesPending) > return ACTION_BEGIN_UPDATE_MORE_RESOURCES; > return ACTION_NONE; > >@@ -83,8 +80,10 @@ void CCSchedulerStateMachine::updateState(Action action) > > case ACTION_BEGIN_FRAME: > ASSERT(m_visible); >- m_commitState = COMMIT_STATE_FRAME_IN_PROGRESS; >+ ASSERT(!m_resourceUpdatesPending); >+ m_commitState = COMMIT_STATE_UPDATING_RESOURCES; > m_needsCommit = false; >+ m_frameComplete = false; > return; > > case ACTION_BEGIN_UPDATE_MORE_RESOURCES: >@@ -144,18 +143,26 @@ void CCSchedulerStateMachine::setNeedsCommit() > m_needsCommit = true; > } > >+void CCSchedulerStateMachine::setResourceUpdatesPending() >+{ >+ m_resourceUpdatesPending = true; >+} >+ > void CCSchedulerStateMachine::beginFrameComplete() > { >- ASSERT(m_commitState == COMMIT_STATE_FRAME_IN_PROGRESS); >- m_commitState = COMMIT_STATE_UPDATING_RESOURCES; >+ ASSERT(m_commitState == COMMIT_STATE_UPDATING_RESOURCES); >+ m_frameComplete = true; >+ if (!m_updateMoreResourcesPending && !m_resourceUpdatesPending) >+ m_commitState = COMMIT_STATE_READY_TO_COMMIT; > } > >-void CCSchedulerStateMachine::beginUpdateMoreResourcesComplete(bool morePending) >+void CCSchedulerStateMachine::updateMoreResourcesComplete(bool morePending) > { > ASSERT(m_commitState == COMMIT_STATE_UPDATING_RESOURCES); > ASSERT(m_updateMoreResourcesPending); > m_updateMoreResourcesPending = false; >- if (!morePending) >+ m_resourceUpdatesPending = morePending; >+ if (!morePending && m_frameComplete) > m_commitState = COMMIT_STATE_READY_TO_COMMIT; > } > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h b/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h >index 5a27bd28b88a74cb694ed3e4551d4337dd61c532..0d9eb1527cd420ad47f277e314ef5579c13d0827 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h >@@ -45,7 +45,6 @@ public: > > enum CommitState { > COMMIT_STATE_IDLE, >- COMMIT_STATE_FRAME_IN_PROGRESS, > COMMIT_STATE_UPDATING_RESOURCES, > COMMIT_STATE_READY_TO_COMMIT, > COMMIT_STATE_WAITING_FOR_FIRST_DRAW, >@@ -89,14 +88,17 @@ public: > // thread to main. > void setNeedsCommit(); > >+ // Indicates that compositor resources that need updating are pending. >+ void setResourceUpdatesPending(); >+ > // Call this only in response to receiving an ACTION_BEGIN_FRAME > // from nextState. Indicates that all painting is complete and that >- // updating of compositor resources can begin. >+ // only updating of compositor resources is left. > void beginFrameComplete(); > > // Call this only in response to receiving an ACTION_UPDATE_MORE_RESOURCES > // from nextState. Indicates that the specific update request completed. >- void beginUpdateMoreResourcesComplete(bool morePending); >+ void updateMoreResourcesComplete(bool morePending); > > protected: > CommitState m_commitState; >@@ -109,6 +111,8 @@ protected: > bool m_updateMoreResourcesPending; > bool m_insideVSync; > bool m_visible; >+ bool m_resourceUpdatesPending; >+ bool m_frameComplete; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >index 72bec2a71664af43cd64d014d28b84265095b203..9273370e527329452281ca9b9c9babf574f53b55 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >@@ -147,15 +147,19 @@ void CCSingleThreadProxy::setNeedsAnimate() > void CCSingleThreadProxy::doCommit() > { > ASSERT(CCProxy::isMainThread()); >+ >+ // Prepare compositor resources >+ if (m_layerTreeHost->needsCompositorResources()) >+ m_layerTreeHost->prepareCompositorResources(m_layerTreeHostImpl->context(), m_layerTreeHostImpl->contentsTextureAllocator()); >+ >+ m_layerTreeHost->paintContents(); >+ > // Commit immediately > { > DebugScopedSetImplThread impl; > m_layerTreeHostImpl->beginCommit(); >- >+ while (m_textureUpdater.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()); > >@@ -208,6 +212,14 @@ void CCSingleThreadProxy::stop() > m_layerTreeHost = 0; > } > >+void CCSingleThreadProxy::update(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ if (m_layerTreeHostImpl->settings().delayTextureUpdates) >+ m_textureUpdater.append(texture, sourceRect, destRect); >+ else >+ texture->updateRect(m_layerTreeHostImpl->context(), sourceRect, destRect); >+} >+ > // Called by the legacy scheduling path (e.g. where render_widget does the scheduling) > void CCSingleThreadProxy::compositeImmediately() > { >@@ -272,7 +284,7 @@ void CCSingleThreadProxy::commitIfNeeded() > { > ASSERT(CCProxy::isMainThread()); > >- m_layerTreeHost->updateLayers(); >+ m_layerTreeHost->prepareToUpdate(); > > doCommit(); > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >index 0d5a4a2d8a516b1d7bcf991a99e1c78789943ec5..783a8db85740128a4d6009eb58184e30cd017db2 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >@@ -28,6 +28,7 @@ > #include "cc/CCCompletionEvent.h" > #include "cc/CCLayerTreeHostImpl.h" > #include "cc/CCProxy.h" >+#include "cc/CCTextureUpdater.h" > #include <wtf/OwnPtr.h> > > namespace WebCore { >@@ -54,6 +55,7 @@ public: > virtual void setVisible(bool); > virtual void start(); > virtual void stop(); >+ virtual void update(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); > > // CCLayerTreeHostImplClient implementation > virtual void onSwapBuffersCompleteOnImplThread() { ASSERT_NOT_REACHED(); } >@@ -82,6 +84,8 @@ private: > bool m_graphicsContextLost; > int m_timesRecreateShouldFail; // Used during testing. > bool m_nextFrameIsNewlyCommittedFrame; >+ >+ CCTextureUpdater m_textureUpdater; > }; > > // 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..a61c3bb33f6e29cbefab730025085d1207536c26 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" >@@ -37,11 +38,8 @@ using namespace std; > > namespace WebCore { > >-CCTextureUpdater::CCTextureUpdater(TextureAllocator* allocator) >- : m_allocator(allocator) >- , m_entryIndex(0) >+CCTextureUpdater::CCTextureUpdater() > { >- ASSERT(m_allocator); > } > > CCTextureUpdater::~CCTextureUpdater() >@@ -66,23 +64,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]; >- entry.m_texture->updateRect(context, m_allocator, entry.m_sourceRect, entry.m_destRect); >- } >+ while (count--) { >+ if (!m_entries.size()) >+ return false; > >- if (maxIndex < m_entries.size()) >- return true; >+ UpdateEntry& entry = m_entries.last(); >+ entry.m_texture->updateRect(context, entry.m_sourceRect, entry.m_destRect); >+ m_entries.removeLast(); >+ } > >- // 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..ab659eceead6dccf56bd8308a864d834d0ec8858 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h >@@ -33,11 +33,10 @@ > namespace WebCore { > > class GraphicsContext3D; >-class TextureAllocator; > > class CCTextureUpdater { > public: >- CCTextureUpdater(TextureAllocator*); >+ CCTextureUpdater(); > ~CCTextureUpdater(); > > void append(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); >@@ -49,8 +48,6 @@ public: > > void clear(); > >- TextureAllocator* allocator() { return m_allocator; } >- > private: > struct UpdateEntry { > LayerTextureUpdater::Texture* m_texture; >@@ -58,8 +55,6 @@ private: > IntRect m_destRect; > }; > >- 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 8e77425e440a4edcf29f265ac3e9eefdbe215d87..d89bfff5845d41dda8fa9beb430094ad0d0ed6da 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >@@ -285,6 +285,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); >@@ -373,7 +387,17 @@ void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim > // updateLayers. > m_commitRequested = false; > >- m_layerTreeHost->updateLayers(); >+ m_layerTreeHost->prepareToUpdate(); >+ >+ if (m_layerTreeHost->needsCompositorResources()) { >+ // Initialize compositor resources require for frame. >+ TRACE_EVENT("allocate", this, 0); >+ CCCompletionEvent completion; >+ CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::prepareFrameResourcesOnImplThread, AllowCrossThreadAccess(&completion))); >+ completion.wait(); >+ } >+ >+ m_layerTreeHost->paintContents(); > > // Before applying scrolls and calling animate, we set m_animateRequested to false. > // If it is true now, it means setNeedAnimate was called again. Call setNeedsCommit >@@ -397,13 +421,37 @@ void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim > ASSERT(m_lastExecutedBeginFrameAndCommitSequenceNumber == sequenceNumber); > } > >+void CCThreadProxy::prepareFrameResourcesOnImplThread(CCCompletionEvent* completion) >+{ >+ TRACE_EVENT("CCThreadProxy::prepareFrameResourcesOnOnImplThread", this, 0); >+ ASSERT(!m_commitCompletionEventOnImplThread); >+ ASSERT(isImplThread()); >+ if (!m_layerTreeHostImpl) { >+ completion->signal(); >+ return; >+ } >+ >+ m_layerTreeHost->prepareCompositorResources(m_layerTreeHostImpl->context(), m_layerTreeHostImpl->contentsTextureAllocator()); >+ >+ completion->signal(); >+} >+ >+void CCThreadProxy::updateTextureOnImplThread(PassOwnPtr<UpdateEntry> entry) >+{ >+ ASSERT(!m_commitCompletionEventOnImplThread); >+ ASSERT(isImplThread()); >+ if (!m_layerTreeHostImpl) >+ return; >+ >+ m_textureUpdaterOnImplThread.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; >@@ -411,36 +459,31 @@ 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); >+ if (hasMoreResourceUpdates()) >+ m_schedulerOnImplThread->setResourceUpdatesPending(); > > m_schedulerOnImplThread->beginFrameComplete(); > } > > bool CCThreadProxy::hasMoreResourceUpdates() const > { >- if (!m_currentTextureUpdaterOnImplThread) >- return false; >- return m_currentTextureUpdaterOnImplThread->hasMoreUpdates(); >+ return m_textureUpdaterOnImplThread.hasMoreUpdates(); > } > > void CCThreadProxy::scheduledActionUpdateMoreResources() > { > TRACE_EVENT("CCThreadProxy::scheduledActionUpdateMoreResources", this, 0); >- ASSERT(m_currentTextureUpdaterOnImplThread); > static const int UpdatesPerFrame = 99999; >- m_currentTextureUpdaterOnImplThread->update(m_layerTreeHostImpl->context(), UpdatesPerFrame); >+ m_textureUpdaterOnImplThread.update(m_layerTreeHostImpl->context(), UpdatesPerFrame); > } > > void CCThreadProxy::scheduledActionCommit() > { > TRACE_EVENT("CCThreadProxy::scheduledActionCommit", this, 0); >- ASSERT(m_currentTextureUpdaterOnImplThread); >- ASSERT(!m_currentTextureUpdaterOnImplThread->hasMoreUpdates()); >+ ASSERT(!m_textureUpdaterOnImplThread.hasMoreUpdates()); > ASSERT(m_commitCompletionEventOnImplThread); > >- m_currentTextureUpdaterOnImplThread.clear(); >+ m_textureUpdaterOnImplThread.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 1df3746c5dc0134a324e4ac864230452933a98fb..f1244c2a19cdf4b2cc931ea5667cf80d4bf8617f 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >@@ -29,6 +29,7 @@ > #include "cc/CCLayerTreeHostImpl.h" > #include "cc/CCProxy.h" > #include "cc/CCScheduler.h" >+#include "cc/CCTextureUpdater.h" > #include "cc/CCThread.h" > #include <wtf/OwnPtr.h> > >@@ -62,6 +63,7 @@ public: > virtual void setVisible(bool); > virtual void start(); > virtual void stop(); >+ virtual void update(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); > > // CCLayerTreeHostImplClient implementation > virtual void onSwapBuffersCompleteOnImplThread(); >@@ -78,6 +80,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(); >@@ -92,6 +100,8 @@ private: > }; > PassOwnPtr<CCThread::Task> createBeginFrameAndCommitTaskOnImplThread(); > void obtainBeginFrameAndCommitTaskFromCCThread(CCCompletionEvent*, CCThread::Task**); >+ void prepareFrameResourcesOnImplThread(CCCompletionEvent*); >+ void updateTextureOnImplThread(PassOwnPtr<UpdateEntry>); > void beginFrameCompleteOnImplThread(CCCompletionEvent*); > void requestReadbackOnImplThread(ReadbackRequest*); > void finishAllRenderingOnImplThread(CCCompletionEvent*); >@@ -127,10 +137,11 @@ private: > > // Set when the main thread is waiting on a commit to complete. > CCCompletionEvent* m_commitCompletionEventOnImplThread; >- OwnPtr<CCTextureUpdater> m_currentTextureUpdaterOnImplThread; > > // Set when the next draw should post didCommitAndDrawFrame to the main thread. > bool m_nextFrameIsNewlyCommittedFrameOnImplThread; >+ >+ CCTextureUpdater m_textureUpdaterOnImplThread; > }; > > } >diff --git a/Source/WebKit/chromium/public/WebSettings.h b/Source/WebKit/chromium/public/WebSettings.h >index e2e743a10db196cd9720b838988e87b8776b9f40..f0f28016c79b4821dd7b6ea567f8dc6ef3be0245 100644 >--- a/Source/WebKit/chromium/public/WebSettings.h >+++ b/Source/WebKit/chromium/public/WebSettings.h >@@ -135,6 +135,8 @@ public: > virtual void setVisualWordMovementEnabled(bool) = 0; > virtual void setPerTilePainting(bool) = 0; > virtual bool perTilePainting() const = 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 06ee010128a856f2ec73d5d23edad82141ff67b8..24012e35157b750667d22c01c0a0b79905cebbfb 100644 >--- a/Source/WebKit/chromium/src/WebSettingsImpl.cpp >+++ b/Source/WebKit/chromium/src/WebSettingsImpl.cpp >@@ -51,6 +51,7 @@ WebSettingsImpl::WebSettingsImpl(Settings* settings) > , m_showFPSCounter(false) > , m_showPlatformLayerTree(false) > , m_perTilePainting(false) >+ , m_delayTextureUpdates(false) > { > ASSERT(settings); > } >@@ -498,10 +499,14 @@ void WebSettingsImpl::setShouldDisplayTextDescriptions(bool enabled) > #endif > } > >- > void WebSettingsImpl::setPerTilePainting(bool enabled) > { > m_perTilePainting = 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 88e25e96efcafe524e08a76661161cb759344ee5..f2fdd3500fc6043f2360e6fa8490a80a5255afe1 100644 >--- a/Source/WebKit/chromium/src/WebSettingsImpl.h >+++ b/Source/WebKit/chromium/src/WebSettingsImpl.h >@@ -130,6 +130,8 @@ public: > virtual void setShouldDisplayTextDescriptions(bool); > virtual void setPerTilePainting(bool); > virtual bool perTilePainting() const { return m_perTilePainting; } >+ virtual void setDelayTextureUpdates(bool); >+ virtual bool delayTextureUpdates() const { return m_delayTextureUpdates; } > > private: > WebCore::Settings* m_settings; >@@ -137,6 +139,7 @@ private: > bool m_showFPSCounter; > bool m_showPlatformLayerTree; > bool m_perTilePainting; >+ bool m_delayTextureUpdates; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp >index 2e39fce40d2af8630e89310777b79d3506b3e595..44ff4d630d48f0a9486beecbdbf109e59ccb92dd 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.cpp >+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp >@@ -2940,6 +2940,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) > ccSettings.refreshRate = defaultRefreshRate; > > ccSettings.perTilePainting = settings()->perTilePainting(); >+ ccSettings.delayTextureUpdates = settings()->delayTextureUpdates(); > > m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this)); > m_layerTreeHost = CCLayerTreeHost::create(this, ccSettings); >diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >index 36fd7dbd07bdc7cf1c861fd82aebc2b084a03a33..4313fa514cec4b4c718885baffb1718173477862 100644 >--- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >@@ -29,6 +29,7 @@ > #include "ContentLayerChromium.h" > #include "GraphicsContext3DPrivate.h" > #include "LayerChromium.h" >+#include "ManagedTexture.h" > #include "MockWebGraphicsContext3D.h" > #include "TextureManager.h" > #include "WebCompositor.h" >@@ -922,6 +923,14 @@ TEST_F(CCLayerTreeHostTestSetVisible, runMultiThread) > runTest(true); > } > >+class MockLayerDelegate : public CCLayerDelegate { >+public: >+ virtual void paintContents(GraphicsContext&, const IntRect&) { } >+ virtual bool drawsContent() const { return true; } >+ virtual bool preserves3D() { return false; } >+ virtual void notifySyncRequired() { } >+}; >+ > class TestOpacityChangeLayerDelegate : public CCLayerDelegate { > public: > TestOpacityChangeLayerDelegate(CCLayerTreeHostTest* test) >@@ -945,37 +954,116 @@ private: > > class ContentLayerChromiumWithUpdateTracking : public ContentLayerChromium { > public: >- static PassRefPtr<ContentLayerChromiumWithUpdateTracking> create(CCLayerDelegate *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) >+ { >+ } >+ >+ virtual ManagedTexture* texture() { return m_texture.get(); } >+ >+ virtual bool needPrepareRect() >+ { >+ return m_textureUpdater->layer()->needPrepareRect(); >+ } >+ >+ virtual void prepareRect(GraphicsContext3D*, TextureAllocator*, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+ { >+ m_textureUpdater->layer()->prepareRect(); >+ } >+ >+ virtual void paintContentsRect(const IntRect& /* sourceRect */) >+ { >+ m_textureUpdater->layer()->paintContentsRect(); >+ } >+ >+ virtual void updateRect(GraphicsContext3D*, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+ { >+ m_textureUpdater->layer()->updateRect(); >+ } >+ >+ private: >+ OwnPtr<ManagedTexture> m_texture; >+ ContentLayerTextureUpdater* m_textureUpdater; >+ }; >+ >+ static PassRefPtr<ContentLayerTextureUpdater> create(ContentLayerChromiumWithUpdateTracking *layer) >+ { >+ return adoptRef(new ContentLayerTextureUpdater(layer)); >+ } > >- int paintContentsCount() { return m_paintContentsCount; } >- void resetPaintContentsCount() { m_paintContentsCount = 0; } >+ virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) >+ { >+ return adoptPtr(new Texture(this, ManagedTexture::create(manager))); >+ } > >- int updateCount() { return m_updateCount; } >- void resetUpdateCount() { m_updateCount = 0; } >+ virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } > >- virtual void paintContentsIfDirty() >+ virtual SampledTexelFormat sampledTexelFormat(GC3Denum /* textureFormat */) >+ { >+ return LayerTextureUpdater::SampledTexelFormatRGBA; >+ } >+ >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */) >+ { >+ m_layer->paintContents(); >+ } >+ >+ ContentLayerChromiumWithUpdateTracking* layer() { return m_layer; } >+ >+ private: >+ explicit ContentLayerTextureUpdater(ContentLayerChromiumWithUpdateTracking* layer) : m_layer(layer) { } >+ >+ ContentLayerChromiumWithUpdateTracking* m_layer; >+ }; >+ >+ static PassRefPtr<ContentLayerChromiumWithUpdateTracking> create(CCLayerDelegate* delegate, bool needPrepareRect) > { >- ContentLayerChromium::paintContentsIfDirty(); >- m_paintContentsCount++; >+ return adoptRef(new ContentLayerChromiumWithUpdateTracking(delegate, needPrepareRect)); > } > >- virtual void updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >+ virtual void createTextureUpdater(const CCLayerTreeHost*) > { >- ContentLayerChromium::updateCompositorResources(context, updater); >- m_updateCount++; >+ m_contentLayerTextureUpdater = ContentLayerTextureUpdater::create(this); > } >+ virtual LayerTextureUpdater* textureUpdater() const { return m_contentLayerTextureUpdater.get(); } >+ >+ void paintContents() { m_paintContentsCount++; } >+ int paintContentsCount() { return m_paintContentsCount; } >+ >+ void prepareRect() { m_prepareRectCount++; } >+ int prepareRectCount() { return m_prepareRectCount; } >+ >+ void paintContentsRect() { m_paintContentsRectCount++; } >+ int paintContentsRectCount() { return m_paintContentsRectCount; } >+ >+ void updateRect() { m_updateRectCount++; } >+ int updateRectCount() { return m_updateRectCount; } >+ >+ int needPrepareRect() { return m_needPrepareRect; } > > private: >- explicit ContentLayerChromiumWithUpdateTracking(CCLayerDelegate *delegate) >+ explicit ContentLayerChromiumWithUpdateTracking(CCLayerDelegate *delegate, bool needPrepareRect) > : ContentLayerChromium(delegate) >+ , m_needPrepareRect(needPrepareRect) > , m_paintContentsCount(0) >- , m_updateCount(0) >+ , m_prepareRectCount(0) >+ , m_paintContentsRectCount(0) >+ , m_updateRectCount(0) > { > setBounds(IntSize(10, 10)); > } > >+ RefPtr<ContentLayerTextureUpdater> m_contentLayerTextureUpdater; >+ bool m_needPrepareRect; > int m_paintContentsCount; >- int m_updateCount; >+ int m_prepareRectCount; >+ int m_paintContentsRectCount; >+ int m_updateRectCount; > }; > > // Layer opacity change during paint should not prevent compositor resources from being updated during commit. >@@ -983,7 +1071,7 @@ class CCLayerTreeHostTestOpacityChange : public CCLayerTreeHostTest { > public: > CCLayerTreeHostTestOpacityChange() > : m_testOpacityChangeDelegate(this) >- , m_updateCheckLayer(ContentLayerChromiumWithUpdateTracking::create(&m_testOpacityChangeDelegate)) >+ , m_updateCheckLayer(ContentLayerChromiumWithUpdateTracking::create(&m_testOpacityChangeDelegate, true)) > { > } > >@@ -1002,13 +1090,18 @@ public: > > virtual void afterTest() > { >- // paintContentsIfDirty() should have been called once. >+ // 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->paintContentsRectCount()); >+ >+ // updateRect() should have been called the same >+ // amount of times as paintContentsRect(). >+ EXPECT_EQ(m_updateCheckLayer->paintContentsRectCount(), >+ m_updateCheckLayer->updateRectCount()); > > // clear m_updateCheckLayer so CCLayerTreeHost dies. > m_updateCheckLayer.clear(); >@@ -1024,4 +1117,49 @@ TEST_F(CCLayerTreeHostTestOpacityChange, runMultiThread) > runTest(true); > } > >+// prepareRect() should not be called when needPrepareRect() returns false. >+class CCLayerTreeHostTestNoPrepareRect : public CCLayerTreeHostTest { >+public: >+ CCLayerTreeHostTestNoPrepareRect() >+ : m_updateCheckLayer(ContentLayerChromiumWithUpdateTracking::create(&m_delegate, false)) >+ { >+ } >+ >+ virtual void beginTest() >+ { >+ m_layerTreeHost->setRootLayer(m_updateCheckLayer); >+ m_layerTreeHost->setViewport(IntSize(10, 10)); >+ >+ postSetNeedsCommitToMainThread(); >+ } >+ >+ virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) >+ { >+ endTest(); >+ } >+ >+ virtual void afterTest() >+ { >+ // paintContents() should have been called once. >+ EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount()); >+ >+ // prepareRect() should not have been called. >+ EXPECT_EQ(0, m_updateCheckLayer->prepareRectCount()); >+ >+ // updateRect() should have been called the same >+ // amount of times as paintContentsRect(). >+ EXPECT_EQ(m_updateCheckLayer->paintContentsRectCount(), >+ m_updateCheckLayer->updateRectCount()); >+ } >+ >+private: >+ MockLayerDelegate m_delegate; >+ RefPtr<ContentLayerChromiumWithUpdateTracking> m_updateCheckLayer; >+}; >+ >+TEST_F(CCLayerTreeHostTestNoPrepareRect, runMultiThread) >+{ >+ runTest(true); >+} >+ > } // namespace >diff --git a/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp b/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp >index f346977666d2c4dff47b4881fab1b16d3f8cd7b2..dbc37dd900c6605efbabe71376c8f448d6984b0b 100644 >--- a/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp >+++ b/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp >@@ -37,7 +37,6 @@ namespace { > > const CCSchedulerStateMachine::CommitState allCommitStates[] = { > CCSchedulerStateMachine::COMMIT_STATE_IDLE, >- CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, > CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, > CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, > CCSchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW >@@ -63,6 +62,12 @@ public: > > void setUpdateMoreResourcesPending(bool b) { m_updateMoreResourcesPending = b; } > bool updateMoreResourcesPending() const { return m_updateMoreResourcesPending; } >+ >+ void setResourceUpdatesPending(bool b) { m_resourceUpdatesPending = b; } >+ bool resourceUpdatesPending() const { return m_resourceUpdatesPending; } >+ >+ void setFrameComplete(bool b) { m_frameComplete = b; } >+ bool frameComplete() const { return m_frameComplete; } > }; > > TEST(CCSchedulerStateMachineTest, TestNextActionBeginsFrameIfNeeded) >@@ -97,7 +102,7 @@ TEST(CCSchedulerStateMachineTest, TestNextActionBeginsFrameIfNeeded) > StateMachine state; > state.setVisible(true); > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); >- EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); > EXPECT_FALSE(state.needsCommit()); > } > } >@@ -251,6 +256,8 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_OneRoundOfUpdates) > state.setNeedsRedraw(false); > state.setUpdateMoreResourcesPending(false); > state.setVisible(true); >+ state.setResourceUpdatesPending(true); >+ state.setFrameComplete(true); > > // Verify we begin update, both for vsync and not vsync. > EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state.nextAction()); >@@ -267,7 +274,7 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_OneRoundOfUpdates) > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); > > // End update with no more updates pending. >- state.beginUpdateMoreResourcesComplete(false); >+ state.updateMoreResourcesComplete(false); > state.didLeaveVSync(); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); > } >@@ -279,6 +286,8 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_TwoRoundsOfUpdates) > state.setNeedsRedraw(false); > state.setUpdateMoreResourcesPending(false); > state.setVisible(true); >+ state.setResourceUpdatesPending(true); >+ state.setFrameComplete(true); > > // Verify the update begins, both for vsync and not vsync. > state.didEnterVSync(); >@@ -295,7 +304,7 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_TwoRoundsOfUpdates) > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); > > // Ack the update with more pending. >- state.beginUpdateMoreResourcesComplete(true); >+ state.updateMoreResourcesComplete(true); > > // Verify we update more, both for vsync and not vsync. > state.didLeaveVSync(); >@@ -305,7 +314,7 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_TwoRoundsOfUpdates) > > // Begin another update, while inside vsync. And, it updating. > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); >- state.beginUpdateMoreResourcesComplete(false); >+ state.updateMoreResourcesComplete(false); > > // Make sure we commit, independent of vsync. > state.didLeaveVSync(); >@@ -321,6 +330,9 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_WithRedraw_OneRoundOfUpdates) > state.setNeedsRedraw(true); > state.setUpdateMoreResourcesPending(false); > state.setVisible(true); >+ state.setResourceUpdatesPending(true); >+ state.setFrameComplete(true); >+ > EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state.nextAction()); > > // Begin an update. >@@ -338,7 +350,7 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_WithRedraw_OneRoundOfUpdates) > state.didLeaveVSync(); > > // Finish update but leave more resources pending. >- state.beginUpdateMoreResourcesComplete(true); >+ state.updateMoreResourcesComplete(true); > > // Verify that regardless of vsync, we update some more. > state.didLeaveVSync(); >@@ -352,7 +364,7 @@ TEST(CCSchedulerStateMachineTest, TestUpdates_WithRedraw_OneRoundOfUpdates) > state.didEnterVSync(); > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); > state.didLeaveVSync(); >- state.beginUpdateMoreResourcesComplete(false); >+ state.updateMoreResourcesComplete(false); > > // Verify we commit regardless of vsync state > state.didLeaveVSync(); >@@ -370,7 +382,11 @@ TEST(CCSchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) > // Begin the frame. > EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); > state.updateState(state.nextAction()); >- EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ >+ // Receive resource that need update. >+ state.setResourceUpdatesPending(true); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); > > // Now, while the frame is in progress, set another commit. > state.setNeedsCommit(true); >@@ -382,7 +398,7 @@ TEST(CCSchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) > EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state.nextAction()); > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); >- state.beginUpdateMoreResourcesComplete(false); >+ state.updateMoreResourcesComplete(false); > EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState()); > > // Expect to commit regardless of vsync state. >@@ -413,10 +429,14 @@ TEST(CCSchedulerStateMachineTest, TestFullCycle) > > // Begin the frame. > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); >- EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); > EXPECT_FALSE(state.needsCommit()); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); > >+ // Receive resource. >+ state.setResourceUpdatesPending(true); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ > // Tell the scheduler the frame finished. > state.beginFrameComplete(); > EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >@@ -424,7 +444,7 @@ TEST(CCSchedulerStateMachineTest, TestFullCycle) > > // Tell the scheduler the update began and finished > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); >- state.beginUpdateMoreResourcesComplete(false); >+ state.updateMoreResourcesComplete(false); > EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState()); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); > >@@ -459,7 +479,7 @@ TEST(CCSchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) > > // Begin the frame. > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); >- EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); > EXPECT_FALSE(state.needsCommit()); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); > >@@ -467,6 +487,10 @@ TEST(CCSchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) > state.setNeedsCommit(true); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); > >+ // Receive resource. >+ state.setResourceUpdatesPending(true); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ > // Tell the scheduler the frame finished. > state.beginFrameComplete(); > EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >@@ -474,7 +498,7 @@ TEST(CCSchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) > > // Tell the scheduler the update began and finished > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); >- state.beginUpdateMoreResourcesComplete(false); >+ state.updateMoreResourcesComplete(false); > EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState()); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); > >@@ -516,13 +540,17 @@ TEST(CCSchedulerStateMachineTest, TestGoesInvisibleMidCommit) > > // Begin the frame while visible. > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); >- EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); > EXPECT_FALSE(state.needsCommit()); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); > > // Become invisible > state.setVisible(false); > >+ // Receive resource. >+ state.setResourceUpdatesPending(true); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ > // Tell the scheduler the frame finished > state.beginFrameComplete(); > EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >@@ -530,7 +558,7 @@ TEST(CCSchedulerStateMachineTest, TestGoesInvisibleMidCommit) > > // Tell the scheduler the update began and finished > state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); >- state.beginUpdateMoreResourcesComplete(false); >+ state.updateMoreResourcesComplete(false); > EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState()); > EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); > >@@ -550,4 +578,65 @@ TEST(CCSchedulerStateMachineTest, TestGoesInvisibleMidCommit) > EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); > } > >+TEST(CCSchedulerStateMachineTest, TestNoResourceUpdates) >+{ >+ StateMachine state; >+ state.setVisible(true); >+ >+ // Start clean and set commit. >+ state.setNeedsCommit(true); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); >+ >+ // Begin the frame. >+ state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ EXPECT_FALSE(state.needsCommit()); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); >+ >+ // Tell the scheduler the frame finished. >+ state.beginFrameComplete(); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); >+} >+ >+TEST(CCSchedulerStateMachineTest, TestNoResourcePending) >+{ >+ StateMachine state; >+ state.setVisible(true); >+ >+ // Start clean and set commit. >+ state.setNeedsCommit(true); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); >+ >+ // Begin the frame. >+ state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ EXPECT_FALSE(state.needsCommit()); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); >+ >+ // Receive resource. >+ state.setResourceUpdatesPending(true); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ >+ // Tell the scheduler the update began and finished. >+ state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); >+ state.updateMoreResourcesComplete(true); >+ >+ // Tell the scheduler another update began and finished. >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state.nextAction()); >+ state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); >+ state.updateMoreResourcesComplete(false); >+ >+ // No pending resources to update. >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); >+ >+ // Tell the scheduler the frame finished. >+ state.beginFrameComplete(); >+ EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState()); >+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); >+} >+ > } >diff --git a/Source/WebKit/chromium/tests/CCSchedulerTest.cpp b/Source/WebKit/chromium/tests/CCSchedulerTest.cpp >index b58ed2c56c28df785cc9c1169d6701cc70dffbd6..f32b0b50641f1b4634554c4b71cf3e7a56dc49d1 100644 >--- a/Source/WebKit/chromium/tests/CCSchedulerTest.cpp >+++ b/Source/WebKit/chromium/tests/CCSchedulerTest.cpp >@@ -76,12 +76,10 @@ TEST(CCSchedulerTest, RequestCommit) > client.reset(); > > // Since, hasMoreResourceUpdates is set to false, >- // beginFrameComplete should updateMoreResources, then >- // commit >+ // beginFrameComplete should commit immediately. > scheduler->beginFrameComplete(); >- EXPECT_EQ(2, client.numActions()); >- EXPECT_STREQ("scheduledActionUpdateMoreResources", client.action(0)); >- EXPECT_STREQ("scheduledActionCommit", client.action(1)); >+ EXPECT_EQ(1, client.numActions()); >+ EXPECT_STREQ("scheduledActionCommit", client.action(0)); > client.reset(); > > // Tick should draw. >@@ -112,12 +110,10 @@ TEST(CCSchedulerTest, RequestCommitAfterBeginFrame) > scheduler->setNeedsCommit(); > > // Since, hasMoreResourceUpdates is set to false, and another commit is >- // needed, beginFrameComplete should updateMoreResources, then commit, then >- // begin another frame. >+ // needed, beginFrameComplete should commit, then begin another frame. > scheduler->beginFrameComplete(); >- EXPECT_EQ(2, client.numActions()); >- EXPECT_STREQ("scheduledActionUpdateMoreResources", client.action(0)); >- EXPECT_STREQ("scheduledActionCommit", client.action(1)); >+ EXPECT_EQ(1, client.numActions()); >+ EXPECT_STREQ("scheduledActionCommit", client.action(0)); > client.reset(); > > // Tick should draw but then begin another frame. >@@ -233,4 +229,52 @@ TEST(CCSchedulerTest, RequestCommitInsideDraw) > EXPECT_FALSE(scheduler->redrawPending()); > } > >+TEST(CCSchedulerTest, UpdateResources) >+{ >+ FakeCCSchedulerClient client; >+ RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); >+ OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CCFrameRateController(timeSource))); >+ scheduler->setVisible(true); >+ >+ // SetNeedsCommit should begin the frame. >+ scheduler->setNeedsCommit(); >+ EXPECT_EQ(1, client.numActions()); >+ EXPECT_STREQ("scheduledActionBeginFrame", client.action(0)); >+ client.reset(); >+ >+ // Now setNeedsCommit again. Calling here means we need a second frame. >+ scheduler->setNeedsCommit(); >+ >+ // Update pending resources. >+ client.setHasMoreResourceUpdates(true); >+ scheduler->setResourceUpdatesPending(); >+ EXPECT_EQ(1, client.numActions()); >+ EXPECT_STREQ("scheduledActionUpdateMoreResources", client.action(0)); >+ client.reset(); >+ >+ // Client finished update but have not yet told scheduler. >+ client.setHasMoreResourceUpdates(false); >+ >+ // beginFrameComplete should not commit, as an update is pending. >+ scheduler->beginFrameComplete(); >+ EXPECT_EQ(0, client.numActions()); >+ client.reset(); >+ >+ // Since, hasMoreResourceUpdates is set to false, and another commit is >+ // needed, updateMoreResourcesComplete() should commit, then begin >+ // another frame. >+ scheduler->updateMoreResourcesComplete(); >+ EXPECT_EQ(1, client.numActions()); >+ EXPECT_STREQ("scheduledActionCommit", client.action(0)); >+ client.reset(); >+ >+ // Tick should draw but then begin another frame. >+ timeSource->tick(); >+ EXPECT_EQ(2, client.numActions()); >+ EXPECT_STREQ("scheduledActionDrawAndSwap", client.action(0)); >+ EXPECT_STREQ("scheduledActionBeginFrame", client.action(1)); >+ client.reset(); >+} >+ >+ > } >diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp >index 63aa456ad8d8ccb3fe04fafc1620bf0f24e67f43..93cfb57883a5f1540b4cc98ea583a9916b16e585 100644 >--- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp >+++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp >@@ -27,9 +27,9 @@ > #include "TiledLayerChromium.h" > > #include "LayerTextureUpdater.h" >+#include "ManagedTexture.h" > #include "TextureManager.h" > #include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread >-#include "cc/CCTextureUpdater.h" > #include "cc/CCTiledLayerImpl.h" > #include <gtest/gtest.h> > >@@ -38,20 +38,23 @@ 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 FakeLayerTextureUpdater : public LayerTextureUpdater { > public: > class Texture : public LayerTextureUpdater::Texture { > public: >- Texture(PassOwnPtr<ManagedTexture> texture) : LayerTextureUpdater::Texture(texture) { } >- virtual ~Texture() { } >+ Texture(PassOwnPtr<ManagedTexture> texture) : m_texture(texture) { } > >- virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect&, const IntRect&) { } >+ virtual ManagedTexture* texture() { return m_texture.get(); } >+ >+ virtual void updateRect(GraphicsContext3D*, const IntRect&, const IntRect&) { } >+ >+ private: >+ OwnPtr<ManagedTexture> m_texture; > }; > > FakeLayerTextureUpdater() { } >@@ -60,7 +63,7 @@ public: > virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(ManagedTexture::create(manager))); } > virtual Orientation orientation() { return BottomUpOrientation; } > virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; } >- virtual void prepareToUpdate(const IntRect&, const IntSize&, int, float) { } >+ virtual void paintContents(const IntRect&, const IntSize&, int, float) { } > }; > > class FakeCCTiledLayerImpl : public CCTiledLayerImpl { >@@ -98,6 +101,11 @@ public: > TiledLayerChromium::prepareToUpdate(rect); > } > >+ void paintContents(const IntRect& rect) >+ { >+ TiledLayerChromium::paintContents(rect); >+ } >+ > virtual TextureManager* textureManager() const { return m_textureManager; } > > private: >@@ -119,13 +127,13 @@ 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->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. >@@ -138,7 +146,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.
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