OLD | NEW |
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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 bool LayerTreeHostImpl::ExternalStencilTestEnabled() const { | 1217 bool LayerTreeHostImpl::ExternalStencilTestEnabled() const { |
1218 return external_stencil_test_enabled_; | 1218 return external_stencil_test_enabled_; |
1219 } | 1219 } |
1220 | 1220 |
1221 static void LayerTreeHostImplDidBeginTracingCallback(LayerImpl* layer) { | 1221 static void LayerTreeHostImplDidBeginTracingCallback(LayerImpl* layer) { |
1222 layer->DidBeginTracing(); | 1222 layer->DidBeginTracing(); |
1223 } | 1223 } |
1224 | 1224 |
1225 void LayerTreeHostImpl::DrawLayers(FrameData* frame, | 1225 void LayerTreeHostImpl::DrawLayers(FrameData* frame, |
1226 base::TimeTicks frame_begin_time) { | 1226 base::TimeTicks frame_begin_time) { |
1227 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); | 1227 TRACE_EVENT_BEGIN0("cc", "LayerTreeHostImpl::DrawLayers"); |
1228 DCHECK(CanDraw()); | 1228 DCHECK(CanDraw()); |
1229 | 1229 |
1230 if (frame->has_no_damage) { | 1230 if (frame->has_no_damage) { |
1231 TRACE_EVENT0("cc", "EarlyOut_NoDamage"); | 1231 TRACE_EVENT0("cc", "EarlyOut_NoDamage"); |
1232 DCHECK(!output_surface_->capabilities() | 1232 DCHECK(!output_surface_->capabilities() |
1233 .draw_and_swap_full_viewport_every_frame); | 1233 .draw_and_swap_full_viewport_every_frame); |
| 1234 TRACE_EVENT_END0("cc", "LayerTreeHostImpl::DrawLayers"); |
1234 return; | 1235 return; |
1235 } | 1236 } |
1236 | 1237 |
1237 DCHECK(!frame->render_passes.empty()); | 1238 DCHECK(!frame->render_passes.empty()); |
1238 | 1239 |
| 1240 int old_dropped_frame_count = fps_counter_->dropped_frame_count(); |
1239 fps_counter_->SaveTimeStamp(frame_begin_time); | 1241 fps_counter_->SaveTimeStamp(frame_begin_time); |
1240 | 1242 |
1241 rendering_stats_instrumentation_->SetScreenFrameCount( | 1243 rendering_stats_instrumentation_->IncrementScreenFrameCount(1); |
1242 fps_counter_->current_frame_number()); | 1244 rendering_stats_instrumentation_->IncrementDroppedFrameCount( |
1243 rendering_stats_instrumentation_->SetDroppedFrameCount( | 1245 fps_counter_->dropped_frame_count() - old_dropped_frame_count); |
1244 fps_counter_->dropped_frame_count()); | |
1245 | 1246 |
1246 if (tile_manager_) { | 1247 if (tile_manager_) { |
1247 memory_history_->SaveEntry( | 1248 memory_history_->SaveEntry( |
1248 tile_manager_->memory_stats_from_last_assign()); | 1249 tile_manager_->memory_stats_from_last_assign()); |
1249 } | 1250 } |
1250 | 1251 |
1251 if (debug_state_.ShowHudRects()) { | 1252 if (debug_state_.ShowHudRects()) { |
1252 debug_rect_history_->SaveDebugRectsForCurrentFrame( | 1253 debug_rect_history_->SaveDebugRectsForCurrentFrame( |
1253 active_tree_->root_layer(), | 1254 active_tree_->root_layer(), |
1254 *frame->render_surface_layer_list, | 1255 *frame->render_surface_layer_list, |
1255 frame->occluding_screen_space_rects, | 1256 frame->occluding_screen_space_rects, |
1256 frame->non_occluding_screen_space_rects, | 1257 frame->non_occluding_screen_space_rects, |
1257 debug_state_); | 1258 debug_state_); |
1258 } | 1259 } |
1259 | 1260 |
1260 if (!settings_.impl_side_painting && debug_state_.continuous_painting) { | 1261 if (!settings_.impl_side_painting && debug_state_.continuous_painting) { |
1261 const RenderingStats& stats = | 1262 const RenderingStats& stats = |
1262 rendering_stats_instrumentation_->GetRenderingStats(); | 1263 rendering_stats_instrumentation_->GetRenderingStats(); |
1263 paint_time_counter_->SavePaintTime(stats.total_paint_time); | 1264 paint_time_counter_->SavePaintTime(stats.main_stats.paint_time); |
1264 } | 1265 } |
1265 | 1266 |
1266 bool is_new_trace; | 1267 bool is_new_trace; |
1267 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 1268 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
1268 if (is_new_trace) { | 1269 if (is_new_trace) { |
1269 if (pending_tree_) { | 1270 if (pending_tree_) { |
1270 LayerTreeHostCommon::CallFunctionForSubtree( | 1271 LayerTreeHostCommon::CallFunctionForSubtree( |
1271 pending_tree_->root_layer(), | 1272 pending_tree_->root_layer(), |
1272 base::Bind(&LayerTreeHostImplDidBeginTracingCallback)); | 1273 base::Bind(&LayerTreeHostImplDidBeginTracingCallback)); |
1273 } | 1274 } |
(...skipping 24 matching lines...) Expand all Loading... |
1298 DCHECK(frame->render_passes.empty()); | 1299 DCHECK(frame->render_passes.empty()); |
1299 frame->render_passes_by_id.clear(); | 1300 frame->render_passes_by_id.clear(); |
1300 | 1301 |
1301 // The next frame should start by assuming nothing has changed, and changes | 1302 // The next frame should start by assuming nothing has changed, and changes |
1302 // are noted as they occur. | 1303 // are noted as they occur. |
1303 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { | 1304 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { |
1304 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> | 1305 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> |
1305 DidDrawDamagedArea(); | 1306 DidDrawDamagedArea(); |
1306 } | 1307 } |
1307 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); | 1308 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); |
| 1309 TRACE_EVENT_END1("cc", "LayerTreeHostImpl::DrawLayers", |
| 1310 "data", rendering_stats_instrumentation_-> |
| 1311 GetImplThreadRenderingStats().AsTraceableData()); |
| 1312 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats(); |
1308 } | 1313 } |
1309 | 1314 |
1310 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { | 1315 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { |
1311 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i) | 1316 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i) |
1312 frame.will_draw_layers[i]->DidDraw(resource_provider_.get()); | 1317 frame.will_draw_layers[i]->DidDraw(resource_provider_.get()); |
1313 | 1318 |
1314 // Once all layers have been drawn, pending texture uploads should no | 1319 // Once all layers have been drawn, pending texture uploads should no |
1315 // longer block future uploads. | 1320 // longer block future uploads. |
1316 resource_provider_->MarkPendingUploadsAsNonBlocking(); | 1321 resource_provider_->MarkPendingUploadsAsNonBlocking(); |
1317 } | 1322 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 | 1507 |
1503 client_->OnCanDrawStateChanged(CanDraw()); | 1508 client_->OnCanDrawStateChanged(CanDraw()); |
1504 client_->OnHasPendingTreeStateChanged(pending_tree_); | 1509 client_->OnHasPendingTreeStateChanged(pending_tree_); |
1505 client_->SetNeedsRedrawOnImplThread(); | 1510 client_->SetNeedsRedrawOnImplThread(); |
1506 client_->RenewTreePriority(); | 1511 client_->RenewTreePriority(); |
1507 | 1512 |
1508 if (debug_state_.continuous_painting) { | 1513 if (debug_state_.continuous_painting) { |
1509 const RenderingStats& stats = | 1514 const RenderingStats& stats = |
1510 rendering_stats_instrumentation_->GetRenderingStats(); | 1515 rendering_stats_instrumentation_->GetRenderingStats(); |
1511 paint_time_counter_->SavePaintTime( | 1516 paint_time_counter_->SavePaintTime( |
1512 stats.total_paint_time + stats.total_record_time + | 1517 stats.main_stats.paint_time + stats.main_stats.record_time + |
1513 stats.total_rasterize_time_for_now_bins_on_pending_tree); | 1518 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); |
1514 } | 1519 } |
1515 | 1520 |
1516 client_->DidActivatePendingTree(); | 1521 client_->DidActivatePendingTree(); |
1517 if (!tree_activation_callback_.is_null()) | 1522 if (!tree_activation_callback_.is_null()) |
1518 tree_activation_callback_.Run(); | 1523 tree_activation_callback_.Run(); |
1519 } | 1524 } |
1520 | 1525 |
1521 void LayerTreeHostImpl::SetVisible(bool visible) { | 1526 void LayerTreeHostImpl::SetVisible(bool visible) { |
1522 DCHECK(proxy_->IsImplThread()); | 1527 DCHECK(proxy_->IsImplThread()); |
1523 | 1528 |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 | 2525 |
2521 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2526 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2522 UIResourceId uid) const { | 2527 UIResourceId uid) const { |
2523 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2528 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2524 if (iter != ui_resource_map_.end()) | 2529 if (iter != ui_resource_map_.end()) |
2525 return iter->second; | 2530 return iter->second; |
2526 return 0; | 2531 return 0; |
2527 } | 2532 } |
2528 | 2533 |
2529 } // namespace cc | 2534 } // namespace cc |
OLD | NEW |