[chromium] Reverting r103011, r103135 due to Aura test failures
authorenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Dec 2011 18:35:09 +0000 (18:35 +0000)
committerenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Dec 2011 18:35:09 +0000 (18:35 +0000)
Unreviewed gardening.

Source/WebCore:

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::~ContentLayerChromium):
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::notifySyncRequired):
* platform/graphics/chromium/GraphicsLayerChromium.h:
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerChromium::paintContentsIfDirty):
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::setLayerTreeHost):
(WebCore::LayerChromium::setNeedsCommit):
(WebCore::LayerChromium::setParent):
(WebCore::LayerChromium::setMaskLayer):
* platform/graphics/chromium/LayerChromium.h:
(WebCore::LayerChromium::setReplicaLayer):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::setLayerTreeHost):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::~CCLayerTreeHost):
(WebCore::CCLayerTreeHost::didRecreateGraphicsContext):
(WebCore::CCLayerTreeHost::paintMaskAndReplicaForRenderSurface):
(WebCore::CCLayerTreeHost::paintLayerContents):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::CCLayerTreeHost::setRootLayer):

Source/WebKit/chromium:

* WebKit.gypi:
* public/platform/WebContentLayer.h:
* public/platform/WebExternalTextureLayer.h:
* public/platform/WebLayer.h:
* public/platform/WebLayerClient.h:
* src/WebContentLayer.cpp:
(WebKit::WebContentLayer::create):
* src/WebContentLayerImpl.cpp:
(WebKit::WebContentLayerImpl::create):
(WebKit::WebContentLayerImpl::WebContentLayerImpl):
(WebKit::WebContentLayerImpl::notifySyncRequired):
* src/WebContentLayerImpl.h:
* src/WebExternalTextureLayer.cpp:
(WebKit::WebExternalTextureLayer::create):
* src/WebExternalTextureLayerImpl.cpp:
(WebKit::WebExternalTextureLayerImpl::create):
(WebKit::WebExternalTextureLayerImpl::WebExternalTextureLayerImpl):
(WebKit::WebExternalTextureLayerImpl::notifySyncRequired):
* src/WebExternalTextureLayerImpl.h:
* src/WebLayer.cpp:
(WebKit::WebLayer::create):
* src/WebLayerImpl.cpp:
(WebKit::WebLayerImpl::create):
(WebKit::WebLayerImpl::WebLayerImpl):
(WebKit::WebLayerImpl::notifySyncRequired):
* src/WebLayerImpl.h:
* src/WebLayerTreeViewImpl.cpp:
(WebKit::WebLayerTreeViewImpl::create):
(WebKit::WebLayerTreeViewImpl::WebLayerTreeViewImpl):
* src/WebLayerTreeViewImpl.h:
* tests/CCLayerTreeHostImplTest.cpp:
* tests/CCLayerTreeHostTest.cpp:
(WTF::MockLayerTreeHost::create):
(WTF::MockLayerTreeHost::MockLayerTreeHost):
(WTF::CompositorMockWebGraphicsContext3D::create):
(WTF::CompositorMockWebGraphicsContext3D::makeContextCurrent):
(WTF::CompositorMockWebGraphicsContext3D::createProgram):
(WTF::CompositorMockWebGraphicsContext3D::createShader):
(WTF::CompositorMockWebGraphicsContext3D::getShaderiv):
(WTF::CompositorMockWebGraphicsContext3D::getProgramiv):
(WTF::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):
(WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D):
(WTF::CCLayerTreeHostTestShortlived1::beginTest):
(WTF::CCLayerTreeHostTestShortlived2::beginTest):
(WTF::CCLayerTreeHostTestShortlived3::beginTest):
(WTF::CCLayerTreeHostTestScrollSimple::beginCommitOnCCThread):
(WTF::TestOpacityChangeLayerDelegate::notifySyncRequired):
* tests/CompositorFakeGraphicsContext3D.h: Removed.
* tests/CompositorFakeWebGraphicsContext3D.h: Removed.
* tests/LayerChromiumTest.cpp:
* tests/MockGraphicsContext3DTest.cpp: Renamed from Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp.
(FrameCountingContext::FrameCountingContext):
(FrameCountingContext::prepareTexture):
(FrameCountingContext::frameCount):
(TEST):
(ContextThatCountsMakeCurrents::ContextThatCountsMakeCurrents):
(ContextThatCountsMakeCurrents::makeContextCurrent):
(ContextThatCountsMakeCurrents::makeCurrentCount):
(ContextWithMakeCurrentThatFails::ContextWithMakeCurrentThatFails):
(ContextWithMakeCurrentThatFails::makeContextCurrent):
* tests/MockWebGraphicsContext3D.h: Renamed from Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h.
(WebKit::MockWebGraphicsContext3D::initialize):
(WebKit::MockWebGraphicsContext3D::makeContextCurrent):
(WebKit::MockWebGraphicsContext3D::width):
(WebKit::MockWebGraphicsContext3D::height):
(WebKit::MockWebGraphicsContext3D::reshape):
(WebKit::MockWebGraphicsContext3D::isGLES2Compliant):
(WebKit::MockWebGraphicsContext3D::readBackFramebuffer):
(WebKit::MockWebGraphicsContext3D::getPlatformTextureId):
(WebKit::MockWebGraphicsContext3D::prepareTexture):
(WebKit::MockWebGraphicsContext3D::postSubBufferCHROMIUM):
(WebKit::MockWebGraphicsContext3D::synthesizeGLError):
(WebKit::MockWebGraphicsContext3D::isContextLost):
(WebKit::MockWebGraphicsContext3D::mapBufferSubDataCHROMIUM):
(WebKit::MockWebGraphicsContext3D::unmapBufferSubDataCHROMIUM):
(WebKit::MockWebGraphicsContext3D::mapTexSubImage2DCHROMIUM):
(WebKit::MockWebGraphicsContext3D::unmapTexSubImage2DCHROMIUM):
(WebKit::MockWebGraphicsContext3D::setVisibilityCHROMIUM):
(WebKit::MockWebGraphicsContext3D::getRequestableExtensionsCHROMIUM):
(WebKit::MockWebGraphicsContext3D::requestExtensionCHROMIUM):
(WebKit::MockWebGraphicsContext3D::blitFramebufferCHROMIUM):
(WebKit::MockWebGraphicsContext3D::renderbufferStorageMultisampleCHROMIUM):
(WebKit::MockWebGraphicsContext3D::activeTexture):
(WebKit::MockWebGraphicsContext3D::attachShader):
(WebKit::MockWebGraphicsContext3D::bindAttribLocation):
(WebKit::MockWebGraphicsContext3D::bindBuffer):
(WebKit::MockWebGraphicsContext3D::bindFramebuffer):
(WebKit::MockWebGraphicsContext3D::bindRenderbuffer):
(WebKit::MockWebGraphicsContext3D::bindTexture):
(WebKit::MockWebGraphicsContext3D::blendColor):
(WebKit::MockWebGraphicsContext3D::blendEquation):
(WebKit::MockWebGraphicsContext3D::blendEquationSeparate):
(WebKit::MockWebGraphicsContext3D::blendFunc):
(WebKit::MockWebGraphicsContext3D::blendFuncSeparate):
(WebKit::MockWebGraphicsContext3D::bufferData):
(WebKit::MockWebGraphicsContext3D::bufferSubData):
(WebKit::MockWebGraphicsContext3D::checkFramebufferStatus):
(WebKit::MockWebGraphicsContext3D::clear):
(WebKit::MockWebGraphicsContext3D::clearColor):
(WebKit::MockWebGraphicsContext3D::clearDepth):
(WebKit::MockWebGraphicsContext3D::clearStencil):
(WebKit::MockWebGraphicsContext3D::colorMask):
(WebKit::MockWebGraphicsContext3D::compileShader):
(WebKit::MockWebGraphicsContext3D::compressedTexImage2D):
(WebKit::MockWebGraphicsContext3D::compressedTexSubImage2D):
(WebKit::MockWebGraphicsContext3D::copyTexImage2D):
(WebKit::MockWebGraphicsContext3D::copyTexSubImage2D):
(WebKit::MockWebGraphicsContext3D::cullFace):
(WebKit::MockWebGraphicsContext3D::depthFunc):
(WebKit::MockWebGraphicsContext3D::depthMask):
(WebKit::MockWebGraphicsContext3D::depthRange):
(WebKit::MockWebGraphicsContext3D::detachShader):
(WebKit::MockWebGraphicsContext3D::disable):
(WebKit::MockWebGraphicsContext3D::disableVertexAttribArray):
(WebKit::MockWebGraphicsContext3D::drawArrays):
(WebKit::MockWebGraphicsContext3D::drawElements):
(WebKit::MockWebGraphicsContext3D::enable):
(WebKit::MockWebGraphicsContext3D::enableVertexAttribArray):
(WebKit::MockWebGraphicsContext3D::finish):
(WebKit::MockWebGraphicsContext3D::flush):
(WebKit::MockWebGraphicsContext3D::framebufferRenderbuffer):
(WebKit::MockWebGraphicsContext3D::framebufferTexture2D):
(WebKit::MockWebGraphicsContext3D::frontFace):
(WebKit::MockWebGraphicsContext3D::generateMipmap):
(WebKit::MockWebGraphicsContext3D::getActiveAttrib):
(WebKit::MockWebGraphicsContext3D::getActiveUniform):
(WebKit::MockWebGraphicsContext3D::getAttachedShaders):
(WebKit::MockWebGraphicsContext3D::getAttribLocation):
(WebKit::MockWebGraphicsContext3D::getBooleanv):
(WebKit::MockWebGraphicsContext3D::getBufferParameteriv):
(WebKit::MockWebGraphicsContext3D::getContextAttributes):
(WebKit::MockWebGraphicsContext3D::getError):
(WebKit::MockWebGraphicsContext3D::getFloatv):
(WebKit::MockWebGraphicsContext3D::getFramebufferAttachmentParameteriv):
(WebKit::MockWebGraphicsContext3D::getIntegerv):
(WebKit::MockWebGraphicsContext3D::getProgramiv):
(WebKit::MockWebGraphicsContext3D::getProgramInfoLog):
(WebKit::MockWebGraphicsContext3D::getRenderbufferParameteriv):
(WebKit::MockWebGraphicsContext3D::getShaderiv):
(WebKit::MockWebGraphicsContext3D::getShaderInfoLog):
(WebKit::MockWebGraphicsContext3D::getShaderSource):
(WebKit::MockWebGraphicsContext3D::getString):
(WebKit::MockWebGraphicsContext3D::getTexParameterfv):
(WebKit::MockWebGraphicsContext3D::getTexParameteriv):
(WebKit::MockWebGraphicsContext3D::getUniformfv):
(WebKit::MockWebGraphicsContext3D::getUniformiv):
(WebKit::MockWebGraphicsContext3D::getUniformLocation):
(WebKit::MockWebGraphicsContext3D::getVertexAttribfv):
(WebKit::MockWebGraphicsContext3D::getVertexAttribiv):
(WebKit::MockWebGraphicsContext3D::getVertexAttribOffset):
(WebKit::MockWebGraphicsContext3D::hint):
(WebKit::MockWebGraphicsContext3D::isBuffer):
(WebKit::MockWebGraphicsContext3D::isEnabled):
(WebKit::MockWebGraphicsContext3D::isFramebuffer):
(WebKit::MockWebGraphicsContext3D::isProgram):
(WebKit::MockWebGraphicsContext3D::isRenderbuffer):
(WebKit::MockWebGraphicsContext3D::isShader):
(WebKit::MockWebGraphicsContext3D::isTexture):
(WebKit::MockWebGraphicsContext3D::lineWidth):
(WebKit::MockWebGraphicsContext3D::linkProgram):
(WebKit::MockWebGraphicsContext3D::pixelStorei):
(WebKit::MockWebGraphicsContext3D::polygonOffset):
(WebKit::MockWebGraphicsContext3D::readPixels):
(WebKit::MockWebGraphicsContext3D::releaseShaderCompiler):
(WebKit::MockWebGraphicsContext3D::renderbufferStorage):
(WebKit::MockWebGraphicsContext3D::sampleCoverage):
(WebKit::MockWebGraphicsContext3D::scissor):
(WebKit::MockWebGraphicsContext3D::shaderSource):
(WebKit::MockWebGraphicsContext3D::stencilFunc):
(WebKit::MockWebGraphicsContext3D::stencilFuncSeparate):
(WebKit::MockWebGraphicsContext3D::stencilMask):
(WebKit::MockWebGraphicsContext3D::stencilMaskSeparate):
(WebKit::MockWebGraphicsContext3D::stencilOp):
(WebKit::MockWebGraphicsContext3D::stencilOpSeparate):
(WebKit::MockWebGraphicsContext3D::texImage2D):
(WebKit::MockWebGraphicsContext3D::texParameterf):
(WebKit::MockWebGraphicsContext3D::texParameteri):
(WebKit::MockWebGraphicsContext3D::texSubImage2D):
(WebKit::MockWebGraphicsContext3D::uniform1f):
(WebKit::MockWebGraphicsContext3D::uniform1fv):
(WebKit::MockWebGraphicsContext3D::uniform1i):
(WebKit::MockWebGraphicsContext3D::uniform1iv):
(WebKit::MockWebGraphicsContext3D::uniform2f):
(WebKit::MockWebGraphicsContext3D::uniform2fv):
(WebKit::MockWebGraphicsContext3D::uniform2i):
(WebKit::MockWebGraphicsContext3D::uniform2iv):
(WebKit::MockWebGraphicsContext3D::uniform3f):
(WebKit::MockWebGraphicsContext3D::uniform3fv):
(WebKit::MockWebGraphicsContext3D::uniform3i):
(WebKit::MockWebGraphicsContext3D::uniform3iv):
(WebKit::MockWebGraphicsContext3D::uniform4f):
(WebKit::MockWebGraphicsContext3D::uniform4fv):
(WebKit::MockWebGraphicsContext3D::uniform4i):
(WebKit::MockWebGraphicsContext3D::uniform4iv):
(WebKit::MockWebGraphicsContext3D::uniformMatrix2fv):
(WebKit::MockWebGraphicsContext3D::uniformMatrix3fv):
(WebKit::MockWebGraphicsContext3D::uniformMatrix4fv):
(WebKit::MockWebGraphicsContext3D::useProgram):
(WebKit::MockWebGraphicsContext3D::validateProgram):
(WebKit::MockWebGraphicsContext3D::vertexAttrib1f):
(WebKit::MockWebGraphicsContext3D::vertexAttrib1fv):
(WebKit::MockWebGraphicsContext3D::vertexAttrib2f):
(WebKit::MockWebGraphicsContext3D::vertexAttrib2fv):
(WebKit::MockWebGraphicsContext3D::vertexAttrib3f):
(WebKit::MockWebGraphicsContext3D::vertexAttrib3fv):
(WebKit::MockWebGraphicsContext3D::vertexAttrib4f):
(WebKit::MockWebGraphicsContext3D::vertexAttrib4fv):
(WebKit::MockWebGraphicsContext3D::vertexAttribPointer):
(WebKit::MockWebGraphicsContext3D::viewport):
(WebKit::MockWebGraphicsContext3D::createBuffer):
(WebKit::MockWebGraphicsContext3D::createFramebuffer):
(WebKit::MockWebGraphicsContext3D::createProgram):
(WebKit::MockWebGraphicsContext3D::createRenderbuffer):
(WebKit::MockWebGraphicsContext3D::createShader):
(WebKit::MockWebGraphicsContext3D::createTexture):
(WebKit::MockWebGraphicsContext3D::deleteBuffer):
(WebKit::MockWebGraphicsContext3D::deleteFramebuffer):
(WebKit::MockWebGraphicsContext3D::deleteProgram):
(WebKit::MockWebGraphicsContext3D::deleteRenderbuffer):
(WebKit::MockWebGraphicsContext3D::deleteShader):
(WebKit::MockWebGraphicsContext3D::deleteTexture):
(WebKit::MockWebGraphicsContext3D::texStorage2DEXT):
* tests/WebGLLayerChromiumTest.cpp:
(WebKit::CompositorMockWebGraphicsContext3D::create):
(WebKit::CompositorMockWebGraphicsContext3D::makeContextCurrent):
(WebKit::CompositorMockWebGraphicsContext3D::createProgram):
(WebKit::CompositorMockWebGraphicsContext3D::createShader):
(WebKit::CompositorMockWebGraphicsContext3D::getShaderiv):
(WebKit::CompositorMockWebGraphicsContext3D::getProgramiv):
(WebKit::CompositorMockWebGraphicsContext3D::getContextAttributes):
(WebKit::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):
(WebKit::createGraphicsContext):
(WebKit::TEST):
* tests/WebLayerTest.cpp:
(testing::WebLayerTest::WebLayerTest):
(testing::TEST_F):

