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-72192-20111118133050.patch (text/plain), 143.00 KB, created by
David Reveman
on 2011-11-18 13:30:51 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
David Reveman
Created:
2011-11-18 13:30:51 PST
Size:
143.00 KB
patch
obsolete
>Subversion Revision: 100672 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f3f87c4f88fbe5a2b915465b1289c9d4425f991b..d54d3a8dea3355c01771d4bd015482463d471338 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,190 @@ >+2011-11-18 David Reveman <reveman@chromium.org> >+ >+ [Chromium] Initialize compositor resources prior to painting. >+ https://bugs.webkit.org/show_bug.cgi?id=72192 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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. >+ >+ No new tests. Covered by existing tests. >+ >+ * WebCore.gypi: >+ * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp: Added. >+ (WebCore::BitmapCanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore::BitmapCanvasLayerTextureUpdater::Texture::~Texture): >+ (WebCore::BitmapCanvasLayerTextureUpdater::Texture::updateRect): >+ (WebCore::BitmapCanvasLayerTextureUpdater::create): >+ (WebCore::BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater): >+ (WebCore::BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater): >+ (WebCore::BitmapCanvasLayerTextureUpdater::createTexture): >+ (WebCore::BitmapCanvasLayerTextureUpdater::sampledTexelFormat): >+ (WebCore::BitmapCanvasLayerTextureUpdater::paintContents): >+ (WebCore::BitmapCanvasLayerTextureUpdater::updateTextureRect): >+ * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h: Added. >+ (WebCore::BitmapCanvasLayerTextureUpdater::Texture::textureUpdater): >+ (WebCore::BitmapCanvasLayerTextureUpdater::orientation): >+ * 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: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h. >+ (WebCore::CanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore::CanvasLayerTextureUpdater::Texture::~Texture): >+ (WebCore::CanvasLayerTextureUpdater::Texture::needPrepareRect): >+ (WebCore::CanvasLayerTextureUpdater::Texture::prepareRect): >+ (WebCore::CanvasLayerTextureUpdater::CanvasLayerTextureUpdater): >+ (WebCore::CanvasLayerTextureUpdater::~CanvasLayerTextureUpdater): >+ (WebCore::CanvasLayerTextureUpdater::paint): >+ * platform/graphics/chromium/CanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h. >+ (WebCore::CanvasLayerTextureUpdater::Texture::texture): >+ (WebCore::CanvasLayerTextureUpdater::contentRect): >+ * platform/graphics/chromium/ContentLayerChromium.cpp: >+ (WebCore::ContentLayerChromium::prepareToUpdateIfDirty): >+ (WebCore::ContentLayerChromium::paintContentsIfDirty): >+ (WebCore::ContentLayerChromium::createTextureUpdater): >+ * platform/graphics/chromium/ContentLayerChromium.h: >+ * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp: Added. >+ (WebCore::FrameBuffer::FrameBuffer::FrameBuffer): >+ (WebCore::FrameBuffer::FrameBuffer::~FrameBuffer): >+ (WebCore::FrameBuffer::FrameBuffer::initialize): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::create): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::FrameBufferSkPictureCanvasLayerTextureUpdater): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::~FrameBufferSkPictureCanvasLayerTextureUpdater): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::createTexture): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::sampledTexelFormat): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect): >+ * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h. >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::textureUpdater): >+ (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::orientation): >+ * 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::Texture::textureUpdater): >+ (WebCore::ImageLayerTextureUpdater::createTexture): >+ (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/LayerRendererChromium.cpp: >+ * platform/graphics/chromium/LayerTextureUpdater.h: >+ (WebCore::LayerTextureUpdater::Texture::~Texture): >+ (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/LayerTextureUpdaterCanvas.cpp: Removed. >+ * platform/graphics/chromium/LayerTextureUpdaterCanvas.h: Removed. >+ * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h. >+ (WebCore::SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater): >+ (WebCore::SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater): >+ (WebCore::SkPictureCanvasLayerTextureUpdater::paintContents): >+ (WebCore::SkPictureCanvasLayerTextureUpdater::drawPicture): >+ * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h. >+ * platform/graphics/chromium/TiledLayerChromium.cpp: >+ (WebCore::UpdatableTile::UpdatableTile): >+ (WebCore::UpdatableTile::texture): >+ (WebCore::UpdatableTile::managedTexture): >+ (WebCore::TiledLayerChromium::forEachCompositorResource): >+ (WebCore::TiledLayerChromium::pushPropertiesTo): >+ (WebCore::TiledLayerChromium::createTile): >+ (WebCore::TiledLayerChromium::protectTileTextures): >+ (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::needPrepareRect): >+ (WebCore::VideoLayerChromium::UpdaterTexture::prepareRect): >+ (WebCore::VideoLayerChromium::UpdaterTexture::updateRect): >+ (WebCore::VideoLayerChromium::VideoLayerChromium): >+ (WebCore::VideoLayerChromium::prepareToUpdateIfDirty): >+ (WebCore::VideoLayerChromium::needPrepareCompositorResources): >+ (WebCore::VideoLayerChromium::prepareCompositorResources): >+ (WebCore::VideoLayerChromium::updateCompositorResources): >+ (WebCore::VideoLayerChromium::forEachCompositorResource): >+ (WebCore::VideoLayerChromium::allocateTexture): >+ (WebCore::VideoLayerChromium::updateTexture): >+ * platform/graphics/chromium/VideoLayerChromium.h: >+ (WebCore::VideoLayerChromium::UpdaterTexture::create): >+ * 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::CCLayerTreeHost::NeedResourceHandler::resources): >+ * platform/graphics/chromium/cc/CCProxy.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::append): >+ (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: >+ * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp: >+ (WebCore::CCTiledLayerImpl::drawTiles): >+ > 2011-11-17 Sheriff Bot <webkit.review.bot@gmail.com> > > Unreviewed, rolling out r100652. >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 36050f69aade31d2cc50d85c8fcf06f51b7259c9..7f0d7c64b2e7bd6a66adaa419ead18a00c19fc4f 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,59 @@ >+2011-11-18 David Reveman <reveman@chromium.org> >+ >+ [Chromium] Initialize compositor resources prior to painting. >+ https://bugs.webkit.org/show_bug.cgi?id=72192 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Track texture updater changes. >+ >+ * tests/CCLayerTreeHostTest.cpp: >+ (WTF::CCLayerTreeHostTest::layerTreeHost): >+ (WTF::MockLayerDelegate::paintContents): >+ (WTF::MockLayerDelegate::drawsContent): >+ (WTF::MockLayerDelegate::preserves3D): >+ (WTF::MockLayerDelegate::notifySyncRequired): >+ (WTF::TestOpacityChangeLayerDelegate::TestOpacityChangeLayerDelegate): >+ (WTF::TestOpacityChangeLayerDelegate::paintContents): >+ (WTF::TestOpacityChangeLayerDelegate::drawsContent): >+ (WTF::TestOpacityChangeLayerDelegate::preserves3D): >+ (WTF::TestOpacityChangeLayerDelegate::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::beginTest): >+ (WTF::CCLayerTreeHostTestOpacityChange::commitCompleteOnCCThread): >+ (WTF::CCLayerTreeHostTestOpacityChange::afterTest): >+ (WTF::TEST_F): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::CCLayerTreeHostTestNoPrepareRect): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::beginTest): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::commitCompleteOnCCThread): >+ (WTF::CCLayerTreeHostTestNoPrepareRect::afterTest): >+ > 2011-11-17 Adrienne Walker <enne@google.com> > > [chromium] Implicitly skip render surfaces that won't be drawn >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index fa433a927729d3379a24a445b1365642292d5ade..4c311d60e0a5edeb0faa26e860a47b750108e062 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -3452,10 +3452,14 @@ > 'platform/graphics/cg/PathCG.cpp', > 'platform/graphics/cg/PatternCG.cpp', > 'platform/graphics/cg/TransformationMatrixCG.cpp', >+ 'platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp', >+ 'platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h', > 'platform/graphics/chromium/Canvas2DLayerChromium.cpp', > 'platform/graphics/chromium/Canvas2DLayerChromium.h', > 'platform/graphics/chromium/CanvasLayerChromium.cpp', > 'platform/graphics/chromium/CanvasLayerChromium.h', >+ 'platform/graphics/chromium/CanvasLayerTextureUpdater.cpp', >+ 'platform/graphics/chromium/CanvasLayerTextureUpdater.h', > 'platform/graphics/chromium/ComplexTextControllerLinux.cpp', > 'platform/graphics/chromium/ComplexTextControllerLinux.h', > 'platform/graphics/chromium/ContentLayerChromium.cpp', >@@ -3476,6 +3480,8 @@ > 'platform/graphics/chromium/FontRenderStyle.h', > 'platform/graphics/chromium/FontUtilsChromiumWin.cpp', > 'platform/graphics/chromium/FontUtilsChromiumWin.h', >+ 'platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp', >+ 'platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h', > 'platform/graphics/chromium/GeometryBinding.cpp', > 'platform/graphics/chromium/GeometryBinding.h', > 'platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp', >@@ -3499,8 +3505,6 @@ > 'platform/graphics/chromium/LayerTextureSubImage.cpp', > 'platform/graphics/chromium/LayerTextureSubImage.h', > 'platform/graphics/chromium/LayerTextureUpdater.h', >- 'platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp', >- 'platform/graphics/chromium/LayerTextureUpdaterCanvas.h', > 'platform/graphics/chromium/NonCompositedContentHost.cpp', > 'platform/graphics/chromium/NonCompositedContentHost.h', > 'platform/graphics/chromium/MediaPlayerPrivateChromium.h', >@@ -3522,6 +3526,8 @@ > 'platform/graphics/chromium/ShaderChromium.h', > 'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp', > 'platform/graphics/chromium/SimpleFontDataLinux.cpp', >+ 'platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp', >+ 'platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h', > 'platform/graphics/chromium/TrackingTextureAllocator.cpp', > 'platform/graphics/chromium/TrackingTextureAllocator.h', > 'platform/graphics/chromium/TextureManager.cpp', >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f12c1e900644e2f12af886c685322c09a2773b2c >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp >@@ -0,0 +1,104 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#include "config.h" >+ >+#if USE(ACCELERATED_COMPOSITING) >+ >+#include "BitmapCanvasLayerTextureUpdater.h" >+ >+#include "LayerPainterChromium.h" >+#include "PlatformColor.h" >+ >+namespace WebCore { >+ >+BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >+ : CanvasLayerTextureUpdater::Texture(texture) >+ , m_textureUpdater(textureUpdater) >+{ >+} >+ >+BitmapCanvasLayerTextureUpdater::Texture::~Texture() >+{ >+} >+ >+void BitmapCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ ASSERT(texture()->textureId()); >+ textureUpdater()->updateTextureRect(context, texture(), sourceRect, destRect); >+} >+ >+PassRefPtr<BitmapCanvasLayerTextureUpdater> BitmapCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage) >+{ >+ return adoptRef(new BitmapCanvasLayerTextureUpdater(painter, useMapTexSubImage)); >+} >+ >+BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage) >+ : CanvasLayerTextureUpdater(painter) >+ , m_texSubImage(useMapTexSubImage) >+{ >+} >+ >+BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater() >+{ >+} >+ >+PassRefPtr<LayerTextureUpdater::Texture> BitmapCanvasLayerTextureUpdater::createTexture(TextureManager* manager) >+{ >+ return adoptRef(new Texture(this, ManagedTexture::create(manager))); >+} >+ >+LayerTextureUpdater::SampledTexelFormat BitmapCanvasLayerTextureUpdater::sampledTexelFormat(GC3Denum textureFormat) >+{ >+ // The component order may be bgra if we uploaded bgra pixels to rgba textures. >+ return PlatformColor::sameComponentOrder(textureFormat) ? >+ LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; >+} >+ >+void BitmapCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) >+{ >+ m_texSubImage.setSubImageSize(tileSize); >+ >+ m_canvas.resize(contentRect.size()); >+ // Assumption: if a tiler is using border texels, then it is because the >+ // layer is likely to be filtered or transformed. Because of it might be >+ // transformed, draw the text in grayscale instead of subpixel antialiasing. >+ PlatformCanvas::Painter::TextOption textOption = >+ borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText; >+ PlatformCanvas::Painter canvasPainter(&m_canvas, textOption); >+ paint(*canvasPainter.context(), contentRect); >+} >+ >+void BitmapCanvasLayerTextureUpdater::updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ PlatformCanvas::AutoLocker locker(&m_canvas); >+ >+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->textureId()); >+ m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context); >+} >+ >+} // namespace WebCore >+#endif // USE(ACCELERATED_COMPOSITING) >diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >new file mode 100644 >index 0000000000000000000000000000000000000000..bfc8b4c8cffba5c2431c53f01ea4948cfc73805e >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h >@@ -0,0 +1,74 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#ifndef BitmapCanvasLayerTextureUpdater_h >+#define BitmapCanvasLayerTextureUpdater_h >+ >+#if USE(ACCELERATED_COMPOSITING) >+ >+#include "CanvasLayerTextureUpdater.h" >+#include "LayerTextureSubImage.h" >+#include "PlatformCanvas.h" >+ >+namespace WebCore { >+ >+class LayerPainterChromium; >+ >+// A CanvasLayerTextureUpdater with an internal bitmap. >+class BitmapCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater { >+public: >+ class Texture : public CanvasLayerTextureUpdater::Texture { >+ public: >+ Texture(BitmapCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>); >+ virtual ~Texture(); >+ >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ BitmapCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } >+ >+ BitmapCanvasLayerTextureUpdater* m_textureUpdater; >+ }; >+ >+ static PassRefPtr<BitmapCanvasLayerTextureUpdater> create(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage); >+ virtual ~BitmapCanvasLayerTextureUpdater(); >+ >+ virtual PassRefPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*); >+ virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } >+ virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); >+ void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); >+ >+private: >+ BitmapCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage); >+ >+ PlatformCanvas m_canvas; >+ LayerTextureSubImage m_texSubImage; >+}; >+ >+} // namespace WebCore >+#endif // USE(ACCELERATED_COMPOSITING) >+#endif // BitmapCanvasLayerTextureUpdater_h >diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp >index 4494586a57ca16bc4b4f232410db8f7fd4cd88c1..39d2d16a1cbbdd17077b0d2e27e1ce859f8a7b7e 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_dirtyRect.isEmpty() || !drawsContent()) > return; >@@ -85,6 +100,11 @@ void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, CCText > resetNeedsDisplay(); > } > >+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..e25ee468a1335e36a569df95a30296b4696099f1 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 PassRefPtr<UpdaterTexture> create(Canvas2DLayerChromium* layer) >+ { >+ return adoptRef(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; >+ >+ RefPtr<UpdaterTexture> m_updaterTexture; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..9b9765f8c3fae19ebb525da1c43681310e80daff >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp >@@ -0,0 +1,77 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#include "config.h" >+ >+#if USE(ACCELERATED_COMPOSITING) >+ >+#include "CanvasLayerTextureUpdater.h" >+ >+#include "GraphicsContext.h" >+#include "LayerPainterChromium.h" >+#include "TraceEvent.h" >+ >+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->bindTexture(context, allocator); >+} >+ >+CanvasLayerTextureUpdater::CanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter) >+ : m_painter(painter) >+{ >+} >+ >+CanvasLayerTextureUpdater::~CanvasLayerTextureUpdater() >+{ >+} >+ >+void CanvasLayerTextureUpdater::paint(GraphicsContext& context, const IntRect& contentRect) >+{ >+ context.translate(-contentRect.x(), -contentRect.y()); >+ { >+ TRACE_EVENT("CanvasLayerTextureUpdater::paint", this, 0); >+ m_painter->paint(context, contentRect); >+ } >+ m_contentRect = contentRect; >+} >+ >+} // namespace WebCore >+#endif // USE(ACCELERATED_COMPOSITING) >diff --git a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >new file mode 100644 >index 0000000000000000000000000000000000000000..f6e05478ab90da74f1690d0e36d1b838672d0fb2 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h >@@ -0,0 +1,74 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#ifndef CanvasLayerTextureUpdater_h >+#define CanvasLayerTextureUpdater_h >+ >+#if USE(ACCELERATED_COMPOSITING) >+ >+#include "LayerTextureUpdater.h" >+#include "ManagedTexture.h" >+ >+namespace WebCore { >+ >+class GraphicsContext3D; >+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 paint(GraphicsContext&, const IntRect& contentRect); >+ const IntRect& contentRect() const { return m_contentRect; } >+ >+private: >+ IntRect m_contentRect; >+ OwnPtr<LayerPainterChromium> m_painter; >+}; >+ >+} // namespace WebCore >+#endif // USE(ACCELERATED_COMPOSITING) >+#endif // CanvasLayerTextureUpdater_h >diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >index ca8b3bd761f0815e47b6cfb0491a1d972879f04c..00d385b9a54217feb0300e5ba13f69608ad5ae70 100644 >--- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >@@ -34,9 +34,10 @@ > > #include "ContentLayerChromium.h" > >+#include "BitmapCanvasLayerTextureUpdater.h" >+#include "FrameBufferSkPictureCanvasLayerTextureUpdater.h" > #include "LayerPainterChromium.h" > #include "LayerRendererChromium.h" >-#include "LayerTextureUpdaterCanvas.h" > #include "PlatformSupport.h" > #include "cc/CCLayerTreeHost.h" > #include <wtf/CurrentTime.h> >@@ -92,25 +93,37 @@ void ContentLayerChromium::cleanupResources() > TiledLayerChromium::cleanupResources(); > } > >-void ContentLayerChromium::paintContentsIfDirty() >+void ContentLayerChromium::prepareToUpdateIfDirty() > { >- ASSERT(drawsContent()); >- > updateTileSizeAndTilingOption(); > >- const IntRect& layerRect = visibleLayerRect(); >- if (layerRect.isEmpty()) >- return; >+ IntRect layerRect; >+ >+ // Always call prepareToUpdate() but with an empty layer rectangle when >+ // layer doesn't draw contents. >+ if (drawsContent()) >+ layerRect = visibleLayerRect(); > > IntRect dirty = enclosingIntRect(m_dirtyRect); > dirty.intersect(IntRect(IntPoint(), contentBounds())); > invalidateRect(dirty); > >+ prepareToUpdate(layerRect); >+ resetNeedsDisplay(); >+} >+ >+void ContentLayerChromium::paintContentsIfDirty() >+{ >+ ASSERT(drawsContent()); >+ >+ const IntRect& layerRect = visibleLayerRect(); >+ if (layerRect.isEmpty()) >+ return; >+ > if (!drawsContent()) > return; > >- prepareToUpdate(layerRect); >- resetNeedsDisplay(); >+ paintContents(layerRect); > } > > bool ContentLayerChromium::drawsContent() const >@@ -122,12 +135,12 @@ void ContentLayerChromium::createTextureUpdater(const CCLayerTreeHost* host) > { > #if USE(SKIA) > if (host->settings().acceleratePainting) { >- m_textureUpdater = LayerTextureUpdaterSkPicture::create(ContentLayerPainter::create(m_delegate)); >+ m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate)); > return; > } > #endif // USE(SKIA) > >- m_textureUpdater = LayerTextureUpdaterBitmap::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub); >+ m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub); > } > > } >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 >new file mode 100644 >index 0000000000000000000000000000000000000000..e09ebe7d5036dd6d0ccc0a124e5c76d2e93a0621 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp >@@ -0,0 +1,163 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#include "config.h" >+ >+#if USE(ACCELERATED_COMPOSITING) >+#if USE(SKIA) >+ >+#include "FrameBufferSkPictureCanvasLayerTextureUpdater.h" >+ >+#include "LayerPainterChromium.h" >+#include "SkCanvas.h" >+#include "SkGpuDevice.h" >+ >+namespace WebCore { >+ >+namespace { >+ >+class FrameBuffer { >+public: >+ FrameBuffer(); >+ ~FrameBuffer(); >+ >+ SkCanvas* initialize(GraphicsContext3D*, ManagedTexture*); >+ >+private: >+ GraphicsContext3D* m_context; >+ Platform3DObject m_fbo; >+ OwnPtr<SkCanvas> m_canvas; >+}; >+ >+FrameBuffer::FrameBuffer() >+ : m_context(0) >+ , m_fbo(0) >+{ >+} >+ >+FrameBuffer::~FrameBuffer() >+{ >+ m_canvas.clear(); >+ >+ if (m_fbo) >+ m_context->deleteFramebuffer(m_fbo); >+} >+ >+SkCanvas* FrameBuffer::initialize(GraphicsContext3D* context, ManagedTexture* texture) >+{ >+ m_context = context; >+ m_fbo = m_context->createFramebuffer(); >+ m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >+ context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->textureId(), 0); >+ >+ // Create a skia gpu canvas. >+ GrContext* grContext = m_context->grContext(); >+ IntSize canvasSize = texture->size(); >+ GrPlatformSurfaceDesc targetDesc; >+ targetDesc.reset(); >+ targetDesc.fSurfaceType = kTextureRenderTarget_GrPlatformSurfaceType; >+ targetDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit; >+ targetDesc.fWidth = canvasSize.width(); >+ targetDesc.fHeight = canvasSize.height(); >+ targetDesc.fConfig = kRGBA_8888_GrPixelConfig; >+ targetDesc.fStencilBits = 8; >+ targetDesc.fPlatformTexture = texture->textureId(); >+ targetDesc.fPlatformRenderTarget = m_fbo; >+ SkAutoTUnref<GrTexture> target(static_cast<GrTexture*>(grContext->createPlatformSurface(targetDesc))); >+ SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); >+ m_canvas = adoptPtr(new SkCanvas(device.get())); >+ >+ return m_canvas.get(); >+} >+ >+} // namespace >+ >+FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture(FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >+ : CanvasLayerTextureUpdater::Texture(texture) >+ , m_textureUpdater(textureUpdater) >+{ >+} >+ >+FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture() >+{ >+} >+ >+void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ ASSERT(texture()->textureId()); >+ textureUpdater()->updateTextureRect(context, texture(), sourceRect, destRect); >+} >+ >+PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> FrameBufferSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter) >+{ >+ return adoptRef(new FrameBufferSkPictureCanvasLayerTextureUpdater(painter)); >+} >+ >+FrameBufferSkPictureCanvasLayerTextureUpdater::FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter) >+ : SkPictureCanvasLayerTextureUpdater(painter) >+{ >+} >+ >+FrameBufferSkPictureCanvasLayerTextureUpdater::~FrameBufferSkPictureCanvasLayerTextureUpdater() >+{ >+} >+ >+PassRefPtr<LayerTextureUpdater::Texture> FrameBufferSkPictureCanvasLayerTextureUpdater::createTexture(TextureManager* manager) >+{ >+ return adoptRef(new Texture(this, ManagedTexture::create(manager))); >+} >+ >+LayerTextureUpdater::SampledTexelFormat FrameBufferSkPictureCanvasLayerTextureUpdater::sampledTexelFormat(GC3Denum textureFormat) >+{ >+ // Here we directly render to the texture, so the component order is always correct. >+ return LayerTextureUpdater::SampledTexelFormatRGBA; >+} >+ >+void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, 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, 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 >+#endif // USE(SKIA) >+#endif // USE(ACCELERATED_COMPOSITING) >diff --git a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >new file mode 100644 >index 0000000000000000000000000000000000000000..31e83a3dadfa5014529137f4da229af70f59e8f4 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#ifndef FrameBufferSkPictureCanvasLayerTextureUpdater_h >+#define FrameBufferSkPictureCanvasLayerTextureUpdater_h >+ >+#if USE(ACCELERATED_COMPOSITING) >+#if USE(SKIA) >+ >+#include "SkPictureCanvasLayerTextureUpdater.h" >+ >+namespace WebCore { >+ >+class FrameBufferSkPictureCanvasLayerTextureUpdater : public SkPictureCanvasLayerTextureUpdater { >+public: >+ class Texture : public CanvasLayerTextureUpdater::Texture { >+ public: >+ Texture(FrameBufferSkPictureCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>); >+ virtual ~Texture(); >+ >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } >+ >+ FrameBufferSkPictureCanvasLayerTextureUpdater* m_textureUpdater; >+ }; >+ >+ static PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> create(PassOwnPtr<LayerPainterChromium>); >+ virtual ~FrameBufferSkPictureCanvasLayerTextureUpdater(); >+ >+ virtual PassRefPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*); >+ virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; } >+ virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >+ void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); >+ >+private: >+ explicit FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>); >+}; >+} // namespace WebCore >+#endif // USE(SKIA) >+#endif // USE(ACCELERATED_COMPOSITING) >+#endif // FrameBufferSkPictureCanvasLayerTextureUpdater_h >diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >index 363362967accdebc2559e29c24d43c1c88880317..d563351e6649be3cf7ecf1150dd5e7f73696efd5 100644 >--- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >@@ -46,6 +46,39 @@ namespace WebCore { > > class ImageLayerTextureUpdater : public LayerTextureUpdater { > public: >+ class Texture : public LayerTextureUpdater::Texture { >+ public: >+ Texture(ImageLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture) >+ : m_texture(texture) >+ , m_textureUpdater(textureUpdater) >+ { >+ } >+ >+ 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 */) >+ { >+ m_texture->bindTexture(context, allocator); >+ } >+ >+ virtual void updateRect(GraphicsContext3D* context, const IntRect& sourceRect, const IntRect& destRect) >+ { >+ ASSERT(texture()->textureId()); >+ textureUpdater()->updateTextureRect(context, texture(), sourceRect, destRect); >+ } >+ >+ private: >+ ImageLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } >+ >+ OwnPtr<ManagedTexture> m_texture; >+ ImageLayerTextureUpdater* m_textureUpdater; >+ }; >+ > static PassRefPtr<ImageLayerTextureUpdater> create(bool useMapTexSubImage) > { > return adoptRef(new ImageLayerTextureUpdater(useMapTexSubImage)); >@@ -53,6 +86,11 @@ public: > > virtual ~ImageLayerTextureUpdater() { } > >+ virtual PassRefPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) >+ { >+ return adoptRef(new Texture(this, ManagedTexture::create(manager))); >+ } >+ > virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } > > virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) >@@ -61,14 +99,14 @@ public: > LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; > } > >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int /* borderTexels */) >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& tileSize, int /* borderTexels */) > { > m_texSubImage.setSubImageSize(tileSize); > } > >- virtual void updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) >+ virtual void updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) > { >- texture->bindTexture(context, allocator); >+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->textureId()); > > // Source rect should never go outside the image pixels, even if this > // is requested because the texture extends outside the image. >@@ -144,7 +182,7 @@ void ImageLayerChromium::setContents(Image* contents) > setOpaque(!m_contents->currentFrameHasAlpha()); > } > >-void ImageLayerChromium::paintContentsIfDirty() >+void ImageLayerChromium::prepareToUpdateIfDirty() > { > if (!m_dirtyRect.isEmpty()) { > 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 1afccfe2fdce64475a74ab2c926d042cb5f37674..8bb9a1dfb354a6f8a99f4f99042c1c097e7e6f8f 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(); > > void setContents(Image* image); > >diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h >index f5c4318dc99ffc17c5af4da4e9318a9c7223d593..39ed9bc0c92771d74dcd56b1ea7b3913a089270d 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 { >@@ -161,8 +161,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/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp >index 0bd6dbc3896ae4a07719a4ea4a3cce7359273e04..cb0623d6923923a293b77b14ec5c1a2c54d9e10a 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp >@@ -35,13 +35,13 @@ > #include "LayerRendererChromium.h" > > #include "Canvas2DLayerChromium.h" >+#include "CanvasLayerTextureUpdater.h" > #include "Extensions3DChromium.h" > #include "FloatQuad.h" > #include "GeometryBinding.h" > #include "GraphicsContext3D.h" > #include "LayerChromium.h" > #include "LayerPainterChromium.h" >-#include "LayerTextureUpdaterCanvas.h" > #include "ManagedTexture.h" > #include "NonCompositedContentHost.h" > #include "NotImplemented.h" >diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >index 3d8597e39e85d4cbf0156d5cc11794679537124f..40cca2e5e3a4dad729231277fd746cd83cd78137 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >@@ -39,9 +39,29 @@ class IntRect; > class IntSize; > class ManagedTexture; > class TextureAllocator; >+class TextureManager; > > class LayerTextureUpdater : public RefCounted<LayerTextureUpdater> { > public: >+ // Allows texture uploaders to store per-tile resources. >+ class Texture : public RefCounted<Texture> { >+ public: >+ virtual ~Texture() { } >+ >+ virtual ManagedTexture* texture() { return 0; } >+ virtual bool needPrepareRect() { return false; } >+ virtual void prepareRect(GraphicsContext3D*, TextureAllocator*, const IntRect& /* sourceRect */, const IntRect& /* destRect */) { } >+ virtual void paintContentsRect(const IntRect& /* sourceRect */) { } >+ 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() { } > > enum Orientation { >@@ -54,6 +74,7 @@ public: > SampledTexelFormatBGRA, > SampledTexelFormatInvalid, > }; >+ virtual PassRefPtr<Texture> createTexture(TextureManager*) = 0; > // Returns the orientation of the texture uploaded by this interface. > virtual Orientation orientation() = 0; > // Returns the format of the texel uploaded by this interface. >@@ -61,8 +82,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) = 0; >- virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0; >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */) { } > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp >deleted file mode 100644 >index acb2cd3e46b30134eaf8805b453e5cab8d545c1b..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp >+++ /dev/null >@@ -1,218 +0,0 @@ >-/* >- * Copyright (C) 2011 Google Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >- >-#include "config.h" >- >-#if USE(ACCELERATED_COMPOSITING) >- >-#include "LayerTextureUpdaterCanvas.h" >- >-#include "Extensions3D.h" >-#include "GraphicsContext.h" >-#include "LayerPainterChromium.h" >-#include "ManagedTexture.h" >-#include "PlatformColor.h" >-#include "TraceEvent.h" >- >-#if USE(SKIA) >-#include "GrContext.h" >-#include "PlatformContextSkia.h" >-#include "SkCanvas.h" >-#include "SkGpuDevice.h" >-#endif // USE(SKIA) >- >-namespace WebCore { >- >-#if USE(SKIA) >-namespace { >- >-class FrameBuffer { >-public: >- FrameBuffer(); >- ~FrameBuffer(); >- >- SkCanvas* initialize(GraphicsContext3D*, TextureAllocator*, ManagedTexture*); >- >-private: >- GraphicsContext3D* m_context; >- Platform3DObject m_fbo; >- OwnPtr<SkCanvas> m_canvas; >-}; >- >-FrameBuffer::FrameBuffer() >- : m_context(0) >- , m_fbo(0) >-{ >-} >- >-FrameBuffer::~FrameBuffer() >-{ >- m_canvas.clear(); >- >- if (m_fbo) >- m_context->deleteFramebuffer(m_fbo); >-} >- >-SkCanvas* FrameBuffer::initialize(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture) >-{ >- m_context = context; >- m_fbo = m_context->createFramebuffer(); >- m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >- texture->framebufferTexture2D(m_context, allocator); >- >- // Create a skia gpu canvas. >- GrContext* grContext = m_context->grContext(); >- IntSize canvasSize = texture->size(); >- GrPlatformSurfaceDesc targetDesc; >- targetDesc.reset(); >- targetDesc.fSurfaceType = kTextureRenderTarget_GrPlatformSurfaceType; >- targetDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit; >- targetDesc.fWidth = canvasSize.width(); >- targetDesc.fHeight = canvasSize.height(); >- targetDesc.fConfig = kRGBA_8888_GrPixelConfig; >- targetDesc.fStencilBits = 8; >- targetDesc.fPlatformTexture = texture->textureId(); >- targetDesc.fPlatformRenderTarget = m_fbo; >- SkAutoTUnref<GrTexture> target(static_cast<GrTexture*>(grContext->createPlatformSurface(targetDesc))); >- SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); >- m_canvas = adoptPtr(new SkCanvas(device.get())); >- >- return m_canvas.get(); >-} >- >-} // namespace >-#endif // USE(SKIA) >- >-LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChromium> painter) >- : m_painter(painter) >-{ >-} >- >-void LayerTextureUpdaterCanvas::paintContents(GraphicsContext& context, const IntRect& contentRect) >-{ >- context.translate(-contentRect.x(), -contentRect.y()); >- { >- TRACE_EVENT("LayerTextureUpdaterCanvas::paint", this, 0); >- m_painter->paint(context, contentRect); >- } >- m_contentRect = contentRect; >-} >- >-PassRefPtr<LayerTextureUpdaterBitmap> LayerTextureUpdaterBitmap::create(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage) >-{ >- return adoptRef(new LayerTextureUpdaterBitmap(painter, useMapTexSubImage)); >-} >- >-LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage) >- : LayerTextureUpdaterCanvas(painter) >- , m_texSubImage(useMapTexSubImage) >-{ >-} >- >-LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterBitmap::sampledTexelFormat(GC3Denum textureFormat) >-{ >- // The component order may be bgra if we uploaded bgra pixels to rgba textures. >- return PlatformColor::sameComponentOrder(textureFormat) ? >- LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA; >-} >- >-void LayerTextureUpdaterBitmap::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) >-{ >- m_texSubImage.setSubImageSize(tileSize); >- >- m_canvas.resize(contentRect.size()); >- // Assumption: if a tiler is using border texels, then it is because the >- // layer is likely to be filtered or transformed. Because of it might be >- // transformed, draw the text in grayscale instead of subpixel antialiasing. >- PlatformCanvas::Painter::TextOption textOption = >- borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText; >- PlatformCanvas::Painter canvasPainter(&m_canvas, textOption); >- paintContents(*canvasPainter.context(), contentRect); >-} >- >-void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, 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); >-} >- >-#if USE(SKIA) >-PassRefPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter) >-{ >- return adoptRef(new LayerTextureUpdaterSkPicture(painter)); >-} >- >-LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter) >- : LayerTextureUpdaterCanvas(painter) >-{ >-} >- >-LayerTextureUpdaterSkPicture::~LayerTextureUpdaterSkPicture() >-{ >-} >- >-LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterSkPicture::sampledTexelFormat(GC3Denum textureFormat) >-{ >- // Here we directly render to the texture, so the component order is always correct. >- return LayerTextureUpdater::SampledTexelFormatRGBA; >-} >- >-void LayerTextureUpdaterSkPicture::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) >-{ >- SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height()); >- PlatformContextSkia platformContext(canvas); >- GraphicsContext graphicsContext(&platformContext); >- paintContents(graphicsContext, contentRect); >- m_picture.endRecording(); >-} >- >-void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, 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()); >- canvas->drawPicture(m_picture); >- >- // Flush SKIA context so that all the rendered stuff appears on the texture. >- context->grContext()->flush(); >-} >-#endif // USE(SKIA) >- >-} // namespace WebCore >-#endif // USE(ACCELERATED_COMPOSITING) >diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h >deleted file mode 100644 >index ffc71c68ff7c7dc9821ce9ac8a1b4088aa588389..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h >+++ /dev/null >@@ -1,102 +0,0 @@ >-/* >- * Copyright (C) 2011 Google Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >- >-#ifndef LayerTextureUpdaterCanvas_h >-#define LayerTextureUpdaterCanvas_h >- >-#if USE(ACCELERATED_COMPOSITING) >- >-#include "GraphicsTypes3D.h" >-#include "LayerTextureSubImage.h" >-#include "LayerTextureUpdater.h" >-#include "PlatformCanvas.h" >-#include <wtf/PassOwnPtr.h> >-#include <wtf/PassRefPtr.h> >- >-#if USE(SKIA) >-#include "SkPicture.h" >- >-class GrContext; >-class SkCanvas; >-class SkPicture; >-#endif >- >-namespace WebCore { >- >-class GraphicsContext3D; >-class LayerPainterChromium; >- >-// A LayerTextureUpdater with an internal canvas. >-class LayerTextureUpdaterCanvas : public LayerTextureUpdater { >-protected: >- explicit LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChromium>); >- >- void paintContents(GraphicsContext&, const IntRect& contentRect); >- const IntRect& contentRect() const { return m_contentRect; } >- >-private: >- >- IntRect m_contentRect; >- OwnPtr<LayerPainterChromium> m_painter; >-}; >- >-// A LayerTextureUpdater with an internal bitmap canvas. >-class LayerTextureUpdaterBitmap : public LayerTextureUpdaterCanvas { >-public: >- static PassRefPtr<LayerTextureUpdaterBitmap> create(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage); >- >- virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } >- virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); >- virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); >- >-private: >- LayerTextureUpdaterBitmap(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage); >- PlatformCanvas m_canvas; >- LayerTextureSubImage m_texSubImage; >-}; >- >-#if USE(SKIA) >-class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas { >-public: >- static PassRefPtr<LayerTextureUpdaterSkPicture> create(PassOwnPtr<LayerPainterChromium>); >- virtual ~LayerTextureUpdaterSkPicture(); >- >- virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; } >- virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); >- virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); >- virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); >- >-private: >- explicit LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium>); >- >- SkPicture m_picture; // Recording canvas. >-}; >-#endif // USE(SKIA) >- >-} // namespace WebCore >-#endif // USE(ACCELERATED_COMPOSITING) >-#endif // LayerTextureUpdaterCanvas_h >diff --git a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..3a5a4df37673881f9a87d193866855f40571a50c >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp >@@ -0,0 +1,68 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#include "config.h" >+ >+#if USE(ACCELERATED_COMPOSITING) >+#if USE(SKIA) >+ >+#include "SkPictureCanvasLayerTextureUpdater.h" >+ >+#include "GraphicsContext.h" >+#include "LayerPainterChromium.h" >+#include "PlatformContextSkia.h" >+#include "SkCanvas.h" >+#include "TraceEvent.h" >+ >+namespace WebCore { >+ >+SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter) >+ : CanvasLayerTextureUpdater(painter) >+{ >+} >+ >+SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater() >+{ >+} >+ >+void SkPictureCanvasLayerTextureUpdater::paintContents(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */) >+{ >+ SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height()); >+ PlatformContextSkia platformContext(canvas); >+ GraphicsContext graphicsContext(&platformContext); >+ paint(graphicsContext, contentRect); >+ m_picture.endRecording(); >+} >+ >+void SkPictureCanvasLayerTextureUpdater::drawPicture(SkCanvas* canvas) >+{ >+ TRACE_EVENT("SkPictureCanvasLayerTextureUpdater::drawPicture", this, 0); >+ canvas->drawPicture(m_picture); >+} >+ >+} // namespace WebCore >+#endif // USE(SKIA) >+#endif // USE(ACCELERATED_COMPOSITING) >diff --git a/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >new file mode 100644 >index 0000000000000000000000000000000000000000..a94e6461adffe7dab08aba8f919765c109fbd04a >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#ifndef SkPictureCanvasLayerTextureUpdater_h >+#define SkPictureCanvasLayerTextureUpdater_h >+ >+#if USE(ACCELERATED_COMPOSITING) >+#if USE(SKIA) >+ >+#include "CanvasLayerTextureUpdater.h" >+#include "SkPicture.h" >+ >+class SkCanvas; >+ >+namespace WebCore { >+ >+class LayerPainterChromium; >+ >+class SkPictureCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater { >+public: >+ virtual ~SkPictureCanvasLayerTextureUpdater(); >+ >+protected: >+ explicit SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>); >+ >+ virtual void paintContents(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); >+ void drawPicture(SkCanvas*); >+ >+private: >+ SkPicture m_picture; // Recording canvas. >+}; >+ >+} // namespace WebCore >+#endif // USE(SKIA) >+#endif // USE(ACCELERATED_COMPOSITING) >+#endif // SkPictureCanvasLayerTextureUpdater_h >diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >index fcc46d993d540a4219d7f27010018738ef7b8ffe..7decc0e35cb3835a22721a49a959ab75f109e489 100644 >--- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >@@ -51,17 +51,20 @@ namespace WebCore { > class UpdatableTile : public CCLayerTilingData::Tile { > WTF_MAKE_NONCOPYABLE(UpdatableTile); > public: >- explicit UpdatableTile(PassOwnPtr<ManagedTexture> tex) : m_tex(tex) { } >+ explicit UpdatableTile(PassRefPtr<LayerTextureUpdater::Texture> texture) : m_texture(texture) { } > >- ManagedTexture* texture() { return m_tex.get(); } >+ LayerTextureUpdater::Texture* texture() { return m_texture.get(); } >+ ManagedTexture* managedTexture() { return m_texture->texture(); } > > bool dirty() const { return !m_dirtyLayerRect.isEmpty(); } > void clearDirty() { m_dirtyLayerRect = IntRect(); } > > // Layer-space dirty rectangle that needs to be repainted. > IntRect m_dirtyLayerRect; >+ // Content-space rectangle that needs to be updated. >+ IntRect m_updateRect; > private: >- OwnPtr<ManagedTexture> m_tex; >+ RefPtr<LayerTextureUpdater::Texture> m_texture; > }; > > TiledLayerChromium::TiledLayerChromium(CCLayerDelegate* delegate) >@@ -151,10 +154,10 @@ void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) > isNonCompositedContent() ? CCLayerTilingData::NoBorderTexels : CCLayerTilingData::HasBorderTexels); > } > >-void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >+void TiledLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) > { > // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. >- if (m_skipsDraw || m_requestedUpdateRect.isEmpty() || !m_tiler->numTiles()) >+ if (m_skipsDraw || m_requestedUpdateRect.isEmpty() || !m_tiler->numTiles() || m_paintRect.isEmpty()) > return; > > int left, top, right, bottom; >@@ -162,22 +165,19 @@ void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, C > for (int j = top; j <= bottom; ++j) { > for (int i = left; i <= right; ++i) { > UpdatableTile* tile = tileAt(i, j); >+ >+ // Required tiles are created in prepareToUpdate(). A tile should >+ // never be removed between the call to prepareToUpdate() and the >+ // call to updateCompositorResources(). > if (!tile) >- tile = createTile(i, j); >- else if (!tile->dirty()) >- continue; >+ CRASH(); > >- // Calculate page-space rectangle to copy from. >- IntRect sourceRect = m_tiler->tileContentRect(tile); >- const IntPoint anchor = sourceRect.location(); >- sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect)); >- // Paint rect not guaranteed to line up on tile boundaries, so >- // make sure that sourceRect doesn't extend outside of it. >- sourceRect.intersect(m_paintRect); >- if (sourceRect.isEmpty()) >+ IntRect sourceRect = tile->m_updateRect; >+ if (tile->m_updateRect.isEmpty()) > continue; > >- ASSERT(tile->texture()->isReserved()); >+ ASSERT(tile->managedTexture()->isReserved()); >+ const IntPoint anchor = m_tiler->tileContentRect(tile).location(); > > // Calculate tile-space rectangle to upload into. > IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size()); >@@ -197,17 +197,9 @@ void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, C > if (paintOffset.y() + destRect.height() > m_paintRect.height()) > CRASH(); > >- tile->texture()->bindTexture(context, updater.allocator()); >- const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; >- GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); >- GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter)); >- >- updater.append(tile->texture(), textureUpdater(), sourceRect, destRect); >- tile->clearDirty(); >+ handler.handle(tile->texture(), sourceRect, destRect); > } > } >- >- m_updateRect = FloatRect(m_tiler->contentRectToLayerRect(m_paintRect)); > } > > void TiledLayerChromium::setTilingOption(TilingOption tilingOption) >@@ -240,10 +232,10 @@ void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer) > int i = iter->first.first; > int j = iter->first.second; > UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); >- if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat)) >+ if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) > continue; > >- tiledLayer->syncTextureId(i, j, tile->texture()->textureId()); >+ tiledLayer->syncTextureId(i, j, tile->managedTexture()->textureId()); > } > } > >@@ -261,7 +253,7 @@ UpdatableTile* TiledLayerChromium::tileAt(int i, int j) const > > UpdatableTile* TiledLayerChromium::createTile(int i, int j) > { >- RefPtr<UpdatableTile> tile = adoptRef(new UpdatableTile(ManagedTexture::create(textureManager()))); >+ RefPtr<UpdatableTile> tile = adoptRef(new UpdatableTile(textureUpdater()->createTexture(textureManager()))); > m_tiler->addTile(tile, i, j); > tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile.get()); > >@@ -309,10 +301,10 @@ void TiledLayerChromium::protectTileTextures(const IntRect& contentRect) > for (int j = top; j <= bottom; ++j) { > for (int i = left; i <= right; ++i) { > UpdatableTile* tile = tileAt(i, j); >- if (!tile || !tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat)) >+ if (!tile || !tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) > continue; > >- tile->texture()->reserve(m_tiler->tileSize(), m_textureFormat); >+ tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat); > } > } > } >@@ -323,6 +315,12 @@ void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect) > > m_skipsDraw = false; > >+ // Reset m_updateRect for all tiles. >+ for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { >+ UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); >+ tile->m_updateRect = IntRect(); >+ } >+ > if (contentRect.isEmpty()) { > m_requestedUpdateRect = IntRect(); > return; >@@ -346,10 +344,10 @@ void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect) > if (!tile) > tile = createTile(i, j); > >- if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat)) >+ if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) > tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile); > >- if (!tile->texture()->reserve(m_tiler->tileSize(), m_textureFormat)) { >+ if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat)) { > m_skipsDraw = true; > cleanupResources(); > return; >@@ -365,16 +363,55 @@ 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 >+ m_tiler->contentRectToTileIndices(m_requestedUpdateRect, left, top, right, bottom); >+ for (int j = top; j <= bottom; ++j) { >+ for (int i = left; i <= right; ++i) { >+ UpdatableTile* tile = tileAt(i, j); >+ >+ // Tiles are created before prepareToUpdate() is called. >+ if (!tile) >+ CRASH(); >+ >+ if (!tile->dirty()) >+ continue; >+ >+ // Calculate content-space rectangle to copy from. >+ IntRect sourceRect = m_tiler->tileContentRect(tile); >+ const IntPoint anchor = sourceRect.location(); >+ sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect)); >+ // Paint rect not guaranteed to line up on tile boundaries, so >+ // make sure that sourceRect doesn't extend outside of it. >+ sourceRect.intersect(m_paintRect); >+ >+ // updateCompositorResources() uses m_updateRect to determine >+ // the tiles to update so we can clear the dirty rectangle here. >+ tile->clearDirty(); >+ >+ tile->m_updateRect = sourceRect; >+ >+ tile->clearDirty(); >+ } >+ } >+} >+ >+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()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels()); >+ textureUpdater()->paintContents(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels()); >+ >+ 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 5daf0f01947a9947cd235f55fb73959e447b1f56..cfddfc86c0adce4c28a2e3f399dacbe864288081 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*); >@@ -65,8 +65,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(); > >@@ -83,7 +85,7 @@ private: > > TextureManager* textureManager() const; > >- // 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 2394568f2d8278f5979a7fe0c5615d9f72098b67..4dc9614d3a366d73c873bac588eb29d0d31b774d 100644 >--- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp >@@ -40,11 +40,34 @@ > #include "VideoFrameChromium.h" > #include "VideoFrameProvider.h" > #include "cc/CCLayerImpl.h" >-#include "cc/CCTextureUpdater.h" > #include "cc/CCVideoLayerImpl.h" > > namespace WebCore { > >+VideoLayerChromium::UpdaterTexture::UpdaterTexture(VideoLayerChromium* layer) >+ : m_layer(layer) >+{ >+} >+ >+VideoLayerChromium::UpdaterTexture::~UpdaterTexture() >+{ >+} >+ >+bool VideoLayerChromium::UpdaterTexture::needPrepareRect() >+{ >+ return m_layer->needPrepareCompositorResources(); >+} >+ >+void VideoLayerChromium::UpdaterTexture::prepareRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ m_layer->prepareCompositorResources(context, allocator); >+} >+ >+void VideoLayerChromium::UpdaterTexture::updateRect(GraphicsContext3D* context, const IntRect& /* sourceRect */, const IntRect& /* destRect */) >+{ >+ m_layer->updateCompositorResources(context); >+} >+ > PassRefPtr<VideoLayerChromium> VideoLayerChromium::create(CCLayerDelegate* delegate, > VideoFrameProvider* provider) > { >@@ -57,6 +80,9 @@ VideoLayerChromium::VideoLayerChromium(CCLayerDelegate* delegate, VideoFrameProv > , m_frameFormat(VideoFrameChromium::Invalid) > , m_provider(provider) > , m_planes(0) >+ , m_frame(0) >+ , m_needPrepare(false) >+ , m_updaterTexture(UpdaterTexture::create(this)) > { > } > >@@ -77,9 +103,13 @@ void VideoLayerChromium::cleanupResources() > m_textures[i].m_texture.clear(); > } > >-void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) >+void VideoLayerChromium::prepareToUpdateIfDirty() > { >- if (!m_delegate || !m_provider) >+ m_needPrepare = false; >+ m_updateRect = IntRect(); >+ ASSERT(!m_frame); >+ >+ if (!m_delegate || !m_provider || !drawsContent()) > return; > > if (m_dirtyRect.isEmpty() && texturesValid()) { >@@ -93,52 +123,90 @@ void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, C > return; > } > >- ASSERT(drawsContent()); >- > m_planes = 0; > m_skipsDraw = false; >- >- VideoFrameChromium* frame = m_provider->getCurrentFrame(); >- if (!frame) { >+ m_frame = m_provider->getCurrentFrame(); >+ if (!m_frame) { > m_skipsDraw = true; >- m_provider->putCurrentFrame(frame); > return; > } > >- m_frameFormat = frame->format(); >- GC3Denum textureFormat = determineTextureFormat(frame); >+ m_frameFormat = m_frame->format(); >+ GC3Denum textureFormat = determineTextureFormat(m_frame); > if (textureFormat == GraphicsContext3D::INVALID_VALUE) { > // FIXME: Implement other paths. > notImplemented(); > m_skipsDraw = true; >- m_provider->putCurrentFrame(frame); >+ m_provider->putCurrentFrame(m_frame); >+ m_frame = 0; > return; > } > > // Allocate textures for planes if they are not allocated already, or > // reallocate textures that are the wrong size for the frame. >- bool texturesReserved = reserveTextures(frame, textureFormat); >+ bool texturesReserved = reserveTextures(m_frame, textureFormat); > if (!texturesReserved) { > m_skipsDraw = true; >- m_provider->putCurrentFrame(frame); >+ m_provider->putCurrentFrame(m_frame); >+ m_frame = 0; > return; > } > >- // Update texture planes. >- for (unsigned plane = 0; plane < frame->planes(); plane++) { >+ m_updateRect = FloatRect(FloatPoint(), bounds()); >+ resetNeedsDisplay(); >+ >+ // Check if we need to allocate texture planes. >+ for (unsigned plane = 0; plane < m_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)); >+ if (!texture.m_texture->textureId()) { >+ m_needPrepare = true; >+ break; >+ } > } >+} > >- m_planes = frame->planes(); >+bool VideoLayerChromium::needPrepareCompositorResources() >+{ >+ return m_needPrepare && !m_skipsDraw; >+} >+ >+void VideoLayerChromium::prepareCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator) >+{ >+ ASSERT(m_frame); >+ >+ // Allocate texture planes. >+ for (unsigned plane = 0; plane < m_frame->planes(); plane++) { >+ Texture& texture = m_textures[plane]; >+ ASSERT(texture.m_texture); >+ ASSERT(m_frame->requiredTextureSize(plane) == texture.m_texture->size()); >+ allocateTexture(context, allocator, texture); >+ } >+ >+ m_planes = m_frame->planes(); > ASSERT(m_planes <= MaxPlanes); >+} > >- m_updateRect = FloatRect(FloatPoint(), bounds()); >- resetNeedsDisplay(); >+void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context) >+{ >+ if (m_updateRect.isEmpty()) >+ return; >+ >+ ASSERT(m_frame); > >- m_provider->putCurrentFrame(frame); >+ // Update texture planes. >+ for (unsigned plane = 0; plane < m_frame->planes(); plane++) { >+ Texture& texture = m_textures[plane]; >+ updateTexture(context, texture, m_frame->data(plane)); >+ } >+ >+ m_provider->putCurrentFrame(m_frame); >+ m_frame = 0; >+} >+ >+void VideoLayerChromium::forEachCompositorResource(LayerTextureUpdater::Handler& handler) >+{ >+ handler.handle(m_updaterTexture.get(), IntRect(), IntRect()); > } > > void VideoLayerChromium::pushPropertiesTo(CCLayerImpl* layer) >@@ -247,12 +315,20 @@ IntSize VideoLayerChromium::computeVisibleSize(const VideoFrameChromium* frame, > return IntSize(visibleWidth, visibleHeight); > } > >-void VideoLayerChromium::updateTexture(GraphicsContext3D* context, TextureAllocator* allocator, Texture& texture, const void* data) const >+void VideoLayerChromium::allocateTexture(GraphicsContext3D* context, TextureAllocator* allocator, Texture& texture) const > { > ASSERT(context); > ASSERT(texture.m_texture); >- > texture.m_texture->bindTexture(context, allocator); >+} >+ >+void VideoLayerChromium::updateTexture(GraphicsContext3D* context, Texture& texture, const void* data) const >+{ >+ ASSERT(context); >+ ASSERT(texture.m_texture); >+ ASSERT(texture.m_texture->textureId()); >+ >+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture.m_texture->textureId()); > > GC3Denum format = texture.m_texture->format(); > IntSize dimensions = texture.m_texture->size(); >diff --git a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h >index 49057225e430ce8ddb8b430bfefc7412cb521b04..4038f678c2de56d963c71c471504bfeff9c4e5b1 100644 >--- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h >@@ -43,6 +43,26 @@ namespace WebCore { > // A Layer that contains a Video element. > class VideoLayerChromium : public LayerChromium { > public: >+ class UpdaterTexture : public LayerTextureUpdater::Texture { >+ public: >+ static PassRefPtr<UpdaterTexture> create(VideoLayerChromium* layer) >+ { >+ return adoptRef(new UpdaterTexture(layer)); >+ } >+ >+ virtual ~UpdaterTexture(); >+ >+ virtual bool needPrepareRect(); >+ >+ virtual void prepareRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ virtual void updateRect(GraphicsContext3D*, const IntRect& sourceRect, const IntRect& destRect); >+ >+ private: >+ explicit UpdaterTexture(VideoLayerChromium*); >+ >+ VideoLayerChromium* m_layer; >+ }; > > static PassRefPtr<VideoLayerChromium> create(CCLayerDelegate* = 0, > VideoFrameProvider* = 0); >@@ -50,7 +70,12 @@ public: > > virtual PassRefPtr<CCLayerImpl> createCCLayerImpl(); > >- virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); >+ bool needPrepareCompositorResources(); >+ void prepareCompositorResources(GraphicsContext3D*, TextureAllocator*); >+ void updateCompositorResources(GraphicsContext3D*); >+ >+ virtual void prepareToUpdateIfDirty(); >+ virtual void forEachCompositorResource(LayerTextureUpdater::Handler&); > virtual bool drawsContent() const { return true; } > > void releaseProvider(); >@@ -74,7 +99,8 @@ private: > static IntSize computeVisibleSize(const VideoFrameChromium*, unsigned plane); > bool texturesValid(); > bool reserveTextures(const VideoFrameChromium*, GC3Denum textureFormat); >- void updateTexture(GraphicsContext3D*, TextureAllocator*, Texture&, const void*) const; >+ void allocateTexture(GraphicsContext3D*, TextureAllocator*, Texture&) const; >+ void updateTexture(GraphicsContext3D*, Texture&, const void*) const; > > void resetFrameParameters(); > >@@ -85,6 +111,11 @@ private: > enum { MaxPlanes = 3 }; > Texture m_textures[MaxPlanes]; > unsigned m_planes; >+ >+ VideoFrameChromium* m_frame; >+ bool m_needPrepare; >+ >+ RefPtr<UpdaterTexture> m_updaterTexture; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp >index 276f3c9fc2fe107f163b2aba098c03fbb3344cb6..7fe43db22d110661ed7f1e947ed7a0df3238cbb2 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..c33b4d5d8c8c298adba00320a52cf8cd9ded3b06 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 PassRefPtr<UpdaterTexture> create(WebGLLayerChromium* layer) >+ { >+ return adoptRef(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; >+ >+ RefPtr<UpdaterTexture> m_updaterTexture; > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >index 498e917dd0b3c6774b1230e1314d8f551b5e1444..5899bf644cc3b10d2c32cc4a862fd2490cefa148 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >@@ -34,11 +34,58 @@ > #include "cc/CCLayerTreeHostCommon.h" > #include "cc/CCLayerTreeHostImpl.h" > #include "cc/CCSingleThreadProxy.h" >+#include "cc/CCTextureUpdater.h" > #include "cc/CCThread.h" > #include "cc/CCThreadProxy.h" > > namespace WebCore { > >+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)); >@@ -294,7 +341,7 @@ void CCLayerTreeHost::composite() > static_cast<CCSingleThreadProxy*>(m_proxy.get())->compositeImmediately(); > } > >-void CCLayerTreeHost::updateLayers() >+void CCLayerTreeHost::prepareToUpdate() > { > if (!rootLayer()) > return; >@@ -302,12 +349,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(); >@@ -316,30 +363,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(); > } >+} > >- paintLayerContents(m_updateList); >+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); > } > >-static void paintContentsIfDirty(LayerChromium* layer) >+void CCLayerTreeHost::paintContents() > { >- if (layer->drawsContent()) >+ 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); >+ } >+} >+ >+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 >@@ -348,34 +442,34 @@ void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderS > if (renderSurfaceLayer->maskLayer()) { > renderSurfaceLayer->maskLayer()->setLayerTreeHost(this); > renderSurfaceLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), renderSurfaceLayer->contentBounds())); >- paintContentsIfDirty(renderSurfaceLayer->maskLayer()); >+ appendVisibleLayer(renderSurfaceLayer->maskLayer(), updateList); > } > > LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer(); > if (replicaLayer) { > > replicaLayer->setLayerTreeHost(this); >- paintContentsIfDirty(replicaLayer); >+ appendVisibleLayer(replicaLayer, updateList); > > if (replicaLayer->maskLayer()) { > replicaLayer->maskLayer()->setLayerTreeHost(this); > replicaLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds())); >- paintContentsIfDirty(replicaLayer->maskLayer()); >+ 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->layerList().size()); > ASSERT(renderSurface->drawOpacity()); > > renderSurfaceLayer->setLayerTreeHost(this); >- paintMaskAndReplicaForRenderSurface(renderSurfaceLayer); >+ appendMaskAndReplicaForRenderSurface(renderSurfaceLayer, updateList); > > const LayerList& layerList = renderSurface->layerList(); > ASSERT(layerList.size()); >@@ -392,60 +486,29 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList > ASSERT(layer->opacity()); > ASSERT(!layer->bounds().isEmpty()); > >- paintContentsIfDirty(layer); >+ 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->layerList().size()); >- ASSERT(renderSurface->drawOpacity()); >- >- if (renderSurfaceLayer->maskLayer()) >- updateCompositorResources(renderSurfaceLayer->maskLayer(), context, updater); >- >- if (renderSurfaceLayer->replicaLayer()) { >- updateCompositorResources(renderSurfaceLayer->replicaLayer(), context, updater); >- >- if (renderSurfaceLayer->replicaLayer()->maskLayer()) >- updateCompositorResources(renderSurfaceLayer->replicaLayer()->maskLayer(), context, updater); >- } >- >- const LayerList& layerList = renderSurface->layerList(); >- ASSERT(layerList.size()); >- for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { >- LayerChromium* layer = layerList[layerIndex].get(); >- if (layer->renderSurface() && layer->renderSurface() != renderSurface) >- continue; >- >- updateCompositorResources(layer, context, updater); >- } >+ for (int layerIndex = m_layerUpdateList.size() - 1; layerIndex >= 0 ; --layerIndex) { >+ LayerChromium* layer = m_layerUpdateList[layerIndex].get(); >+ layer->forEachCompositorResource(handler); > } > } > >-void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context, CCTextureUpdater& updater) >-{ >- // 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; >- >- layer->updateCompositorResources(context, updater); >-} >- > void CCLayerTreeHost::clearPendingUpdate() > { >- for (size_t surfaceIndex = 0; surfaceIndex < m_updateList.size(); ++surfaceIndex) { >- LayerChromium* layer = m_updateList[surfaceIndex].get(); >+ m_layerUpdateList.clear(); >+ >+ for (size_t surfaceIndex = 0; surfaceIndex < m_renderSurfaceUpdateList.size(); ++surfaceIndex) { >+ LayerChromium* layer = m_renderSurfaceUpdateList[surfaceIndex].get(); > ASSERT(layer->renderSurface()); > layer->clearRenderSurface(); > } >- m_updateList.clear(); >+ m_renderSurfaceUpdateList.clear(); > } > > void CCLayerTreeHost::applyScrollAndScale(const CCScrollAndScaleSet& info) >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >index d814149c54b053ecea6fcae05624448dd311d911..cb6d9ae1996d29ca7fd3b3a0c9171740fd2d1768 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; >@@ -175,9 +174,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*); >@@ -187,13 +189,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 updateCompositorResources(LayerChromium*, GraphicsContext3D*, CCTextureUpdater&); >+ void prepareToUpdate(LayerChromium*); >+ void paintContents(LayerChromium*); > void clearPendingUpdate(); > > int m_compositorIdentifier; >@@ -209,7 +248,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 a6230eacd5689d5bea42f0d0cdb9c638533788aa..1c5317d2fb0d17fc156f600be58fbcc729273a99 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> >@@ -78,6 +79,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/CCSingleThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >index ddc01c1409b8c9129d1cfa3927c44138dfe5ec55..9321e90e400fe231c8439285a4eb85670b1ecfbf 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >@@ -31,7 +31,6 @@ > #include "TraceEvent.h" > #include "cc/CCLayerTreeHost.h" > #include "cc/CCScrollController.h" >-#include "cc/CCTextureUpdater.h" > #include <wtf/CurrentTime.h> > > using namespace WTF; >@@ -148,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()); > >@@ -209,6 +212,11 @@ void CCSingleThreadProxy::stop() > m_layerTreeHost = 0; > } > >+void CCSingleThreadProxy::update(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) >+{ >+ m_textureUpdater.append(texture, sourceRect, destRect); >+} >+ > // Called by the legacy scheduling path (e.g. where render_widget does the scheduling) > void CCSingleThreadProxy::compositeImmediately() > { >@@ -273,7 +281,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 edab61f2c032796ec84235b41b4ef773a8229f13..6d9a13a3c571fbc50a7c9c3276d4210252fe08bb 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 984370eda95c523f59ee55c87ac82871e02a73bb..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,25 +38,20 @@ using namespace std; > > namespace WebCore { > >-CCTextureUpdater::CCTextureUpdater(TextureAllocator* allocator) >- : m_allocator(allocator) >- , m_entryIndex(0) >+CCTextureUpdater::CCTextureUpdater() > { >- ASSERT(m_allocator); > } > > CCTextureUpdater::~CCTextureUpdater() > { > } > >-void CCTextureUpdater::append(ManagedTexture* texture, LayerTextureUpdater* updater, const IntRect& sourceRect, const IntRect& destRect) >+void CCTextureUpdater::append(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) > { > ASSERT(texture); >- ASSERT(updater); > > UpdateEntry entry; > entry.m_texture = texture; >- entry.m_updater = updater; > entry.m_sourceRect = sourceRect; > entry.m_destRect = destRect; > m_entries.append(entry); >@@ -68,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_updater->updateTextureRect(context, m_allocator, entry.m_texture, 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 17b8aafa06ce7a6d20a0e5fb4c914e72fc9394a1..ab659eceead6dccf56bd8308a864d834d0ec8858 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h >@@ -27,21 +27,19 @@ > #define CCTextureUpdater_h > > #include "IntRect.h" >+#include "LayerTextureUpdater.h" > #include <wtf/Vector.h> > > namespace WebCore { > > class GraphicsContext3D; >-class LayerTextureUpdater; >-class ManagedTexture; >-class TextureAllocator; > > class CCTextureUpdater { > public: >- CCTextureUpdater(TextureAllocator*); >+ CCTextureUpdater(); > ~CCTextureUpdater(); > >- void append(ManagedTexture*, LayerTextureUpdater*, const IntRect& sourceRect, const IntRect& destRect); >+ void append(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); > > bool hasMoreUpdates() const; > >@@ -50,18 +48,13 @@ public: > > void clear(); > >- TextureAllocator* allocator() { return m_allocator; } >- > private: > struct UpdateEntry { >- ManagedTexture* m_texture; >- LayerTextureUpdater* m_updater; >+ LayerTextureUpdater::Texture* m_texture; > IntRect m_sourceRect; > 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 747c8df12ce2a918689a16ad772efeeaefe770ec..a913c36c90cdde50e40ab4c2ecf0378d9c69635a 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >@@ -35,7 +35,6 @@ > #include "cc/CCScheduler.h" > #include "cc/CCScopedThreadProxy.h" > #include "cc/CCScrollController.h" >-#include "cc/CCTextureUpdater.h" > #include "cc/CCThreadTask.h" > #include <wtf/CurrentTime.h> > #include <wtf/MainThread.h> >@@ -292,6 +291,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); >+ >+ UpdateEntry* entry = new UpdateEntry; >+ entry->m_texture = texture; >+ entry->m_sourceRect = sourceRect; >+ entry->m_destRect = destRect; >+ >+ CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::updateTextureOnImplThread, AllowCrossThreadAccess(entry))); >+} >+ > void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion) > { > TRACE_EVENT("CCThreadProxy::finishAllRenderingOnImplThread", this, 0); >@@ -367,7 +380,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(); > > { > // Notify the impl thread that the beginFrame has completed. This will >@@ -385,6 +408,39 @@ 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()); >+ ASSERT(m_schedulerOnImplThread); >+ ASSERT(m_schedulerOnImplThread->commitPending()); >+ if (!m_layerTreeHostImpl) { >+ completion->signal(); >+ return; >+ } >+ >+ m_layerTreeHost->prepareCompositorResources(m_layerTreeHostImpl->context(), m_layerTreeHostImpl->contentsTextureAllocator()); >+ >+ completion->signal(); >+} >+ >+void CCThreadProxy::updateTextureOnImplThread(UpdateEntry* entry) >+{ >+ ASSERT(!m_commitCompletionEventOnImplThread); >+ ASSERT(isImplThread()); >+ ASSERT(m_schedulerOnImplThread); >+ ASSERT(m_schedulerOnImplThread->commitPending()); >+ if (!m_layerTreeHostImpl) { >+ delete entry; >+ return; >+ } >+ >+ m_textureUpdaterOnImplThread.append(entry->m_texture, entry->m_sourceRect, entry->m_destRect); >+ >+ delete entry; >+} >+ > void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion) > { > TRACE_EVENT("CCThreadProxy::beginFrameCompleteOnImplThread", this, 0); >@@ -399,36 +455,28 @@ void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion > > m_commitCompletionEventOnImplThread = completion; > >- ASSERT(!m_currentTextureUpdaterOnImplThread); >- m_currentTextureUpdaterOnImplThread = adoptPtr(new CCTextureUpdater(m_layerTreeHostImpl->contentsTextureAllocator())); >- m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), *m_currentTextureUpdaterOnImplThread); >- > m_schedulerOnImplThread->beginFrameComplete(); > } > > 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 = 16; >- 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 ebf4328839c2aa41b2994224b819cb84d3514335..5d7fb3c8cb2407d9cb218d91033ad7d63b5c5527 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(UpdateEntry*); > void beginFrameCompleteOnImplThread(CCCompletionEvent*); > void requestReadbackOnImplThread(ReadbackRequest*); > void finishAllRenderingOnImplThread(CCCompletionEvent*); >@@ -128,10 +138,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/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp >index 2209c8a4b105e710e9df18d506b3c90395125fb7..18fed26e8333458cf09a91a2a58dc1ce11db6b0e 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp >@@ -219,6 +219,7 @@ void CCTiledLayerImpl::drawTiles(LayerRendererChromium* layerRenderer, const Int > m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); > IntRect layerRect = m_tiler->contentRectToLayerRect(contentRect); > float sign = FloatQuad(contentRect).isCounterclockwise() ? -1 : 1; >+ const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; > for (int j = top; j <= bottom; ++j) { > CCLayerQuad::Edge prevEdgeX = contentQuad.left(); > >@@ -343,6 +344,9 @@ void CCTiledLayerImpl::drawTiles(LayerRendererChromium* layerRenderer, const Int > > if (tile && tile->textureId()) { > context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId()); >+ GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); >+ GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter)); >+ > layerRenderer->drawTexturedQuad(globalTransform, > tileRect.width(), tileRect.height(), opacity, quad, > program->vertexShader().matrixLocation(), >diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >index d1dcf5d866f2f15c10e25af2faee215be93b2779..aef576fdfd627bd6e16d06c325da1c62d0220207 100644 >--- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp >@@ -26,13 +26,16 @@ > > #include "cc/CCLayerTreeHost.h" > >+#include "ContentLayerChromium.h" > #include "cc/CCLayerImpl.h" > #include "cc/CCLayerTreeHostImpl.h" > #include "cc/CCScopedThreadProxy.h" >+#include "cc/CCTextureUpdater.h" > #include "cc/CCThreadTask.h" > #include "GraphicsContext3DPrivate.h" > #include <gtest/gtest.h> > #include "LayerChromium.h" >+#include "ManagedTexture.h" > #include "MockWebGraphicsContext3D.h" > #include "TextureManager.h" > #include "WebCompositor.h" >@@ -227,6 +230,8 @@ public: > m_timeoutTask = 0; > } > >+ CCLayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } >+ > > protected: > CCLayerTreeHostTest() >@@ -826,4 +831,240 @@ 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) >+ : m_test(test) >+ { >+ } >+ >+ virtual void paintContents(GraphicsContext&, const IntRect&) >+ { >+ // Set layer opacity to 0. >+ m_test->layerTreeHost()->rootLayer()->setOpacity(0); >+ } >+ >+ virtual bool drawsContent() const { return true; } >+ virtual bool preserves3D() { return false; } >+ virtual void notifySyncRequired() { } >+ >+private: >+ CCLayerTreeHostTest* m_test; >+}; >+ >+class ContentLayerChromiumWithUpdateTracking : public ContentLayerChromium { >+public: >+ 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)); >+ } >+ >+ virtual PassRefPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) >+ { >+ return adoptRef(new Texture(this, ManagedTexture::create(manager))); >+ } >+ >+ virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } >+ >+ virtual SampledTexelFormat sampledTexelFormat(GC3Denum /* textureFormat */) >+ { >+ return LayerTextureUpdater::SampledTexelFormatRGBA; >+ } >+ >+ virtual void paintContents(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */) >+ { >+ 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) >+ { >+ return adoptRef(new ContentLayerChromiumWithUpdateTracking(delegate, needPrepareRect)); >+ } >+ >+ virtual void createTextureUpdater(const CCLayerTreeHost*) >+ { >+ 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, bool needPrepareRect) >+ : ContentLayerChromium(delegate) >+ , m_needPrepareRect(needPrepareRect) >+ , m_paintContentsCount(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_prepareRectCount; >+ int m_paintContentsRectCount; >+ int m_updateRectCount; >+}; >+ >+// Layer opacity change during paint should not prevent compositor resources from being updated during commit. >+class CCLayerTreeHostTestOpacityChange : public CCLayerTreeHostTest { >+public: >+ CCLayerTreeHostTestOpacityChange() >+ : m_testOpacityChangeDelegate(this) >+ , m_updateCheckLayer(ContentLayerChromiumWithUpdateTracking::create(&m_testOpacityChangeDelegate, true)) >+ { >+ } >+ >+ 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()); >+ >+ // 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()); >+ } >+ >+private: >+ TestOpacityChangeLayerDelegate m_testOpacityChangeDelegate; >+ RefPtr<ContentLayerChromiumWithUpdateTracking> m_updateCheckLayer; >+}; >+ >+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
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 72192
:
114786
|
114791
|
114804
|
114863
|
115078
|
115097
|
115220
|
115859
|
115881
|
115884
|
116003
|
116116
|
116293
|
118711
|
120686
|
120745
|
121173