| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 << output_surface->capabilities().deferred_gl_initialization; | 565 << output_surface->capabilities().deferred_gl_initialization; |
| 567 return DRAW_MODE_SOFTWARE; | 566 return DRAW_MODE_SOFTWARE; |
| 568 } | 567 } |
| 569 } | 568 } |
| 570 | 569 |
| 571 static void AppendQuadsForLayer( | 570 static void AppendQuadsForLayer( |
| 572 RenderPass* target_render_pass, | 571 RenderPass* target_render_pass, |
| 573 LayerImpl* layer, | 572 LayerImpl* layer, |
| 574 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 573 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 575 AppendQuadsData* append_quads_data) { | 574 AppendQuadsData* append_quads_data) { |
| 576 QuadSink quad_culler(target_render_pass, &occlusion_tracker); | 575 layer->AppendQuads(target_render_pass, occlusion_tracker, append_quads_data); |
| 577 layer->AppendQuads(&quad_culler, append_quads_data); | |
| 578 } | 576 } |
| 579 | 577 |
| 580 static void AppendQuadsForRenderSurfaceLayer( | 578 static void AppendQuadsForRenderSurfaceLayer( |
| 581 RenderPass* target_render_pass, | 579 RenderPass* target_render_pass, |
| 582 LayerImpl* layer, | 580 LayerImpl* layer, |
| 583 const RenderPass* contributing_render_pass, | 581 const RenderPass* contributing_render_pass, |
| 584 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 582 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 585 AppendQuadsData* append_quads_data) { | 583 AppendQuadsData* append_quads_data) { |
| 586 QuadSink quad_culler(target_render_pass, &occlusion_tracker); | |
| 587 | |
| 588 bool is_replica = false; | 584 bool is_replica = false; |
| 589 layer->render_surface()->AppendQuads(&quad_culler, | 585 layer->render_surface()->AppendQuads(target_render_pass, |
| 586 occlusion_tracker, |
| 590 append_quads_data, | 587 append_quads_data, |
| 591 is_replica, | 588 is_replica, |
| 592 contributing_render_pass->id); | 589 contributing_render_pass->id); |
| 593 | 590 |
| 594 // Add replica after the surface so that it appears below the surface. | 591 // Add replica after the surface so that it appears below the surface. |
| 595 if (layer->has_replica()) { | 592 if (layer->has_replica()) { |
| 596 is_replica = true; | 593 is_replica = true; |
| 597 layer->render_surface()->AppendQuads(&quad_culler, | 594 layer->render_surface()->AppendQuads(target_render_pass, |
| 595 occlusion_tracker, |
| 598 append_quads_data, | 596 append_quads_data, |
| 599 is_replica, | 597 is_replica, |
| 600 contributing_render_pass->id); | 598 contributing_render_pass->id); |
| 601 } | 599 } |
| 602 } | 600 } |
| 603 | 601 |
| 604 static void AppendQuadsToFillScreen( | 602 static void AppendQuadsToFillScreen( |
| 605 ResourceProvider::ResourceId overhang_resource_id, | 603 ResourceProvider::ResourceId overhang_resource_id, |
| 606 const gfx::SizeF& overhang_resource_scaled_size, | 604 const gfx::SizeF& overhang_resource_scaled_size, |
| 607 const gfx::Rect& root_scroll_layer_rect, | 605 const gfx::Rect& root_scroll_layer_rect, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 619 // Divide the fill region into the part to be filled with the overhang | 617 // Divide the fill region into the part to be filled with the overhang |
| 620 // resource and the part to be filled with the background color. | 618 // resource and the part to be filled with the background color. |
| 621 Region screen_background_color_region = fill_region; | 619 Region screen_background_color_region = fill_region; |
| 622 Region overhang_region; | 620 Region overhang_region; |
| 623 if (overhang_resource_id) { | 621 if (overhang_resource_id) { |
| 624 overhang_region = fill_region; | 622 overhang_region = fill_region; |
| 625 overhang_region.Subtract(root_scroll_layer_rect); | 623 overhang_region.Subtract(root_scroll_layer_rect); |
| 626 screen_background_color_region.Intersect(root_scroll_layer_rect); | 624 screen_background_color_region.Intersect(root_scroll_layer_rect); |
| 627 } | 625 } |
| 628 | 626 |
| 629 QuadSink quad_culler(target_render_pass, &occlusion_tracker); | |
| 630 | |
| 631 // Manually create the quad state for the gutter quads, as the root layer | 627 // Manually create the quad state for the gutter quads, as the root layer |
| 632 // doesn't have any bounds and so can't generate this itself. | 628 // doesn't have any bounds and so can't generate this itself. |
| 633 // TODO(danakj): Make the gutter quads generated by the solid color layer | 629 // TODO(danakj): Make the gutter quads generated by the solid color layer |
| 634 // (make it smarter about generating quads to fill unoccluded areas). | 630 // (make it smarter about generating quads to fill unoccluded areas). |
| 635 | 631 |
| 636 gfx::Rect root_target_rect = root_layer->render_surface()->content_rect(); | 632 gfx::Rect root_target_rect = root_layer->render_surface()->content_rect(); |
| 637 float opacity = 1.f; | 633 float opacity = 1.f; |
| 638 int sorting_context_id = 0; | 634 int sorting_context_id = 0; |
| 639 SharedQuadState* shared_quad_state = quad_culler.CreateSharedQuadState(); | 635 SharedQuadState* shared_quad_state = |
| 636 target_render_pass->CreateAndAppendSharedQuadState(); |
| 640 shared_quad_state->SetAll(gfx::Transform(), | 637 shared_quad_state->SetAll(gfx::Transform(), |
| 641 root_target_rect.size(), | 638 root_target_rect.size(), |
| 642 root_target_rect, | 639 root_target_rect, |
| 643 root_target_rect, | 640 root_target_rect, |
| 644 false, | 641 false, |
| 645 opacity, | 642 opacity, |
| 646 SkXfermode::kSrcOver_Mode, | 643 SkXfermode::kSrcOver_Mode, |
| 647 sorting_context_id); | 644 sorting_context_id); |
| 648 | 645 |
| 649 for (Region::Iterator fill_rects(screen_background_color_region); | 646 for (Region::Iterator fill_rects(screen_background_color_region); |
| 650 fill_rects.has_rect(); | 647 fill_rects.has_rect(); |
| 651 fill_rects.next()) { | 648 fill_rects.next()) { |
| 652 gfx::Rect screen_space_rect = fill_rects.rect(); | 649 gfx::Rect screen_space_rect = fill_rects.rect(); |
| 653 gfx::Rect visible_screen_space_rect = screen_space_rect; | 650 gfx::Rect visible_screen_space_rect = screen_space_rect; |
| 654 // Skip the quad culler and just append the quads directly to avoid | 651 // Skip the quad culler and just append the quads directly to avoid |
| 655 // occlusion checks. | 652 // occlusion checks. |
| 656 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 653 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 657 quad->SetNew(shared_quad_state, | 654 quad->SetNew(shared_quad_state, |
| 658 screen_space_rect, | 655 screen_space_rect, |
| 659 visible_screen_space_rect, | 656 visible_screen_space_rect, |
| 660 screen_background_color, | 657 screen_background_color, |
| 661 false); | 658 false); |
| 662 quad_culler.Append(quad.PassAs<DrawQuad>()); | 659 target_render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 663 } | 660 } |
| 664 for (Region::Iterator fill_rects(overhang_region); | 661 for (Region::Iterator fill_rects(overhang_region); |
| 665 fill_rects.has_rect(); | 662 fill_rects.has_rect(); |
| 666 fill_rects.next()) { | 663 fill_rects.next()) { |
| 667 DCHECK(overhang_resource_id); | 664 DCHECK(overhang_resource_id); |
| 668 gfx::Rect screen_space_rect = fill_rects.rect(); | 665 gfx::Rect screen_space_rect = fill_rects.rect(); |
| 669 gfx::Rect opaque_screen_space_rect = screen_space_rect; | 666 gfx::Rect opaque_screen_space_rect = screen_space_rect; |
| 670 gfx::Rect visible_screen_space_rect = screen_space_rect; | 667 gfx::Rect visible_screen_space_rect = screen_space_rect; |
| 671 scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create(); | 668 scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create(); |
| 672 const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; | 669 const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; |
| 673 tex_quad->SetNew( | 670 tex_quad->SetNew( |
| 674 shared_quad_state, | 671 shared_quad_state, |
| 675 screen_space_rect, | 672 screen_space_rect, |
| 676 opaque_screen_space_rect, | 673 opaque_screen_space_rect, |
| 677 visible_screen_space_rect, | 674 visible_screen_space_rect, |
| 678 overhang_resource_id, | 675 overhang_resource_id, |
| 679 false, | 676 false, |
| 680 gfx::PointF( | 677 gfx::PointF( |
| 681 screen_space_rect.x() / overhang_resource_scaled_size.width(), | 678 screen_space_rect.x() / overhang_resource_scaled_size.width(), |
| 682 screen_space_rect.y() / overhang_resource_scaled_size.height()), | 679 screen_space_rect.y() / overhang_resource_scaled_size.height()), |
| 683 gfx::PointF( | 680 gfx::PointF( |
| 684 screen_space_rect.right() / overhang_resource_scaled_size.width(), | 681 screen_space_rect.right() / overhang_resource_scaled_size.width(), |
| 685 screen_space_rect.bottom() / | 682 screen_space_rect.bottom() / |
| 686 overhang_resource_scaled_size.height()), | 683 overhang_resource_scaled_size.height()), |
| 687 screen_background_color, | 684 screen_background_color, |
| 688 vertex_opacity, | 685 vertex_opacity, |
| 689 false); | 686 false); |
| 690 quad_culler.Append(tex_quad.PassAs<DrawQuad>()); | 687 target_render_pass->AppendDrawQuad(tex_quad.PassAs<DrawQuad>()); |
| 691 } | 688 } |
| 692 } | 689 } |
| 693 | 690 |
| 694 DrawResult LayerTreeHostImpl::CalculateRenderPasses( | 691 DrawResult LayerTreeHostImpl::CalculateRenderPasses( |
| 695 FrameData* frame) { | 692 FrameData* frame) { |
| 696 DCHECK(frame->render_passes.empty()); | 693 DCHECK(frame->render_passes.empty()); |
| 697 DCHECK(CanDraw()); | 694 DCHECK(CanDraw()); |
| 698 DCHECK(active_tree_->root_layer()); | 695 DCHECK(active_tree_->root_layer()); |
| 699 | 696 |
| 700 TrackDamageForAllSurfaces(active_tree_->root_layer(), | 697 TrackDamageForAllSurfaces(active_tree_->root_layer(), |
| (...skipping 2441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3142 } | 3139 } |
| 3143 | 3140 |
| 3144 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3141 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3145 std::vector<PictureLayerImpl*>::iterator it = | 3142 std::vector<PictureLayerImpl*>::iterator it = |
| 3146 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3143 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3147 DCHECK(it != picture_layers_.end()); | 3144 DCHECK(it != picture_layers_.end()); |
| 3148 picture_layers_.erase(it); | 3145 picture_layers_.erase(it); |
| 3149 } | 3146 } |
| 3150 | 3147 |
| 3151 } // namespace cc | 3148 } // namespace cc |
| OLD | NEW |