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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "cc/animation/scrollbar_animation_controller.h" | 15 #include "cc/animation/scrollbar_animation_controller.h" |
16 #include "cc/base/math_util.h" | 16 #include "cc/base/math_util.h" |
17 #include "cc/base/util.h" | 17 #include "cc/base/util.h" |
18 #include "cc/debug/debug_rect_history.h" | 18 #include "cc/debug/debug_rect_history.h" |
19 #include "cc/debug/frame_rate_counter.h" | 19 #include "cc/debug/frame_rate_counter.h" |
20 #include "cc/debug/overdraw_metrics.h" | 20 #include "cc/debug/overdraw_metrics.h" |
21 #include "cc/debug/paint_time_counter.h" | 21 #include "cc/debug/paint_time_counter.h" |
22 #include "cc/debug/rendering_stats_instrumentation.h" | 22 #include "cc/debug/rendering_stats_instrumentation.h" |
23 #include "cc/input/page_scale_animation.h" | 23 #include "cc/input/page_scale_animation.h" |
24 #include "cc/input/top_controls_manager.h" | 24 #include "cc/input/top_controls_manager.h" |
25 #include "cc/layers/append_quads_data.h" | 25 #include "cc/layers/append_quads_data.h" |
26 #include "cc/layers/heads_up_display_layer_impl.h" | 26 #include "cc/layers/heads_up_display_layer_impl.h" |
| 27 #include "cc/layers/layer_impl.h" |
27 #include "cc/layers/layer_iterator.h" | 28 #include "cc/layers/layer_iterator.h" |
| 29 #include "cc/layers/render_surface_impl.h" |
28 #include "cc/layers/scrollbar_layer_impl.h" | 30 #include "cc/layers/scrollbar_layer_impl.h" |
29 #include "cc/output/compositor_frame_metadata.h" | 31 #include "cc/output/compositor_frame_metadata.h" |
30 #include "cc/output/delegating_renderer.h" | 32 #include "cc/output/delegating_renderer.h" |
31 #include "cc/output/gl_renderer.h" | 33 #include "cc/output/gl_renderer.h" |
32 #include "cc/output/software_renderer.h" | 34 #include "cc/output/software_renderer.h" |
33 #include "cc/quads/render_pass_draw_quad.h" | 35 #include "cc/quads/render_pass_draw_quad.h" |
34 #include "cc/quads/shared_quad_state.h" | 36 #include "cc/quads/shared_quad_state.h" |
35 #include "cc/quads/solid_color_draw_quad.h" | 37 #include "cc/quads/solid_color_draw_quad.h" |
36 #include "cc/resources/memory_history.h" | 38 #include "cc/resources/memory_history.h" |
37 #include "cc/resources/picture_layer_tiling.h" | 39 #include "cc/resources/picture_layer_tiling.h" |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 if (LayerTreeHostCommon::LayerHasTouchEventHandlersAt(device_viewport_point, | 359 if (LayerTreeHostCommon::LayerHasTouchEventHandlersAt(device_viewport_point, |
358 layer_impl)) | 360 layer_impl)) |
359 return true; | 361 return true; |
360 } | 362 } |
361 | 363 |
362 return false; | 364 return false; |
363 } | 365 } |
364 | 366 |
365 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 367 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
366 LayerImpl* root_draw_layer, | 368 LayerImpl* root_draw_layer, |
367 const LayerList& render_surface_layer_list) { | 369 const LayerImplList& render_surface_layer_list) { |
368 // For now, we use damage tracking to compute a global scissor. To do this, we | 370 // For now, we use damage tracking to compute a global scissor. To do this, we |
369 // must compute all damage tracking before drawing anything, so that we know | 371 // must compute all damage tracking before drawing anything, so that we know |
370 // the root damage rect. The root damage rect is then used to scissor each | 372 // the root damage rect. The root damage rect is then used to scissor each |
371 // surface. | 373 // surface. |
372 | 374 |
373 for (int surface_index = render_surface_layer_list.size() - 1; | 375 for (int surface_index = render_surface_layer_list.size() - 1; |
374 surface_index >= 0; | 376 surface_index >= 0; |
375 --surface_index) { | 377 --surface_index) { |
376 LayerImpl* render_surface_layer = render_surface_layer_list[surface_index]; | 378 LayerImpl* render_surface_layer = render_surface_layer_list[surface_index]; |
377 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); | 379 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 &frame->occluding_screen_space_rects); | 534 &frame->occluding_screen_space_rects); |
533 } | 535 } |
534 if (debug_state_.show_non_occluding_rects) { | 536 if (debug_state_.show_non_occluding_rects) { |
535 occlusion_tracker.set_non_occluding_screen_space_rects_container( | 537 occlusion_tracker.set_non_occluding_screen_space_rects_container( |
536 &frame->non_occluding_screen_space_rects); | 538 &frame->non_occluding_screen_space_rects); |
537 } | 539 } |
538 | 540 |
539 // Add quads to the Render passes in FrontToBack order to allow for testing | 541 // Add quads to the Render passes in FrontToBack order to allow for testing |
540 // occlusion and performing culling during the tree walk. | 542 // occlusion and performing culling during the tree walk. |
541 typedef LayerIterator<LayerImpl, | 543 typedef LayerIterator<LayerImpl, |
542 std::vector<LayerImpl*>, | 544 LayerImplList, |
543 RenderSurfaceImpl, | 545 RenderSurfaceImpl, |
544 LayerIteratorActions::FrontToBack> LayerIteratorType; | 546 LayerIteratorActions::FrontToBack> LayerIteratorType; |
545 | 547 |
546 // Typically when we are missing a texture and use a checkerboard quad, we | 548 // Typically when we are missing a texture and use a checkerboard quad, we |
547 // still draw the frame. However when the layer being checkerboarded is moving | 549 // still draw the frame. However when the layer being checkerboarded is moving |
548 // due to an impl-animation, we drop the frame to avoid flashing due to the | 550 // due to an impl-animation, we drop the frame to avoid flashing due to the |
549 // texture suddenly appearing in the future. | 551 // texture suddenly appearing in the future. |
550 bool draw_frame = true; | 552 bool draw_frame = true; |
551 | 553 |
552 int layers_drawn = 0; | 554 int layers_drawn = 0; |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 | 2035 |
2034 // static | 2036 // static |
2035 LayerImpl* LayerTreeHostImpl::GetNonCompositedContentLayerRecursive( | 2037 LayerImpl* LayerTreeHostImpl::GetNonCompositedContentLayerRecursive( |
2036 LayerImpl* layer) { | 2038 LayerImpl* layer) { |
2037 if (!layer) | 2039 if (!layer) |
2038 return NULL; | 2040 return NULL; |
2039 | 2041 |
2040 if (layer->DrawsContent()) | 2042 if (layer->DrawsContent()) |
2041 return layer; | 2043 return layer; |
2042 | 2044 |
2043 for (LayerImpl::LayerList::const_iterator it = layer->children().begin(); | 2045 for (LayerImplList::const_iterator it = layer->children().begin(); |
2044 it != layer->children().end(); ++it) { | 2046 it != layer->children().end(); ++it) { |
2045 LayerImpl* nccr = GetNonCompositedContentLayerRecursive(*it); | 2047 LayerImpl* nccr = GetNonCompositedContentLayerRecursive(*it); |
2046 if (nccr) | 2048 if (nccr) |
2047 return nccr; | 2049 return nccr; |
2048 } | 2050 } |
2049 | 2051 |
2050 return NULL; | 2052 return NULL; |
2051 } | 2053 } |
2052 | 2054 |
2053 skia::RefPtr<SkPicture> LayerTreeHostImpl::CapturePicture() { | 2055 skia::RefPtr<SkPicture> LayerTreeHostImpl::CapturePicture() { |
2054 LayerTreeImpl* tree = | 2056 LayerTreeImpl* tree = |
2055 pending_tree_ ? pending_tree_.get() : active_tree_.get(); | 2057 pending_tree_ ? pending_tree_.get() : active_tree_.get(); |
2056 LayerImpl* layer = GetNonCompositedContentLayerRecursive(tree->root_layer()); | 2058 LayerImpl* layer = GetNonCompositedContentLayerRecursive(tree->root_layer()); |
2057 return layer ? layer->GetPicture() : skia::RefPtr<SkPicture>(); | 2059 return layer ? layer->GetPicture() : skia::RefPtr<SkPicture>(); |
2058 } | 2060 } |
2059 | 2061 |
2060 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2062 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2061 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2063 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2062 paint_time_counter_->ClearHistory(); | 2064 paint_time_counter_->ClearHistory(); |
2063 | 2065 |
2064 debug_state_ = debug_state; | 2066 debug_state_ = debug_state; |
2065 } | 2067 } |
2066 | 2068 |
2067 } // namespace cc | 2069 } // namespace cc |
OLD | NEW |