LayoutTests:

* platform/chromium/test_expectations.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103150 268f45cc-cd09-0410-ab3c-d52691b4dbfc

38 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerChromium.h
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/public/platform/WebContentLayer.h
Source/WebKit/chromium/public/platform/WebExternalTextureLayer.h
Source/WebKit/chromium/public/platform/WebLayer.h
Source/WebKit/chromium/public/platform/WebLayerClient.h
Source/WebKit/chromium/src/WebContentLayer.cpp
Source/WebKit/chromium/src/WebContentLayerImpl.cpp
Source/WebKit/chromium/src/WebContentLayerImpl.h
Source/WebKit/chromium/src/WebExternalTextureLayer.cpp
Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp
Source/WebKit/chromium/src/WebExternalTextureLayerImpl.h
Source/WebKit/chromium/src/WebLayer.cpp
Source/WebKit/chromium/src/WebLayerImpl.cpp
Source/WebKit/chromium/src/WebLayerImpl.h
Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp
Source/WebKit/chromium/src/WebLayerTreeViewImpl.h
Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h [deleted file]
Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h [deleted file]
Source/WebKit/chromium/tests/LayerChromiumTest.cpp
Source/WebKit/chromium/tests/MockGraphicsContext3DTest.cpp [moved from Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp with 89% similarity]
Source/WebKit/chromium/tests/MockWebGraphicsContext3D.h [moved from Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h with 98% similarity]
Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp
Source/WebKit/chromium/tests/WebLayerTest.cpp

index a5819a81fe2d3426f17aa47d02e5cbc0d59c0ed0..1408a2fd9075a1d9b4668bef1e676ba6c55a07e0 100644 (file)
@@ -1,3 +1,11 @@
+2011-12-17  Adrienne Walker  <enne@google.com>
+
+        [chromium] Reverting r103011, r103135 due to Aura test failures
+
+        Unreviewed gardening.
+
+        * platform/chromium/test_expectations.txt:
+
 2011-12-16  Chris Marrin  <cmarrin@apple.com>
 
         Hardware acceleration of W3C Filter Effects
index 479ab97a3d8377ccfc53a5050a9ba81dd6cd5410..5ae669b857e45a7fac3ec5c3a53170eb558fce7f 100644 (file)
@@ -2824,10 +2824,6 @@ BUGWK49629 SKIP : platform/chromium/compositing/lots-of-img-layers.html = PASS
 BUGWK49629 SKIP : platform/chromium/compositing/lots-of-img-layers-with-opacity.html = PASS
 BUGWK49629 SKIP : compositing/iframes/page-cache-layer-tree.html = PASS
 
-// Needs an image-only rebaseline since we no longer invalidate when setting the replica layer
-// to NULL when it already was NULL so we have no damage at the end of the test.
-BUGJAMESR : compositing/iframes/iframe-content-flipping.html = IMAGE
-
 BUGNONE SLOW WIN DEBUG GPU : fast/canvas/canvas-getImageData.html = PASS
 
 // Accelerated 2d for mac isn't supported yet, so SKIP this test for now.
index 4da3b019601a1831b9006a7927ff577534c5133d..d5589734780694627368b4ef1dd7c6ebfd09622a 100644 (file)
@@ -1,3 +1,33 @@
+2011-12-17  Adrienne Walker  <enne@google.com>
+
+        [chromium] Reverting r103011, r103135 due to Aura test failures
+
+        Unreviewed gardening.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::~ContentLayerChromium):
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::notifySyncRequired):
+        * platform/graphics/chromium/GraphicsLayerChromium.h:
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        (WebCore::ImageLayerChromium::paintContentsIfDirty):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::setLayerTreeHost):
+        (WebCore::LayerChromium::setNeedsCommit):
+        (WebCore::LayerChromium::setParent):
+        (WebCore::LayerChromium::setMaskLayer):
+        * platform/graphics/chromium/LayerChromium.h:
+        (WebCore::LayerChromium::setReplicaLayer):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::setLayerTreeHost):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::~CCLayerTreeHost):
+        (WebCore::CCLayerTreeHost::didRecreateGraphicsContext):
+        (WebCore::CCLayerTreeHost::paintMaskAndReplicaForRenderSurface):
+        (WebCore::CCLayerTreeHost::paintLayerContents):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::CCLayerTreeHost::setRootLayer):
+
 2011-12-16  Chris Marrin  <cmarrin@apple.com>
 
         Hardware acceleration of W3C Filter Effects
index c6395636d4c3732186b0ceee16a312197d0c96a0..c284eea31a400e3e9253295b5f2603449f9d80da 100644 (file)
@@ -85,6 +85,7 @@ ContentLayerChromium::ContentLayerChromium(CCLayerDelegate* delegate)
 
 ContentLayerChromium::~ContentLayerChromium()
 {
+    cleanupResources();
 }
 
 void ContentLayerChromium::cleanupResources()
index d22f1dc4554d022785e01518fde12a50f231b0a6..229ba9d81b8d0679b1fda56afe0522f1f8da20cd 100644 (file)
@@ -665,6 +665,12 @@ void GraphicsLayerChromium::paintContents(GraphicsContext& context, const IntRec
     paintGraphicsLayerContents(context, clip);
 }
 
+void GraphicsLayerChromium::notifySyncRequired()
+{
+    if (m_client)
+        m_client->notifySyncRequired(this);
+}
+
 } // namespace WebCore
 
 #endif // USE(ACCELERATED_COMPOSITING)
index 34c3d32645d0d632cf4c077e35bfbeed474e8bde..2fc8e52488acacbd39df8098468f7c993fc26456 100644 (file)
@@ -99,6 +99,7 @@ public:
     // The following functions implement the CCLayerDelegate interface.
     virtual bool drawsContent() const;
     virtual void paintContents(GraphicsContext&, const IntRect& clip);
+    virtual void notifySyncRequired();
 
     // Exposed for tests.
     LayerChromium* contentsLayer() const { return m_contentsLayer.get(); }
index 6eedcce714386f0c59fbae8205f9cff318dff51f..3cb2377a886245f933744f2beff03308fc694cb9 100644 (file)
@@ -169,8 +169,11 @@ void ImageLayerChromium::paintContentsIfDirty()
     if (m_needsDisplay) {
         m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame());
         updateTileSizeAndTilingOption();
-        invalidateRect(IntRect(IntPoint(), contentBounds()));
-        m_needsDisplay = false;
+        IntRect paintRect(IntPoint(), contentBounds());
+        if (m_needsDisplay) {
+            invalidateRect(paintRect);
+            m_needsDisplay = false;
+        }
     }
 
     prepareToUpdate(visibleLayerRect());
index 0f697ffc56d665cfb61688d45e4df4f0d9c938f1..b45e1259573f9ed3571b61a01e830c5ede44f28b 100644 (file)
@@ -108,38 +108,26 @@ void LayerChromium::cleanupResourcesRecursive()
 
 void LayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
 {
-    if (m_layerTreeHost == host)
-        return;
-
-    // If we're changing hosts then we need to free up any resources
-    // allocated by the old host.
-    if (m_layerTreeHost) {
+    // If we're changing layer renderers then we need to free up any resources
+    // allocated by the old renderer.
+    if (layerTreeHost() && layerTreeHost() != host) {
         cleanupResources();
         setNeedsDisplay();
     }
 
     m_layerTreeHost = host;
-
-    for (size_t i = 0; i < m_children.size(); ++i)
-        m_children[i]->setLayerTreeHost(host);
-
-    if (m_maskLayer)
-        m_maskLayer->setLayerTreeHost(host);
-    if (m_replicaLayer)
-        m_replicaLayer->setLayerTreeHost(host);
 }
 
 void LayerChromium::setNeedsCommit()
 {
-    if (m_layerTreeHost)
-        m_layerTreeHost->setNeedsCommit();
+    if (m_delegate)
+        m_delegate->notifySyncRequired();
 }
 
 void LayerChromium::setParent(LayerChromium* layer)
 {
     ASSERT(!layer || !layer->hasAncestor(this));
     m_parent = layer;
-    setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0);
 }
 
 bool LayerChromium::hasAncestor(LayerChromium* ancestor) const
@@ -293,23 +281,7 @@ void LayerChromium::setMaskLayer(LayerChromium* maskLayer)
 {
     if (m_maskLayer == maskLayer)
         return;
-    if (m_maskLayer)
-        m_maskLayer->setLayerTreeHost(0);
     m_maskLayer = maskLayer;
-    if (m_maskLayer)
-        m_maskLayer->setLayerTreeHost(m_layerTreeHost.get());
-    setNeedsCommit();
-}
-
-void LayerChromium::setReplicaLayer(LayerChromium* layer)
-{
-    if (m_replicaLayer == layer)
-        return;
-    if (m_replicaLayer)
-        m_replicaLayer->setLayerTreeHost(0);
-    m_replicaLayer = layer;
-    if (m_replicaLayer)
-        m_replicaLayer->setLayerTreeHost(m_layerTreeHost.get());
     setNeedsCommit();
 }
 
index f93755f09bf1c8e66594c3748b096ff3e6ec0687..173434e98eb923055ab78660343d746090799e1b 100644 (file)
@@ -61,6 +61,7 @@ public:
     virtual ~CCLayerDelegate() { }
     virtual bool drawsContent() const = 0;
     virtual void paintContents(GraphicsContext&, const IntRect& clip) = 0;
+    virtual void notifySyncRequired() = 0;
 };
 
 // Base class for composited layers. Special layer types are derived from
@@ -154,7 +155,7 @@ public:
 
     void setDelegate(CCLayerDelegate* delegate) { m_delegate = delegate; }
 
-    void setReplicaLayer(LayerChromium*);
+    void setReplicaLayer(LayerChromium* layer) { m_replicaLayer = layer; setNeedsCommit(); }
     LayerChromium* replicaLayer() const { return m_replicaLayer.get(); }
 
     // These methods typically need to be overwritten by derived classes.
index a0e9102b8e1ac9e0fb9298b55c78b533cb121a2e..97c95253d069ce1a04f30b8bd9e1f2199676185c 100644 (file)
@@ -155,18 +155,13 @@ IntSize TiledLayerChromium::contentBounds() const
 
 void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
 {
-    if (host == layerTreeHost())
-        return;
-
-    if (layerTreeHost())
-        cleanupResources();
-
     LayerChromium::setLayerTreeHost(host);
 
-    if (!host)
+    if (m_tiler || !host)
         return;
 
     createTextureUpdater(host);
+
     setTextureFormat(host->layerRendererCapabilities().bestTextureFormat);
     m_sampledTexelFormat = textureUpdater()->sampledTexelFormat(m_textureFormat);
 }
index 726a7c911710bee9e52ae4d1a1a75104a21bd2e7..6607baf9292f53e18097c56991f38ebf96ad41fa 100644 (file)
@@ -104,7 +104,6 @@ CCLayerTreeHost::~CCLayerTreeHost()
 {
     ASSERT(CCProxy::isMainThread());
     TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0);
-    ASSERT(m_proxy);
     m_proxy->stop();
     m_proxy.clear();
     clearPendingUpdate();
@@ -176,10 +175,8 @@ PassOwnPtr<CCLayerTreeHostImpl> CCLayerTreeHost::createLayerTreeHostImpl(CCLayer
 
 void CCLayerTreeHost::didRecreateGraphicsContext(bool success)
 {
-    if (m_rootLayer) {
-        m_rootLayer->setLayerTreeHost(0);
-        m_rootLayer->setLayerTreeHost(this);
-    }
+    if (rootLayer())
+        rootLayer()->cleanupResourcesRecursive();
     m_client->didRecreateGraphicsContext(success);
 }
 
@@ -239,19 +236,6 @@ void CCLayerTreeHost::setNeedsRedraw()
         m_client->scheduleComposite();
 }
 
-void CCLayerTreeHost::setRootLayer(PassRefPtr<LayerChromium> rootLayer)
-{
-    if (m_rootLayer == rootLayer)
-        return;
-
-    if (m_rootLayer)
-        m_rootLayer->setLayerTreeHost(0);
-    m_rootLayer = rootLayer;
-    if (m_rootLayer)
-        m_rootLayer->setLayerTreeHost(this);
-    setNeedsCommit();
-}
-
 void CCLayerTreeHost::setViewport(const IntSize& viewportSize)
 {
     contentsTextureManager()->setMaxMemoryLimitBytes(TextureManager::highLimitBytes(viewportSize));
@@ -416,16 +400,18 @@ void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderS
     // mask and replica should be painted.
 
     if (renderSurfaceLayer->maskLayer()) {
+        renderSurfaceLayer->maskLayer()->setLayerTreeHost(this);
         renderSurfaceLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), renderSurfaceLayer->contentBounds()));
         paintContentsIfDirty(renderSurfaceLayer->maskLayer(), paintType);
     }
 
     LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer();
     if (replicaLayer) {
-
+        replicaLayer->setLayerTreeHost(this);
         paintContentsIfDirty(replicaLayer, paintType);
 
         if (replicaLayer->maskLayer()) {
+            replicaLayer->maskLayer()->setLayerTreeHost(this);
             replicaLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds()));
             paintContentsIfDirty(replicaLayer->maskLayer(), paintType);
         }
@@ -440,6 +426,7 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
         ASSERT(renderSurface);
         ASSERT(renderSurface->drawOpacity());
 
+        renderSurfaceLayer->setLayerTreeHost(this);
         paintMaskAndReplicaForRenderSurface(renderSurfaceLayer, paintType);
 
         const LayerList& layerList = renderSurface->layerList();
@@ -451,6 +438,7 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
             if (CCLayerTreeHostCommon::renderSurfaceContributesToTarget<LayerChromium>(layer, renderSurfaceLayer->id()))
                 continue;
 
+            layer->setLayerTreeHost(this);
             ASSERT(!layer->bounds().isEmpty());
 
             paintContentsIfDirty(layer, paintType);
