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
+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
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.
+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
ContentLayerChromium::~ContentLayerChromium()
{
+ cleanupResources();
}
void ContentLayerChromium::cleanupResources()
paintGraphicsLayerContents(context, clip);
}
+void GraphicsLayerChromium::notifySyncRequired()
+{
+ if (m_client)
+ m_client->notifySyncRequired(this);
+}
+
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
// 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(); }
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());
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
{
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();
}
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
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.
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);
}
{
ASSERT(CCProxy::isMainThread());
TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0);
- ASSERT(m_proxy);
m_proxy->stop();
m_proxy.clear();
clearPendingUpdate();
void CCLayerTreeHost::didRecreateGraphicsContext(bool success)
{
- if (m_rootLayer) {
- m_rootLayer->setLayerTreeHost(0);
- m_rootLayer->setLayerTreeHost(this);
- }
+ if (rootLayer())
+ rootLayer()->cleanupResourcesRecursive();
m_client->didRecreateGraphicsContext(success);
}
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));
// 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);
}
ASSERT(renderSurface);
ASSERT(renderSurface->drawOpacity());
+ renderSurfaceLayer->setLayerTreeHost(this);
paintMaskAndReplicaForRenderSurface(renderSurfaceLayer, paintType);
const LayerList& layerList = renderSurface->layerList();
if (CCLayerTreeHostCommon::renderSurfaceContributesToTarget<LayerChromium>(layer, renderSurfaceLayer->id()))
continue;
+ layer->setLayerTreeHost(this);
ASSERT(!layer->bounds().isEmpty());
paintContentsIfDirty(layer, paintType);
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; }
+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
'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',
'tests/KeyboardTest.cpp',
'tests/KURLTest.cpp',
'tests/LayerChromiumTest.cpp',
+ 'tests/MockGraphicsContext3DTest.cpp',
+ 'tests/MockWebGraphicsContext3D.h',
'tests/PODArenaTest.cpp',
'tests/PODIntervalTreeTest.cpp',
'tests/PODRedBlackTreeTest.cpp',
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() { }
// 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() { }
class WebLayer {
public:
- WEBKIT_EXPORT static WebLayer create();
- // FIXME: Remove this constructor once downstream clients are updated.
WEBKIT_EXPORT static WebLayer create(WebLayerClient*);
WebLayer() { }
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() { }
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)
#include "WebContentLayerImpl.h"
#include "platform/WebContentLayerClient.h"
+#include "platform/WebLayerClient.h"
#include "platform/WebRect.h"
#include "GraphicsContext.h"
#include "platform/WebCanvas.h"
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)
{
m_contentClient->paintContents(canvas, WebRect(clip));
}
+void WebContentLayerImpl::notifySyncRequired()
+{
+ if (m_client)
+ m_client->notifyNeedsComposite();
+}
+
} // namespace WebKit
#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;
};
namespace WebKit {
-WebExternalTextureLayer WebExternalTextureLayer::create()
+WebExternalTextureLayer WebExternalTextureLayer::create(WebLayerClient* client)
{
- return WebExternalTextureLayer(WebExternalTextureLayerImpl::create());
+ return WebExternalTextureLayer(WebExternalTextureLayerImpl::create(client));
}
void WebExternalTextureLayer::setTextureId(unsigned id)
#include "config.h"
#include "WebExternalTextureLayerImpl.h"
+#include "platform/WebLayerClient.h"
#include "GraphicsContext.h"
#include "platform/WebCanvas.h"
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);
}
{
}
+void WebExternalTextureLayerImpl::notifySyncRequired()
+{
+ if (m_client)
+ m_client->notifyNeedsComposite();
+}
+
} // namespace WebKit
#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
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()
#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)
{
}
{
}
+void WebLayerImpl::notifySyncRequired()
+{
+ if (m_client)
+ m_client->notifyNeedsComposite();
+}
+
} // namespace WebKit
#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
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()
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);
#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>
EXPECT_TRUE(m_didRequestCommit);
}
-class BlendStateTrackerContext: public FakeWebGraphicsContext3D {
+class BlendStateTrackerContext: public MockWebGraphicsContext3D {
public:
BlendStateTrackerContext() : m_blend(false) { }
EXPECT_TRUE(layer2->drawn());
}
-class ReshapeTrackerContext: public FakeWebGraphicsContext3D {
+class ReshapeTrackerContext: public MockWebGraphicsContext3D {
public:
ReshapeTrackerContext() : m_reshapeCalled(false) { }
#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"
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)
}
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:
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()
virtual void beginTest()
{
// Kill the layerTreeHost immediately.
- m_layerTreeHost->setRootLayer(0);
+ m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
m_layerTreeHost.clear();
endTest();
postSetNeedsCommitToMainThread();
// Kill the layerTreeHost immediately.
- m_layerTreeHost->setRootLayer(0);
+ m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
m_layerTreeHost.clear();
endTest();
postSetNeedsRedrawToMainThread();
// Kill the layerTreeHost immediately.
- m_layerTreeHost->setRootLayer(0);
+ m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
m_layerTreeHost.clear();
endTest();
postSetNeedsCommitToMainThread();
}
- virtual void animateAndLayout(double frameBeginTime)
+ virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl)
{
LayerChromium* root = m_layerTreeHost->rootLayer();
if (!m_layerTreeHost->frameNumber())
virtual bool drawsContent() const { return true; }
virtual bool preserves3D() { return false; }
+ virtual void notifySyncRequired() { }
private:
CCLayerTreeHostTest* m_test;
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
#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
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]);
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]);
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());
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]);
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)
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]);
// 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);
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());
{
// 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);
// 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);
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 {
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
#include "GraphicsContext3D.h"
-#include "FakeWebGraphicsContext3D.h"
#include "GraphicsContext3DPrivate.h"
+#include "MockWebGraphicsContext3D.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using namespace WebKit;
using namespace testing;
-class FrameCountingContext : public FakeWebGraphicsContext3D {
+class FrameCountingContext : public MockWebGraphicsContext3D {
public:
FrameCountingContext() : m_frame(0) { }
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);
}
-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);
EXPECT_EQ((int)context->getError(), 314);
}
-class ContextThatCountsMakeCurrents : public FakeWebGraphicsContext3D {
+class ContextThatCountsMakeCurrents : public MockWebGraphicsContext3D {
public:
ContextThatCountsMakeCurrents() : m_makeCurrentCount(0) { }
virtual bool makeContextCurrent()
};
-TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
+TEST(MockGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
{
GraphicsContext3D::Attributes attrs;
RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);
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);
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);
* 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"
// 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; }
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) { }
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
#include "WebGLLayerChromium.h"
-#include "CompositorFakeGraphicsContext3D.h"
#include "DrawingBuffer.h"
+#include "GraphicsContext3DPrivate.h"
+#include "MockWebGraphicsContext3D.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
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;
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);
#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>
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 {
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
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());
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);