| 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 14 matching lines...) Expand all Loading... |
| 25 #include "cc/debug/paint_time_counter.h" | 25 #include "cc/debug/paint_time_counter.h" |
| 26 #include "cc/debug/rendering_stats_instrumentation.h" | 26 #include "cc/debug/rendering_stats_instrumentation.h" |
| 27 #include "cc/debug/traced_value.h" | 27 #include "cc/debug/traced_value.h" |
| 28 #include "cc/input/page_scale_animation.h" | 28 #include "cc/input/page_scale_animation.h" |
| 29 #include "cc/input/top_controls_manager.h" | 29 #include "cc/input/top_controls_manager.h" |
| 30 #include "cc/layers/append_quads_data.h" | 30 #include "cc/layers/append_quads_data.h" |
| 31 #include "cc/layers/heads_up_display_layer_impl.h" | 31 #include "cc/layers/heads_up_display_layer_impl.h" |
| 32 #include "cc/layers/layer_impl.h" | 32 #include "cc/layers/layer_impl.h" |
| 33 #include "cc/layers/layer_iterator.h" | 33 #include "cc/layers/layer_iterator.h" |
| 34 #include "cc/layers/painted_scrollbar_layer_impl.h" | 34 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 35 #include "cc/layers/quad_sink.h" | |
| 36 #include "cc/layers/render_surface_impl.h" | 35 #include "cc/layers/render_surface_impl.h" |
| 37 #include "cc/layers/scrollbar_layer_impl_base.h" | 36 #include "cc/layers/scrollbar_layer_impl_base.h" |
| 38 #include "cc/output/compositor_frame_metadata.h" | 37 #include "cc/output/compositor_frame_metadata.h" |
| 39 #include "cc/output/copy_output_request.h" | 38 #include "cc/output/copy_output_request.h" |
| 40 #include "cc/output/delegating_renderer.h" | 39 #include "cc/output/delegating_renderer.h" |
| 41 #include "cc/output/gl_renderer.h" | 40 #include "cc/output/gl_renderer.h" |
| 42 #include "cc/output/software_renderer.h" | 41 #include "cc/output/software_renderer.h" |
| 43 #include "cc/quads/render_pass_draw_quad.h" | 42 #include "cc/quads/render_pass_draw_quad.h" |
| 44 #include "cc/quads/shared_quad_state.h" | 43 #include "cc/quads/shared_quad_state.h" |
| 45 #include "cc/quads/solid_color_draw_quad.h" | 44 #include "cc/quads/solid_color_draw_quad.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 << output_surface->capabilities().deferred_gl_initialization; | 574 << output_surface->capabilities().deferred_gl_initialization; |
| 576 return DRAW_MODE_SOFTWARE; | 575 return DRAW_MODE_SOFTWARE; |
| 577 } | 576 } |
| 578 } | 577 } |
| 579 | 578 |
| 580 static void AppendQuadsForLayer( | 579 static void AppendQuadsForLayer( |
| 581 RenderPass* target_render_pass, | 580 RenderPass* target_render_pass, |
| 582 LayerImpl* layer, | 581 LayerImpl* layer, |
| 583 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 582 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 584 AppendQuadsData* append_quads_data) { | 583 AppendQuadsData* append_quads_data) { |
| 585 QuadSink quad_culler(target_render_pass, &occlusion_tracker); | 584 layer->AppendQuads(target_render_pass, occlusion_tracker, append_quads_data); |
| 586 layer->AppendQuads(&quad_culler, append_quads_data); | |
| 587 } | 585 } |
| 588 | 586 |
| 589 static void AppendQuadsForRenderSurfaceLayer( | 587 static void AppendQuadsForRenderSurfaceLayer( |
| 590 RenderPass* target_render_pass, | 588 RenderPass* target_render_pass, |
| 591 LayerImpl* layer, | 589 LayerImpl* layer, |
| 592 const RenderPass* contributing_render_pass, | 590 const RenderPass* contributing_render_pass, |
| 593 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 591 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 594 AppendQuadsData* append_quads_data) { | 592 AppendQuadsData* append_quads_data) { |
| 595 QuadSink quad_culler(target_render_pass, &occlusion_tracker); | |
| 596 | |
| 597 bool is_replica = false; | 593 bool is_replica = false; |
| 598 layer->render_surface()->AppendQuads(&quad_culler, | 594 layer->render_surface()->AppendQuads(target_render_pass, |
| 595 occlusion_tracker, |
| 599 append_quads_data, | 596 append_quads_data, |
| 600 is_replica, | 597 is_replica, |
| 601 contributing_render_pass->id); | 598 contributing_render_pass->id); |
| 602 | 599 |
| 603 // Add replica after the surface so that it appears below the surface. | 600 // Add replica after the surface so that it appears below the surface. |
| 604 if (layer->has_replica()) { | 601 if (layer->has_replica()) { |
| 605 is_replica = true; | 602 is_replica = true; |
| 606 layer->render_surface()->AppendQuads(&quad_culler, | 603 layer->render_surface()->AppendQuads(target_render_pass, |
| 604 occlusion_tracker, |
| 607 append_quads_data, | 605 append_quads_data, |
| 608 is_replica, | 606 is_replica, |
| 609 contributing_render_pass->id); | 607 contributing_render_pass->id); |
| 610 } | 608 } |
| 611 } | 609 } |
| 612 | 610 |
| 613 static void AppendQuadsToFillScreen( | 611 static void AppendQuadsToFillScreen( |
| 614 ResourceProvider::ResourceId overhang_resource_id, | 612 ResourceProvider::ResourceId overhang_resource_id, |
| 615 const gfx::SizeF& overhang_resource_scaled_size, | 613 const gfx::SizeF& overhang_resource_scaled_size, |
| 616 const gfx::Rect& root_scroll_layer_rect, | 614 const gfx::Rect& root_scroll_layer_rect, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 628 // Divide the fill region into the part to be filled with the overhang | 626 // Divide the fill region into the part to be filled with the overhang |
| 629 // resource and the part to be filled with the background color. | 627 // resource and the part to be filled with the background color. |
| 630 Region screen_background_color_region = fill_region; | 628 Region screen_background_color_region = fill_region; |
| 631 Region overhang_region; | 629 Region overhang_region; |
| 632 if (overhang_resource_id) { | 630 if (overhang_resource_id) { |
| 633 overhang_region = fill_region; | 631 overhang_region = fill_region; |
| 634 overhang_region.Subtract(root_scroll_layer_rect); | 632 overhang_region.Subtract(root_scroll_layer_rect); |
| 635 screen_background_color_region.Intersect(root_scroll_layer_rect); | 633 screen_background_color_region.Intersect(root_scroll_layer_rect); |
| 636 } | 634 } |
| 637 | 635 |
| 638 QuadSink quad_culler(target_render_pass, &occlusion_tracker); | |
| 639 | |
| 640 // Manually create the quad state for the gutter quads, as the root layer | 636 // Manually create the quad state for the gutter quads, as the root layer |
| 641 // doesn't have any bounds and so can't generate this itself. | 637 // doesn't have any bounds and so can't generate this itself. |
| 642 // TODO(danakj): Make the gutter quads generated by the solid color layer | 638 // TODO(danakj): Make the gutter quads generated by the solid color layer |
| 643 // (make it smarter about generating quads to fill unoccluded areas). | 639 // (make it smarter about generating quads to fill unoccluded areas). |
| 644 | 640 |
| 645 gfx::Rect root_target_rect = root_layer->render_surface()->content_rect(); | 641 gfx::Rect root_target_rect = root_layer->render_surface()->content_rect(); |
| 646 float opacity = 1.f; | 642 float opacity = 1.f; |
| 647 SharedQuadState* shared_quad_state = quad_culler.CreateSharedQuadState(); | 643 SharedQuadState* shared_quad_state = |
| 644 target_render_pass->CreateAndAppendSharedQuadState(); |
| 648 shared_quad_state->SetAll(gfx::Transform(), | 645 shared_quad_state->SetAll(gfx::Transform(), |
| 649 root_target_rect.size(), | 646 root_target_rect.size(), |
| 650 root_target_rect, | 647 root_target_rect, |
| 651 root_target_rect, | 648 root_target_rect, |
| 652 false, | 649 false, |
| 653 opacity, | 650 opacity, |
| 654 SkXfermode::kSrcOver_Mode); | 651 SkXfermode::kSrcOver_Mode); |
| 655 | 652 |
| 656 for (Region::Iterator fill_rects(screen_background_color_region); | 653 for (Region::Iterator fill_rects(screen_background_color_region); |
| 657 fill_rects.has_rect(); | 654 fill_rects.has_rect(); |
| 658 fill_rects.next()) { | 655 fill_rects.next()) { |
| 659 gfx::Rect screen_space_rect = fill_rects.rect(); | 656 gfx::Rect screen_space_rect = fill_rects.rect(); |
| 660 gfx::Rect visible_screen_space_rect = screen_space_rect; | 657 gfx::Rect visible_screen_space_rect = screen_space_rect; |
| 661 // Skip the quad culler and just append the quads directly to avoid | 658 // Skip the quad culler and just append the quads directly to avoid |
| 662 // occlusion checks. | 659 // occlusion checks. |
| 663 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 660 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 664 quad->SetNew(shared_quad_state, | 661 quad->SetNew(shared_quad_state, |
| 665 screen_space_rect, | 662 screen_space_rect, |
| 666 visible_screen_space_rect, | 663 visible_screen_space_rect, |
| 667 screen_background_color, | 664 screen_background_color, |
| 668 false); | 665 false); |
| 669 quad_culler.Append(quad.PassAs<DrawQuad>()); | 666 target_render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 670 } | 667 } |
| 671 for (Region::Iterator fill_rects(overhang_region); | 668 for (Region::Iterator fill_rects(overhang_region); |
| 672 fill_rects.has_rect(); | 669 fill_rects.has_rect(); |
| 673 fill_rects.next()) { | 670 fill_rects.next()) { |
| 674 DCHECK(overhang_resource_id); | 671 DCHECK(overhang_resource_id); |
| 675 gfx::Rect screen_space_rect = fill_rects.rect(); | 672 gfx::Rect screen_space_rect = fill_rects.rect(); |
| 676 gfx::Rect opaque_screen_space_rect = screen_space_rect; | 673 gfx::Rect opaque_screen_space_rect = screen_space_rect; |
| 677 gfx::Rect visible_screen_space_rect = screen_space_rect; | 674 gfx::Rect visible_screen_space_rect = screen_space_rect; |
| 678 scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create(); | 675 scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create(); |
| 679 const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; | 676 const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; |
| 680 tex_quad->SetNew( | 677 tex_quad->SetNew( |
| 681 shared_quad_state, | 678 shared_quad_state, |
| 682 screen_space_rect, | 679 screen_space_rect, |
| 683 opaque_screen_space_rect, | 680 opaque_screen_space_rect, |
| 684 visible_screen_space_rect, | 681 visible_screen_space_rect, |
| 685 overhang_resource_id, | 682 overhang_resource_id, |
| 686 false, | 683 false, |
| 687 gfx::PointF( | 684 gfx::PointF( |
| 688 screen_space_rect.x() / overhang_resource_scaled_size.width(), | 685 screen_space_rect.x() / overhang_resource_scaled_size.width(), |
| 689 screen_space_rect.y() / overhang_resource_scaled_size.height()), | 686 screen_space_rect.y() / overhang_resource_scaled_size.height()), |
| 690 gfx::PointF( | 687 gfx::PointF( |
| 691 screen_space_rect.right() / overhang_resource_scaled_size.width(), | 688 screen_space_rect.right() / overhang_resource_scaled_size.width(), |
| 692 screen_space_rect.bottom() / | 689 screen_space_rect.bottom() / |
| 693 overhang_resource_scaled_size.height()), | 690 overhang_resource_scaled_size.height()), |
| 694 screen_background_color, | 691 screen_background_color, |
| 695 vertex_opacity, | 692 vertex_opacity, |
| 696 false); | 693 false); |
| 697 quad_culler.Append(tex_quad.PassAs<DrawQuad>()); | 694 target_render_pass->AppendDrawQuad(tex_quad.PassAs<DrawQuad>()); |
| 698 } | 695 } |
| 699 } | 696 } |
| 700 | 697 |
| 701 DrawResult LayerTreeHostImpl::CalculateRenderPasses( | 698 DrawResult LayerTreeHostImpl::CalculateRenderPasses( |
| 702 FrameData* frame) { | 699 FrameData* frame) { |
| 703 DCHECK(frame->render_passes.empty()); | 700 DCHECK(frame->render_passes.empty()); |
| 704 DCHECK(CanDraw()); | 701 DCHECK(CanDraw()); |
| 705 DCHECK(active_tree_->root_layer()); | 702 DCHECK(active_tree_->root_layer()); |
| 706 | 703 |
| 707 TrackDamageForAllSurfaces(active_tree_->root_layer(), | 704 TrackDamageForAllSurfaces(active_tree_->root_layer(), |
| (...skipping 2420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3128 swap_promise_monitor_.erase(monitor); | 3125 swap_promise_monitor_.erase(monitor); |
| 3129 } | 3126 } |
| 3130 | 3127 |
| 3131 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3128 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
| 3132 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3129 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3133 for (; it != swap_promise_monitor_.end(); it++) | 3130 for (; it != swap_promise_monitor_.end(); it++) |
| 3134 (*it)->OnSetNeedsRedrawOnImpl(); | 3131 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3135 } | 3132 } |
| 3136 | 3133 |
| 3137 } // namespace cc | 3134 } // namespace cc |
| OLD | NEW |