index b7d1b1e5f03dd39bdc66800ff129fb24e4cb05ec..2ddb9ade2f4c71ceb5a75502382f4794c9210904 100644 (file)
@@ -163,13 +163,12 @@ public:
     void loseCompositorContext(int numTimes);
 
     void setNeedsAnimate();
-    // virtual for testing
-    virtual void setNeedsCommit();
+    void setNeedsCommit();
     void setNeedsRedraw();
 
     LayerChromium* rootLayer() { return m_rootLayer.get(); }
     const LayerChromium* rootLayer() const { return m_rootLayer.get(); }
-    void setRootLayer(PassRefPtr<LayerChromium>);
+    void setRootLayer(PassRefPtr<LayerChromium> rootLayer) { m_rootLayer = rootLayer; }
 
     const CCSettings& settings() const { return m_settings; }
 
index edac1199d512b51945a820a087c31a63bacfe835..50939482ef6d339cf80a0ddbd58171e582fec41a 100644 (file)
@@ -1,3 +1,246 @@
+2011-12-17  Adrienne Walker  <enne@google.com>
+
+        [chromium] Reverting r103011, r103135 due to Aura test failures
+
+        Unreviewed gardening.
+
+        * WebKit.gypi:
+        * public/platform/WebContentLayer.h:
+        * public/platform/WebExternalTextureLayer.h:
+        * public/platform/WebLayer.h:
+        * public/platform/WebLayerClient.h:
+        * src/WebContentLayer.cpp:
+        (WebKit::WebContentLayer::create):
+        * src/WebContentLayerImpl.cpp:
+        (WebKit::WebContentLayerImpl::create):
+        (WebKit::WebContentLayerImpl::WebContentLayerImpl):
+        (WebKit::WebContentLayerImpl::notifySyncRequired):
+        * src/WebContentLayerImpl.h:
+        * src/WebExternalTextureLayer.cpp:
+        (WebKit::WebExternalTextureLayer::create):
+        * src/WebExternalTextureLayerImpl.cpp:
+        (WebKit::WebExternalTextureLayerImpl::create):
+        (WebKit::WebExternalTextureLayerImpl::WebExternalTextureLayerImpl):
+        (WebKit::WebExternalTextureLayerImpl::notifySyncRequired):
+        * src/WebExternalTextureLayerImpl.h:
+        * src/WebLayer.cpp:
+        (WebKit::WebLayer::create):
+        * src/WebLayerImpl.cpp:
+        (WebKit::WebLayerImpl::create):
+        (WebKit::WebLayerImpl::WebLayerImpl):
+        (WebKit::WebLayerImpl::notifySyncRequired):
+        * src/WebLayerImpl.h:
+        * src/WebLayerTreeViewImpl.cpp:
+        (WebKit::WebLayerTreeViewImpl::create):
+        (WebKit::WebLayerTreeViewImpl::WebLayerTreeViewImpl):
+        * src/WebLayerTreeViewImpl.h:
+        * tests/CCLayerTreeHostImplTest.cpp:
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::MockLayerTreeHost::create):
+        (WTF::MockLayerTreeHost::MockLayerTreeHost):
+        (WTF::CompositorMockWebGraphicsContext3D::create):
+        (WTF::CompositorMockWebGraphicsContext3D::makeContextCurrent):
+        (WTF::CompositorMockWebGraphicsContext3D::createProgram):
+        (WTF::CompositorMockWebGraphicsContext3D::createShader):
+        (WTF::CompositorMockWebGraphicsContext3D::getShaderiv):
+        (WTF::CompositorMockWebGraphicsContext3D::getProgramiv):
+        (WTF::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):
+        (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D):
+        (WTF::CCLayerTreeHostTestShortlived1::beginTest):
+        (WTF::CCLayerTreeHostTestShortlived2::beginTest):
+        (WTF::CCLayerTreeHostTestShortlived3::beginTest):
+        (WTF::CCLayerTreeHostTestScrollSimple::beginCommitOnCCThread):
+        (WTF::TestOpacityChangeLayerDelegate::notifySyncRequired):
+        * tests/CompositorFakeGraphicsContext3D.h: Removed.
+        * tests/CompositorFakeWebGraphicsContext3D.h: Removed.
+        * tests/LayerChromiumTest.cpp:
+        * tests/MockGraphicsContext3DTest.cpp: Renamed from Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp.
+        (FrameCountingContext::FrameCountingContext):
+        (FrameCountingContext::prepareTexture):
+        (FrameCountingContext::frameCount):
+        (TEST):
+        (ContextThatCountsMakeCurrents::ContextThatCountsMakeCurrents):
+        (ContextThatCountsMakeCurrents::makeContextCurrent):
+        (ContextThatCountsMakeCurrents::makeCurrentCount):
+        (ContextWithMakeCurrentThatFails::ContextWithMakeCurrentThatFails):
+        (ContextWithMakeCurrentThatFails::makeContextCurrent):
+        * tests/MockWebGraphicsContext3D.h: Renamed from Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h.
+        (WebKit::MockWebGraphicsContext3D::initialize):
+        (WebKit::MockWebGraphicsContext3D::makeContextCurrent):
+        (WebKit::MockWebGraphicsContext3D::width):
+        (WebKit::MockWebGraphicsContext3D::height):
+        (WebKit::MockWebGraphicsContext3D::reshape):
+        (WebKit::MockWebGraphicsContext3D::isGLES2Compliant):
+        (WebKit::MockWebGraphicsContext3D::readBackFramebuffer):
+        (WebKit::MockWebGraphicsContext3D::getPlatformTextureId):
+        (WebKit::MockWebGraphicsContext3D::prepareTexture):
+        (WebKit::MockWebGraphicsContext3D::postSubBufferCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::synthesizeGLError):
+        (WebKit::MockWebGraphicsContext3D::isContextLost):
+        (WebKit::MockWebGraphicsContext3D::mapBufferSubDataCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::unmapBufferSubDataCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::mapTexSubImage2DCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::unmapTexSubImage2DCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::setVisibilityCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::getRequestableExtensionsCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::requestExtensionCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::blitFramebufferCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::renderbufferStorageMultisampleCHROMIUM):
+        (WebKit::MockWebGraphicsContext3D::activeTexture):
+        (WebKit::MockWebGraphicsContext3D::attachShader):
+        (WebKit::MockWebGraphicsContext3D::bindAttribLocation):
+        (WebKit::MockWebGraphicsContext3D::bindBuffer):
+        (WebKit::MockWebGraphicsContext3D::bindFramebuffer):
+        (WebKit::MockWebGraphicsContext3D::bindRenderbuffer):
+        (WebKit::MockWebGraphicsContext3D::bindTexture):
+        (WebKit::MockWebGraphicsContext3D::blendColor):
+        (WebKit::MockWebGraphicsContext3D::blendEquation):
+        (WebKit::MockWebGraphicsContext3D::blendEquationSeparate):
+        (WebKit::MockWebGraphicsContext3D::blendFunc):
+        (WebKit::MockWebGraphicsContext3D::blendFuncSeparate):
+        (WebKit::MockWebGraphicsContext3D::bufferData):
+        (WebKit::MockWebGraphicsContext3D::bufferSubData):
+        (WebKit::MockWebGraphicsContext3D::checkFramebufferStatus):
+        (WebKit::MockWebGraphicsContext3D::clear):
+        (WebKit::MockWebGraphicsContext3D::clearColor):
+        (WebKit::MockWebGraphicsContext3D::clearDepth):
+        (WebKit::MockWebGraphicsContext3D::clearStencil):
+        (WebKit::MockWebGraphicsContext3D::colorMask):
+        (WebKit::MockWebGraphicsContext3D::compileShader):
+        (WebKit::MockWebGraphicsContext3D::compressedTexImage2D):
+        (WebKit::MockWebGraphicsContext3D::compressedTexSubImage2D):
+        (WebKit::MockWebGraphicsContext3D::copyTexImage2D):
+        (WebKit::MockWebGraphicsContext3D::copyTexSubImage2D):
+        (WebKit::MockWebGraphicsContext3D::cullFace):
+        (WebKit::MockWebGraphicsContext3D::depthFunc):
+        (WebKit::MockWebGraphicsContext3D::depthMask):
+        (WebKit::MockWebGraphicsContext3D::depthRange):
+        (WebKit::MockWebGraphicsContext3D::detachShader):
+        (WebKit::MockWebGraphicsContext3D::disable):
+        (WebKit::MockWebGraphicsContext3D::disableVertexAttribArray):
+        (WebKit::MockWebGraphicsContext3D::drawArrays):
+        (WebKit::MockWebGraphicsContext3D::drawElements):
+        (WebKit::MockWebGraphicsContext3D::enable):
+        (WebKit::MockWebGraphicsContext3D::enableVertexAttribArray):
+        (WebKit::MockWebGraphicsContext3D::finish):
+        (WebKit::MockWebGraphicsContext3D::flush):
+        (WebKit::MockWebGraphicsContext3D::framebufferRenderbuffer):
+        (WebKit::MockWebGraphicsContext3D::framebufferTexture2D):
+        (WebKit::MockWebGraphicsContext3D::frontFace):
+        (WebKit::MockWebGraphicsContext3D::generateMipmap):
+        (WebKit::MockWebGraphicsContext3D::getActiveAttrib):
+        (WebKit::MockWebGraphicsContext3D::getActiveUniform):
+        (WebKit::MockWebGraphicsContext3D::getAttachedShaders):
+        (WebKit::MockWebGraphicsContext3D::getAttribLocation):
+        (WebKit::MockWebGraphicsContext3D::getBooleanv):
+        (WebKit::MockWebGraphicsContext3D::getBufferParameteriv):
+        (WebKit::MockWebGraphicsContext3D::getContextAttributes):
+        (WebKit::MockWebGraphicsContext3D::getError):
+        (WebKit::MockWebGraphicsContext3D::getFloatv):
+        (WebKit::MockWebGraphicsContext3D::getFramebufferAttachmentParameteriv):
+        (WebKit::MockWebGraphicsContext3D::getIntegerv):
+        (WebKit::MockWebGraphicsContext3D::getProgramiv):
+        (WebKit::MockWebGraphicsContext3D::getProgramInfoLog):
+        (WebKit::MockWebGraphicsContext3D::getRenderbufferParameteriv):
+        (WebKit::MockWebGraphicsContext3D::getShaderiv):
+        (WebKit::MockWebGraphicsContext3D::getShaderInfoLog):
+        (WebKit::MockWebGraphicsContext3D::getShaderSource):
+        (WebKit::MockWebGraphicsContext3D::getString):
+        (WebKit::MockWebGraphicsContext3D::getTexParameterfv):
+        (WebKit::MockWebGraphicsContext3D::getTexParameteriv):
+        (WebKit::MockWebGraphicsContext3D::getUniformfv):
+        (WebKit::MockWebGraphicsContext3D::getUniformiv):
+        (WebKit::MockWebGraphicsContext3D::getUniformLocation):
+        (WebKit::MockWebGraphicsContext3D::getVertexAttribfv):
+        (WebKit::MockWebGraphicsContext3D::getVertexAttribiv):
+        (WebKit::MockWebGraphicsContext3D::getVertexAttribOffset):
+        (WebKit::MockWebGraphicsContext3D::hint):
+        (WebKit::MockWebGraphicsContext3D::isBuffer):
+        (WebKit::MockWebGraphicsContext3D::isEnabled):
+        (WebKit::MockWebGraphicsContext3D::isFramebuffer):
+        (WebKit::MockWebGraphicsContext3D::isProgram):
+        (WebKit::MockWebGraphicsContext3D::isRenderbuffer):
+        (WebKit::MockWebGraphicsContext3D::isShader):
+        (WebKit::MockWebGraphicsContext3D::isTexture):
+        (WebKit::MockWebGraphicsContext3D::lineWidth):
+        (WebKit::MockWebGraphicsContext3D::linkProgram):
+        (WebKit::MockWebGraphicsContext3D::pixelStorei):
+        (WebKit::MockWebGraphicsContext3D::polygonOffset):
+        (WebKit::MockWebGraphicsContext3D::readPixels):
+        (WebKit::MockWebGraphicsContext3D::releaseShaderCompiler):
+        (WebKit::MockWebGraphicsContext3D::renderbufferStorage):
+        (WebKit::MockWebGraphicsContext3D::sampleCoverage):
+        (WebKit::MockWebGraphicsContext3D::scissor):
+        (WebKit::MockWebGraphicsContext3D::shaderSource):
+        (WebKit::MockWebGraphicsContext3D::stencilFunc):
+        (WebKit::MockWebGraphicsContext3D::stencilFuncSeparate):
+        (WebKit::MockWebGraphicsContext3D::stencilMask):
+        (WebKit::MockWebGraphicsContext3D::stencilMaskSeparate):
+        (WebKit::MockWebGraphicsContext3D::stencilOp):
+        (WebKit::MockWebGraphicsContext3D::stencilOpSeparate):
+        (WebKit::MockWebGraphicsContext3D::texImage2D):
+        (WebKit::MockWebGraphicsContext3D::texParameterf):
+        (WebKit::MockWebGraphicsContext3D::texParameteri):
+        (WebKit::MockWebGraphicsContext3D::texSubImage2D):
+        (WebKit::MockWebGraphicsContext3D::uniform1f):
+        (WebKit::MockWebGraphicsContext3D::uniform1fv):
+        (WebKit::MockWebGraphicsContext3D::uniform1i):
+        (WebKit::MockWebGraphicsContext3D::uniform1iv):
+        (WebKit::MockWebGraphicsContext3D::uniform2f):
+        (WebKit::MockWebGraphicsContext3D::uniform2fv):
+        (WebKit::MockWebGraphicsContext3D::uniform2i):
+        (WebKit::MockWebGraphicsContext3D::uniform2iv):
+        (WebKit::MockWebGraphicsContext3D::uniform3f):
+        (WebKit::MockWebGraphicsContext3D::uniform3fv):
+        (WebKit::MockWebGraphicsContext3D::uniform3i):
+        (WebKit::MockWebGraphicsContext3D::uniform3iv):
+        (WebKit::MockWebGraphicsContext3D::uniform4f):
+        (WebKit::MockWebGraphicsContext3D::uniform4fv):
+        (WebKit::MockWebGraphicsContext3D::uniform4i):
+        (WebKit::MockWebGraphicsContext3D::uniform4iv):
+        (WebKit::MockWebGraphicsContext3D::uniformMatrix2fv):
+        (WebKit::MockWebGraphicsContext3D::uniformMatrix3fv):
+        (WebKit::MockWebGraphicsContext3D::uniformMatrix4fv):
+        (WebKit::MockWebGraphicsContext3D::useProgram):
+        (WebKit::MockWebGraphicsContext3D::validateProgram):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib1f):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib1fv):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib2f):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib2fv):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib3f):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib3fv):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib4f):
+        (WebKit::MockWebGraphicsContext3D::vertexAttrib4fv):
+        (WebKit::MockWebGraphicsContext3D::vertexAttribPointer):
+        (WebKit::MockWebGraphicsContext3D::viewport):
+        (WebKit::MockWebGraphicsContext3D::createBuffer):
+        (WebKit::MockWebGraphicsContext3D::createFramebuffer):
+        (WebKit::MockWebGraphicsContext3D::createProgram):
+        (WebKit::MockWebGraphicsContext3D::createRenderbuffer):
+        (WebKit::MockWebGraphicsContext3D::createShader):
+        (WebKit::MockWebGraphicsContext3D::createTexture):
+        (WebKit::MockWebGraphicsContext3D::deleteBuffer):
+        (WebKit::MockWebGraphicsContext3D::deleteFramebuffer):
+        (WebKit::MockWebGraphicsContext3D::deleteProgram):
+        (WebKit::MockWebGraphicsContext3D::deleteRenderbuffer):
+        (WebKit::MockWebGraphicsContext3D::deleteShader):
+        (WebKit::MockWebGraphicsContext3D::deleteTexture):
+        (WebKit::MockWebGraphicsContext3D::texStorage2DEXT):
+        * tests/WebGLLayerChromiumTest.cpp:
+        (WebKit::CompositorMockWebGraphicsContext3D::create):
+        (WebKit::CompositorMockWebGraphicsContext3D::makeContextCurrent):
+        (WebKit::CompositorMockWebGraphicsContext3D::createProgram):
+        (WebKit::CompositorMockWebGraphicsContext3D::createShader):
+        (WebKit::CompositorMockWebGraphicsContext3D::getShaderiv):
+        (WebKit::CompositorMockWebGraphicsContext3D::getProgramiv):
+        (WebKit::CompositorMockWebGraphicsContext3D::getContextAttributes):
+        (WebKit::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):
+        (WebKit::createGraphicsContext):
+        (WebKit::TEST):
+        * tests/WebLayerTest.cpp:
+        (testing::WebLayerTest::WebLayerTest):
+        (testing::TEST_F):
+
 2011-12-17  Kenichi Ishibashi  <bashi@chromium.org>
 
         [Chromium] Implement PluginViewBase::getFormValue
