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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: else if typo Created 7 years, 5 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
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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/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/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // construct a DebugScopedSetImplThread object. There is no need to do 99 // construct a DebugScopedSetImplThread object. There is no need to do
100 // this in multi-threaded mode since the real thread id's will be 100 // this in multi-threaded mode since the real thread id's will be
101 // correct. In fact, setting fake thread id's interferes with the real 101 // correct. In fact, setting fake thread id's interferes with the real
102 // thread id's and causes breakage. 102 // thread id's and causes breakage.
103 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; 103 scoped_ptr<DebugScopedSetImplThread> set_impl_thread;
104 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { 104 if (!layer_tree_host_impl_->proxy()->HasImplThread()) {
105 set_impl_thread.reset( 105 set_impl_thread.reset(
106 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); 106 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy()));
107 } 107 }
108 108
109 // TODO(enne): This should probably happen post-animate.
110 if (layer_tree_host_impl_->pending_tree()) { 109 if (layer_tree_host_impl_->pending_tree()) {
111 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); 110 layer_tree_host_impl_->ActivatePendingTreeIfNeeded();
112 111
113 if (layer_tree_host_impl_->pending_tree()) { 112 if (layer_tree_host_impl_->pending_tree()) {
114 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); 113 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
115 layer_tree_host_impl_->ManageTiles(); 114 layer_tree_host_impl_->ManageTiles();
116 } 115 }
117 } 116 }
118 117
119 layer_tree_host_impl_->Animate( 118 layer_tree_host_impl_->Animate(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 rendering_stats_instrumentation)); 161 rendering_stats_instrumentation));
163 } 162 }
164 163
165 LayerTreeHostImpl::LayerTreeHostImpl( 164 LayerTreeHostImpl::LayerTreeHostImpl(
166 const LayerTreeSettings& settings, 165 const LayerTreeSettings& settings,
167 LayerTreeHostImplClient* client, 166 LayerTreeHostImplClient* client,
168 Proxy* proxy, 167 Proxy* proxy,
169 RenderingStatsInstrumentation* rendering_stats_instrumentation) 168 RenderingStatsInstrumentation* rendering_stats_instrumentation)
170 : client_(client), 169 : client_(client),
171 proxy_(proxy), 170 proxy_(proxy),
171 output_surface_lost_(true),
172 input_handler_client_(NULL), 172 input_handler_client_(NULL),
173 did_lock_scrolling_layer_(false), 173 did_lock_scrolling_layer_(false),
174 should_bubble_scrolls_(false), 174 should_bubble_scrolls_(false),
175 wheel_scrolling_(false), 175 wheel_scrolling_(false),
176 manage_tiles_needed_(false), 176 manage_tiles_needed_(false),
177 root_layer_scroll_offset_delegate_(NULL), 177 root_layer_scroll_offset_delegate_(NULL),
178 settings_(settings), 178 settings_(settings),
179 visible_(true), 179 visible_(true),
180 managed_memory_policy_( 180 managed_memory_policy_(
181 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), 181 PrioritizedResourceManager::DefaultMemoryAllocationLimit(),
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 bool LayerTreeHostImpl::IsContextLost() { 1264 bool LayerTreeHostImpl::IsContextLost() {
1265 DCHECK(proxy_->IsImplThread()); 1265 DCHECK(proxy_->IsImplThread());
1266 return renderer_ && renderer_->IsContextLost(); 1266 return renderer_ && renderer_->IsContextLost();
1267 } 1267 }
1268 1268
1269 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { 1269 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const {
1270 return renderer_->Capabilities(); 1270 return renderer_->Capabilities();
1271 } 1271 }
1272 1272
1273 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { 1273 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
1274 if (frame.has_no_damage) 1274 if (frame.has_no_damage || output_surface_lost_)
brianderson 2013/07/10 21:58:04 I avoid swapping if we don't have an output surfac
1275 return false; 1275 return false;
1276 renderer_->SwapBuffers(); 1276 renderer_->SwapBuffers();
1277 active_tree_->ClearLatencyInfo(); 1277 active_tree_->ClearLatencyInfo();
1278 return true; 1278 return true;
1279 } 1279 }
1280 1280
1281 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { 1281 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) {
1282 if (output_surface_) 1282 if (output_surface_)
1283 output_surface_->SetNeedsBeginFrame(enable); 1283 output_surface_->SetNeedsBeginFrame(enable);
1284 } 1284 }
(...skipping 20 matching lines...) Expand all
1305 } 1305 }
1306 1306
1307 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { 1307 const LayerTreeSettings& LayerTreeHostImpl::Settings() const {
1308 return settings(); 1308 return settings();
1309 } 1309 }
1310 1310
1311 void LayerTreeHostImpl::DidLoseOutputSurface() { 1311 void LayerTreeHostImpl::DidLoseOutputSurface() {
1312 // TODO(jamesr): The renderer_ check is needed to make some of the 1312 // TODO(jamesr): The renderer_ check is needed to make some of the
1313 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or 1313 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or
1314 // important) in production. We should adjust the test to not need this. 1314 // important) in production. We should adjust the test to not need this.
1315 output_surface_lost_ = true;
1315 if (renderer_) 1316 if (renderer_)
1316 client_->DidLoseOutputSurfaceOnImplThread(); 1317 client_->DidLoseOutputSurfaceOnImplThread();
1317 } 1318 }
1318 1319
1319 void LayerTreeHostImpl::Readback(void* pixels, 1320 void LayerTreeHostImpl::Readback(void* pixels,
1320 gfx::Rect rect_in_device_viewport) { 1321 gfx::Rect rect_in_device_viewport) {
1321 DCHECK(renderer_); 1322 DCHECK(renderer_);
1322 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); 1323 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport);
1323 } 1324 }
1324 1325
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 1420
1420 // Now that we've synced everything from the pending tree to the active 1421 // Now that we've synced everything from the pending tree to the active
1421 // tree, rename the pending tree the recycle tree so we can reuse it on the 1422 // tree, rename the pending tree the recycle tree so we can reuse it on the
1422 // next sync. 1423 // next sync.
1423 pending_tree_.swap(recycle_tree_); 1424 pending_tree_.swap(recycle_tree_);
1424 1425
1425 active_tree_->SetRootLayerScrollOffsetDelegate( 1426 active_tree_->SetRootLayerScrollOffsetDelegate(
1426 root_layer_scroll_offset_delegate_); 1427 root_layer_scroll_offset_delegate_);
1427 active_tree_->DidBecomeActive(); 1428 active_tree_->DidBecomeActive();
1428 1429
1430 client_->DidActivatePendingTree();
1431
1429 // Reduce wasted memory now that unlinked resources are guaranteed not 1432 // Reduce wasted memory now that unlinked resources are guaranteed not
1430 // to be used. 1433 // to be used.
1431 client_->ReduceWastedContentsTextureMemoryOnImplThread(); 1434 client_->ReduceWastedContentsTextureMemoryOnImplThread();
1432 1435
1433 client_->OnCanDrawStateChanged(CanDraw()); 1436 client_->OnCanDrawStateChanged(CanDraw());
1434 client_->OnHasPendingTreeStateChanged(pending_tree_); 1437 client_->OnHasPendingTreeStateChanged(pending_tree_);
1435 client_->SetNeedsRedrawOnImplThread(); 1438 client_->SetNeedsRedrawOnImplThread();
1436 client_->RenewTreePriority(); 1439 client_->RenewTreePriority();
1437 1440
1438 if (debug_state_.continuous_painting) { 1441 if (debug_state_.continuous_painting) {
1439 const RenderingStats& stats = 1442 const RenderingStats& stats =
1440 rendering_stats_instrumentation_->GetRenderingStats(); 1443 rendering_stats_instrumentation_->GetRenderingStats();
1441 paint_time_counter_->SavePaintTime( 1444 paint_time_counter_->SavePaintTime(
1442 stats.total_paint_time + stats.total_record_time + 1445 stats.total_paint_time + stats.total_record_time +
1443 stats.total_rasterize_time_for_now_bins_on_pending_tree); 1446 stats.total_rasterize_time_for_now_bins_on_pending_tree);
1444 } 1447 }
1445
1446 client_->DidActivatePendingTree();
1447 } 1448 }
1448 1449
1449 void LayerTreeHostImpl::SetVisible(bool visible) { 1450 void LayerTreeHostImpl::SetVisible(bool visible) {
1450 DCHECK(proxy_->IsImplThread()); 1451 DCHECK(proxy_->IsImplThread());
1451 1452
1452 if (visible_ == visible) 1453 if (visible_ == visible)
1453 return; 1454 return;
1454 visible_ = visible; 1455 visible_ = visible;
1455 DidVisibilityChange(this, visible_); 1456 DidVisibilityChange(this, visible_);
1456 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1457 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 // before we destroy the old resource provider. 1530 // before we destroy the old resource provider.
1530 ReleaseTreeResources(); 1531 ReleaseTreeResources();
1531 if (resource_provider_) 1532 if (resource_provider_)
1532 resource_provider_->DidLoseOutputSurface(); 1533 resource_provider_->DidLoseOutputSurface();
1533 1534
1534 // Note: order is important here. 1535 // Note: order is important here.
1535 renderer_.reset(); 1536 renderer_.reset();
1536 tile_manager_.reset(); 1537 tile_manager_.reset();
1537 resource_provider_.reset(); 1538 resource_provider_.reset();
1538 output_surface_.reset(); 1539 output_surface_.reset();
1540 output_surface_lost_ = true;
1539 1541
1540 if (!output_surface->BindToClient(this)) 1542 if (!output_surface->BindToClient(this))
1541 return false; 1543 return false;
1542 1544
1543 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( 1545 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create(
1544 output_surface.get(), settings_.highp_threshold_min); 1546 output_surface.get(), settings_.highp_threshold_min);
1545 if (!resource_provider) 1547 if (!resource_provider)
1546 return false; 1548 return false;
1547 1549
1548 if (output_surface->capabilities().deferred_gl_initialization) 1550 if (output_surface->capabilities().deferred_gl_initialization)
(...skipping 28 matching lines...) Expand all
1577 } 1579 }
1578 1580
1579 int max_frames_pending = 1581 int max_frames_pending =
1580 output_surface->capabilities().max_frames_pending; 1582 output_surface->capabilities().max_frames_pending;
1581 if (max_frames_pending <= 0) 1583 if (max_frames_pending <= 0)
1582 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; 1584 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING;
1583 output_surface->SetMaxFramesPending(max_frames_pending); 1585 output_surface->SetMaxFramesPending(max_frames_pending);
1584 1586
1585 resource_provider_ = resource_provider.Pass(); 1587 resource_provider_ = resource_provider.Pass();
1586 output_surface_ = output_surface.Pass(); 1588 output_surface_ = output_surface.Pass();
1589 output_surface_lost_ = false;
1587 1590
1588 client_->OnCanDrawStateChanged(CanDraw()); 1591 client_->OnCanDrawStateChanged(CanDraw());
1589 1592
1590 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs 1593 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs
1591 // to be initialized to get max texture size. 1594 // to be initialized to get max texture size.
1592 active_tree_->set_needs_update_draw_properties(); 1595 active_tree_->set_needs_update_draw_properties();
1593 if (pending_tree_) 1596 if (pending_tree_)
1594 pending_tree_->set_needs_update_draw_properties(); 1597 pending_tree_->set_needs_update_draw_properties();
1595 1598
1596 return true; 1599 return true;
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 2376 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
2374 return; 2377 return;
2375 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) 2378 if (debug_state_.continuous_painting != new_debug_state.continuous_painting)
2376 paint_time_counter_->ClearHistory(); 2379 paint_time_counter_->ClearHistory();
2377 2380
2378 debug_state_ = new_debug_state; 2381 debug_state_ = new_debug_state;
2379 SetFullRootLayerDamage(); 2382 SetFullRootLayerDamage();
2380 } 2383 }
2381 2384
2382 } // namespace cc 2385 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698