diff options
author | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-01 00:42:41 +0000 |
---|---|---|
committer | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-01 00:42:41 +0000 |
commit | 27664a514b029b131906e4e8b2246f7afb5b34cd (patch) | |
tree | 83845269db9094f758c5d02a8c1f33e1878269c7 | |
parent | 9c52413002109eed3ac64b2ec6c258dd67b2d941 (diff) | |
download | chromium_src-27664a514b029b131906e4e8b2246f7afb5b34cd.zip chromium_src-27664a514b029b131906e4e8b2246f7afb5b34cd.tar.gz chromium_src-27664a514b029b131906e4e8b2246f7afb5b34cd.tar.bz2 |
This change switches the compositor to the new WebLayerTreeViewClient::createFontAtlas() API. LayerTreeHost now manages whether a font atlas needs to be loaded.
commit order:
https://bugs.webkit.org/show_bug.cgi?id=102958
https://codereview.chromium.org/11413123
https://bugs.webkit.org/show_bug.cgi?id=102960
BUG=
Review URL: https://chromiumcodereview.appspot.com/11413123
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170614 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/heads_up_display_layer.cc | 3 | ||||
-rw-r--r-- | cc/heads_up_display_layer.h | 3 | ||||
-rw-r--r-- | cc/layer_tree_host.cc | 33 | ||||
-rw-r--r-- | cc/layer_tree_host.h | 6 | ||||
-rw-r--r-- | cc/layer_tree_host_client.h | 4 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_client.cc | 5 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_client.h | 3 | ||||
-rw-r--r-- | cc/test/layer_tree_test_common.cc | 7 | ||||
-rw-r--r-- | ui/compositor/compositor.cc | 5 | ||||
-rw-r--r-- | ui/compositor/compositor.h | 2 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_layer_tree_view_impl.cc | 16 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_layer_tree_view_impl.h | 4 |
12 files changed, 60 insertions, 31 deletions
diff --git a/cc/heads_up_display_layer.cc b/cc/heads_up_display_layer.cc index 5f7ba23..b3d85cd 100644 --- a/cc/heads_up_display_layer.cc +++ b/cc/heads_up_display_layer.cc @@ -17,6 +17,7 @@ scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::create() HeadsUpDisplayLayer::HeadsUpDisplayLayer() : Layer() + , m_hasFontAtlas(false) { setBounds(gfx::Size(256, 128)); } @@ -55,7 +56,7 @@ bool HeadsUpDisplayLayer::drawsContent() const void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) { m_fontAtlas = fontAtlas.Pass(); - setNeedsCommit(); + m_hasFontAtlas = true; } scoped_ptr<LayerImpl> HeadsUpDisplayLayer::createLayerImpl() diff --git a/cc/heads_up_display_layer.h b/cc/heads_up_display_layer.h index 52de0f4..ff276b5 100644 --- a/cc/heads_up_display_layer.h +++ b/cc/heads_up_display_layer.h @@ -23,6 +23,8 @@ public: virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE; virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; + bool hasFontAtlas() const { return m_hasFontAtlas; } + protected: HeadsUpDisplayLayer(); @@ -30,6 +32,7 @@ private: virtual ~HeadsUpDisplayLayer(); scoped_ptr<FontAtlas> m_fontAtlas; + bool m_hasFontAtlas; }; } // namespace cc diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index 30bae77..ed393fb 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -64,6 +64,11 @@ bool LayerTreeDebugState::showHudRects() const return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects || showNonOccludingRects; } +bool LayerTreeDebugState::hudNeedsFont() const +{ + return showFPSCounter || showPlatformLayerTree; +} + bool LayerTreeDebugState::equal(const LayerTreeDebugState& a, const LayerTreeDebugState& b) { return memcmp(&a, &b, sizeof(LayerTreeDebugState)) == 0; @@ -339,27 +344,23 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) m_commitNumber++; } -void LayerTreeHost::createHUDLayerIfNeeded() -{ - if (!m_hudLayer) - m_hudLayer = HeadsUpDisplayLayer::create(); -} - -void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) -{ - createHUDLayerIfNeeded(); - m_hudLayer->setFontAtlas(fontAtlas.Pass()); -} - void LayerTreeHost::willCommit() { m_client->willCommit(); - if (m_debugState.showHudInfo()) - createHUDLayerIfNeeded(); + if (m_debugState.showHudInfo()) { + if (!m_hudLayer) + m_hudLayer = HeadsUpDisplayLayer::create(); - if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) - m_rootLayer->addChild(m_hudLayer); + if (m_debugState.hudNeedsFont() && !m_hudLayer->hasFontAtlas()) + m_hudLayer->setFontAtlas(m_client->createFontAtlas()); + + if (m_rootLayer && !m_hudLayer->parent()) + m_rootLayer->addChild(m_hudLayer); + } else if (m_hudLayer) { + m_hudLayer->removeFromParent(); + m_hudLayer = 0; + } } void LayerTreeHost::commitComplete() diff --git a/cc/layer_tree_host.h b/cc/layer_tree_host.h index 6e8795f..fd73692 100644 --- a/cc/layer_tree_host.h +++ b/cc/layer_tree_host.h @@ -40,7 +40,6 @@ struct hash<WebKit::WebGraphicsContext3D*> { namespace cc { -class FontAtlas; class Layer; class LayerTreeHostImpl; class LayerTreeHostImplClient; @@ -68,6 +67,7 @@ struct CC_EXPORT LayerTreeDebugState { bool showHudInfo() const; bool showHudRects() const; + bool hudNeedsFont() const; static bool equal(const LayerTreeDebugState& a, const LayerTreeDebugState& b); static LayerTreeDebugState unite(const LayerTreeDebugState& a, const LayerTreeDebugState& b); @@ -237,8 +237,6 @@ public: void setDeviceScaleFactor(float); float deviceScaleFactor() const { return m_deviceScaleFactor; } - void setFontAtlas(scoped_ptr<FontAtlas>); - HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } Proxy* proxy() const { return m_proxy.get(); } @@ -268,8 +266,6 @@ private: bool animateLayersRecursive(Layer* current, base::TimeTicks time); void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base::Time wallClockTime); - void createHUDLayerIfNeeded(); - bool m_animating; bool m_needsAnimateLayers; diff --git a/cc/layer_tree_host_client.h b/cc/layer_tree_host_client.h index f6cb702..ad28443 100644 --- a/cc/layer_tree_host_client.h +++ b/cc/layer_tree_host_client.h @@ -16,6 +16,7 @@ class WebCompositorOutputSurface; } namespace cc { +class FontAtlas; class InputHandler; class LayerTreeHostClient { @@ -37,6 +38,9 @@ public: // Used only in the single-threaded path. virtual void scheduleComposite() = 0; + // Creates a font atlas to use for debug visualizations. + virtual scoped_ptr<FontAtlas> createFontAtlas() = 0; + protected: virtual ~LayerTreeHostClient() { } }; diff --git a/cc/test/fake_layer_tree_host_client.cc b/cc/test/fake_layer_tree_host_client.cc index cddece1..030142b 100644 --- a/cc/test/fake_layer_tree_host_client.cc +++ b/cc/test/fake_layer_tree_host_client.cc @@ -17,4 +17,9 @@ scoped_ptr<InputHandler> FakeLayerImplTreeHostClient::createInputHandler() return scoped_ptr<InputHandler>(); } +scoped_ptr<FontAtlas> FakeLayerImplTreeHostClient::createFontAtlas() +{ + return scoped_ptr<FontAtlas>(); +} + } diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h index 5ca8168..321e926 100644 --- a/cc/test/fake_layer_tree_host_client.h +++ b/cc/test/fake_layer_tree_host_client.h @@ -5,6 +5,7 @@ #define CC_TEST_FAKE_LAYER_TREE_HOST_CLIENT_H_ #include "base/memory/scoped_ptr.h" +#include "cc/font_atlas.h" #include "cc/input_handler.h" #include "cc/layer_tree_host.h" #include "cc/test/compositor_fake_web_graphics_context_3d.h" @@ -30,6 +31,8 @@ public: // Used only in the single-threaded path. virtual void scheduleComposite() OVERRIDE { } + + virtual scoped_ptr<FontAtlas> createFontAtlas() OVERRIDE; }; } diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc index 8be9cf9..f24d8e6 100644 --- a/cc/test/layer_tree_test_common.cc +++ b/cc/test/layer_tree_test_common.cc @@ -7,6 +7,7 @@ #include "base/stl_util.h" #include "cc/active_animation.h" #include "cc/content_layer.h" +#include "cc/font_atlas.h" #include "cc/input_handler.h" #include "cc/layer.h" #include "cc/layer_animation_controller.h" @@ -25,6 +26,7 @@ #include <public/WebFilterOperation.h> #include <public/WebFilterOperations.h> +using cc::FontAtlas; using cc::InputHandler; using cc::Layer; using cc::LayerTreeHostImplClient; @@ -263,6 +265,11 @@ public: m_testHooks->scheduleComposite(); } + virtual scoped_ptr<FontAtlas> createFontAtlas() OVERRIDE + { + return scoped_ptr<FontAtlas>(); + } + private: explicit ThreadedMockLayerTreeHostClient(TestHooks* testHooks) : m_testHooks(testHooks) { } diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index a36e96b..14f6a1b 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -12,6 +12,7 @@ #include "base/message_loop.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" +#include "cc/font_atlas.h" #include "cc/input_handler.h" #include "cc/layer.h" #include "cc/layer_tree_host.h" @@ -543,6 +544,10 @@ void Compositor::scheduleComposite() { ScheduleDraw(); } +scoped_ptr<cc::FontAtlas> Compositor::createFontAtlas() { + return scoped_ptr<cc::FontAtlas>(); +} + scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { if (!compositor_lock_) { compositor_lock_ = new CompositorLock(this); diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h index 5029b50..0e2445f 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -19,6 +19,7 @@ class SkBitmap; namespace cc { +class FontAtlas; class Layer; class LayerTreeHost; } @@ -258,6 +259,7 @@ class COMPOSITOR_EXPORT Compositor virtual void didCommitAndDrawFrame() OVERRIDE; virtual void didCompleteSwapBuffers() OVERRIDE; virtual void scheduleComposite() OVERRIDE; + virtual scoped_ptr<cc::FontAtlas> createFontAtlas() OVERRIDE; int last_started_frame() { return last_started_frame_; } diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.cc b/webkit/compositor_bindings/web_layer_tree_view_impl.cc index a983a9e..1bd44a3e 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl.cc +++ b/webkit/compositor_bindings/web_layer_tree_view_impl.cc @@ -185,17 +185,19 @@ void WebLayerTreeViewImpl::setShowFPSCounter(bool show) m_layerTreeHost->setDebugState(debugState); } -void WebLayerTreeViewImpl::setFontAtlas(SkBitmap bitmap, WebRect asciiToWebRectTable[128], int fontHeight) { - setFontAtlas(asciiToWebRectTable, bitmap, fontHeight); -} - -void WebLayerTreeViewImpl::setFontAtlas(WebRect asciiToWebRectTable[128], const SkBitmap& bitmap, int fontHeight) +scoped_ptr<FontAtlas> WebLayerTreeViewImpl::createFontAtlas() { + int fontHeight; + WebRect asciiToWebRectTable[128]; gfx::Rect asciiToRectTable[128]; + SkBitmap bitmap; + + m_client->createFontAtlas(bitmap, asciiToWebRectTable, fontHeight); + for (int i = 0; i < 128; ++i) asciiToRectTable[i] = asciiToWebRectTable[i]; - scoped_ptr<FontAtlas> fontAtlas = FontAtlas::create(bitmap, asciiToRectTable, fontHeight); - m_layerTreeHost->setFontAtlas(fontAtlas.Pass()); + + return FontAtlas::create(bitmap, asciiToRectTable, fontHeight).Pass(); } void WebLayerTreeViewImpl::loseCompositorContext(int numTimes) diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.h b/webkit/compositor_bindings/web_layer_tree_view_impl.h index 33c6eef..dcd61f4 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl.h +++ b/webkit/compositor_bindings/web_layer_tree_view_impl.h @@ -10,6 +10,7 @@ #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" namespace cc { +class FontAtlas; class LayerTreeHost; class Thread; } @@ -51,8 +52,6 @@ public: virtual void setDeferCommits(bool deferCommits) OVERRIDE; virtual void renderingStats(WebRenderingStats&) const OVERRIDE; virtual void setShowFPSCounter(bool show); - virtual void setFontAtlas(SkBitmap, WebRect asciiToRectTable[128], int fontHeight); - virtual void setFontAtlas(WebRect asciiToRectTable[128], const SkBitmap&, int fontHeight); virtual void loseCompositorContext(int numTimes) OVERRIDE; // cc::LayerTreeHostClient implementation. @@ -69,6 +68,7 @@ public: virtual void didCommitAndDrawFrame() OVERRIDE; virtual void didCompleteSwapBuffers() OVERRIDE; virtual void scheduleComposite() OVERRIDE; + virtual scoped_ptr<cc::FontAtlas> createFontAtlas(); private: WebLayerTreeViewClient* m_client; |