index 9575d2d6678c01cd9f69c070528c11a92f251818..db99897c2537df1c910e01a7cf3dd6c83adefd6f 100644 (file)
             'tests/CCLayerTreeHostTest.cpp',
             'tests/CCLayerTreeTestCommon.h',
             'tests/CCRenderSurfaceTest.cpp',
+            'tests/CCSchedulerTest.cpp',
             'tests/CCSchedulerStateMachineTest.cpp',
             'tests/CCSchedulerTestCommon.h',
-            'tests/CCSchedulerTest.cpp',
             'tests/CCThreadTaskTest.cpp',
-            'tests/CompositorFakeGraphicsContext3D.h',
-            'tests/CompositorFakeWebGraphicsContext3D.h',
-            'tests/FakeGraphicsContext3DTest.cpp',
-            'tests/FakeWebGraphicsContext3D.h',
             'tests/FloatQuadTest.cpp',
             'tests/FrameTestHelpers.cpp',
             'tests/FrameTestHelpers.h',
@@ -83,6 +79,8 @@
             'tests/KeyboardTest.cpp',
             'tests/KURLTest.cpp',
             'tests/LayerChromiumTest.cpp',
+            'tests/MockGraphicsContext3DTest.cpp',
+            'tests/MockWebGraphicsContext3D.h',
             'tests/PODArenaTest.cpp',
             'tests/PODIntervalTreeTest.cpp',
             'tests/PODRedBlackTreeTest.cpp',
