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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/debug/trace_event_argument.h" |
12 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "cc/animation/animation_id_provider.h" | 17 #include "cc/animation/animation_id_provider.h" |
17 #include "cc/animation/scroll_offset_animation_curve.h" | 18 #include "cc/animation/scroll_offset_animation_curve.h" |
18 #include "cc/animation/scrollbar_animation_controller.h" | 19 #include "cc/animation/scrollbar_animation_controller.h" |
19 #include "cc/animation/timing_function.h" | 20 #include "cc/animation/timing_function.h" |
20 #include "cc/base/latency_info_swap_promise_monitor.h" | 21 #include "cc/base/latency_info_swap_promise_monitor.h" |
21 #include "cc/base/math_util.h" | 22 #include "cc/base/math_util.h" |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 render_surface->damage_tracker()->UpdateDamageTrackingState( | 521 render_surface->damage_tracker()->UpdateDamageTrackingState( |
521 render_surface->layer_list(), | 522 render_surface->layer_list(), |
522 render_surface_layer->id(), | 523 render_surface_layer->id(), |
523 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 524 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
524 render_surface->content_rect(), | 525 render_surface->content_rect(), |
525 render_surface_layer->mask_layer(), | 526 render_surface_layer->mask_layer(), |
526 render_surface_layer->filters()); | 527 render_surface_layer->filters()); |
527 } | 528 } |
528 } | 529 } |
529 | 530 |
530 scoped_ptr<base::Value> LayerTreeHostImpl::FrameData::AsValue() const { | 531 void LayerTreeHostImpl::FrameData::AsValueInto( |
531 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 532 base::debug::TracedValue* value) const { |
532 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); | 533 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); |
533 value->SetBoolean("has_no_damage", has_no_damage); | 534 value->SetBoolean("has_no_damage", has_no_damage); |
534 | 535 |
535 // Quad data can be quite large, so only dump render passes if we select | 536 // Quad data can be quite large, so only dump render passes if we select |
536 // cc.debug.quads. | 537 // cc.debug.quads. |
537 bool quads_enabled; | 538 bool quads_enabled; |
538 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 539 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
539 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 540 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
540 if (quads_enabled) { | 541 if (quads_enabled) { |
541 scoped_ptr<base::ListValue> render_pass_list(new base::ListValue()); | 542 value->BeginArray("render_passes"); |
542 for (size_t i = 0; i < render_passes.size(); ++i) | 543 for (size_t i = 0; i < render_passes.size(); ++i) { |
543 render_pass_list->Append(render_passes[i]->AsValue().release()); | 544 value->BeginDictionary(); |
544 value->Set("render_passes", render_pass_list.release()); | 545 render_passes[i]->AsValueInto(value); |
| 546 value->EndDictionary(); |
| 547 } |
| 548 value->EndArray(); |
545 } | 549 } |
546 return value.PassAs<base::Value>(); | |
547 } | 550 } |
548 | 551 |
549 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 552 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
550 scoped_ptr<RenderPass> render_pass) { | 553 scoped_ptr<RenderPass> render_pass) { |
551 render_passes_by_id[render_pass->id] = render_pass.get(); | 554 render_passes_by_id[render_pass->id] = render_pass.get(); |
552 render_passes.push_back(render_pass.Pass()); | 555 render_passes.push_back(render_pass.Pass()); |
553 } | 556 } |
554 | 557 |
555 DrawMode LayerTreeHostImpl::GetDrawMode() const { | 558 DrawMode LayerTreeHostImpl::GetDrawMode() const { |
556 if (resourceless_software_draw_) { | 559 if (resourceless_software_draw_) { |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 } | 1521 } |
1519 | 1522 |
1520 { | 1523 { |
1521 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); | 1524 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); |
1522 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1525 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
1523 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," | 1526 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," |
1524 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," | 1527 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," |
1525 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), | 1528 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), |
1526 "cc::LayerTreeHostImpl", | 1529 "cc::LayerTreeHostImpl", |
1527 id_, | 1530 id_, |
1528 TracedValue::FromValue(AsValueWithFrame(frame).release())); | 1531 AsValueWithFrame(frame)); |
1529 } | 1532 } |
1530 | 1533 |
1531 const DrawMode draw_mode = GetDrawMode(); | 1534 const DrawMode draw_mode = GetDrawMode(); |
1532 | 1535 |
1533 // Because the contents of the HUD depend on everything else in the frame, the | 1536 // Because the contents of the HUD depend on everything else in the frame, the |
1534 // contents of its texture are updated as the last thing before the frame is | 1537 // contents of its texture are updated as the last thing before the frame is |
1535 // drawn. | 1538 // drawn. |
1536 if (active_tree_->hud_layer()) { | 1539 if (active_tree_->hud_layer()) { |
1537 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1540 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
1538 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1541 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3137 | 3140 |
3138 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { | 3141 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { |
3139 // Try to use the current frame time to keep animations non-jittery. But if | 3142 // Try to use the current frame time to keep animations non-jittery. But if |
3140 // we're not in a frame (because this is during an input event or a delayed | 3143 // we're not in a frame (because this is during an input event or a delayed |
3141 // task), fall back to physical time. This should still be monotonic. | 3144 // task), fall back to physical time. This should still be monotonic. |
3142 if (!current_frame_timeticks_.is_null()) | 3145 if (!current_frame_timeticks_.is_null()) |
3143 return current_frame_timeticks_; | 3146 return current_frame_timeticks_; |
3144 return gfx::FrameTime::Now(); | 3147 return gfx::FrameTime::Now(); |
3145 } | 3148 } |
3146 | 3149 |
3147 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame( | 3150 scoped_refptr<base::debug::ConvertableToTraceFormat> |
3148 FrameData* frame) const { | 3151 LayerTreeHostImpl::AsValue() const { |
3149 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 3152 return AsValueWithFrame(NULL); |
3150 if (this->pending_tree_) | |
3151 state->Set("activation_state", ActivationStateAsValue().release()); | |
3152 state->Set("device_viewport_size", | |
3153 MathUtil::AsValue(device_viewport_size_).release()); | |
3154 if (tile_manager_) | |
3155 state->Set("tiles", tile_manager_->AllTilesAsValue().release()); | |
3156 state->Set("active_tree", active_tree_->AsValue().release()); | |
3157 if (pending_tree_) | |
3158 state->Set("pending_tree", pending_tree_->AsValue().release()); | |
3159 if (frame) | |
3160 state->Set("frame", frame->AsValue().release()); | |
3161 return state.PassAs<base::Value>(); | |
3162 } | 3153 } |
3163 | 3154 |
3164 scoped_ptr<base::Value> LayerTreeHostImpl::ActivationStateAsValue() const { | 3155 scoped_refptr<base::debug::ConvertableToTraceFormat> |
3165 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 3156 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
3166 state->Set("lthi", TracedValue::CreateIDRef(this).release()); | 3157 scoped_refptr<base::debug::TracedValue> state = |
3167 if (tile_manager_) | 3158 new base::debug::TracedValue(); |
3168 state->Set("tile_manager", tile_manager_->BasicStateAsValue().release()); | 3159 AsValueWithFrameInto(frame, state.get()); |
3169 return state.PassAs<base::Value>(); | 3160 return state; |
| 3161 } |
| 3162 |
| 3163 void LayerTreeHostImpl::AsValueWithFrameInto( |
| 3164 FrameData* frame, |
| 3165 base::debug::TracedValue* state) const { |
| 3166 if (this->pending_tree_) { |
| 3167 state->BeginDictionary("activation_state"); |
| 3168 ActivationStateAsValueInto(state); |
| 3169 state->EndDictionary(); |
| 3170 } |
| 3171 state->BeginDictionary("device_viewport_size"); |
| 3172 MathUtil::AddToTracedValue(device_viewport_size_, state); |
| 3173 state->EndDictionary(); |
| 3174 if (tile_manager_) { |
| 3175 state->BeginArray("tiles"); |
| 3176 tile_manager_->AllTilesAsValueInto(state); |
| 3177 state->EndArray(); |
| 3178 } |
| 3179 state->BeginDictionary("active_tree"); |
| 3180 active_tree_->AsValueInto(state); |
| 3181 state->EndDictionary(); |
| 3182 if (pending_tree_) { |
| 3183 state->BeginDictionary("pending_tree"); |
| 3184 pending_tree_->AsValueInto(state); |
| 3185 state->EndDictionary(); |
| 3186 } |
| 3187 if (frame) { |
| 3188 state->BeginDictionary("frame"); |
| 3189 frame->AsValueInto(state); |
| 3190 state->EndDictionary(); |
| 3191 } |
| 3192 } |
| 3193 |
| 3194 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3195 LayerTreeHostImpl::ActivationStateAsValue() const { |
| 3196 scoped_refptr<base::debug::TracedValue> state = |
| 3197 new base::debug::TracedValue(); |
| 3198 ActivationStateAsValueInto(state.get()); |
| 3199 return state; |
| 3200 } |
| 3201 |
| 3202 void LayerTreeHostImpl::ActivationStateAsValueInto( |
| 3203 base::debug::TracedValue* state) const { |
| 3204 TracedValue::SetIDRef(this, state, "lthi"); |
| 3205 if (tile_manager_) { |
| 3206 state->BeginDictionary("tile_manager"); |
| 3207 tile_manager_->BasicStateAsValueInto(state); |
| 3208 state->EndDictionary(); |
| 3209 } |
3170 } | 3210 } |
3171 | 3211 |
3172 void LayerTreeHostImpl::SetDebugState( | 3212 void LayerTreeHostImpl::SetDebugState( |
3173 const LayerTreeDebugState& new_debug_state) { | 3213 const LayerTreeDebugState& new_debug_state) { |
3174 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 3214 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
3175 return; | 3215 return; |
3176 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) | 3216 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) |
3177 paint_time_counter_->ClearHistory(); | 3217 paint_time_counter_->ClearHistory(); |
3178 | 3218 |
3179 debug_state_ = new_debug_state; | 3219 debug_state_ = new_debug_state; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3306 } | 3346 } |
3307 | 3347 |
3308 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3348 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3309 std::vector<PictureLayerImpl*>::iterator it = | 3349 std::vector<PictureLayerImpl*>::iterator it = |
3310 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3350 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3311 DCHECK(it != picture_layers_.end()); | 3351 DCHECK(it != picture_layers_.end()); |
3312 picture_layers_.erase(it); | 3352 picture_layers_.erase(it); |
3313 } | 3353 } |
3314 | 3354 |
3315 } // namespace cc | 3355 } // namespace cc |
OLD | NEW |