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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 render_surface->damage_tracker()->UpdateDamageTrackingState( | 522 render_surface->damage_tracker()->UpdateDamageTrackingState( |
522 render_surface->layer_list(), | 523 render_surface->layer_list(), |
523 render_surface_layer->id(), | 524 render_surface_layer->id(), |
524 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 525 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
525 render_surface->content_rect(), | 526 render_surface->content_rect(), |
526 render_surface_layer->mask_layer(), | 527 render_surface_layer->mask_layer(), |
527 render_surface_layer->filters()); | 528 render_surface_layer->filters()); |
528 } | 529 } |
529 } | 530 } |
530 | 531 |
531 scoped_ptr<base::Value> LayerTreeHostImpl::FrameData::AsValue() const { | 532 void LayerTreeHostImpl::FrameData::AsValueInto( |
532 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 533 base::debug::TracedValue* value) const { |
533 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); | 534 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); |
534 value->SetBoolean("has_no_damage", has_no_damage); | 535 value->SetBoolean("has_no_damage", has_no_damage); |
535 | 536 |
536 // Quad data can be quite large, so only dump render passes if we select | 537 // Quad data can be quite large, so only dump render passes if we select |
537 // cc.debug.quads. | 538 // cc.debug.quads. |
538 bool quads_enabled; | 539 bool quads_enabled; |
539 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 540 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
540 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 541 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
541 if (quads_enabled) { | 542 if (quads_enabled) { |
542 scoped_ptr<base::ListValue> render_pass_list(new base::ListValue()); | 543 value->BeginArray("render_passes"); |
543 for (size_t i = 0; i < render_passes.size(); ++i) | 544 for (size_t i = 0; i < render_passes.size(); ++i) { |
544 render_pass_list->Append(render_passes[i]->AsValue().release()); | 545 value->BeginDictionary(); |
545 value->Set("render_passes", render_pass_list.release()); | 546 render_passes[i]->AsValueInto(value); |
| 547 value->EndDictionary(); |
| 548 } |
| 549 value->EndArray(); |
546 } | 550 } |
547 return value.PassAs<base::Value>(); | |
548 } | 551 } |
549 | 552 |
550 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 553 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
551 scoped_ptr<RenderPass> render_pass) { | 554 scoped_ptr<RenderPass> render_pass) { |
552 render_passes_by_id[render_pass->id] = render_pass.get(); | 555 render_passes_by_id[render_pass->id] = render_pass.get(); |
553 render_passes.push_back(render_pass.Pass()); | 556 render_passes.push_back(render_pass.Pass()); |
554 } | 557 } |
555 | 558 |
556 DrawMode LayerTreeHostImpl::GetDrawMode() const { | 559 DrawMode LayerTreeHostImpl::GetDrawMode() const { |
557 if (resourceless_software_draw_) { | 560 if (resourceless_software_draw_) { |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 } | 1539 } |
1537 | 1540 |
1538 { | 1541 { |
1539 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); | 1542 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); |
1540 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1543 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
1541 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," | 1544 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," |
1542 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," | 1545 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," |
1543 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), | 1546 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), |
1544 "cc::LayerTreeHostImpl", | 1547 "cc::LayerTreeHostImpl", |
1545 id_, | 1548 id_, |
1546 TracedValue::FromValue(AsValueWithFrame(frame).release())); | 1549 AsValueWithFrame(frame)); |
1547 } | 1550 } |
1548 | 1551 |
1549 const DrawMode draw_mode = GetDrawMode(); | 1552 const DrawMode draw_mode = GetDrawMode(); |
1550 | 1553 |
1551 // Because the contents of the HUD depend on everything else in the frame, the | 1554 // Because the contents of the HUD depend on everything else in the frame, the |
1552 // contents of its texture are updated as the last thing before the frame is | 1555 // contents of its texture are updated as the last thing before the frame is |
1553 // drawn. | 1556 // drawn. |
1554 if (active_tree_->hud_layer()) { | 1557 if (active_tree_->hud_layer()) { |
1555 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1558 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
1556 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1559 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3162 | 3165 |
3163 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { | 3166 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { |
3164 // Try to use the current frame time to keep animations non-jittery. But if | 3167 // Try to use the current frame time to keep animations non-jittery. But if |
3165 // we're not in a frame (because this is during an input event or a delayed | 3168 // we're not in a frame (because this is during an input event or a delayed |
3166 // task), fall back to physical time. This should still be monotonic. | 3169 // task), fall back to physical time. This should still be monotonic. |
3167 if (!current_frame_timeticks_.is_null()) | 3170 if (!current_frame_timeticks_.is_null()) |
3168 return current_frame_timeticks_; | 3171 return current_frame_timeticks_; |
3169 return gfx::FrameTime::Now(); | 3172 return gfx::FrameTime::Now(); |
3170 } | 3173 } |
3171 | 3174 |
3172 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame( | 3175 scoped_refptr<base::debug::ConvertableToTraceFormat> |
3173 FrameData* frame) const { | 3176 LayerTreeHostImpl::AsValue() const { |
3174 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 3177 return AsValueWithFrame(NULL); |
3175 if (this->pending_tree_) | |
3176 state->Set("activation_state", ActivationStateAsValue().release()); | |
3177 state->Set("device_viewport_size", | |
3178 MathUtil::AsValue(device_viewport_size_).release()); | |
3179 if (tile_manager_) | |
3180 state->Set("tiles", tile_manager_->AllTilesAsValue().release()); | |
3181 state->Set("active_tree", active_tree_->AsValue().release()); | |
3182 if (pending_tree_) | |
3183 state->Set("pending_tree", pending_tree_->AsValue().release()); | |
3184 if (frame) | |
3185 state->Set("frame", frame->AsValue().release()); | |
3186 return state.PassAs<base::Value>(); | |
3187 } | 3178 } |
3188 | 3179 |
3189 scoped_ptr<base::Value> LayerTreeHostImpl::ActivationStateAsValue() const { | 3180 scoped_refptr<base::debug::ConvertableToTraceFormat> |
3190 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 3181 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
3191 state->Set("lthi", TracedValue::CreateIDRef(this).release()); | 3182 scoped_refptr<base::debug::TracedValue> state = |
3192 if (tile_manager_) | 3183 new base::debug::TracedValue(); |
3193 state->Set("tile_manager", tile_manager_->BasicStateAsValue().release()); | 3184 AsValueWithFrameInto(frame, state.get()); |
3194 return state.PassAs<base::Value>(); | 3185 return state; |
| 3186 } |
| 3187 |
| 3188 void LayerTreeHostImpl::AsValueWithFrameInto( |
| 3189 FrameData* frame, |
| 3190 base::debug::TracedValue* state) const { |
| 3191 if (this->pending_tree_) { |
| 3192 state->BeginDictionary("activation_state"); |
| 3193 ActivationStateAsValueInto(state); |
| 3194 state->EndDictionary(); |
| 3195 } |
| 3196 state->BeginDictionary("device_viewport_size"); |
| 3197 MathUtil::AddToTracedValue(device_viewport_size_, state); |
| 3198 state->EndDictionary(); |
| 3199 if (tile_manager_) { |
| 3200 state->BeginArray("tiles"); |
| 3201 tile_manager_->AllTilesAsValueInto(state); |
| 3202 state->EndArray(); |
| 3203 } |
| 3204 state->BeginDictionary("active_tree"); |
| 3205 active_tree_->AsValueInto(state); |
| 3206 state->EndDictionary(); |
| 3207 if (pending_tree_) { |
| 3208 state->BeginDictionary("pending_tree"); |
| 3209 pending_tree_->AsValueInto(state); |
| 3210 state->EndDictionary(); |
| 3211 } |
| 3212 if (frame) { |
| 3213 state->BeginDictionary("frame"); |
| 3214 frame->AsValueInto(state); |
| 3215 state->EndDictionary(); |
| 3216 } |
| 3217 } |
| 3218 |
| 3219 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3220 LayerTreeHostImpl::ActivationStateAsValue() const { |
| 3221 scoped_refptr<base::debug::TracedValue> state = |
| 3222 new base::debug::TracedValue(); |
| 3223 ActivationStateAsValueInto(state.get()); |
| 3224 return state; |
| 3225 } |
| 3226 |
| 3227 void LayerTreeHostImpl::ActivationStateAsValueInto( |
| 3228 base::debug::TracedValue* state) const { |
| 3229 TracedValue::SetIDRef(this, state, "lthi"); |
| 3230 if (tile_manager_) { |
| 3231 state->BeginDictionary("tile_manager"); |
| 3232 tile_manager_->BasicStateAsValueInto(state); |
| 3233 state->EndDictionary(); |
| 3234 } |
3195 } | 3235 } |
3196 | 3236 |
3197 void LayerTreeHostImpl::SetDebugState( | 3237 void LayerTreeHostImpl::SetDebugState( |
3198 const LayerTreeDebugState& new_debug_state) { | 3238 const LayerTreeDebugState& new_debug_state) { |
3199 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 3239 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
3200 return; | 3240 return; |
3201 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) | 3241 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) |
3202 paint_time_counter_->ClearHistory(); | 3242 paint_time_counter_->ClearHistory(); |
3203 | 3243 |
3204 debug_state_ = new_debug_state; | 3244 debug_state_ = new_debug_state; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3331 } | 3371 } |
3332 | 3372 |
3333 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3373 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3334 std::vector<PictureLayerImpl*>::iterator it = | 3374 std::vector<PictureLayerImpl*>::iterator it = |
3335 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3375 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3336 DCHECK(it != picture_layers_.end()); | 3376 DCHECK(it != picture_layers_.end()); |
3337 picture_layers_.erase(it); | 3377 picture_layers_.erase(it); |
3338 } | 3378 } |
3339 | 3379 |
3340 } // namespace cc | 3380 } // namespace cc |
OLD | NEW |