index 208eb056a99813ba6b20c4913a085f721c65bec9..5d00dc93e3710ac9dd33e78ba5e0286ab9d20c34 100644 (file)
@@ -37,8 +37,6 @@ class WebLayerClient;
 
 class WebContentLayer : public WebLayer {
 public:
-    WEBKIT_EXPORT static WebContentLayer create(WebContentLayerClient*);
-    // FIXME: Remove this as soon as downstream clients are updated.
     WEBKIT_EXPORT static WebContentLayer create(WebLayerClient*, WebContentLayerClient*);
 
     WebContentLayer() { }
index 55745ac96f14f90c0dc32af2803880269a3845d9..63d5485f2ee1bb38c03e18d6635d120d0061d981 100644 (file)
@@ -42,8 +42,6 @@ class WebLayerClient;
 // the WebLayerTreeView is destroyed.
 class WebExternalTextureLayer : public WebLayer {
 public:
-    WEBKIT_EXPORT static WebExternalTextureLayer create();
-    // FIXME: Remove as soon as downstream clients are updated.
     WEBKIT_EXPORT static WebExternalTextureLayer create(WebLayerClient*);
 
     WebExternalTextureLayer() { }
index 033bee45aec14eae4e5f099626ffc4f07256ae95..565671c3bc9302f70c49a5255ca1e0334c281683 100644 (file)
@@ -40,8 +40,6 @@ struct WebSize;
 
 class WebLayer {
 public:
-    WEBKIT_EXPORT static WebLayer create();
-    // FIXME: Remove this constructor once downstream clients are updated.
     WEBKIT_EXPORT static WebLayer create(WebLayerClient*);
 
     WebLayer() { }
index d2a69fff051e6cc7187828f06c7eeea19239a0ea..9f148ba2ee137842b112dc3292c98049e55ce96e 100644 (file)
@@ -30,8 +30,14 @@ namespace WebKit {
 
 class WebLayerClient {
 public:
-    // This empty interface exists only for legacy reasons - it will be deleted as soon
-    // as downstream consumers stop depending on this interface existing.
+    // Notifies the client that the layer has changed in a way that needs a
+    // compositing pass to visually update. The client should eventually call
+    // WebLayerTreeView::composite.
+    // Note: some complex operations (e.g layer reparenting) can cause this to
+    // be called while the layer tree is in an inconsistent state, so to get
+    // correct results, WebLayerTreeView::composite should be called after the
+    // operation has finished (e.g. by posting a task).
+    virtual void notifyNeedsComposite() = 0;
 
 protected:
     virtual ~WebLayerClient() { }
index faa6a09687adb81a049994a4508a9b4b65db611e..c9894e203c57ab61c27f2d23dca1795f4497bd63 100644 (file)
 
 namespace WebKit {
 
-WebContentLayer WebContentLayer::create(WebContentLayerClient* contentClient)
+WebContentLayer WebContentLayer::create(WebLayerClient* client, WebContentLayerClient* contentClient)
 {
-    return WebContentLayer(WebContentLayerImpl::create(contentClient));
-}
-
-WebContentLayer WebContentLayer::create(WebLayerClient*, WebContentLayerClient* contentClient)
-{
-    return WebContentLayer::create(contentClient);
+    return WebContentLayer(WebContentLayerImpl::create(client, contentClient));
 }
 
 void WebContentLayer::setDrawsContent(bool drawsContent)
index 79e20fef7952eec8170e3def2ecf1e3121fe295e..cd88900bda34a53be1e6feff98d593cfcae68110 100644 (file)
@@ -27,6 +27,7 @@
 #include "WebContentLayerImpl.h"
 
 #include "platform/WebContentLayerClient.h"
+#include "platform/WebLayerClient.h"
 #include "platform/WebRect.h"
 #include "GraphicsContext.h"
 #include "platform/WebCanvas.h"
@@ -38,13 +39,14 @@ using namespace WebCore;
 
 namespace WebKit {
 
-PassRefPtr<WebContentLayerImpl> WebContentLayerImpl::create(WebContentLayerClient* contentClient)
+PassRefPtr<WebContentLayerImpl> WebContentLayerImpl::create(WebLayerClient* client, WebContentLayerClient* contentClient)
 {
-    return adoptRef(new WebContentLayerImpl(contentClient));
+    return adoptRef(new WebContentLayerImpl(client, contentClient));
 }
 
-WebContentLayerImpl::WebContentLayerImpl(WebContentLayerClient* contentClient)
+WebContentLayerImpl::WebContentLayerImpl(WebLayerClient* client, WebContentLayerClient* contentClient)
     : ContentLayerChromium(this)
+    , m_client(client)
     , m_contentClient(contentClient)
     , m_drawsContent(true)
 {
@@ -78,4 +80,10 @@ void WebContentLayerImpl::paintContents(GraphicsContext& gc, const IntRect& clip
     m_contentClient->paintContents(canvas, WebRect(clip));
 }
 
+void WebContentLayerImpl::notifySyncRequired()
+{
+    if (m_client)
+        m_client->notifyNeedsComposite();
+}
+
 } // namespace WebKit
index b30c8ae562dd4369c391b81fb486747848d63d34..108df5e3a254ed956945986fd6541a84a98865ff 100644 (file)
 #include <wtf/PassRefPtr.h>
 
 namespace WebKit {
+class WebLayerClient;
 class WebContentLayerClient;
 
 class WebContentLayerImpl : public WebCore::ContentLayerChromium, public WebCore::CCLayerDelegate {
 public:
-    static PassRefPtr<WebContentLayerImpl> create(WebContentLayerClient* contentClient);
+    static PassRefPtr<WebContentLayerImpl> create(WebLayerClient*, WebContentLayerClient* contentClient);
 
     void setDrawsContent(bool);
     virtual bool drawsContent() const;
 
 protected:
-    explicit WebContentLayerImpl(WebContentLayerClient* contentClient);
+    WebContentLayerImpl(WebLayerClient*, WebContentLayerClient* contentClient);
     virtual ~WebContentLayerImpl();
     virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip);
+    virtual void notifySyncRequired();
 
+    WebLayerClient* m_client;
     WebContentLayerClient* m_contentClient;
     bool m_drawsContent;
 };
index b3a332b2a2142f6735bce8428f0429a569edc454..5a06c176b2527e5cd6dfd218132381b50607f515 100644 (file)
@@ -31,9 +31,9 @@
 
 namespace WebKit {
 
-WebExternalTextureLayer WebExternalTextureLayer::create()
+WebExternalTextureLayer WebExternalTextureLayer::create(WebLayerClient* client)
 {
-    return WebExternalTextureLayer(WebExternalTextureLayerImpl::create());
+    return WebExternalTextureLayer(WebExternalTextureLayerImpl::create(client));
 }
 
 void WebExternalTextureLayer::setTextureId(unsigned id)
index 1b1da103c9fb674c80e848ca94f307dc6bd8127a..442eacd7da4e0aeb5174c43df910c80008b18748 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebExternalTextureLayerImpl.h"
 
+#include "platform/WebLayerClient.h"
 #include "GraphicsContext.h"
 #include "platform/WebCanvas.h"
 
@@ -33,13 +34,14 @@ using namespace WebCore;
 
 namespace WebKit {
 
-PassRefPtr<WebExternalTextureLayerImpl> WebExternalTextureLayerImpl::create()
+PassRefPtr<WebExternalTextureLayerImpl> WebExternalTextureLayerImpl::create(WebLayerClient* client)
 {
-    return adoptRef(new WebExternalTextureLayerImpl());
+    return adoptRef(new WebExternalTextureLayerImpl(client));
 }
 
-WebExternalTextureLayerImpl::WebExternalTextureLayerImpl()
+WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(WebLayerClient* client)
     : PluginLayerChromium(this)
+    , m_client(client)
 {
     setFlipped(false);
 }
@@ -58,4 +60,10 @@ void WebExternalTextureLayerImpl::paintContents(GraphicsContext&, const IntRect&
 {
 }
 
+void WebExternalTextureLayerImpl::notifySyncRequired()
+{
+    if (m_client)
+        m_client->notifyNeedsComposite();
+}
+
 } // namespace WebKit
index 1ad2b81998f30df6c9eca093a0c2ff5abee91cea..4f9a98727c97d9b5c958744c269b884d1853e76f 100644 (file)
 #include <wtf/PassRefPtr.h>
 
 namespace WebKit {
+class WebLayerClient;
 
 class WebExternalTextureLayerImpl : public WebCore::PluginLayerChromium, public WebCore::CCLayerDelegate {
 public:
-    static PassRefPtr<WebExternalTextureLayerImpl> create();
+    static PassRefPtr<WebExternalTextureLayerImpl> create(WebLayerClient*);
 
 protected:
-    WebExternalTextureLayerImpl();
+    WebExternalTextureLayerImpl(WebLayerClient*);
     virtual ~WebExternalTextureLayerImpl();
     virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip);
+    virtual void notifySyncRequired();
     virtual bool drawsContent() const;
+
+    WebLayerClient* m_client;
 };
 
 } // namespace WebKit
index f9479c984a9f9ba0d6b62334e09478a1369732f5..15e040d8a95c932528bbafc3519880895c92cb95 100644 (file)
@@ -74,14 +74,9 @@ SkMatrix44 skMatrix44FromTransformationMatrix(const TransformationMatrix& matrix
 
 namespace WebKit {
 
-WebLayer WebLayer::create(WebLayerClient*)
+WebLayer WebLayer::create(WebLayerClient* client)
 {
-    return WebLayer::create();
-}
-
-WebLayer WebLayer::create()
-{
-    return WebLayer(WebLayerImpl::create());
+    return WebLayer(WebLayerImpl::create(client));
 }
 
 void WebLayer::reset()
index a4a2f09f0979979413517a4fc22dd81e3cbd933a..ddc0611209416f95045116c0afd72977f8f8a6e5 100644 (file)
 #include "config.h"
 #include "WebLayerImpl.h"
 
+#include "platform/WebLayerClient.h"
+
 using namespace WebCore;
 
 namespace WebKit {
 
-PassRefPtr<WebLayerImpl> WebLayerImpl::create()
+PassRefPtr<WebLayerImpl> WebLayerImpl::create(WebLayerClient* client)
 {
-    return adoptRef(new WebLayerImpl());
+    return adoptRef(new WebLayerImpl(client));
 }
 
-WebLayerImpl::WebLayerImpl()
-    : LayerChromium(this)
+WebLayerImpl::WebLayerImpl(WebLayerClient* client) : LayerChromium(this), m_client(client)
 {
 }
 
@@ -54,4 +55,10 @@ void WebLayerImpl::paintContents(GraphicsContext&, const IntRect& clip)
 {
 }
 
+void WebLayerImpl::notifySyncRequired()
+{
+    if (m_client)
+        m_client->notifyNeedsComposite();
+}
+
 } // namespace WebKit
index 0298959a5d567b63f105df87d4e8838ce6d03f1b..558d41b5cde1a848702cad0f37512c8911551116 100644 (file)
 #include <wtf/PassRefPtr.h>
 
 namespace WebKit {
+class WebLayerClient;
 
 class WebLayerImpl : public WebCore::LayerChromium, public WebCore::CCLayerDelegate {
 public:
-    static PassRefPtr<WebLayerImpl> create();
+    static PassRefPtr<WebLayerImpl> create(WebLayerClient*);
 
 protected:
-    WebLayerImpl();
+    WebLayerImpl(WebLayerClient*);
     virtual ~WebLayerImpl();
     virtual bool drawsContent() const;
     virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip);
+    virtual void notifySyncRequired();
+
+    WebLayerClient* m_client;
 };
 
 } // namespace WebKit
index 9c1b5aef412b8f128291474ee5d7181580b8aa78..599aab9dde7ec2ed90dcd73c62db27be85726309 100644 (file)
@@ -43,17 +43,17 @@ namespace WebKit {
 
 PassRefPtr<WebLayerTreeViewImpl> WebLayerTreeViewImpl::create(WebLayerTreeViewClient* client, const WebLayer& root, const WebLayerTreeView::Settings& settings)
 {
-    RefPtr<WebLayerTreeViewImpl> host = adoptRef(new WebLayerTreeViewImpl(client, settings));
+    RefPtr<WebLayerTreeViewImpl> host = adoptRef(new WebLayerTreeViewImpl(client, root, settings));
     if (!host->initialize())
         return 0;
-    host->setRootLayer(root);
     return host;
 }
 
-WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client, const WebLayerTreeView::Settings& settings)
+WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client, const WebLayer& root, const WebLayerTreeView::Settings& settings) 
     : CCLayerTreeHost(this, settings)
     , m_client(client)
 {
+    setRootLayer(root);
 }
 
 WebLayerTreeViewImpl::~WebLayerTreeViewImpl()
index 3811e093e5f3a1a5c7cc133378ff00868c6dc543..2e145fa71ef9c9808a70e9921925e619db4dac02 100644 (file)
@@ -39,7 +39,7 @@ public:
     static PassRefPtr<WebLayerTreeViewImpl> create(WebLayerTreeViewClient*, const WebLayer& root, const WebLayerTreeView::Settings&);
 
 private:
-    WebLayerTreeViewImpl(WebLayerTreeViewClient*, const WebLayerTreeView::Settings&);
+    WebLayerTreeViewImpl(WebLayerTreeViewClient*, const WebLayer& root, const WebLayerTreeView::Settings&);
     virtual ~WebLayerTreeViewImpl();
     virtual void animateAndLayout(double frameBeginTime);
     virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale);
index c47a7c290c4d104cd5d7f9bba960487d8efd7213..e835ab789bfd29e74d08cd7a1fe21373e605a52e 100644 (file)
@@ -26,9 +26,9 @@
 
 #include "cc/CCLayerTreeHostImpl.h"
 
-#include "FakeWebGraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
 #include "LayerRendererChromium.h"
+#include "MockWebGraphicsContext3D.h"
 #include "cc/CCLayerImpl.h"
 #include "cc/CCSingleThreadProxy.h"
 #include <gtest/gtest.h>
@@ -155,7 +155,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
     EXPECT_TRUE(m_didRequestCommit);
 }
 
-class BlendStateTrackerContext: public FakeWebGraphicsContext3D {
+class BlendStateTrackerContext: public MockWebGraphicsContext3D {
 public:
     BlendStateTrackerContext() : m_blend(false) { }
 
@@ -289,7 +289,7 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     EXPECT_TRUE(layer2->drawn());
 }
 
-class ReshapeTrackerContext: public FakeWebGraphicsContext3D {
+class ReshapeTrackerContext: public MockWebGraphicsContext3D {
 public:
     ReshapeTrackerContext() : m_reshapeCalled(false) { }
 
index edaf5131f033da7c7a75991821f9183ae28bed3e..1876238b58562b4aa87b92150858c086da197278 100644 (file)
 
 #include "cc/CCLayerTreeHost.h"
 
-#include "CompositorFakeGraphicsContext3D.h"
 #include "ContentLayerChromium.h"
-#include "FakeWebGraphicsContext3D.h"
+#include "GraphicsContext3DPrivate.h"
 #include "LayerChromium.h"
+#include "MockWebGraphicsContext3D.h"
 #include "TextureManager.h"
 #include "WebCompositor.h"
 #include "WebKit.h"
@@ -103,13 +103,12 @@ class MockLayerTreeHost : public CCLayerTreeHost {
 public:
     static PassRefPtr<MockLayerTreeHost> create(TestHooks* testHooks, CCLayerTreeHostClient* client, PassRefPtr<LayerChromium> rootLayer, const CCSettings& settings)
     {
-        RefPtr<MockLayerTreeHost> mock = adoptRef(new MockLayerTreeHost(testHooks, client, settings));
-        bool success = mock->initialize();
-        EXPECT_TRUE(success);
-        mock->setRootLayer(rootLayer);
+        RefPtr<MockLayerTreeHost> layerTreeHost = adoptRef(new MockLayerTreeHost(testHooks, client, rootLayer, settings));
+
         // LayerTreeHostImpl won't draw if it has 1x1 viewport.
-        mock->setViewport(IntSize(1, 1));
-        return mock.release();
+        layerTreeHost->setViewport(IntSize(1, 1));
+
+        return layerTreeHost;
     }
 
     virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient* client)
@@ -118,15 +117,36 @@ public:
     }
 
 private:
-    MockLayerTreeHost(TestHooks* testHooks, CCLayerTreeHostClient* client, const CCSettings& settings)
+    MockLayerTreeHost(TestHooks* testHooks, CCLayerTreeHostClient* client, PassRefPtr<LayerChromium> rootLayer, const CCSettings& settings)
         : CCLayerTreeHost(client, settings)
         , m_testHooks(testHooks)
     {
+        setRootLayer(rootLayer);
+        bool success = initialize();
+        EXPECT_TRUE(success);
     }
 
     TestHooks* m_testHooks;
 };
 
+// Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.
+class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {
+public:
+    static PassOwnPtr<CompositorMockWebGraphicsContext3D> create()
+    {
+        return adoptPtr(new CompositorMockWebGraphicsContext3D());
+    }
+
+    virtual bool makeContextCurrent() { return true; }
+    virtual WebGLId createProgram() { return 1; }
+    virtual WebGLId createShader(WGC3Denum) { return 1; }
+    virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
+    virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
+
+private:
+    CompositorMockWebGraphicsContext3D() { }
+};
+
 // Implementation of CCLayerTreeHost callback interface.
 class MockLayerTreeHostClient : public CCLayerTreeHostClient {
 public:
@@ -147,7 +167,10 @@ public:
 
     virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D()
     {
-        return createCompositorMockGraphicsContext3D(GraphicsContext3D::Attributes());
+        OwnPtr<WebGraphicsContext3D> mock = CompositorMockWebGraphicsContext3D::create();
+        GraphicsContext3D::Attributes attrs;
+        RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(mock.release(), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnAnotherThread);
+        return context;
     }
 
     virtual void didCommitAndDrawFrame()
@@ -430,7 +453,7 @@ public:
     virtual void beginTest()
     {
         // Kill the layerTreeHost immediately.
-        m_layerTreeHost->setRootLayer(0);
+        m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
         m_layerTreeHost.clear();
 
         endTest();
@@ -463,7 +486,7 @@ public:
         postSetNeedsCommitToMainThread();
 
         // Kill the layerTreeHost immediately.
-        m_layerTreeHost->setRootLayer(0);
+        m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
         m_layerTreeHost.clear();
 
         endTest();
@@ -486,7 +509,7 @@ public:
         postSetNeedsRedrawToMainThread();
 
         // Kill the layerTreeHost immediately.
-        m_layerTreeHost->setRootLayer(0);
+        m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
         m_layerTreeHost.clear();
 
         endTest();
@@ -734,7 +757,7 @@ public:
         postSetNeedsCommitToMainThread();
     }
 
-    virtual void animateAndLayout(double frameBeginTime)
+    virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl)
     {
         LayerChromium* root = m_layerTreeHost->rootLayer();
         if (!m_layerTreeHost->frameNumber())
@@ -919,6 +942,7 @@ public:
 
     virtual bool drawsContent() const { return true; }
     virtual bool preserves3D() { return false; }
+    virtual void notifySyncRequired() { }
 
 private:
     CCLayerTreeHostTest* m_test;
diff --git a/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h b/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h
deleted file mode 100644 (file)
index 1f08973..0000000
+++ /dev/null
@@ -1,48 +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 INC. 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 INC. 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 CompositorFakeGraphicsContext3D_h
-#define CompositorFakeGraphicsContext3D_h
-
-#include "CompositorFakeWebGraphicsContext3D.h"
-#include "GraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
-
-namespace WebCore {
-
-static PassRefPtr<GraphicsContext3D> createCompositorMockGraphicsContext3D(GraphicsContext3D::Attributes attrs)
-{
-    WebKit::WebGraphicsContext3D::Attributes webAttrs;
-    webAttrs.alpha = attrs.alpha;
-
-    OwnPtr<WebKit::WebGraphicsContext3D> webContext = WebKit::CompositorFakeWebGraphicsContext3D::create(webAttrs);
-    return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(
-        webContext.release(), attrs, 0,
-        GraphicsContext3D::RenderDirectlyToHostWindow,
-        GraphicsContext3DPrivate::ForUseOnAnotherThread);
-}
-
-}
-
-#endif
diff --git a/Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h b/Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h
deleted file mode 100644 (file)
index de1409b..0000000
+++ /dev/null
@@ -1,55 +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 INC. 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 INC. 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 CompositorFakeWebGraphicsContext3D_h
-#define CompositorFakeWebGraphicsContext3D_h
-
-#include "FakeWebGraphicsContext3D.h"
-
-namespace WebKit {
-
-// Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.
-class CompositorFakeWebGraphicsContext3D : public FakeWebGraphicsContext3D {
-public:
-    static PassOwnPtr<CompositorFakeWebGraphicsContext3D> create(Attributes attrs)
-    {
-        return adoptPtr(new CompositorFakeWebGraphicsContext3D(attrs));
-    }
-
-    virtual bool makeContextCurrent() { return true; }
-    virtual WebGLId createProgram() { return 1; }
-    virtual WebGLId createShader(WGC3Denum) { return 1; }
-    virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
-    virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
-
-private:
-    explicit CompositorFakeWebGraphicsContext3D(Attributes attrs)
-    {
-        m_attrs = attrs;
-    }
-};
-
-}
-
-#endif
index fbb9c19ea0119d7bc8d2dc8e4f248bd35a8933e5..28665aa776bcae01cf0b885fed5c5a5c8ed318d0 100644 (file)
 
 #include "LayerChromium.h"
 
-#include "cc/CCLayerTreeHost.h"
 #include "CCLayerTreeTestCommon.h"
 #include "LayerPainterChromium.h"
 #include "NonCompositedContentHost.h"
-#include "WebCompositor.h"
-#include "cc/CCLayerTreeHost.h"
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
 using namespace WebCore;
+using namespace WebKit;
 using namespace WebKitTests;
 using ::testing::Mock;
 using ::testing::_;
 using ::testing::AtLeast;
 using ::testing::AnyNumber;
 
-#define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCommit, codeToTest) do { \
-        EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedSetNeedsCommit));      \
-        codeToTest;                                                                                   \
-        Mock::VerifyAndClearExpectations(m_layerTreeHost.get());                                      \
-    } while (0)
+#define EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(delegate, numTimesExpectedNotifySync, codeToTest) \
+    EXPECT_CALL((delegate), notifySyncRequired()).Times((numTimesExpectedNotifySync)); \
+    codeToTest;                                                         \
+    Mock::VerifyAndClearExpectations(&(delegate))
 
 namespace {
 
-class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
+class MockLayerDelegate : public CCLayerDelegate {
 public:
-    virtual void animateAndLayout(double frameBeginTime) { }
-    virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }
-    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; }
-    virtual void didRecreateGraphicsContext(bool success) { }
-    virtual void didCommitAndDrawFrame() { }
-    virtual void didCompleteSwapBuffers() { }
-
-    // Used only in the single-threaded path.
-    virtual void scheduleComposite() { }
+    MOCK_CONST_METHOD0(drawsContent, bool());
+    MOCK_CONST_METHOD0(preserves3D, bool());
+    MOCK_METHOD2(paintContents, void(GraphicsContext&, const IntRect&));
+    MOCK_METHOD0(notifySyncRequired, void());
 };
 
-class MockCCLayerTreeHost : public CCLayerTreeHost {
+class MockLayerPainterChromium : public LayerPainterChromium {
+public:
+    virtual void paint(GraphicsContext&, const IntRect&) { }
+};
+
+class MockNonCompositedContentHost : public NonCompositedContentHost {
 public:
-    MockCCLayerTreeHost()
-        : CCLayerTreeHost(&m_fakeClient, CCSettings())
+    static PassOwnPtr<MockNonCompositedContentHost> create()
     {
-        initialize();
+        return adoptPtr(new MockNonCompositedContentHost);
     }
 
-    MOCK_METHOD0(setNeedsCommit, void());
+    MOCK_METHOD1(notifySyncRequired, void(const GraphicsLayer*));
 
 private:
-    FakeCCLayerTreeHostClient m_fakeClient;
+    MockNonCompositedContentHost()
+        : NonCompositedContentHost(adoptPtr(new MockLayerPainterChromium()))
+    {
+        m_scrollLayer = GraphicsLayer::create(0);
+        setScrollLayer(m_scrollLayer.get());
+    }
+    OwnPtr<GraphicsLayer> m_scrollLayer;
 };
 
-class MockLayerPainterChromium : public LayerPainterChromium {
+class LayerChromiumWithInstrumentedDestructor : public LayerChromium {
 public:
-    virtual void paint(GraphicsContext&, const IntRect&) { }
+    explicit LayerChromiumWithInstrumentedDestructor(CCLayerDelegate* delegate)
+        : LayerChromium(delegate)
+    {
+    }
+
+    virtual ~LayerChromiumWithInstrumentedDestructor()
+    {
+        s_numInstancesDestroyed++;
+    }
+
+    static int getNumInstancesDestroyed() { return s_numInstancesDestroyed; }
+    static void resetNumInstancesDestroyed() { s_numInstancesDestroyed = 0; }
+
+private:
+    static int s_numInstancesDestroyed;
 };
 
+int LayerChromiumWithInstrumentedDestructor::s_numInstancesDestroyed = 0;
 
 class LayerChromiumTest : public testing::Test {
 protected:
     virtual void SetUp()
     {
-        // Initialize without threading support.
-        WebKit::WebCompositor::initialize(0);
-        m_layerTreeHost = adoptRef(new MockCCLayerTreeHost);
-    }
-
-    virtual void TearDown()
-    {
-        Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
-        EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
-        m_parent.clear();
-        m_child1.clear();
-        m_child2.clear();
-        m_child3.clear();
-        m_grandChild1.clear();
-        m_grandChild2.clear();
-        m_grandChild3.clear();
-
-        m_layerTreeHost->setRootLayer(0);
-        m_layerTreeHost.clear();
-        WebKit::WebCompositor::shutdown();
+        // m_silentDelegate is initialized to be just a stub and will
+        // not print any warnings. It is used when we are not worried
+        // about testing how the delegate is called.
+        EXPECT_CALL(m_silentDelegate, drawsContent()).Times(AnyNumber());
+        EXPECT_CALL(m_silentDelegate, preserves3D()).Times(AnyNumber());
+        EXPECT_CALL(m_silentDelegate, paintContents(_, _)).Times(AnyNumber());
+        EXPECT_CALL(m_silentDelegate, notifySyncRequired()).Times(AnyNumber());
+
+        // Static variables need to be reset for every new test case
+        LayerChromiumWithInstrumentedDestructor::resetNumInstancesDestroyed();
     }
 
     void verifyTestTreeInitialState() const
@@ -134,90 +141,162 @@ protected:
 
     void createSimpleTestTree()
     {
-        m_parent = LayerChromium::create(0);
-        m_child1 = LayerChromium::create(0);
-        m_child2 = LayerChromium::create(0);
-        m_child3 = LayerChromium::create(0);
-        m_grandChild1 = LayerChromium::create(0);
-        m_grandChild2 = LayerChromium::create(0);
-        m_grandChild3 = LayerChromium::create(0);
-
-        EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
-        m_layerTreeHost->setRootLayer(m_parent);
-
+        m_parent = LayerChromium::create(&m_parentDelegate);
+        m_child1 = LayerChromium::create(&m_silentDelegate);
+        m_child2 = LayerChromium::create(&m_silentDelegate);
+        m_child3 = LayerChromium::create(&m_silentDelegate);
+        m_grandChild1 = LayerChromium::create(&m_silentDelegate);
+        m_grandChild2 = LayerChromium::create(&m_silentDelegate);
+        m_grandChild3 = LayerChromium::create(&m_silentDelegate);
+
+        EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(3);
         m_parent->addChild(m_child1);
         m_parent->addChild(m_child2);
         m_parent->addChild(m_child3);
+        Mock::VerifyAndClearExpectations(&m_parentDelegate);
         m_child1->addChild(m_grandChild1);
         m_child1->addChild(m_grandChild2);
         m_child2->addChild(m_grandChild3);
 
-        Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
-
         verifyTestTreeInitialState();
     }
 
-    RefPtr<MockCCLayerTreeHost> m_layerTreeHost;
+    MockLayerDelegate m_silentDelegate, m_parentDelegate;
     RefPtr<LayerChromium> m_parent, m_child1, m_child2, m_child3, m_grandChild1, m_grandChild2, m_grandChild3;
 };
 
 TEST_F(LayerChromiumTest, basicCreateAndDestroy)
 {
-    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
-    ASSERT_TRUE(testLayer);
+    MockLayerDelegate mockDelegate;
+
+    // notifySyncRequired should not be called just because the layer is created or destroyed.
+    EXPECT_CALL(mockDelegate, notifySyncRequired()).Times(0);
+
+    RefPtr<LayerChromiumWithInstrumentedDestructor> testLayer = adoptRef(new LayerChromiumWithInstrumentedDestructor(&mockDelegate));
+    ASSERT_TRUE(testLayer.get());
 
-    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0);
-    testLayer->setLayerTreeHost(m_layerTreeHost.get());
+    // notifySyncRequired should also not be called on the destructor when the layer has no children.
+    // so we need to make sure the layer is destroyed before the mock delegate.
+    ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
+    testLayer.release();
+    ASSERT_EQ(1, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
 }
 
 TEST_F(LayerChromiumTest, addAndRemoveChild)
 {
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<LayerChromium> child = LayerChromium::create(0);
+    MockLayerDelegate parentDelegate;
+    MockLayerDelegate childDelegate;
+    RefPtr<LayerChromium> parent = LayerChromium::create(&parentDelegate);
+    RefPtr<LayerChromium> child = LayerChromium::create(&childDelegate);
 
     // Upon creation, layers should not have children or parent.
     ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
     EXPECT_FALSE(child->parent());
 
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, m_layerTreeHost->setRootLayer(parent));
-
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child));
+    // Parent calls notifySyncRequired exactly once when adding child.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->addChild(child));
 
     ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
     EXPECT_EQ(child.get(), parent->children()[0]);
     EXPECT_EQ(parent.get(), child->parent());
     EXPECT_EQ(parent.get(), child->rootLayer());
 
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromParent());
+    // removeFromParent should cause the parent's notifySyncRequired to be called exactly once.
+    // The childDelegate notifySyncRequired should remain un-used.
+    EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0);
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, child->removeFromParent());
 }
 
