Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11882037: Activate LayerImpl tree with sync+push instead of pointer swap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 21 matching lines...) Expand all
32 #include "cc/render_pass_draw_quad.h" 32 #include "cc/render_pass_draw_quad.h"
33 #include "cc/rendering_stats.h" 33 #include "cc/rendering_stats.h"
34 #include "cc/scrollbar_animation_controller.h" 34 #include "cc/scrollbar_animation_controller.h"
35 #include "cc/scrollbar_layer_impl.h" 35 #include "cc/scrollbar_layer_impl.h"
36 #include "cc/shared_quad_state.h" 36 #include "cc/shared_quad_state.h"
37 #include "cc/single_thread_proxy.h" 37 #include "cc/single_thread_proxy.h"
38 #include "cc/software_renderer.h" 38 #include "cc/software_renderer.h"
39 #include "cc/solid_color_draw_quad.h" 39 #include "cc/solid_color_draw_quad.h"
40 #include "cc/texture_uploader.h" 40 #include "cc/texture_uploader.h"
41 #include "cc/top_controls_manager.h" 41 #include "cc/top_controls_manager.h"
42 #include "cc/tree_synchronizer.h"
42 #include "cc/util.h" 43 #include "cc/util.h"
43 #include "ui/gfx/size_conversions.h" 44 #include "ui/gfx/size_conversions.h"
44 #include "ui/gfx/vector2d_conversions.h" 45 #include "ui/gfx/vector2d_conversions.h"
45 46
46 namespace { 47 namespace {
47 48
48 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) 49 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible)
49 { 50 {
50 if (visible) { 51 if (visible) {
51 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id, "LayerTreeHostImpl", id); 52 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id, "LayerTreeHostImpl", id);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 { 170 {
170 DCHECK(m_proxy->isImplThread()); 171 DCHECK(m_proxy->isImplThread());
171 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); 172 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
172 173
173 if (rootLayer()) { 174 if (rootLayer()) {
174 clearRenderSurfaces(); 175 clearRenderSurfaces();
175 // The layer trees must be destroyed before the layer tree host. We've 176 // The layer trees must be destroyed before the layer tree host. We've
176 // made a contract with our animation controllers that the registrar 177 // made a contract with our animation controllers that the registrar
177 // will outlive them, and we must make good. 178 // will outlive them, and we must make good.
178 m_activeTree.reset(); 179 m_activeTree.reset();
180 m_recycleTree.reset();
enne (OOO) 2013/01/17 23:34:55 There are a couple of other cleanup functions in L
jamesr 2013/01/18 01:16:42 Added code to clear the render surfaces on the rec
179 m_pendingTree.reset(); 181 m_pendingTree.reset();
180 } 182 }
181 } 183 }
182 184
183 void LayerTreeHostImpl::beginCommit() 185 void LayerTreeHostImpl::beginCommit()
184 { 186 {
185 } 187 }
186 188
187 void LayerTreeHostImpl::commitComplete() 189 void LayerTreeHostImpl::commitComplete()
188 { 190 {
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } 914 }
913 915
914 LayerTreeImpl* LayerTreeHostImpl::activeTree() 916 LayerTreeImpl* LayerTreeHostImpl::activeTree()
915 { 917 {
916 return m_activeTree.get(); 918 return m_activeTree.get();
917 } 919 }
918 920
919 void LayerTreeHostImpl::createPendingTree() 921 void LayerTreeHostImpl::createPendingTree()
920 { 922 {
921 CHECK(!m_pendingTree); 923 CHECK(!m_pendingTree);
922 m_pendingTree = LayerTreeImpl::create(this); 924 if (m_recycleTree)
925 m_recycleTree.swap(m_pendingTree);
926 else
927 m_pendingTree = LayerTreeImpl::create(this);
923 m_client->onCanDrawStateChanged(canDraw()); 928 m_client->onCanDrawStateChanged(canDraw());
924 m_client->onHasPendingTreeStateChanged(pendingTree()); 929 m_client->onHasPendingTreeStateChanged(pendingTree());
925 } 930 }
926 931
927 void LayerTreeHostImpl::checkForCompletedSetPixels() 932 void LayerTreeHostImpl::checkForCompletedSetPixels()
928 { 933 {
929 if (m_tileManager) 934 if (m_tileManager)
930 m_tileManager->CheckForCompletedSetPixels(); 935 m_tileManager->CheckForCompletedSetPixels();
931 } 936 }
932 937
(...skipping 11 matching lines...) Expand all
944 return; 949 return;
945 950
946 activatePendingTree(); 951 activatePendingTree();
947 } 952 }
948 953
949 void LayerTreeHostImpl::activatePendingTree() 954 void LayerTreeHostImpl::activatePendingTree()
950 { 955 {
951 CHECK(m_pendingTree); 956 CHECK(m_pendingTree);
952 957
953 m_activeTree->PushPersistedState(m_pendingTree.get()); 958 m_activeTree->PushPersistedState(m_pendingTree.get());
954 m_activeTree.swap(m_pendingTree); 959 m_activeTree->SetRootLayer(TreeSynchronizer::synchronizeTrees(m_pendingTree- >RootLayer(), m_activeTree->DetachLayerTree(), m_activeTree.get()));
955 // TODO(enne): consider recycling this tree to prevent layer churn 960 TreeSynchronizer::pushProperties(m_pendingTree->RootLayer(), m_activeTree->R ootLayer());
956 m_pendingTree.reset(); 961 DCHECK(!m_recycleTree);
962 m_activeTree->set_source_frame_number(m_pendingTree->source_frame_number());
enne (OOO) 2013/01/17 23:34:55 I wish there were some better way to establish the
jamesr 2013/01/18 01:16:42 Added a comment. While adding this I also thought
963 m_activeTree->set_background_color(m_pendingTree->background_color());
964 m_activeTree->set_has_transparent_background(m_pendingTree->has_transparent_ background());
965 m_pendingTree.swap(m_recycleTree);
jamesr 2013/01/18 01:16:42 added another comment here, for kicks
957 m_activeTree->DidBecomeActive(); 966 m_activeTree->DidBecomeActive();
958 967
959 m_client->onCanDrawStateChanged(canDraw()); 968 m_client->onCanDrawStateChanged(canDraw());
960 m_client->onHasPendingTreeStateChanged(pendingTree()); 969 m_client->onHasPendingTreeStateChanged(pendingTree());
961 m_client->setNeedsRedrawOnImplThread(); 970 m_client->setNeedsRedrawOnImplThread();
962 } 971 }
963 972
964 void LayerTreeHostImpl::setVisible(bool visible) 973 void LayerTreeHostImpl::setVisible(bool visible)
965 { 974 {
966 DCHECK(m_proxy->isImplThread()); 975 DCHECK(m_proxy->isImplThread());
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); 1683 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer());
1675 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); 1684 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>();
1676 } 1685 }
1677 1686
1678 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) 1687 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime)
1679 { 1688 {
1680 m_paintTimeCounter->SavePaintTime(totalPaintTime); 1689 m_paintTimeCounter->SavePaintTime(totalPaintTime);
1681 } 1690 }
1682 1691
1683 } // namespace cc 1692 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698