| 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" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "cc/resources/memory_history.h" | 47 #include "cc/resources/memory_history.h" |
| 48 #include "cc/resources/picture_layer_tiling.h" | 48 #include "cc/resources/picture_layer_tiling.h" |
| 49 #include "cc/resources/prioritized_resource_manager.h" | 49 #include "cc/resources/prioritized_resource_manager.h" |
| 50 #include "cc/resources/texture_mailbox_deleter.h" | 50 #include "cc/resources/texture_mailbox_deleter.h" |
| 51 #include "cc/resources/ui_resource_bitmap.h" | 51 #include "cc/resources/ui_resource_bitmap.h" |
| 52 #include "cc/scheduler/delay_based_time_source.h" | 52 #include "cc/scheduler/delay_based_time_source.h" |
| 53 #include "cc/trees/damage_tracker.h" | 53 #include "cc/trees/damage_tracker.h" |
| 54 #include "cc/trees/layer_tree_host.h" | 54 #include "cc/trees/layer_tree_host.h" |
| 55 #include "cc/trees/layer_tree_host_common.h" | 55 #include "cc/trees/layer_tree_host_common.h" |
| 56 #include "cc/trees/layer_tree_impl.h" | 56 #include "cc/trees/layer_tree_impl.h" |
| 57 #include "cc/trees/occlusion_tracker.h" |
| 57 #include "cc/trees/quad_culler.h" | 58 #include "cc/trees/quad_culler.h" |
| 58 #include "cc/trees/single_thread_proxy.h" | 59 #include "cc/trees/single_thread_proxy.h" |
| 59 #include "cc/trees/tree_synchronizer.h" | 60 #include "cc/trees/tree_synchronizer.h" |
| 60 #include "gpu/GLES2/gl2extchromium.h" | 61 #include "gpu/GLES2/gl2extchromium.h" |
| 61 #include "ui/gfx/frame_time.h" | 62 #include "ui/gfx/frame_time.h" |
| 62 #include "ui/gfx/size_conversions.h" | 63 #include "ui/gfx/size_conversions.h" |
| 63 #include "ui/gfx/vector2d_conversions.h" | 64 #include "ui/gfx/vector2d_conversions.h" |
| 64 | 65 |
| 65 namespace { | 66 namespace { |
| 66 | 67 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 return DRAW_MODE_RESOURCELESS_SOFTWARE; | 554 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
| 554 } else if (output_surface->context_provider()) { | 555 } else if (output_surface->context_provider()) { |
| 555 return DRAW_MODE_HARDWARE; | 556 return DRAW_MODE_HARDWARE; |
| 556 } else { | 557 } else { |
| 557 DCHECK_EQ(!output_surface->software_device(), | 558 DCHECK_EQ(!output_surface->software_device(), |
| 558 output_surface->capabilities().delegated_rendering); | 559 output_surface->capabilities().delegated_rendering); |
| 559 return DRAW_MODE_SOFTWARE; | 560 return DRAW_MODE_SOFTWARE; |
| 560 } | 561 } |
| 561 } | 562 } |
| 562 | 563 |
| 563 static void AppendQuadsForLayer(RenderPass* target_render_pass, | 564 static void AppendQuadsForLayer( |
| 564 LayerImpl* layer, | 565 RenderPass* target_render_pass, |
| 565 const OcclusionTrackerImpl& occlusion_tracker, | 566 LayerImpl* layer, |
| 566 AppendQuadsData* append_quads_data) { | 567 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 568 AppendQuadsData* append_quads_data) { |
| 567 bool for_surface = false; | 569 bool for_surface = false; |
| 568 QuadCuller quad_culler(&target_render_pass->quad_list, | 570 QuadCuller quad_culler(&target_render_pass->quad_list, |
| 569 &target_render_pass->shared_quad_state_list, | 571 &target_render_pass->shared_quad_state_list, |
| 570 layer, | 572 layer, |
| 571 occlusion_tracker, | 573 occlusion_tracker, |
| 572 layer->ShowDebugBorders(), | 574 layer->ShowDebugBorders(), |
| 573 for_surface); | 575 for_surface); |
| 574 layer->AppendQuads(&quad_culler, append_quads_data); | 576 layer->AppendQuads(&quad_culler, append_quads_data); |
| 575 } | 577 } |
| 576 | 578 |
| 577 static void AppendQuadsForRenderSurfaceLayer( | 579 static void AppendQuadsForRenderSurfaceLayer( |
| 578 RenderPass* target_render_pass, | 580 RenderPass* target_render_pass, |
| 579 LayerImpl* layer, | 581 LayerImpl* layer, |
| 580 const RenderPass* contributing_render_pass, | 582 const RenderPass* contributing_render_pass, |
| 581 const OcclusionTrackerImpl& occlusion_tracker, | 583 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 582 AppendQuadsData* append_quads_data) { | 584 AppendQuadsData* append_quads_data) { |
| 583 bool for_surface = true; | 585 bool for_surface = true; |
| 584 QuadCuller quad_culler(&target_render_pass->quad_list, | 586 QuadCuller quad_culler(&target_render_pass->quad_list, |
| 585 &target_render_pass->shared_quad_state_list, | 587 &target_render_pass->shared_quad_state_list, |
| 586 layer, | 588 layer, |
| 587 occlusion_tracker, | 589 occlusion_tracker, |
| 588 layer->ShowDebugBorders(), | 590 layer->ShowDebugBorders(), |
| 589 for_surface); | 591 for_surface); |
| 590 | 592 |
| 591 bool is_replica = false; | 593 bool is_replica = false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 604 } | 606 } |
| 605 } | 607 } |
| 606 | 608 |
| 607 static void AppendQuadsToFillScreen( | 609 static void AppendQuadsToFillScreen( |
| 608 ResourceProvider::ResourceId overhang_resource_id, | 610 ResourceProvider::ResourceId overhang_resource_id, |
| 609 const gfx::SizeF& overhang_resource_scaled_size, | 611 const gfx::SizeF& overhang_resource_scaled_size, |
| 610 const gfx::Rect& root_scroll_layer_rect, | 612 const gfx::Rect& root_scroll_layer_rect, |
| 611 RenderPass* target_render_pass, | 613 RenderPass* target_render_pass, |
| 612 LayerImpl* root_layer, | 614 LayerImpl* root_layer, |
| 613 SkColor screen_background_color, | 615 SkColor screen_background_color, |
| 614 const OcclusionTrackerImpl& occlusion_tracker) { | 616 const OcclusionTracker<LayerImpl>& occlusion_tracker) { |
| 615 if (!root_layer || !SkColorGetA(screen_background_color)) | 617 if (!root_layer || !SkColorGetA(screen_background_color)) |
| 616 return; | 618 return; |
| 617 | 619 |
| 618 Region fill_region = occlusion_tracker.ComputeVisibleRegionInScreen(); | 620 Region fill_region = occlusion_tracker.ComputeVisibleRegionInScreen(); |
| 619 if (fill_region.IsEmpty()) | 621 if (fill_region.IsEmpty()) |
| 620 return; | 622 return; |
| 621 | 623 |
| 622 // Divide the fill region into the part to be filled with the overhang | 624 // Divide the fill region into the part to be filled with the overhang |
| 623 // resource and the part to be filled with the background color. | 625 // resource and the part to be filled with the background color. |
| 624 Region screen_background_color_region = fill_region; | 626 Region screen_background_color_region = fill_region; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 render_surface->contributes_to_drawn_surface() || | 742 render_surface->contributes_to_drawn_surface() || |
| 741 render_surface_layer->HasCopyRequest(); | 743 render_surface_layer->HasCopyRequest(); |
| 742 if (should_draw_into_render_pass) | 744 if (should_draw_into_render_pass) |
| 743 render_surface_layer->render_surface()->AppendRenderPasses(frame); | 745 render_surface_layer->render_surface()->AppendRenderPasses(frame); |
| 744 } | 746 } |
| 745 | 747 |
| 746 bool record_metrics_for_frame = | 748 bool record_metrics_for_frame = |
| 747 settings_.show_overdraw_in_tracing && | 749 settings_.show_overdraw_in_tracing && |
| 748 base::debug::TraceLog::GetInstance() && | 750 base::debug::TraceLog::GetInstance() && |
| 749 base::debug::TraceLog::GetInstance()->IsEnabled(); | 751 base::debug::TraceLog::GetInstance()->IsEnabled(); |
| 750 OcclusionTrackerImpl occlusion_tracker( | 752 OcclusionTracker<LayerImpl> occlusion_tracker( |
| 751 active_tree_->root_layer()->render_surface()->content_rect(), | 753 active_tree_->root_layer()->render_surface()->content_rect(), |
| 752 record_metrics_for_frame); | 754 record_metrics_for_frame); |
| 753 occlusion_tracker.set_minimum_tracking_size( | 755 occlusion_tracker.set_minimum_tracking_size( |
| 754 settings_.minimum_occlusion_tracking_size); | 756 settings_.minimum_occlusion_tracking_size); |
| 755 | 757 |
| 756 if (debug_state_.show_occluding_rects) { | 758 if (debug_state_.show_occluding_rects) { |
| 757 occlusion_tracker.set_occluding_screen_space_rects_container( | 759 occlusion_tracker.set_occluding_screen_space_rects_container( |
| 758 &frame->occluding_screen_space_rects); | 760 &frame->occluding_screen_space_rects); |
| 759 } | 761 } |
| 760 if (debug_state_.show_non_occluding_rects) { | 762 if (debug_state_.show_non_occluding_rects) { |
| (...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3023 swap_promise_monitor_.erase(monitor); | 3025 swap_promise_monitor_.erase(monitor); |
| 3024 } | 3026 } |
| 3025 | 3027 |
| 3026 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3028 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
| 3027 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3029 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3028 for (; it != swap_promise_monitor_.end(); it++) | 3030 for (; it != swap_promise_monitor_.end(); it++) |
| 3029 (*it)->OnSetNeedsRedrawOnImpl(); | 3031 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3030 } | 3032 } |
| 3031 | 3033 |
| 3032 } // namespace cc | 3034 } // namespace cc |
| OLD | NEW |