-TEST_F(LayerChromiumTest, insertChild)
+TEST_F(LayerChromiumTest, verifyDestructorSemantics)
 {
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
-    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
-    RefPtr<LayerChromium> child3 = LayerChromium::create(0);
-    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
+    MockLayerDelegate parentDelegate;
+    MockLayerDelegate childDelegate;
+    RefPtr<LayerChromiumWithInstrumentedDestructor> parent = adoptRef(new LayerChromiumWithInstrumentedDestructor(&parentDelegate));
+    RefPtr<LayerChromium> child = LayerChromium::create(&childDelegate);
+
+    // Set up initial test conditions
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->addChild(child));
+    EXPECT_TRUE(child->parent());
 
-    parent->setLayerTreeHost(m_layerTreeHost.get());
+    // When being destroyed, notifySyncRequired is called once for the parent, because it has one child,
+    // but should not be called for the child which has no children.
+    EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(1);
+    EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0);
+
+    ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
+    parent.release();
+    ASSERT_EQ(1, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
+
+    // Child should have been un-parented correctly, but not yet destroyed since we have a reference to it.
+    EXPECT_FALSE(child->parent());
+}
+
+TEST_F(LayerChromiumTest, verifyDestructorDoesNotLeak)
+{
+    // In this test we explicitly instantiate a special subclass of
+    // LayerChromium so we can track the number of destructors called.
+
+    RefPtr<LayerChromiumWithInstrumentedDestructor> parent, child1, child2, child3, grandChild1, grandChild2, grandChild3;
+    parent = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
+    child1 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
+    child2 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
+    child3 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
+    grandChild1 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
+    grandChild2 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
+    grandChild3 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
+
+    // set up a simple tree.
+    parent->addChild(child1);
+    parent->addChild(child2);
+    parent->addChild(child3);
+    child1->addChild(grandChild1);
+    child1->addChild(grandChild2);
+    child2->addChild(grandChild3);
+
+    // Clear all the children RefPtrs here. But since they are attached to the tree, no destructors should be called yet.
+    child1.clear();
+    child2.clear();
+    child3.clear();
+    grandChild1.clear();
+    grandChild2.clear();
+    grandChild3.clear();
+
+    // releasing the parent should cause all destructors to be invoked.
+    ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
+    parent.release();
+    ASSERT_EQ(7, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
+}
+
+TEST_F(LayerChromiumTest, insertChild)
+{
+    MockLayerDelegate parentDelegate;
+    MockLayerDelegate childDelegate;
+    RefPtr<LayerChromium>parent = LayerChromium::create(&parentDelegate);
+    RefPtr<LayerChromium>child1 = LayerChromium::create(&childDelegate);
+    RefPtr<LayerChromium>child2 = LayerChromium::create(&childDelegate);
+    RefPtr<LayerChromium>child3 = LayerChromium::create(&childDelegate);
+    RefPtr<LayerChromium>child4 = LayerChromium::create(&childDelegate);
 
     ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
 
+    // The child delegate notifySyncRequired should not be called when inserting.
+    EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0);
+
     // Case 1: inserting to empty list.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child3, 0));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child3, 0));
     ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
     EXPECT_EQ(child3, parent->children()[0]);
     EXPECT_EQ(parent.get(), child3->parent());
 
     // Case 2: inserting to beginning of list
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1, 0));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child1, 0));
     ASSERT_EQ(static_cast<size_t>(2), parent->children().size());
     EXPECT_EQ(child1, parent->children()[0]);
     EXPECT_EQ(child3, parent->children()[1]);
     EXPECT_EQ(parent.get(), child1->parent());
 
     // Case 3: inserting to middle of list
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2, 1));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child2, 1));
     ASSERT_EQ(static_cast<size_t>(3), parent->children().size());
     EXPECT_EQ(child1, parent->children()[0]);
     EXPECT_EQ(child2, parent->children()[1]);
@@ -225,7 +304,7 @@ TEST_F(LayerChromiumTest, insertChild)
     EXPECT_EQ(parent.get(), child2->parent());
 
     // Case 4: inserting to end of list
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child4, 3));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child4, 3));
 
     ASSERT_EQ(static_cast<size_t>(4), parent->children().size());
     EXPECT_EQ(child1, parent->children()[0]);
@@ -234,14 +313,15 @@ TEST_F(LayerChromiumTest, insertChild)
     EXPECT_EQ(child4, parent->children()[3]);
     EXPECT_EQ(parent.get(), child4->parent());
 
-    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
+    // parent's destructor will invoke notifySyncRequired as it removes its children.
+    EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(AtLeast(1));
 }
 
 TEST_F(LayerChromiumTest, insertChildPastEndOfList)
 {
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
-    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
+    RefPtr<LayerChromium> parent = LayerChromium::create(&m_silentDelegate);
+    RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate);
+    RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate);
 
     ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
 
@@ -261,40 +341,65 @@ TEST_F(LayerChromiumTest, insertChildPastEndOfList)
 
 TEST_F(LayerChromiumTest, insertSameChildTwice)
 {
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
-    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
-
-    parent->setLayerTreeHost(m_layerTreeHost.get());
+    MockLayerDelegate parentDelegate;
+    RefPtr<LayerChromium> parent = LayerChromium::create(&parentDelegate);
+    RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate);
+    RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate);
 
     ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
 
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1, 0));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2, 1));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child1, 0));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child2, 1));
 
     ASSERT_EQ(static_cast<size_t>(2), parent->children().size());
     EXPECT_EQ(child1, parent->children()[0]);
     EXPECT_EQ(child2, parent->children()[1]);
 
     // Inserting the same child again should cause the child to be removed and re-inserted at the new location.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), parent->insertChild(child1, 1));
+    // So the parent's notifySyncRequired would be called one or more times.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, AtLeast(1), parent->insertChild(child1, 1));
 
     // child1 should now be at the end of the list.
     ASSERT_EQ(static_cast<size_t>(2), parent->children().size());
     EXPECT_EQ(child2, parent->children()[0]);
     EXPECT_EQ(child1, parent->children()[1]);
 
-    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
+    // parent's destructor will invoke notifySyncRequired as it removes leftover children
+    EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(AtLeast(1));
+}
+
+TEST_F(LayerChromiumTest, insertChildThatAlreadyHadParent)
+{
+    MockLayerDelegate oldParentDelegate;
+    RefPtr<LayerChromium> oldParent = LayerChromium::create(&oldParentDelegate);
+    RefPtr<LayerChromium> parent = LayerChromium::create(&m_silentDelegate);
+    RefPtr<LayerChromium> child = LayerChromium::create(&m_silentDelegate);
+
+    // set up and sanity-check initial test conditions
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(oldParentDelegate, 1, oldParent->addChild(child));
+    ASSERT_EQ(static_cast<size_t>(1), oldParent->children().size());
+    ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
+    EXPECT_EQ(child, oldParent->children()[0]);
+    EXPECT_EQ(oldParent.get(), child->parent());
+
+    // Inserting to new parent causes old parent's notifySyncRequired to be called.
+    // Note that it also causes parent's notifySyncRequired to be called, but that is tested elsewhere.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(oldParentDelegate, 1, parent->insertChild(child, 0));
+
+    ASSERT_EQ(static_cast<size_t>(0), oldParent->children().size());
+    ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
+    EXPECT_EQ(child, parent->children()[0]);
+    EXPECT_EQ(parent.get(), child->parent());
 }
 
 TEST_F(LayerChromiumTest, replaceChildWithNewChild)
 {
     createSimpleTestTree();
-    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
+    RefPtr<LayerChromium> child4 = LayerChromium::create(&m_silentDelegate);
 
     EXPECT_FALSE(child4->parent());
 
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
 
     ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size());
     EXPECT_EQ(m_child1, m_parent->children()[0]);
@@ -303,6 +408,9 @@ TEST_F(LayerChromiumTest, replaceChildWithNewChild)
     EXPECT_EQ(m_parent.get(), child4->parent());
 
     EXPECT_FALSE(m_child2->parent());
+
+    // parent's destructor will invoke notifySyncRequired as it removes leftover children
+    EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));
 }
 
 TEST_F(LayerChromiumTest, replaceChildWithNewChildThatHasOtherParent)
@@ -310,14 +418,14 @@ TEST_F(LayerChromiumTest, replaceChildWithNewChildThatHasOtherParent)
     createSimpleTestTree();
 
     // create another simple tree with testLayer and child4.
-    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
-    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
+    RefPtr<LayerChromium> testLayer = LayerChromium::create(&m_silentDelegate);
+    RefPtr<LayerChromium> child4 = LayerChromium::create(&m_silentDelegate);
     testLayer->addChild(child4);
     ASSERT_EQ(static_cast<size_t>(1), testLayer->children().size());
     EXPECT_EQ(child4, testLayer->children()[0]);
     EXPECT_EQ(testLayer.get(), child4->parent());
 
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
 
     ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size());
     EXPECT_EQ(m_child1, m_parent->children()[0]);
@@ -329,37 +437,47 @@ TEST_F(LayerChromiumTest, replaceChildWithNewChildThatHasOtherParent)
     // and child2 should no longer have a parent.
     ASSERT_EQ(static_cast<size_t>(0), testLayer->children().size());
     EXPECT_FALSE(m_child2->parent());
+
+    // parent's destructor will invoke notifySyncRequired as it removes leftover children
+    EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));
 }
 
 TEST_F(LayerChromiumTest, replaceChildWithSameChild)
 {
     createSimpleTestTree();
 
-    // setNeedsCommit should not be called because its the same child
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, m_parent->replaceChild(m_child2.get(), m_child2));
+    // notifySyncRequired should not be called because its the same child
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, 0, m_parent->replaceChild(m_child2.get(), m_child2));
 
     verifyTestTreeInitialState();
+
+    // parent's destructor will invoke notifySyncRequired as it removes leftover children
+    EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));
 }
 
 TEST_F(LayerChromiumTest, removeAllChildren)
 {
     createSimpleTestTree();
 
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(3), m_parent->removeAllChildren());
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, AtLeast(1), m_parent->removeAllChildren());
 
     ASSERT_EQ(static_cast<size_t>(0), m_parent->children().size());
     EXPECT_FALSE(m_child1->parent());
     EXPECT_FALSE(m_child2->parent());
     EXPECT_FALSE(m_child3->parent());
+
+    // notifySyncRequired should not be called if trying to removeAllChildren when there are no children.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, 0, m_parent->removeAllChildren());
 }
 
 TEST_F(LayerChromiumTest, setChildren)
 {
-    RefPtr<LayerChromium> oldParent = LayerChromium::create(0);
-    RefPtr<LayerChromium> newParent = LayerChromium::create(0);
+    MockLayerDelegate newParentDelegate;
+    RefPtr<LayerChromium> oldParent = LayerChromium::create(&m_silentDelegate);
+    RefPtr<LayerChromium> newParent = LayerChromium::create(&newParentDelegate);
 
-    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
-    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
+    RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate);
+    RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate);
 
     Vector<RefPtr<LayerChromium> > newChildren;
     newChildren.append(child1);
@@ -371,25 +489,23 @@ TEST_F(LayerChromiumTest, setChildren)
     EXPECT_EQ(oldParent.get(), child1->parent());
     EXPECT_FALSE(child2->parent());
 
-    newParent->setLayerTreeHost(m_layerTreeHost.get());
-
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), newParent->setChildren(newChildren));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(newParentDelegate, AtLeast(1), newParent->setChildren(newChildren));
 
     ASSERT_EQ(static_cast<size_t>(2), newParent->children().size());
     EXPECT_EQ(newParent.get(), child1->parent());
     EXPECT_EQ(newParent.get(), child2->parent());
 
-    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
+    // parent's destructor will invoke notifySyncRequired as it removes its children.
+    EXPECT_CALL(newParentDelegate, notifySyncRequired()).Times(AtLeast(1));
 }
 
 TEST_F(LayerChromiumTest, getRootLayerAfterTreeManipulations)
 {
     createSimpleTestTree();
+    RefPtr<LayerChromium> child4 = LayerChromium::create(&m_silentDelegate);
 
-    // For this test we don't care about setNeedsCommit calls.
-    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
-
-    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
+    // In this test case, we don't care about how the parent's notifySyncRequired is called.
+    EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AnyNumber());
 
     EXPECT_EQ(m_parent.get(), m_parent->rootLayer());
     EXPECT_EQ(m_parent.get(), m_child1->rootLayer());
