diff options
-rw-r--r-- | cc/gl_renderer.cc | 3 | ||||
-rw-r--r-- | cc/layer_tree_host.cc | 25 | ||||
-rw-r--r-- | cc/layer_tree_host.h | 3 | ||||
-rw-r--r-- | cc/layer_tree_host_unittest.cc | 94 | ||||
-rw-r--r-- | cc/software_renderer.cc | 2 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_client.cc | 4 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_client.h | 8 | ||||
-rw-r--r-- | cc/test/fake_proxy.cc | 22 | ||||
-rw-r--r-- | cc/test/fake_proxy.h | 4 |
9 files changed, 153 insertions, 12 deletions
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index 9fa72f2..e02eb4b 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -129,6 +129,9 @@ bool GLRenderer::initialize() GLC(m_context, m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_capabilities.maxTextureSize)); m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context, extensions.count("GL_EXT_texture_format_BGRA8888")); + // The updater can access textures while the GLRenderer is using them. + m_capabilities.allowPartialTextureUpdates = true; + m_isUsingBindUniform = extensions.count("GL_CHROMIUM_bind_uniform_location"); // Make sure scissoring starts as disabled. diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index ea36c7d..d372a2e 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -155,6 +155,7 @@ RendererCapabilities::RendererCapabilities() , usingGpuMemoryManager(false) , usingDiscardFramebuffer(false) , usingEglImage(false) + , allowPartialTextureUpdates(false) , maxTextureSize(0) { } @@ -204,14 +205,23 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) { - TRACE_EVENT0("cc", "LayerTreeHost::initialize"); - if (implThread) - m_proxy = ThreadProxy::create(this, implThread.Pass()); + return initializeProxy(ThreadProxy::create(this, implThread.Pass())); else - m_proxy = SingleThreadProxy::create(this); - m_proxy->start(); + return initializeProxy(SingleThreadProxy::create(this)); +} +bool LayerTreeHost::initializeForTesting(scoped_ptr<Proxy> proxyForTesting) +{ + return initializeProxy(proxyForTesting.Pass()); +} + +bool LayerTreeHost::initializeProxy(scoped_ptr<Proxy> proxy) +{ + TRACE_EVENT0("cc", "LayerTreeHost::initializeForReal"); + + m_proxy = proxy.Pass(); + m_proxy->start(); return m_proxy->initializeContext(); } @@ -247,7 +257,10 @@ void LayerTreeHost::initializeRenderer() m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceleratedPainting; // Update m_settings based on partial update capability. - m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates()); + size_t maxPartialTextureUpdates = 0; + if (m_proxy->rendererCapabilities().allowPartialTextureUpdates) + maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates()); + m_settings.maxPartialTextureUpdates = maxPartialTextureUpdates; m_contentsTextureManager = PrioritizedResourceManager::create(Renderer::ContentPool, m_proxy.get()); m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Size(), GL_RGBA); diff --git a/cc/layer_tree_host.h b/cc/layer_tree_host.h index 6d58d46..0e7bab5 100644 --- a/cc/layer_tree_host.h +++ b/cc/layer_tree_host.h @@ -110,6 +110,7 @@ struct CC_EXPORT RendererCapabilities { bool usingGpuMemoryManager; bool usingDiscardFramebuffer; bool usingEglImage; + bool allowPartialTextureUpdates; int maxTextureSize; }; @@ -246,10 +247,12 @@ public: protected: LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); bool initialize(scoped_ptr<Thread> implThread); + bool initializeForTesting(scoped_ptr<Proxy> proxyForTesting); private: typedef std::vector<scoped_refptr<Layer> > LayerList; + bool initializeProxy(scoped_ptr<Proxy> proxy); void initializeRenderer(); void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index ea6a1b9..3752537 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -11,6 +11,8 @@ #include "cc/layer_tree_host_impl.h" #include "cc/single_thread_proxy.h" #include "cc/test/fake_content_layer_client.h" +#include "cc/test/fake_layer_tree_host_client.h" +#include "cc/test/fake_proxy.h" #include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_tree_test_common.h" @@ -3262,5 +3264,97 @@ TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) runTest(true); } +class LayerTreeHostWithProxy : public LayerTreeHost { +public: + LayerTreeHostWithProxy(FakeLayerImplTreeHostClient* client, const LayerTreeSettings& settings, scoped_ptr<Proxy> proxy) + : LayerTreeHost(client, settings) + { + EXPECT_TRUE(initializeForTesting(proxy.Pass())); + } + +private: + FakeLayerImplTreeHostClient m_client; +}; + +TEST(LayerTreeHostTest, LimitPartialUpdates) +{ + // When partial updates are not allowed, max updates should be 0. + { + FakeLayerImplTreeHostClient client; + + scoped_ptr<FakeProxy> proxy = make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); + proxy->rendererCapabilities().allowPartialTextureUpdates = false; + proxy->setMaxPartialTextureUpdates(5); + + LayerTreeSettings settings; + settings.maxPartialTextureUpdates = 10; + + LayerTreeHostWithProxy host(&client, settings, proxy.PassAs<Proxy>()); + EXPECT_TRUE(host.initializeRendererIfNeeded()); + + EXPECT_EQ(0u, host.settings().maxPartialTextureUpdates); + } + + // When partial updates are allowed, max updates should be limited by the proxy. + { + FakeLayerImplTreeHostClient client; + + scoped_ptr<FakeProxy> proxy = make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); + proxy->rendererCapabilities().allowPartialTextureUpdates = true; + proxy->setMaxPartialTextureUpdates(5); + + LayerTreeSettings settings; + settings.maxPartialTextureUpdates = 10; + + LayerTreeHostWithProxy host(&client, settings, proxy.PassAs<Proxy>()); + EXPECT_TRUE(host.initializeRendererIfNeeded()); + + EXPECT_EQ(5u, host.settings().maxPartialTextureUpdates); + } + + // When partial updates are allowed, max updates should also be limited by the settings. + { + FakeLayerImplTreeHostClient client; + + scoped_ptr<FakeProxy> proxy = make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); + proxy->rendererCapabilities().allowPartialTextureUpdates = true; + proxy->setMaxPartialTextureUpdates(20); + + LayerTreeSettings settings; + settings.maxPartialTextureUpdates = 10; + + LayerTreeHostWithProxy host(&client, settings, proxy.PassAs<Proxy>()); + EXPECT_TRUE(host.initializeRendererIfNeeded()); + + EXPECT_EQ(10u, host.settings().maxPartialTextureUpdates); + } +} + +TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) +{ + bool useSoftwareRendering = false; + FakeLayerImplTreeHostClient client(useSoftwareRendering); + + LayerTreeSettings settings; + settings.maxPartialTextureUpdates = 4; + + scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, scoped_ptr<Thread>()); + EXPECT_TRUE(host->initializeRendererIfNeeded()); + EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); +} + +TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) +{ + bool useSoftwareRendering = true; + FakeLayerImplTreeHostClient client(useSoftwareRendering); + + LayerTreeSettings settings; + settings.maxPartialTextureUpdates = 4; + + scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, scoped_ptr<Thread>()); + EXPECT_TRUE(host->initializeRendererIfNeeded()); + EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); +} + } // namespace } // namespace cc diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc index a2fd08a..cbfffe5 100644 --- a/cc/software_renderer.cc +++ b/cc/software_renderer.cc @@ -73,6 +73,8 @@ SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* res m_capabilities.bestTextureFormat = GL_RGBA; m_capabilities.contextHasCachedFrontBuffer = true; m_capabilities.usingSetVisibility = true; + // The updater can access bitmaps while the SoftwareRenderer is using them. + m_capabilities.allowPartialTextureUpdates = true; viewportChanged(); } diff --git a/cc/test/fake_layer_tree_host_client.cc b/cc/test/fake_layer_tree_host_client.cc index 030142b..a2833b3 100644 --- a/cc/test/fake_layer_tree_host_client.cc +++ b/cc/test/fake_layer_tree_host_client.cc @@ -8,6 +8,10 @@ namespace cc { scoped_ptr<WebKit::WebCompositorOutputSurface> FakeLayerImplTreeHostClient::createOutputSurface() { + if (m_useSoftwareRendering) { + return WebKit::FakeWebCompositorOutputSurface::createSoftware(make_scoped_ptr(new WebKit::FakeWebCompositorSoftwareOutputDevice).PassAs<WebKit::WebCompositorSoftwareOutputDevice>()).PassAs<WebKit::WebCompositorOutputSurface>(); + } + WebKit::WebGraphicsContext3D::Attributes attrs; return WebKit::FakeWebCompositorOutputSurface::create(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>(); } diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h index 321e926..8d0cfd6 100644 --- a/cc/test/fake_layer_tree_host_client.h +++ b/cc/test/fake_layer_tree_host_client.h @@ -15,6 +15,11 @@ namespace cc { class FakeLayerImplTreeHostClient : public LayerTreeHostClient { public: + FakeLayerImplTreeHostClient(bool useSoftwareRendering = false) + : m_useSoftwareRendering(useSoftwareRendering) + { + } + virtual void willBeginFrame() OVERRIDE { } virtual void didBeginFrame() OVERRIDE { } virtual void animate(double monotonicFrameBeginTime) OVERRIDE { } @@ -33,6 +38,9 @@ public: virtual void scheduleComposite() OVERRIDE { } virtual scoped_ptr<FontAtlas> createFontAtlas() OVERRIDE; + +private: + bool m_useSoftwareRendering; }; } diff --git a/cc/test/fake_proxy.cc b/cc/test/fake_proxy.cc index d6dbb40..d485056 100644 --- a/cc/test/fake_proxy.cc +++ b/cc/test/fake_proxy.cc @@ -8,27 +8,27 @@ namespace cc { bool FakeProxy::compositeAndReadback(void *pixels, const gfx::Rect&) { - return false; + return true; } bool FakeProxy::isStarted() const { - return false; + return true; } bool FakeProxy::initializeContext() { - return false; + return true; } bool FakeProxy::initializeRenderer() { - return false; + return true; } bool FakeProxy::recreateContext() { - return false; + return true; } const RendererCapabilities& FakeProxy::rendererCapabilities() const @@ -36,6 +36,11 @@ const RendererCapabilities& FakeProxy::rendererCapabilities() const return m_capabilities; } +RendererCapabilities& FakeProxy::rendererCapabilities() +{ + return m_capabilities; +} + bool FakeProxy::commitRequested() const { return false; @@ -43,7 +48,12 @@ bool FakeProxy::commitRequested() const size_t FakeProxy::maxPartialTextureUpdates() const { - return 0; + return m_maxPartialTextureUpdates; +} + +void FakeProxy::setMaxPartialTextureUpdates(size_t max) +{ + m_maxPartialTextureUpdates = max; } diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h index fdbc43d..3bbacb5 100644 --- a/cc/test/fake_proxy.h +++ b/cc/test/fake_proxy.h @@ -39,8 +39,12 @@ public: virtual void acquireLayerTextures() OVERRIDE { } virtual void loseContext() OVERRIDE { } + virtual RendererCapabilities& rendererCapabilities(); + void setMaxPartialTextureUpdates(size_t); + private: RendererCapabilities m_capabilities; + size_t m_maxPartialTextureUpdates; }; } // namespace cc |