@@ -444,11 +560,10 @@ TEST_F(LayerChromiumTest, checkSetNeedsDisplayCausesCorrectBehavior)
 {
     // The semantics for setNeedsDisplay which are tested here:
     //   1. sets needsDisplay flag appropriately.
-    //   2. indirectly calls setNeedsCommit, exactly once for each call to setNeedsDisplay.
-
-    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
-    testLayer->setLayerTreeHost(m_layerTreeHost.get());
+    //   2. indirectly calls notifySyncRequired, exactly once for each call to setNeedsDisplay.
 
+    MockLayerDelegate mockDelegate;
+    RefPtr<LayerChromium> testLayer = LayerChromium::create(&mockDelegate);
     IntSize testBounds = IntSize(501, 508);
 
     FloatRect dirty1 = FloatRect(10.0f, 15.0f, 1.0f, 2.0f);
@@ -459,43 +574,48 @@ TEST_F(LayerChromiumTest, checkSetNeedsDisplayCausesCorrectBehavior)
     // Before anything, testLayer should not be dirty.
     EXPECT_FALSE(testLayer->needsDisplay());
 
-    // This is just initialization, but setNeedsCommit behavior is verified anyway to avoid warnings.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
-    testLayer = LayerChromium::create(0);
-    testLayer->setLayerTreeHost(m_layerTreeHost.get());
+    // This is just initialization, but notifySyncRequired behavior is verified anyway to avoid warnings.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
+    testLayer = LayerChromium::create(&mockDelegate);
     EXPECT_FALSE(testLayer->needsDisplay());
 
     // The real test begins here.
 
     // Case 1: needsDisplay flag should not change because of an empty dirty rect.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(emptyDirtyRect));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(emptyDirtyRect));
     EXPECT_FALSE(testLayer->needsDisplay());
 
     // Case 2: basic.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(dirty1));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(dirty1));
     EXPECT_TRUE(testLayer->needsDisplay());
 
     // Case 3: a second dirty rect.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(dirty2));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(dirty2));
     EXPECT_TRUE(testLayer->needsDisplay());
 
     // Case 4: LayerChromium should accept dirty rects that go beyond its bounds.
-    testLayer = LayerChromium::create(0);
-    testLayer->setLayerTreeHost(m_layerTreeHost.get());
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect));
+    testLayer = LayerChromium::create(&mockDelegate);
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect));
     EXPECT_TRUE(testLayer->needsDisplay());
 
     // Case 5: setNeedsDisplay() without the dirty rect arg.
-    testLayer = LayerChromium::create(0);
-    testLayer->setLayerTreeHost(m_layerTreeHost.get());
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplay());
+    testLayer = LayerChromium::create(&mockDelegate);
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay());
     EXPECT_TRUE(testLayer->needsDisplay());
+
+    // Case 6: setNeedsDisplay() without the dirty rect arg should not cause
+    // needsDisplay flag to change for LayerChromium with empty bounds.
+    testLayer = LayerChromium::create(&mockDelegate);
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay());
+    EXPECT_FALSE(testLayer->needsDisplay());
 }
 
 TEST_F(LayerChromiumTest, checkSetNeedsDisplayWithNullDelegate)
 {
+    // Without a delegate, the layer should still mark itself dirty as appropriate,
+    // and it should not crash trying to use a non-existing delegate.
     RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
     IntSize testBounds = IntSize(501, 508);
 
@@ -513,50 +633,72 @@ TEST_F(LayerChromiumTest, checkSetNeedsDisplayWithNullDelegate)
 
 TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior)
 {
-    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
-    testLayer->setLayerTreeHost(m_layerTreeHost.get());
-
-    RefPtr<LayerChromium> dummyLayer = LayerChromium::create(0); // just a dummy layer for this test case.
+    MockLayerDelegate initialDelegate;
+    MockLayerDelegate mockDelegate;
+    RefPtr<LayerChromium> testLayer = LayerChromium::create(&initialDelegate);
+    RefPtr<LayerChromium> dummyLayer = LayerChromium::create(&m_silentDelegate); // just a dummy layer for this test case.
 
     // sanity check of initial test condition
     EXPECT_FALSE(testLayer->needsDisplay());
 
     // Test properties that should not call needsDisplay and needsCommit when changed.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setName("Test Layer"));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUsesLayerClipping(true));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setIsNonCompositedContent(true));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5f));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setClipRect(IntRect(3, 3, 8, 8)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setTargetRenderSurface(0));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(TransformationMatrix()));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(TransformationMatrix()));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7)));
+    // notifySyncRequired should not be called, and the needsDisplay flag should remain false.
+    EXPECT_CALL(initialDelegate, notifySyncRequired()).Times(0); // old delegate should not be used when setDelegate gives a new delegate.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDelegate(&mockDelegate));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setName("Test Layer"));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setUsesLayerClipping(true));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setIsNonCompositedContent(true));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawOpacity(0.5f));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setClipRect(IntRect(3, 3, 8, 8)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setTargetRenderSurface(0));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawTransform(TransformationMatrix()));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setScreenSpaceTransform(TransformationMatrix()));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7)));
     EXPECT_FALSE(testLayer->needsDisplay());
 
     // Next, test properties that should call setNeedsCommit (but not setNeedsDisplay)
-    // All properties need to be set to new values in order for setNeedsCommit to be called.
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPointZ(0.7f));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMasksToBounds(true));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMaskLayer(dummyLayer.get()));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5f));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpaque(true));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(FloatPoint(4.0f, 9.0f)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get()));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
+    // These properties should indirectly call notifySyncRequired, but the needsDisplay flag should not change.
+    // All properties need to be set to new values in order for setNeedsCommit
+    // to be called.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPointZ(0.7f));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMasksToBounds(true));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMaskLayer(dummyLayer.get()));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpacity(0.5f));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpaque(true));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setPosition(FloatPoint(4.0f, 9.0f)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setReplicaLayer(dummyLayer.get()));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setScrollable(true));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setScrollPosition(IntPoint(10, 10)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setDoubleSided(false));
 
     // The above tests should not have caused a change to the needsDisplay flag.
     EXPECT_FALSE(testLayer->needsDisplay());
 
-    // Test properties that should call setNeedsDisplay and setNeedsCommit
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(IntSize(5, 10)));
+    // Test properties that should call setNeedsDisplay
+    // These properties will call notifySyncRequired and change the needsDisplay flag.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(IntSize(5, 10)));
     EXPECT_TRUE(testLayer->needsDisplay());
+
+    // FIXME: need to add a test for setLayerTreeHost with a non-null stubbed CCLayerTreeHost.
+}
+
+TEST_F(LayerChromiumTest, checkNonCompositedContentPropertyChangeCausesCommit)
+{
+    OwnPtr<MockNonCompositedContentHost> nonCompositedContentHost(MockNonCompositedContentHost::create());
+
+    GraphicsLayer* rootLayer = nonCompositedContentHost->topLevelRootLayer();
+
+    EXPECT_CALL(*nonCompositedContentHost, notifySyncRequired(_)).Times(1);
+    rootLayer->platformLayer()->setScrollPosition(IntPoint(1, 1));
+    Mock::VerifyAndClearExpectations(nonCompositedContentHost.get());
+
+    EXPECT_CALL(*nonCompositedContentHost, notifySyncRequired(_)).Times(AtLeast(1));
+    nonCompositedContentHost->setViewport(IntSize(30, 30), IntSize(20, 20), IntPoint(10, 10), 1);
 }
 
 class LayerChromiumWithContentScaling : public LayerChromium {
@@ -579,221 +721,17 @@ public:
 
 TEST_F(LayerChromiumTest, checkContentsScaleChangeTriggersNeedsDisplay)
 {
-    RefPtr<LayerChromiumWithContentScaling> testLayer = adoptRef(new LayerChromiumWithContentScaling(0));
-    testLayer->setLayerTreeHost(m_layerTreeHost.get());
+    MockLayerDelegate mockDelegate;
+    RefPtr<LayerChromiumWithContentScaling> testLayer = adoptRef(new LayerChromiumWithContentScaling(&mockDelegate));
 
     IntSize testBounds = IntSize(320, 240);
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
 
     testLayer->resetNeedsDisplay();
     EXPECT_FALSE(testLayer->needsDisplay());
 
-    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(testLayer->contentsScale() + 1.f));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setContentsScale(testLayer->contentsScale() + 1.f));
     EXPECT_TRUE(testLayer->needsDisplay());
 }
 
-class FakeCCLayerTreeHost : public CCLayerTreeHost {
-public:
-    static PassRefPtr<FakeCCLayerTreeHost> create()
-    {
-        RefPtr<FakeCCLayerTreeHost> host = adoptRef(new FakeCCLayerTreeHost);
-        // The initialize call will fail, since our client doesn't provide a valid GraphicsContext3D, but it doesn't matter in the tests that use this fake so ignore the return value.
-        host->initialize();
-        return host.release();
-    }
-
-private:
-    FakeCCLayerTreeHost()
-        : CCLayerTreeHost(&m_client, CCSettings())
-    {
-    }
-
-    FakeCCLayerTreeHostClient m_client;
-};
-
-void assertLayerTreeHostMatchesForSubtree(LayerChromium* layer, CCLayerTreeHost* host)
-{
-    EXPECT_EQ(host, layer->layerTreeHost());
-
-    for (size_t i = 0; i < layer->children().size(); ++i)
-        assertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host);
-
-    if (layer->maskLayer())
-        assertLayerTreeHostMatchesForSubtree(layer->maskLayer(), host);
-
-    if (layer->replicaLayer())
-        assertLayerTreeHostMatchesForSubtree(layer->replicaLayer(), host);
-}
-
-
-TEST(LayerChromiumLayerTreeHostTest, enteringTree)
-{
-    WebKit::WebCompositor::initialize(0);
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<LayerChromium> child = LayerChromium::create(0);
-    RefPtr<LayerChromium> mask = LayerChromium::create(0);
-    RefPtr<LayerChromium> replica = LayerChromium::create(0);
-    RefPtr<LayerChromium> replicaMask = LayerChromium::create(0);
-
-    // Set up a detached tree of layers. The host pointer should be nil for these layers.
-    parent->addChild(child);
-    child->setMaskLayer(mask.get());
-    child->setReplicaLayer(replica.get());
-    replica->setMaskLayer(mask.get());
-
-    assertLayerTreeHostMatchesForSubtree(parent.get(), 0);
-
-    RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create();
-    // Setting the root layer should set the host pointer for all layers in the tree.
-    layerTreeHost->setRootLayer(parent.get());
-
-    assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get());
-
-    // Clearing the root layer should also clear out the host pointers for all layers in the tree.
-    layerTreeHost->setRootLayer(0);
-
-    assertLayerTreeHostMatchesForSubtree(parent.get(), 0);
-
-    layerTreeHost.clear();
-    WebKit::WebCompositor::shutdown();
-}
-
-TEST(LayerChromiumLayerTreeHostTest, addingLayerSubtree)
-{
-    WebKit::WebCompositor::initialize(0);
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create();
-
-    layerTreeHost->setRootLayer(parent.get());
-
-    EXPECT_EQ(parent->layerTreeHost(), layerTreeHost.get());
-
-    // Adding a subtree to a layer already associated with a host should set the host pointer on all layers in that subtree.
-    RefPtr<LayerChromium> child = LayerChromium::create(0);
-    RefPtr<LayerChromium> grandChild = LayerChromium::create(0);
-    child->addChild(grandChild);
-
-    // Masks, replicas, and replica masks should pick up the new host too.
-    RefPtr<LayerChromium> childMask = LayerChromium::create(0);
-    child->setMaskLayer(childMask.get());
-    RefPtr<LayerChromium> childReplica = LayerChromium::create(0);
-    child->setReplicaLayer(childReplica.get());
-    RefPtr<LayerChromium> childReplicaMask = LayerChromium::create(0);
-    childReplica->setMaskLayer(childReplicaMask.get());
-
-    parent->addChild(child);
-    assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get());
-
-    layerTreeHost->setRootLayer(0);
-    layerTreeHost.clear();
-    WebKit::WebCompositor::shutdown();
-}
-
-TEST(LayerChromiumLayerTreeHostTest, changeHost)
-{
-    WebKit::WebCompositor::initialize(0);
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<LayerChromium> child = LayerChromium::create(0);
-    RefPtr<LayerChromium> mask = LayerChromium::create(0);
-    RefPtr<LayerChromium> replica = LayerChromium::create(0);
-    RefPtr<LayerChromium> replicaMask = LayerChromium::create(0);
-
-    // Same setup as the previous test.
-    parent->addChild(child);
-    child->setMaskLayer(mask.get());
-    child->setReplicaLayer(replica.get());
-    replica->setMaskLayer(mask.get());
-
-    RefPtr<FakeCCLayerTreeHost> firstLayerTreeHost = FakeCCLayerTreeHost::create();
-    firstLayerTreeHost->setRootLayer(parent.get());
-
-    assertLayerTreeHostMatchesForSubtree(parent.get(), firstLayerTreeHost.get());
-
-    // Now re-root the tree to a new host (simulating what we do on a context lost event).
-    // This should update the host pointers for all layers in the tree.
-    RefPtr<FakeCCLayerTreeHost> secondLayerTreeHost = FakeCCLayerTreeHost::create();
-    secondLayerTreeHost->setRootLayer(parent.get());
-
-    assertLayerTreeHostMatchesForSubtree(parent.get(), secondLayerTreeHost.get());
-
-    secondLayerTreeHost->setRootLayer(0);
-    firstLayerTreeHost.clear();
-    secondLayerTreeHost.clear();
-    WebKit::WebCompositor::shutdown();
-}
-
-TEST(LayerChromiumLayerTreeHostTest, changeHostInSubtree)
-{
-    WebKit::WebCompositor::initialize(0);
-    RefPtr<LayerChromium> firstParent = LayerChromium::create(0);
-    RefPtr<LayerChromium> firstChild = LayerChromium::create(0);
-    RefPtr<LayerChromium> secondParent = LayerChromium::create(0);
-    RefPtr<LayerChromium> secondChild = LayerChromium::create(0);
-    RefPtr<LayerChromium> secondGrandChild = LayerChromium::create(0);
-
-    // First put all children under the first parent and set the first host.
-    firstParent->addChild(firstChild);
-    secondChild->addChild(secondGrandChild);
-    firstParent->addChild(secondChild);
-
-    RefPtr<FakeCCLayerTreeHost> firstLayerTreeHost = FakeCCLayerTreeHost::create();
-    firstLayerTreeHost->setRootLayer(firstParent.get());
-
-    assertLayerTreeHostMatchesForSubtree(firstParent.get(), firstLayerTreeHost.get());
-
-    // Now reparent the subtree starting at secondChild to a layer in a different tree.
-    RefPtr<FakeCCLayerTreeHost> secondLayerTreeHost = FakeCCLayerTreeHost::create();
-    secondLayerTreeHost->setRootLayer(secondParent.get());
-
-    secondParent->addChild(secondChild);
-
-    // The moved layer and its children should point to the new host.
-    EXPECT_EQ(secondLayerTreeHost.get(), secondChild->layerTreeHost());
-    EXPECT_EQ(secondLayerTreeHost.get(), secondGrandChild->layerTreeHost());
-
-    // Test over, cleanup time.
-    firstLayerTreeHost->setRootLayer(0);
-    secondLayerTreeHost->setRootLayer(0);
-    firstLayerTreeHost.clear();
-    secondLayerTreeHost.clear();
-    WebKit::WebCompositor::shutdown();
-}
-
-TEST(LayerChromiumLayerTreeHostTest, replaceMaskAndReplicaLayer)
-{
-    WebKit::WebCompositor::initialize(0);
-    RefPtr<LayerChromium> parent = LayerChromium::create(0);
-    RefPtr<LayerChromium> mask = LayerChromium::create(0);
-    RefPtr<LayerChromium> replica = LayerChromium::create(0);
-    RefPtr<LayerChromium> maskChild = LayerChromium::create(0);
-    RefPtr<LayerChromium> replicaChild = LayerChromium::create(0);
-    RefPtr<LayerChromium> maskReplacement = LayerChromium::create(0);
-    RefPtr<LayerChromium> replicaReplacement = LayerChromium::create(0);
-
-    parent->setMaskLayer(mask.get());
-    parent->setReplicaLayer(replica.get());
-    mask->addChild(maskChild);
-    replica->addChild(replicaChild);
-
-    RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create();
-    layerTreeHost->setRootLayer(parent.get());
-
-    assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get());
-
-    // Replacing the mask should clear out the old mask's subtree's host pointers.
-    parent->setMaskLayer(maskReplacement.get());
-    EXPECT_EQ(0, mask->layerTreeHost());
-    EXPECT_EQ(0, maskChild->layerTreeHost());
-
-    // Same for replacing a replica layer.
-    parent->setReplicaLayer(replicaReplacement.get());
-    EXPECT_EQ(0, replica->layerTreeHost());
-    EXPECT_EQ(0, replicaChild->layerTreeHost());
-
-    // Test over, cleanup time.
-    layerTreeHost->setRootLayer(0);
-    layerTreeHost.clear();
-    WebKit::WebCompositor::shutdown();
-}
-
 } // namespace
similarity index 89%
rename from Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
rename to Source/WebKit/chromium/tests/MockGraphicsContext3DTest.cpp
index 636d6be6e2cce041ea05b561c43b0039986efafb..a3746c7544fe395acd49ae63a0581c002248a2d9 100644 (file)
@@ -27,8 +27,8 @@
 
 #include "GraphicsContext3D.h"
 
-#include "FakeWebGraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
+#include "MockWebGraphicsContext3D.h"
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
@@ -37,7 +37,7 @@ using namespace WebCore;
 using namespace WebKit;
 using namespace testing;
 
-class FrameCountingContext : public FakeWebGraphicsContext3D {
+class FrameCountingContext : public MockWebGraphicsContext3D {
 public:
     FrameCountingContext() : m_frame(0) { }
 
@@ -50,7 +50,7 @@ private:
     int m_frame;
 };
 
-TEST(FakeGraphicsContext3DTest, CanOverrideManually)
+TEST(MockGraphicsContext3DTest, CanOverrideManually)
 {
     GraphicsContext3D::Attributes attrs;
     RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);
@@ -66,12 +66,12 @@ TEST(FakeGraphicsContext3DTest, CanOverrideManually)
 }
 
 
-class GMockContext : public FakeWebGraphicsContext3D {
+class GMockContext : public MockWebGraphicsContext3D {
 public:
     MOCK_METHOD0(getError, WGC3Denum());
 };
 
-TEST(FakeGraphicsContext3DTest, CanUseGMock)
+TEST(MockGraphicsContext3DTest, CanUseGMock)
 {
     GraphicsContext3D::Attributes attrs;
     RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new GMockContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);
@@ -88,7 +88,7 @@ TEST(FakeGraphicsContext3DTest, CanUseGMock)
         EXPECT_EQ((int)context->getError(), 314);
 }
 
-class ContextThatCountsMakeCurrents : public FakeWebGraphicsContext3D {
+class ContextThatCountsMakeCurrents : public MockWebGraphicsContext3D {
 public:
     ContextThatCountsMakeCurrents() : m_makeCurrentCount(0) { }
     virtual bool makeContextCurrent()
@@ -102,7 +102,7 @@ private:
 };
 
 
-TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
+TEST(MockGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
 {
     GraphicsContext3D::Attributes attrs;
     RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);
@@ -111,7 +111,7 @@ TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
     EXPECT_EQ(1, mockContext.makeCurrentCount());
 }
 
-TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
+TEST(MockGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
 {
     GraphicsContext3D::Attributes attrs;
     RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnAnotherThread);
@@ -120,13 +120,13 @@ TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
     EXPECT_EQ(0, mockContext.makeCurrentCount());
 }
 
-class ContextWithMakeCurrentThatFails : public FakeWebGraphicsContext3D {
+class ContextWithMakeCurrentThatFails : public MockWebGraphicsContext3D {
 public:
     ContextWithMakeCurrentThatFails() { }
     virtual bool makeContextCurrent() { return false; }
 };
 
-TEST(FakeGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails)
+TEST(MockGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails)
 {
     GraphicsContext3D::Attributes attrs;
     RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextWithMakeCurrentThatFails()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);
similarity index 98%
rename from Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h
rename to Source/WebKit/chromium/tests/MockWebGraphicsContext3D.h
index cf0651b77032bd80e583c668277462886055ddb8..494b622551bd7b9d673ac2039b5c184a84b8fcb0 100644 (file)
@@ -23,8 +23,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef FakeWebGraphicsContext3D_h
-#define FakeWebGraphicsContext3D_h
+#ifndef MockWebGraphicsContext3D_h
+#define MockWebGraphicsContext3D_h
 
 #include "GraphicsContext3D.h"
 #include "platform/WebGraphicsContext3D.h"
@@ -33,7 +33,7 @@ namespace WebKit {
 
 // WebGraphicsContext3D base class for use in WebKit unit tests.
 // All operations are no-ops (returning 0 if necessary).
-class FakeWebGraphicsContext3D : public WebGraphicsContext3D {
+class MockWebGraphicsContext3D : public WebGraphicsContext3D {
 public:
     virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return false; }
 
@@ -128,7 +128,7 @@ public:
     virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) { return 0; }
     virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { }
     virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) { }
-    virtual Attributes getContextAttributes() { return m_attrs; }
+    virtual Attributes getContextAttributes() { return Attributes(); }
     virtual WGC3Denum getError() { return 0; }
     virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { }
     virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum attachment, WGC3Denum pname, WGC3Dint* value) { }
@@ -254,11 +254,8 @@ public:
 
     virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
                                  WGC3Dint width, WGC3Dint height) { }
-
-protected:
-    Attributes m_attrs;
 };
 
 } // namespace WebKit
 
-#endif // FakeWebGraphicsContext3D_h
+#endif // MockWebGraphicsContext3D_h
index 66ea690fab3fb54aa832c9a2aa81cb9c59322b3a..24cb527191187ad8e9d680ba6111a22af943559d 100644 (file)
@@ -26,8 +26,9 @@
 
 #include "WebGLLayerChromium.h"
 
-#include "CompositorFakeGraphicsContext3D.h"
 #include "DrawingBuffer.h"
+#include "GraphicsContext3DPrivate.h"
+#include "MockWebGraphicsContext3D.h"
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
@@ -36,6 +37,32 @@ using namespace WebKit;
 
 namespace {
 
+// Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.
+class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {
+public:
+    static PassOwnPtr<CompositorMockWebGraphicsContext3D> create(GraphicsContext3D::Attributes attrs) { return adoptPtr(new CompositorMockWebGraphicsContext3D(attrs)); }
+    virtual bool makeContextCurrent() { return true; }
+    virtual WebGLId createProgram() { return 1; }
+    virtual WebGLId createShader(WGC3Denum) { return 1; }
+    virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
+    virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
+    virtual WebGraphicsContext3D::Attributes getContextAttributes() { return m_attrs; }
+
+private:
+    CompositorMockWebGraphicsContext3D(GraphicsContext3D::Attributes attrs) { m_attrs.alpha = attrs.alpha; }
+
+    WebGraphicsContext3D::Attributes m_attrs;
+};
+
+static PassRefPtr<GraphicsContext3D> createGraphicsContext(GraphicsContext3D::Attributes attrs)
+{
+    OwnPtr<WebGraphicsContext3D> webContext = CompositorMockWebGraphicsContext3D::create(attrs);
+    return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(
+        webContext.release(), attrs, 0,
+        GraphicsContext3D::RenderDirectlyToHostWindow,
+        GraphicsContext3DPrivate::ForUseOnAnotherThread);
+}
+
 TEST(WebGLLayerChromiumTest, opaqueFormats)
 {
     RefPtr<DrawingBuffer> buffer;
@@ -45,9 +72,9 @@ TEST(WebGLLayerChromiumTest, opaqueFormats)
     GraphicsContext3D::Attributes opaqueAttrs;
     opaqueAttrs.alpha = false;
 
-    RefPtr<GraphicsContext3D> alphaContext = createCompositorMockGraphicsContext3D(alphaAttrs);
+    RefPtr<GraphicsContext3D> alphaContext = createGraphicsContext(alphaAttrs);
     EXPECT_TRUE(alphaContext);
-    RefPtr<GraphicsContext3D> opaqueContext = createCompositorMockGraphicsContext3D(opaqueAttrs);
+    RefPtr<GraphicsContext3D> opaqueContext = createGraphicsContext(opaqueAttrs);
     EXPECT_TRUE(opaqueContext);
 
     buffer = DrawingBuffer::create(alphaContext.get(), IntSize(), false);
index 367c066ba598b6f358ee748aa19bd8ef7038aa32..1589881d210ea93cad475d25c967d2b876728e38 100644 (file)
 #include "config.h"
 #include "platform/WebLayer.h"
 
-#include "CompositorFakeWebGraphicsContext3D.h"
-#include "WebCompositor.h"
-#include "platform/WebContentLayer.h"
-#include "platform/WebContentLayerClient.h"
-#include "platform/WebExternalTextureLayer.h"
 #include "platform/WebFloatPoint.h"
 #include "platform/WebFloatRect.h"
-#include "platform/WebLayerTreeView.h"
-#include "platform/WebLayerTreeViewClient.h"
 #include "platform/WebRect.h"
 #include "platform/WebSize.h"
+#include "platform/WebContentLayer.h"
+#include "platform/WebContentLayerClient.h"
+#include "platform/WebExternalTextureLayer.h"
+#include "platform/WebLayerClient.h"
 
 #include <gmock/gmock.h>
 
@@ -44,14 +41,9 @@ using namespace testing;
 
 namespace {
 
-class MockWebLayerTreeViewClient : public WebLayerTreeViewClient {
+class MockWebLayerClient : public WebLayerClient {
 public:
-    MOCK_METHOD0(scheduleComposite, void());
-
-    virtual void animateAndLayout(double frameBeginTime) { }
-    virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { }
-    virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
-    virtual void didRebindGraphicsContext(bool success) { }
+    MOCK_METHOD0(notifyNeedsComposite, void());
 };
 
 class MockWebContentLayerClient : public WebContentLayerClient {
@@ -61,30 +53,7 @@ public:
 
 class WebLayerTest : public Test {
 public:
-    virtual void SetUp()
-    {
-        // Initialize without threading support.
-        WebKit::WebCompositor::initialize(0);
-        m_rootLayer = WebLayer::create();
-        EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
-        m_view = WebLayerTreeView::create(&m_client, m_rootLayer, WebLayerTreeView::Settings());
-        Mock::VerifyAndClearExpectations(&m_client);
-    }
-
-    virtual void TearDown()
-    {
-        // We may get any number of scheduleComposite calls during shutdown.
-        EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
-        m_view.setRootLayer(0);
-        m_rootLayer.reset();
-        m_view.reset();
-        WebKit::WebCompositor::shutdown();
-    }
-
-protected:
-    MockWebLayerTreeViewClient m_client;
-    WebLayer m_rootLayer;
-    WebLayerTreeView m_view;
+    WebLayerTest() { }
 };
 
 // Tests that the client gets called to ask for a composite if we change the
@@ -92,100 +61,99 @@ protected:
 TEST_F(WebLayerTest, Client)
 {
     // Base layer.
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
-    WebLayer layer = WebLayer::create();
-    m_rootLayer.addChild(layer);
-    Mock::VerifyAndClearExpectations(&m_client);
+    MockWebLayerClient client;
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebLayer layer = WebLayer::create(&client);
+    Mock::VerifyAndClearExpectations(&client);
 
     WebFloatPoint point(3, 4);
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     layer.setAnchorPoint(point);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_EQ(point, layer.anchorPoint());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     float anchorZ = 5;
     layer.setAnchorPointZ(anchorZ);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_EQ(anchorZ, layer.anchorPointZ());
 
     WebSize size(7, 8);
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     layer.setBounds(size);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_EQ(size, layer.bounds());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     layer.setMasksToBounds(true);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_TRUE(layer.masksToBounds());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
-    WebLayer otherLayer = WebLayer::create();
-    m_rootLayer.addChild(otherLayer);
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    MockWebLayerClient otherClient;
+    EXPECT_CALL(otherClient, notifyNeedsComposite()).Times(AnyNumber());
+    WebLayer otherLayer = WebLayer::create(&otherClient);
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     layer.setMaskLayer(otherLayer);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_EQ(otherLayer, layer.maskLayer());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     float opacity = 0.123;
     layer.setOpacity(opacity);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_EQ(opacity, layer.opacity());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     layer.setOpaque(true);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_TRUE(layer.opaque());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     layer.setPosition(point);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_EQ(point, layer.position());
 
     // Texture layer.
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
-    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create();
-    m_rootLayer.addChild(textureLayer);
-    Mock::VerifyAndClearExpectations(&m_client);
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(&client);
+    Mock::VerifyAndClearExpectations(&client);
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     textureLayer.setTextureId(3);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_EQ(3u, textureLayer.textureId());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     textureLayer.setFlipped(true);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_TRUE(textureLayer.flipped());
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     WebFloatRect uvRect(0.1, 0.1, 0.9, 0.9);
     textureLayer.setUVRect(uvRect);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_TRUE(textureLayer.flipped());
 
 
     // Content layer.
     MockWebContentLayerClient contentClient;
     EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber());
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
-    WebContentLayer contentLayer = WebContentLayer::create(&contentClient);
-    m_rootLayer.addChild(contentLayer);
-    Mock::VerifyAndClearExpectations(&m_client);
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebContentLayer contentLayer = WebContentLayer::create(&client, &contentClient);
+    Mock::VerifyAndClearExpectations(&client);
 
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     contentLayer.setDrawsContent(false);
-    Mock::VerifyAndClearExpectations(&m_client);
+    Mock::VerifyAndClearExpectations(&client);
     EXPECT_FALSE(contentLayer.drawsContent());
 }
 
 TEST_F(WebLayerTest, Hierarchy)
 {
-    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
-    WebLayer layer1 = WebLayer::create();
-    WebLayer layer2 = WebLayer::create();
+    MockWebLayerClient client;
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebLayer layer1 = WebLayer::create(&client);
+    WebLayer layer2 = WebLayer::create(&client);
 
     EXPECT_TRUE(layer1.parent().isNull());
     EXPECT_TRUE(layer2.parent().isNull());
@@ -204,8 +172,8 @@ TEST_F(WebLayerTest, Hierarchy)
 
     MockWebContentLayerClient contentClient;
     EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber());
-    WebContentLayer contentLayer = WebContentLayer::create(&contentClient);
-    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create();
+    WebContentLayer contentLayer = WebContentLayer::create(&client, &contentClient);
+    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(&client);
 
     textureLayer.addChild(contentLayer);
     contentLayer.addChild(layer1);