| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "cc/resources/software_rasterizer.h" | 61 #include "cc/resources/software_rasterizer.h" |
| 62 #include "cc/resources/texture_mailbox_deleter.h" | 62 #include "cc/resources/texture_mailbox_deleter.h" |
| 63 #include "cc/resources/tile_task_worker_pool.h" | 63 #include "cc/resources/tile_task_worker_pool.h" |
| 64 #include "cc/resources/ui_resource_bitmap.h" | 64 #include "cc/resources/ui_resource_bitmap.h" |
| 65 #include "cc/resources/zero_copy_tile_task_worker_pool.h" | 65 #include "cc/resources/zero_copy_tile_task_worker_pool.h" |
| 66 #include "cc/scheduler/delay_based_time_source.h" | 66 #include "cc/scheduler/delay_based_time_source.h" |
| 67 #include "cc/trees/damage_tracker.h" | 67 #include "cc/trees/damage_tracker.h" |
| 68 #include "cc/trees/layer_tree_host.h" | 68 #include "cc/trees/layer_tree_host.h" |
| 69 #include "cc/trees/layer_tree_host_common.h" | 69 #include "cc/trees/layer_tree_host_common.h" |
| 70 #include "cc/trees/layer_tree_impl.h" | 70 #include "cc/trees/layer_tree_impl.h" |
| 71 #include "cc/trees/occlusion_tracker.h" | |
| 72 #include "cc/trees/single_thread_proxy.h" | 71 #include "cc/trees/single_thread_proxy.h" |
| 73 #include "cc/trees/tree_synchronizer.h" | 72 #include "cc/trees/tree_synchronizer.h" |
| 74 #include "gpu/command_buffer/client/gles2_interface.h" | 73 #include "gpu/command_buffer/client/gles2_interface.h" |
| 75 #include "gpu/GLES2/gl2extchromium.h" | 74 #include "gpu/GLES2/gl2extchromium.h" |
| 76 #include "ui/gfx/frame_time.h" | 75 #include "ui/gfx/frame_time.h" |
| 77 #include "ui/gfx/geometry/rect_conversions.h" | 76 #include "ui/gfx/geometry/rect_conversions.h" |
| 78 #include "ui/gfx/geometry/size_conversions.h" | 77 #include "ui/gfx/geometry/size_conversions.h" |
| 79 #include "ui/gfx/geometry/vector2d_conversions.h" | 78 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 80 | 79 |
| 81 namespace cc { | 80 namespace cc { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 is_likely_to_require_a_draw_(false), | 227 is_likely_to_require_a_draw_(false), |
| 229 frame_timing_tracker_(FrameTimingTracker::Create()) { | 228 frame_timing_tracker_(FrameTimingTracker::Create()) { |
| 230 DCHECK(proxy_->IsImplThread()); | 229 DCHECK(proxy_->IsImplThread()); |
| 231 DidVisibilityChange(this, visible_); | 230 DidVisibilityChange(this, visible_); |
| 232 animation_registrar_->set_supports_scroll_animations( | 231 animation_registrar_->set_supports_scroll_animations( |
| 233 proxy_->SupportsImplScrolling()); | 232 proxy_->SupportsImplScrolling()); |
| 234 | 233 |
| 235 SetDebugState(settings.initial_debug_state); | 234 SetDebugState(settings.initial_debug_state); |
| 236 | 235 |
| 237 // LTHI always has an active tree. | 236 // LTHI always has an active tree. |
| 238 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), | 237 active_tree_ = |
| 239 new SyncedElasticOverscroll); | 238 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), |
| 239 new SyncedTopControls, new SyncedElasticOverscroll); |
| 240 | 240 |
| 241 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 241 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
| 242 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 242 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
| 243 | 243 |
| 244 if (settings.calculate_top_controls_position) { | 244 if (settings.calculate_top_controls_position) { |
| 245 top_controls_manager_ = | 245 top_controls_manager_ = |
| 246 TopControlsManager::Create(this, | 246 TopControlsManager::Create(this, |
| 247 settings.top_controls_show_threshold, | 247 settings.top_controls_show_threshold, |
| 248 settings.top_controls_hide_threshold); | 248 settings.top_controls_hide_threshold); |
| 249 } | 249 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 void LayerTreeHostImpl::BeginCommit() { | 289 void LayerTreeHostImpl::BeginCommit() { |
| 290 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); | 290 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); |
| 291 | 291 |
| 292 // Ensure all textures are returned so partial texture updates can happen | 292 // Ensure all textures are returned so partial texture updates can happen |
| 293 // during the commit. Impl-side-painting doesn't upload during commits, so | 293 // during the commit. Impl-side-painting doesn't upload during commits, so |
| 294 // is unaffected. | 294 // is unaffected. |
| 295 if (!settings_.impl_side_painting && output_surface_) | 295 if (!settings_.impl_side_painting && output_surface_) |
| 296 output_surface_->ForceReclaimResources(); | 296 output_surface_->ForceReclaimResources(); |
| 297 | 297 |
| 298 if (UsePendingTreeForSync()) | 298 if (settings_.impl_side_painting && !proxy_->CommitToActiveTree()) |
| 299 CreatePendingTree(); | 299 CreatePendingTree(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void LayerTreeHostImpl::CommitComplete() { | 302 void LayerTreeHostImpl::CommitComplete() { |
| 303 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 303 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
| 304 | 304 |
| 305 sync_tree()->set_needs_update_draw_properties(); | 305 sync_tree()->set_needs_update_draw_properties(); |
| 306 | 306 |
| 307 if (settings_.impl_side_painting) { | 307 if (settings_.impl_side_painting) { |
| 308 // Impl-side painting needs an update immediately post-commit to have the | 308 // Impl-side painting needs an update immediately post-commit to have the |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 render_surface->layer_list(), | 541 render_surface->layer_list(), |
| 542 render_surface_layer->id(), | 542 render_surface_layer->id(), |
| 543 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 543 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
| 544 render_surface->content_rect(), | 544 render_surface->content_rect(), |
| 545 render_surface_layer->mask_layer(), | 545 render_surface_layer->mask_layer(), |
| 546 render_surface_layer->filters()); | 546 render_surface_layer->filters()); |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 | 549 |
| 550 void LayerTreeHostImpl::FrameData::AsValueInto( | 550 void LayerTreeHostImpl::FrameData::AsValueInto( |
| 551 base::debug::TracedValue* value) const { | 551 base::trace_event::TracedValue* value) const { |
| 552 value->SetBoolean("has_no_damage", has_no_damage); | 552 value->SetBoolean("has_no_damage", has_no_damage); |
| 553 | 553 |
| 554 // Quad data can be quite large, so only dump render passes if we select | 554 // Quad data can be quite large, so only dump render passes if we select |
| 555 // cc.debug.quads. | 555 // cc.debug.quads. |
| 556 bool quads_enabled; | 556 bool quads_enabled; |
| 557 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 557 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 558 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 558 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
| 559 if (quads_enabled) { | 559 if (quads_enabled) { |
| 560 value->BeginArray("render_passes"); | 560 value->BeginArray("render_passes"); |
| 561 for (size_t i = 0; i < render_passes.size(); ++i) { | 561 for (size_t i = 0; i < render_passes.size(); ++i) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 581 } else { | 581 } else { |
| 582 DCHECK_EQ(!output_surface_->software_device(), | 582 DCHECK_EQ(!output_surface_->software_device(), |
| 583 output_surface_->capabilities().delegated_rendering && | 583 output_surface_->capabilities().delegated_rendering && |
| 584 !output_surface_->capabilities().deferred_gl_initialization) | 584 !output_surface_->capabilities().deferred_gl_initialization) |
| 585 << output_surface_->capabilities().delegated_rendering << " " | 585 << output_surface_->capabilities().delegated_rendering << " " |
| 586 << output_surface_->capabilities().deferred_gl_initialization; | 586 << output_surface_->capabilities().deferred_gl_initialization; |
| 587 return DRAW_MODE_SOFTWARE; | 587 return DRAW_MODE_SOFTWARE; |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 static void AppendQuadsForLayer( | |
| 592 RenderPass* target_render_pass, | |
| 593 LayerImpl* layer, | |
| 594 const OcclusionTracker<LayerImpl>& occlusion_tracker, | |
| 595 AppendQuadsData* append_quads_data) { | |
| 596 layer->AppendQuads( | |
| 597 target_render_pass, | |
| 598 occlusion_tracker.GetCurrentOcclusionForLayer(layer->draw_transform()), | |
| 599 append_quads_data); | |
| 600 } | |
| 601 | |
| 602 static void AppendQuadsForRenderSurfaceLayer( | 591 static void AppendQuadsForRenderSurfaceLayer( |
| 603 RenderPass* target_render_pass, | 592 RenderPass* target_render_pass, |
| 604 LayerImpl* layer, | 593 LayerImpl* layer, |
| 605 const RenderPass* contributing_render_pass, | 594 const RenderPass* contributing_render_pass, |
| 606 const OcclusionTracker<LayerImpl>& occlusion_tracker, | |
| 607 AppendQuadsData* append_quads_data) { | 595 AppendQuadsData* append_quads_data) { |
| 608 bool is_replica = false; | 596 RenderSurfaceImpl* surface = layer->render_surface(); |
| 609 layer->render_surface()->AppendQuads(target_render_pass, | 597 const gfx::Transform& draw_transform = surface->draw_transform(); |
| 610 occlusion_tracker, | 598 const Occlusion& occlusion = surface->occlusion_in_content_space(); |
| 611 append_quads_data, | 599 SkColor debug_border_color = surface->GetDebugBorderColor(); |
| 612 is_replica, | 600 float debug_border_width = surface->GetDebugBorderWidth(); |
| 613 contributing_render_pass->id); | 601 LayerImpl* mask_layer = layer->mask_layer(); |
| 602 |
| 603 surface->AppendQuads(target_render_pass, draw_transform, occlusion, |
| 604 debug_border_color, debug_border_width, mask_layer, |
| 605 append_quads_data, contributing_render_pass->id); |
| 614 | 606 |
| 615 // Add replica after the surface so that it appears below the surface. | 607 // Add replica after the surface so that it appears below the surface. |
| 616 if (layer->has_replica()) { | 608 if (layer->has_replica()) { |
| 617 is_replica = true; | 609 const gfx::Transform& replica_draw_transform = |
| 618 layer->render_surface()->AppendQuads(target_render_pass, | 610 surface->replica_draw_transform(); |
| 619 occlusion_tracker, | 611 Occlusion replica_occlusion = occlusion.GetOcclusionWithGivenDrawTransform( |
| 620 append_quads_data, | 612 surface->replica_draw_transform()); |
| 621 is_replica, | 613 SkColor replica_debug_border_color = surface->GetReplicaDebugBorderColor(); |
| 622 contributing_render_pass->id); | 614 float replica_debug_border_width = surface->GetReplicaDebugBorderWidth(); |
| 615 // TODO(danakj): By using the same RenderSurfaceImpl for both the |
| 616 // content and its reflection, it's currently not possible to apply a |
| 617 // separate mask to the reflection layer or correctly handle opacity in |
| 618 // reflections (opacity must be applied after drawing both the layer and its |
| 619 // reflection). The solution is to introduce yet another RenderSurfaceImpl |
| 620 // to draw the layer and its reflection in. For now we only apply a separate |
| 621 // reflection mask if the contents don't have a mask of their own. |
| 622 LayerImpl* replica_mask_layer = |
| 623 mask_layer ? mask_layer : layer->replica_layer()->mask_layer(); |
| 624 |
| 625 surface->AppendQuads(target_render_pass, replica_draw_transform, |
| 626 replica_occlusion, replica_debug_border_color, |
| 627 replica_debug_border_width, replica_mask_layer, |
| 628 append_quads_data, contributing_render_pass->id); |
| 623 } | 629 } |
| 624 } | 630 } |
| 625 | 631 |
| 626 static void AppendQuadsToFillScreen( | 632 static void AppendQuadsToFillScreen(const gfx::Rect& root_scroll_layer_rect, |
| 627 const gfx::Rect& root_scroll_layer_rect, | 633 RenderPass* target_render_pass, |
| 628 RenderPass* target_render_pass, | 634 LayerImpl* root_layer, |
| 629 LayerImpl* root_layer, | 635 SkColor screen_background_color, |
| 630 SkColor screen_background_color, | 636 const Region& fill_region) { |
| 631 const OcclusionTracker<LayerImpl>& occlusion_tracker) { | |
| 632 if (!root_layer || !SkColorGetA(screen_background_color)) | 637 if (!root_layer || !SkColorGetA(screen_background_color)) |
| 633 return; | 638 return; |
| 634 | |
| 635 Region fill_region = occlusion_tracker.ComputeVisibleRegionInScreen(); | |
| 636 if (fill_region.IsEmpty()) | 639 if (fill_region.IsEmpty()) |
| 637 return; | 640 return; |
| 638 | 641 |
| 639 // Manually create the quad state for the gutter quads, as the root layer | 642 // Manually create the quad state for the gutter quads, as the root layer |
| 640 // doesn't have any bounds and so can't generate this itself. | 643 // doesn't have any bounds and so can't generate this itself. |
| 641 // TODO(danakj): Make the gutter quads generated by the solid color layer | 644 // TODO(danakj): Make the gutter quads generated by the solid color layer |
| 642 // (make it smarter about generating quads to fill unoccluded areas). | 645 // (make it smarter about generating quads to fill unoccluded areas). |
| 643 | 646 |
| 644 gfx::Rect root_target_rect = root_layer->render_surface()->content_rect(); | 647 gfx::Rect root_target_rect = root_layer->render_surface()->content_rect(); |
| 645 float opacity = 1.f; | 648 float opacity = 1.f; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 // entire root surface. This will disable partial-swap/scissor optimizations | 732 // entire root surface. This will disable partial-swap/scissor optimizations |
| 730 // that would prevent the HUD from updating, since the HUD does not cause | 733 // that would prevent the HUD from updating, since the HUD does not cause |
| 731 // damage itself, to prevent it from messing with damage visualizations. Since | 734 // damage itself, to prevent it from messing with damage visualizations. Since |
| 732 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, | 735 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, |
| 733 // changing the RenderPass does not affect them. | 736 // changing the RenderPass does not affect them. |
| 734 if (active_tree_->hud_layer()) { | 737 if (active_tree_->hud_layer()) { |
| 735 RenderPass* root_pass = frame->render_passes.back(); | 738 RenderPass* root_pass = frame->render_passes.back(); |
| 736 root_pass->damage_rect = root_pass->output_rect; | 739 root_pass->damage_rect = root_pass->output_rect; |
| 737 } | 740 } |
| 738 | 741 |
| 739 OcclusionTracker<LayerImpl> occlusion_tracker( | 742 // Grab this region here before iterating layers. Taking copy requests from |
| 740 active_tree_->root_layer()->render_surface()->content_rect()); | 743 // the layers while constructing the render passes will dirty the render |
| 741 occlusion_tracker.set_minimum_tracking_size( | 744 // surface layer list and this unoccluded region, flipping the dirty bit to |
| 742 settings_.minimum_occlusion_tracking_size); | 745 // true, and making us able to query for it without doing |
| 743 | 746 // UpdateDrawProperties again. The value inside the Region is not actually |
| 744 if (debug_state_.show_occluding_rects) { | 747 // changed until UpdateDrawProperties happens, so a reference to it is safe. |
| 745 occlusion_tracker.set_occluding_screen_space_rects_container( | 748 const Region& unoccluded_screen_space_region = |
| 746 &frame->occluding_screen_space_rects); | 749 active_tree_->UnoccludedScreenSpaceRegion(); |
| 747 } | |
| 748 if (debug_state_.show_non_occluding_rects) { | |
| 749 occlusion_tracker.set_non_occluding_screen_space_rects_container( | |
| 750 &frame->non_occluding_screen_space_rects); | |
| 751 } | |
| 752 | |
| 753 // Add quads to the Render passes in front-to-back order to allow for testing | |
| 754 // occlusion and performing culling during the tree walk. | |
| 755 typedef LayerIterator<LayerImpl> LayerIteratorType; | |
| 756 | 750 |
| 757 // Typically when we are missing a texture and use a checkerboard quad, we | 751 // Typically when we are missing a texture and use a checkerboard quad, we |
| 758 // still draw the frame. However when the layer being checkerboarded is moving | 752 // still draw the frame. However when the layer being checkerboarded is moving |
| 759 // due to an impl-animation, we drop the frame to avoid flashing due to the | 753 // due to an impl-animation, we drop the frame to avoid flashing due to the |
| 760 // texture suddenly appearing in the future. | 754 // texture suddenly appearing in the future. |
| 761 DrawResult draw_result = DRAW_SUCCESS; | 755 DrawResult draw_result = DRAW_SUCCESS; |
| 762 // When we have a copy request for a layer, we need to draw no matter | 756 // When we have a copy request for a layer, we need to draw no matter |
| 763 // what, as the layer may disappear after this frame. | 757 // what, as the layer may disappear after this frame. |
| 764 bool have_copy_request = false; | 758 bool have_copy_request = false; |
| 765 | 759 |
| 766 int layers_drawn = 0; | 760 int layers_drawn = 0; |
| 767 | 761 |
| 768 const DrawMode draw_mode = GetDrawMode(); | 762 const DrawMode draw_mode = GetDrawMode(); |
| 769 | 763 |
| 770 int num_missing_tiles = 0; | 764 int num_missing_tiles = 0; |
| 771 int num_incomplete_tiles = 0; | 765 int num_incomplete_tiles = 0; |
| 772 | 766 |
| 773 LayerIteratorType end = | 767 auto end = LayerIterator<LayerImpl>::End(frame->render_surface_layer_list); |
| 774 LayerIteratorType::End(frame->render_surface_layer_list); | 768 for (auto it = |
| 775 for (LayerIteratorType it = | 769 LayerIterator<LayerImpl>::Begin(frame->render_surface_layer_list); |
| 776 LayerIteratorType::Begin(frame->render_surface_layer_list); | 770 it != end; ++it) { |
| 777 it != end; | |
| 778 ++it) { | |
| 779 RenderPassId target_render_pass_id = | 771 RenderPassId target_render_pass_id = |
| 780 it.target_render_surface_layer()->render_surface()->GetRenderPassId(); | 772 it.target_render_surface_layer()->render_surface()->GetRenderPassId(); |
| 781 RenderPass* target_render_pass = | 773 RenderPass* target_render_pass = |
| 782 frame->render_passes_by_id[target_render_pass_id]; | 774 frame->render_passes_by_id[target_render_pass_id]; |
| 783 | 775 |
| 784 occlusion_tracker.EnterLayer(it); | |
| 785 | |
| 786 AppendQuadsData append_quads_data; | 776 AppendQuadsData append_quads_data; |
| 787 | 777 |
| 788 if (it.represents_target_render_surface()) { | 778 if (it.represents_target_render_surface()) { |
| 789 if (it->HasCopyRequest()) { | 779 if (it->HasCopyRequest()) { |
| 790 have_copy_request = true; | 780 have_copy_request = true; |
| 791 it->TakeCopyRequestsAndTransformToTarget( | 781 it->TakeCopyRequestsAndTransformToTarget( |
| 792 &target_render_pass->copy_requests); | 782 &target_render_pass->copy_requests); |
| 793 } | 783 } |
| 794 } else if (it.represents_contributing_render_surface() && | 784 } else if (it.represents_contributing_render_surface() && |
| 795 it->render_surface()->contributes_to_drawn_surface()) { | 785 it->render_surface()->contributes_to_drawn_surface()) { |
| 796 RenderPassId contributing_render_pass_id = | 786 RenderPassId contributing_render_pass_id = |
| 797 it->render_surface()->GetRenderPassId(); | 787 it->render_surface()->GetRenderPassId(); |
| 798 RenderPass* contributing_render_pass = | 788 RenderPass* contributing_render_pass = |
| 799 frame->render_passes_by_id[contributing_render_pass_id]; | 789 frame->render_passes_by_id[contributing_render_pass_id]; |
| 800 AppendQuadsForRenderSurfaceLayer(target_render_pass, | 790 AppendQuadsForRenderSurfaceLayer(target_render_pass, |
| 801 *it, | 791 *it, |
| 802 contributing_render_pass, | 792 contributing_render_pass, |
| 803 occlusion_tracker, | |
| 804 &append_quads_data); | 793 &append_quads_data); |
| 805 } else if (it.represents_itself() && | 794 } else if (it.represents_itself() && |
| 806 !it->visible_content_rect().IsEmpty()) { | 795 !it->visible_content_rect().IsEmpty()) { |
| 807 bool occluded = | 796 bool occluded = |
| 808 occlusion_tracker.GetCurrentOcclusionForLayer(it->draw_transform()) | 797 it->draw_properties().occlusion_in_content_space.IsOccluded( |
| 809 .IsOccluded(it->visible_content_rect()); | 798 it->visible_content_rect()); |
| 810 if (!occluded && it->WillDraw(draw_mode, resource_provider_.get())) { | 799 if (!occluded && it->WillDraw(draw_mode, resource_provider_.get())) { |
| 811 DCHECK_EQ(active_tree_, it->layer_tree_impl()); | 800 DCHECK_EQ(active_tree_, it->layer_tree_impl()); |
| 812 | 801 |
| 813 frame->will_draw_layers.push_back(*it); | 802 frame->will_draw_layers.push_back(*it); |
| 814 | 803 |
| 815 if (it->HasContributingDelegatedRenderPasses()) { | 804 if (it->HasContributingDelegatedRenderPasses()) { |
| 816 RenderPassId contributing_render_pass_id = | 805 RenderPassId contributing_render_pass_id = |
| 817 it->FirstContributingRenderPassId(); | 806 it->FirstContributingRenderPassId(); |
| 818 while (frame->render_passes_by_id.find(contributing_render_pass_id) != | 807 while (frame->render_passes_by_id.find(contributing_render_pass_id) != |
| 819 frame->render_passes_by_id.end()) { | 808 frame->render_passes_by_id.end()) { |
| 820 RenderPass* render_pass = | 809 RenderPass* render_pass = |
| 821 frame->render_passes_by_id[contributing_render_pass_id]; | 810 frame->render_passes_by_id[contributing_render_pass_id]; |
| 822 | 811 |
| 823 AppendQuadsForLayer(render_pass, | 812 it->AppendQuads(render_pass, &append_quads_data); |
| 824 *it, | |
| 825 occlusion_tracker, | |
| 826 &append_quads_data); | |
| 827 | 813 |
| 828 contributing_render_pass_id = | 814 contributing_render_pass_id = |
| 829 it->NextContributingRenderPassId(contributing_render_pass_id); | 815 it->NextContributingRenderPassId(contributing_render_pass_id); |
| 830 } | 816 } |
| 831 } | 817 } |
| 832 | 818 |
| 833 AppendQuadsForLayer(target_render_pass, | 819 it->AppendQuads(target_render_pass, &append_quads_data); |
| 834 *it, | |
| 835 occlusion_tracker, | |
| 836 &append_quads_data); | |
| 837 | 820 |
| 838 // For layers that represent themselves, add composite frame timing | 821 // For layers that represent themselves, add composite frame timing |
| 839 // requests if the visible rect intersects the requested rect. | 822 // requests if the visible rect intersects the requested rect. |
| 840 for (const auto& request : it->frame_timing_requests()) { | 823 for (const auto& request : it->frame_timing_requests()) { |
| 841 const gfx::Rect& request_content_rect = | 824 const gfx::Rect& request_content_rect = |
| 842 it->LayerRectToContentRect(request.rect()); | 825 it->LayerRectToContentRect(request.rect()); |
| 843 if (request_content_rect.Intersects(it->visible_content_rect())) { | 826 if (request_content_rect.Intersects(it->visible_content_rect())) { |
| 844 frame->composite_events.push_back( | 827 frame->composite_events.push_back( |
| 845 FrameTimingTracker::FrameAndRectIds( | 828 FrameTimingTracker::FrameAndRectIds( |
| 846 active_tree_->source_frame_number(), request.id())); | 829 active_tree_->source_frame_number(), request.id())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 865 it->draw_transform_is_animating(); | 848 it->draw_transform_is_animating(); |
| 866 if (layer_has_animating_transform) | 849 if (layer_has_animating_transform) |
| 867 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 850 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 868 } | 851 } |
| 869 | 852 |
| 870 if (append_quads_data.num_incomplete_tiles || | 853 if (append_quads_data.num_incomplete_tiles || |
| 871 append_quads_data.num_missing_tiles) { | 854 append_quads_data.num_missing_tiles) { |
| 872 if (RequiresHighResToDraw()) | 855 if (RequiresHighResToDraw()) |
| 873 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; | 856 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; |
| 874 } | 857 } |
| 875 | |
| 876 occlusion_tracker.LeaveLayer(it); | |
| 877 } | 858 } |
| 878 | 859 |
| 879 if (have_copy_request || | 860 if (have_copy_request || |
| 880 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) | 861 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) |
| 881 draw_result = DRAW_SUCCESS; | 862 draw_result = DRAW_SUCCESS; |
| 882 | 863 |
| 883 #if DCHECK_IS_ON() | 864 #if DCHECK_IS_ON() |
| 884 for (const auto& render_pass : frame->render_passes) { | 865 for (const auto& render_pass : frame->render_passes) { |
| 885 for (const auto& quad : render_pass->quad_list) | 866 for (const auto& quad : render_pass->quad_list) |
| 886 DCHECK(quad->shared_quad_state); | 867 DCHECK(quad->shared_quad_state); |
| 887 DCHECK(frame->render_passes_by_id.find(render_pass->id) != | 868 DCHECK(frame->render_passes_by_id.find(render_pass->id) != |
| 888 frame->render_passes_by_id.end()); | 869 frame->render_passes_by_id.end()); |
| 889 } | 870 } |
| 890 #endif | 871 #endif |
| 891 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin()); | 872 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin()); |
| 892 | 873 |
| 893 if (!active_tree_->has_transparent_background()) { | 874 if (!active_tree_->has_transparent_background()) { |
| 894 frame->render_passes.back()->has_transparent_background = false; | 875 frame->render_passes.back()->has_transparent_background = false; |
| 895 AppendQuadsToFillScreen( | 876 AppendQuadsToFillScreen( |
| 896 active_tree_->RootScrollLayerDeviceViewportBounds(), | 877 active_tree_->RootScrollLayerDeviceViewportBounds(), |
| 897 frame->render_passes.back(), | 878 frame->render_passes.back(), active_tree_->root_layer(), |
| 898 active_tree_->root_layer(), | 879 active_tree_->background_color(), unoccluded_screen_space_region); |
| 899 active_tree_->background_color(), | |
| 900 occlusion_tracker); | |
| 901 } | 880 } |
| 902 | 881 |
| 903 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame); | 882 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame); |
| 904 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); | 883 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); |
| 905 | 884 |
| 906 // Any copy requests left in the tree are not going to get serviced, and | 885 // Any copy requests left in the tree are not going to get serviced, and |
| 907 // should be aborted. | 886 // should be aborted. |
| 908 ScopedPtrVector<CopyOutputRequest> requests_to_abort; | 887 ScopedPtrVector<CopyOutputRequest> requests_to_abort; |
| 909 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { | 888 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { |
| 910 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); | 889 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); | 1085 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); |
| 1107 } | 1086 } |
| 1108 | 1087 |
| 1109 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1088 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
| 1110 NOTREACHED(); | 1089 NOTREACHED(); |
| 1111 } | 1090 } |
| 1112 | 1091 |
| 1113 void LayerTreeHostImpl::ResetTreesForTesting() { | 1092 void LayerTreeHostImpl::ResetTreesForTesting() { |
| 1114 if (active_tree_) | 1093 if (active_tree_) |
| 1115 active_tree_->DetachLayerTree(); | 1094 active_tree_->DetachLayerTree(); |
| 1116 active_tree_ = LayerTreeImpl::create(this, active_tree()->page_scale_factor(), | 1095 active_tree_ = |
| 1117 active_tree()->elastic_overscroll()); | 1096 LayerTreeImpl::create(this, active_tree()->page_scale_factor(), |
| 1097 active_tree()->top_controls_shown_ratio(), |
| 1098 active_tree()->elastic_overscroll()); |
| 1118 if (pending_tree_) | 1099 if (pending_tree_) |
| 1119 pending_tree_->DetachLayerTree(); | 1100 pending_tree_->DetachLayerTree(); |
| 1120 pending_tree_ = nullptr; | 1101 pending_tree_ = nullptr; |
| 1121 if (recycle_tree_) | 1102 if (recycle_tree_) |
| 1122 recycle_tree_->DetachLayerTree(); | 1103 recycle_tree_->DetachLayerTree(); |
| 1123 recycle_tree_ = nullptr; | 1104 recycle_tree_ = nullptr; |
| 1124 } | 1105 } |
| 1125 | 1106 |
| 1126 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( | 1107 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( |
| 1127 const ManagedMemoryPolicy& policy) { | 1108 const ManagedMemoryPolicy& policy) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 DCHECK(settings_.impl_side_painting); | 1180 DCHECK(settings_.impl_side_painting); |
| 1200 // Mark priorities as dirty and schedule a PrepareTiles(). | 1181 // Mark priorities as dirty and schedule a PrepareTiles(). |
| 1201 tile_priorities_dirty_ = true; | 1182 tile_priorities_dirty_ = true; |
| 1202 client_->SetNeedsPrepareTilesOnImplThread(); | 1183 client_->SetNeedsPrepareTilesOnImplThread(); |
| 1203 } | 1184 } |
| 1204 | 1185 |
| 1205 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1186 void LayerTreeHostImpl::GetPictureLayerImplPairs( |
| 1206 std::vector<PictureLayerImpl::Pair>* layer_pairs, | 1187 std::vector<PictureLayerImpl::Pair>* layer_pairs, |
| 1207 bool need_valid_tile_priorities) const { | 1188 bool need_valid_tile_priorities) const { |
| 1208 DCHECK(layer_pairs->empty()); | 1189 DCHECK(layer_pairs->empty()); |
| 1209 for (std::vector<PictureLayerImpl*>::const_iterator it = | |
| 1210 picture_layers_.begin(); | |
| 1211 it != picture_layers_.end(); | |
| 1212 ++it) { | |
| 1213 PictureLayerImpl* layer = *it; | |
| 1214 | 1190 |
| 1215 if (!layer->IsOnActiveOrPendingTree() || | 1191 for (auto& layer : active_tree_->picture_layers()) { |
| 1216 (need_valid_tile_priorities && !layer->HasValidTilePriorities())) | 1192 if (need_valid_tile_priorities && !layer->HasValidTilePriorities()) |
| 1217 continue; | 1193 continue; |
| 1218 | |
| 1219 PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); | 1194 PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); |
| 1220 | |
| 1221 // Ignore the twin layer when tile priorities are invalid. | 1195 // Ignore the twin layer when tile priorities are invalid. |
| 1222 if (need_valid_tile_priorities && twin_layer && | 1196 if (need_valid_tile_priorities && twin_layer && |
| 1223 !twin_layer->HasValidTilePriorities()) | 1197 !twin_layer->HasValidTilePriorities()) { |
| 1224 twin_layer = NULL; | 1198 twin_layer = nullptr; |
| 1199 } |
| 1200 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); |
| 1201 } |
| 1225 | 1202 |
| 1226 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. | 1203 if (pending_tree_) { |
| 1227 // If current tree is PENDING_TREE, then only generate a layer_pair if | 1204 for (auto& layer : pending_tree_->picture_layers()) { |
| 1228 // there is no twin layer. | 1205 if (need_valid_tile_priorities && !layer->HasValidTilePriorities()) |
| 1229 if (layer->GetTree() == ACTIVE_TREE) { | 1206 continue; |
| 1230 DCHECK_IMPLIES(twin_layer, twin_layer->GetTree() == PENDING_TREE); | 1207 if (PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer()) { |
| 1231 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); | 1208 if (!need_valid_tile_priorities || |
| 1232 } else if (!twin_layer) { | 1209 twin_layer->HasValidTilePriorities()) { |
| 1233 DCHECK(layer->GetTree() == PENDING_TREE); | 1210 // Already captured from the active tree. |
| 1234 layer_pairs->push_back(PictureLayerImpl::Pair(NULL, layer)); | 1211 continue; |
| 1212 } |
| 1213 } |
| 1214 layer_pairs->push_back(PictureLayerImpl::Pair(nullptr, layer)); |
| 1235 } | 1215 } |
| 1236 } | 1216 } |
| 1237 } | 1217 } |
| 1238 | 1218 |
| 1239 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( | 1219 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( |
| 1240 TreePriority tree_priority, | 1220 TreePriority tree_priority, |
| 1241 RasterTilePriorityQueue::Type type) { | 1221 RasterTilePriorityQueue::Type type) { |
| 1242 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1222 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
| 1243 picture_layer_pairs_.clear(); | 1223 picture_layer_pairs_.clear(); |
| 1244 GetPictureLayerImplPairs(&picture_layer_pairs_, true); | 1224 GetPictureLayerImplPairs(&picture_layer_pairs_, true); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1258 | 1238 |
| 1259 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( | 1239 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( |
| 1260 bool is_likely_to_require_a_draw) { | 1240 bool is_likely_to_require_a_draw) { |
| 1261 // Proactively tell the scheduler that we expect to draw within each vsync | 1241 // Proactively tell the scheduler that we expect to draw within each vsync |
| 1262 // until we get all the tiles ready to draw. If we happen to miss a required | 1242 // until we get all the tiles ready to draw. If we happen to miss a required |
| 1263 // for draw tile here, then we will miss telling the scheduler each frame that | 1243 // for draw tile here, then we will miss telling the scheduler each frame that |
| 1264 // we intend to draw so it may make worse scheduling decisions. | 1244 // we intend to draw so it may make worse scheduling decisions. |
| 1265 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; | 1245 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; |
| 1266 } | 1246 } |
| 1267 | 1247 |
| 1268 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | |
| 1269 const { | |
| 1270 return picture_layers_; | |
| 1271 } | |
| 1272 | |
| 1273 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1248 void LayerTreeHostImpl::NotifyReadyToActivate() { |
| 1274 client_->NotifyReadyToActivate(); | 1249 client_->NotifyReadyToActivate(); |
| 1275 } | 1250 } |
| 1276 | 1251 |
| 1277 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1252 void LayerTreeHostImpl::NotifyReadyToDraw() { |
| 1278 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we | 1253 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we |
| 1279 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from | 1254 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from |
| 1280 // causing optimistic requests to draw a frame. | 1255 // causing optimistic requests to draw a frame. |
| 1281 is_likely_to_require_a_draw_ = false; | 1256 is_likely_to_require_a_draw_ = false; |
| 1282 | 1257 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 if (top_controls_manager_) { | 1420 if (top_controls_manager_) { |
| 1446 metadata.location_bar_offset = | 1421 metadata.location_bar_offset = |
| 1447 gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset()); | 1422 gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset()); |
| 1448 metadata.location_bar_content_translation = | 1423 metadata.location_bar_content_translation = |
| 1449 gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset()); | 1424 gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset()); |
| 1450 } | 1425 } |
| 1451 | 1426 |
| 1452 active_tree_->GetViewportSelection(&metadata.selection_start, | 1427 active_tree_->GetViewportSelection(&metadata.selection_start, |
| 1453 &metadata.selection_end); | 1428 &metadata.selection_end); |
| 1454 | 1429 |
| 1430 LayerImpl* root_layer_for_overflow = OuterViewportScrollLayer() |
| 1431 ? OuterViewportScrollLayer() |
| 1432 : InnerViewportScrollLayer(); |
| 1433 if (root_layer_for_overflow) { |
| 1434 metadata.root_overflow_x_hidden = |
| 1435 !root_layer_for_overflow->user_scrollable_horizontal(); |
| 1436 metadata.root_overflow_y_hidden = |
| 1437 !root_layer_for_overflow->user_scrollable_vertical(); |
| 1438 } |
| 1439 |
| 1455 if (!InnerViewportScrollLayer()) | 1440 if (!InnerViewportScrollLayer()) |
| 1456 return metadata; | 1441 return metadata; |
| 1457 | 1442 |
| 1458 // TODO(miletus) : Change the metadata to hold ScrollOffset. | 1443 // TODO(miletus) : Change the metadata to hold ScrollOffset. |
| 1459 metadata.root_scroll_offset = gfx::ScrollOffsetToVector2dF( | 1444 metadata.root_scroll_offset = gfx::ScrollOffsetToVector2dF( |
| 1460 active_tree_->TotalScrollOffset()); | 1445 active_tree_->TotalScrollOffset()); |
| 1461 | 1446 |
| 1462 return metadata; | 1447 return metadata; |
| 1463 } | 1448 } |
| 1464 | 1449 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1492 if (tile_manager_) { | 1477 if (tile_manager_) { |
| 1493 memory_history_->SaveEntry( | 1478 memory_history_->SaveEntry( |
| 1494 tile_manager_->memory_stats_from_last_assign()); | 1479 tile_manager_->memory_stats_from_last_assign()); |
| 1495 } | 1480 } |
| 1496 | 1481 |
| 1497 if (debug_state_.ShowHudRects()) { | 1482 if (debug_state_.ShowHudRects()) { |
| 1498 debug_rect_history_->SaveDebugRectsForCurrentFrame( | 1483 debug_rect_history_->SaveDebugRectsForCurrentFrame( |
| 1499 active_tree_->root_layer(), | 1484 active_tree_->root_layer(), |
| 1500 active_tree_->hud_layer(), | 1485 active_tree_->hud_layer(), |
| 1501 *frame->render_surface_layer_list, | 1486 *frame->render_surface_layer_list, |
| 1502 frame->occluding_screen_space_rects, | |
| 1503 frame->non_occluding_screen_space_rects, | |
| 1504 debug_state_); | 1487 debug_state_); |
| 1505 } | 1488 } |
| 1506 | 1489 |
| 1507 if (!settings_.impl_side_painting && debug_state_.continuous_painting) { | 1490 if (!settings_.impl_side_painting && debug_state_.continuous_painting) { |
| 1508 const RenderingStats& stats = | 1491 const RenderingStats& stats = |
| 1509 rendering_stats_instrumentation_->GetRenderingStats(); | 1492 rendering_stats_instrumentation_->GetRenderingStats(); |
| 1510 paint_time_counter_->SavePaintTime( | 1493 paint_time_counter_->SavePaintTime( |
| 1511 stats.begin_main_frame_to_commit_duration.GetLastTimeDelta()); | 1494 stats.begin_main_frame_to_commit_duration.GetLastTimeDelta()); |
| 1512 } | 1495 } |
| 1513 | 1496 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 | 1654 |
| 1672 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1655 ViewportAnchor anchor(InnerViewportScrollLayer(), |
| 1673 OuterViewportScrollLayer()); | 1656 OuterViewportScrollLayer()); |
| 1674 | 1657 |
| 1675 // Adjust the inner viewport by shrinking/expanding the container to account | 1658 // Adjust the inner viewport by shrinking/expanding the container to account |
| 1676 // for the change in top controls height since the last Resize from Blink. | 1659 // for the change in top controls height since the last Resize from Blink. |
| 1677 float top_controls_layout_height = | 1660 float top_controls_layout_height = |
| 1678 active_tree_->top_controls_shrink_blink_size() | 1661 active_tree_->top_controls_shrink_blink_size() |
| 1679 ? active_tree_->top_controls_height() | 1662 ? active_tree_->top_controls_height() |
| 1680 : 0.f; | 1663 : 0.f; |
| 1681 inner_container->SetBoundsDelta( | 1664 inner_container->SetBoundsDelta(gfx::Vector2dF( |
| 1682 gfx::Vector2dF(0, top_controls_layout_height - | 1665 0, |
| 1683 active_tree_->total_top_controls_content_offset())); | 1666 top_controls_layout_height - top_controls_manager_->ContentTopOffset())); |
| 1684 | 1667 |
| 1685 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) | 1668 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) |
| 1686 return; | 1669 return; |
| 1687 | 1670 |
| 1688 // Adjust the outer viewport container as well, since adjusting only the | 1671 // Adjust the outer viewport container as well, since adjusting only the |
| 1689 // inner may cause its bounds to exceed those of the outer, causing scroll | 1672 // inner may cause its bounds to exceed those of the outer, causing scroll |
| 1690 // clamping. We adjust it so it maintains the same aspect ratio as the | 1673 // clamping. We adjust it so it maintains the same aspect ratio as the |
| 1691 // inner viewport. | 1674 // inner viewport. |
| 1692 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 1675 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
| 1693 inner_container->BoundsForScrolling().height(); | 1676 inner_container->BoundsForScrolling().height(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 return NULL; | 1744 return NULL; |
| 1762 } | 1745 } |
| 1763 | 1746 |
| 1764 void LayerTreeHostImpl::CreatePendingTree() { | 1747 void LayerTreeHostImpl::CreatePendingTree() { |
| 1765 CHECK(!pending_tree_); | 1748 CHECK(!pending_tree_); |
| 1766 if (recycle_tree_) | 1749 if (recycle_tree_) |
| 1767 recycle_tree_.swap(pending_tree_); | 1750 recycle_tree_.swap(pending_tree_); |
| 1768 else | 1751 else |
| 1769 pending_tree_ = | 1752 pending_tree_ = |
| 1770 LayerTreeImpl::create(this, active_tree()->page_scale_factor(), | 1753 LayerTreeImpl::create(this, active_tree()->page_scale_factor(), |
| 1754 active_tree()->top_controls_shown_ratio(), |
| 1771 active_tree()->elastic_overscroll()); | 1755 active_tree()->elastic_overscroll()); |
| 1772 | 1756 |
| 1773 // Update the delta from the active tree, which may have | |
| 1774 // adjusted its delta prior to the pending tree being created. | |
| 1775 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); | |
| 1776 pending_tree_->set_top_controls_delta( | |
| 1777 active_tree_->top_controls_delta() - | |
| 1778 active_tree_->sent_top_controls_delta()); | |
| 1779 pending_tree_->set_top_controls_height(active_tree_->top_controls_height()); | |
| 1780 | |
| 1781 client_->OnCanDrawStateChanged(CanDraw()); | 1757 client_->OnCanDrawStateChanged(CanDraw()); |
| 1782 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1758 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 1783 } | 1759 } |
| 1784 | 1760 |
| 1785 void LayerTreeHostImpl::ActivateSyncTree() { | 1761 void LayerTreeHostImpl::ActivateSyncTree() { |
| 1786 if (pending_tree_) { | 1762 if (pending_tree_) { |
| 1787 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1763 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 1788 | 1764 |
| 1789 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1765 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
| 1790 active_tree_->PushPersistedState(pending_tree_.get()); | 1766 active_tree_->PushPersistedState(pending_tree_.get()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1805 | 1781 |
| 1806 // Now that we've synced everything from the pending tree to the active | 1782 // Now that we've synced everything from the pending tree to the active |
| 1807 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1783 // tree, rename the pending tree the recycle tree so we can reuse it on the |
| 1808 // next sync. | 1784 // next sync. |
| 1809 DCHECK(!recycle_tree_); | 1785 DCHECK(!recycle_tree_); |
| 1810 pending_tree_.swap(recycle_tree_); | 1786 pending_tree_.swap(recycle_tree_); |
| 1811 | 1787 |
| 1812 active_tree_->SetRootLayerScrollOffsetDelegate( | 1788 active_tree_->SetRootLayerScrollOffsetDelegate( |
| 1813 root_layer_scroll_offset_delegate_); | 1789 root_layer_scroll_offset_delegate_); |
| 1814 | 1790 |
| 1815 if (top_controls_manager_) { | |
| 1816 top_controls_manager_->SetTopControlsHeight( | |
| 1817 active_tree_->top_controls_height()); | |
| 1818 top_controls_manager_->SetControlsTopOffset( | |
| 1819 active_tree_->total_top_controls_content_offset() - | |
| 1820 active_tree_->top_controls_height()); | |
| 1821 } | |
| 1822 | |
| 1823 UpdateViewportContainerSizes(); | 1791 UpdateViewportContainerSizes(); |
| 1824 } else { | 1792 } else { |
| 1825 active_tree_->ProcessUIResourceRequestQueue(); | 1793 active_tree_->ProcessUIResourceRequestQueue(); |
| 1826 } | 1794 } |
| 1827 | 1795 |
| 1828 active_tree_->DidBecomeActive(); | 1796 active_tree_->DidBecomeActive(); |
| 1829 ActivateAnimations(); | 1797 ActivateAnimations(); |
| 1830 if (settings_.impl_side_painting) { | 1798 if (settings_.impl_side_painting) { |
| 1831 client_->RenewTreePriority(); | 1799 client_->RenewTreePriority(); |
| 1832 // If we have any picture layers, then by activating we also modified tile | 1800 // If we have any picture layers, then by activating we also modified tile |
| 1833 // priorities. | 1801 // priorities. |
| 1834 if (!picture_layers_.empty()) | 1802 if (!active_tree_->picture_layers().empty()) |
| 1835 DidModifyTilePriorities(); | 1803 DidModifyTilePriorities(); |
| 1836 } | 1804 } |
| 1837 | 1805 |
| 1838 client_->OnCanDrawStateChanged(CanDraw()); | 1806 client_->OnCanDrawStateChanged(CanDraw()); |
| 1839 client_->DidActivateSyncTree(); | 1807 client_->DidActivateSyncTree(); |
| 1840 if (!tree_activation_callback_.is_null()) | 1808 if (!tree_activation_callback_.is_null()) |
| 1841 tree_activation_callback_.Run(); | 1809 tree_activation_callback_.Run(); |
| 1842 | 1810 |
| 1843 if (debug_state_.continuous_painting) { | 1811 if (debug_state_.continuous_painting) { |
| 1844 const RenderingStats& stats = | 1812 const RenderingStats& stats = |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 resource_provider_.get()); | 2000 resource_provider_.get()); |
| 2033 return; | 2001 return; |
| 2034 } | 2002 } |
| 2035 | 2003 |
| 2036 if (use_gpu_rasterization_) { | 2004 if (use_gpu_rasterization_) { |
| 2037 *resource_pool = | 2005 *resource_pool = |
| 2038 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); | 2006 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); |
| 2039 | 2007 |
| 2040 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( | 2008 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( |
| 2041 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), | 2009 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), |
| 2042 resource_provider_.get()); | 2010 static_cast<GpuRasterizer*>(rasterizer_.get())); |
| 2043 return; | 2011 return; |
| 2044 } | 2012 } |
| 2045 | 2013 |
| 2046 if (GetRendererCapabilities().using_image) { | 2014 if (GetRendererCapabilities().using_image) { |
| 2047 unsigned image_target = settings_.use_image_texture_target; | 2015 unsigned image_target = settings_.use_image_texture_target; |
| 2048 DCHECK_IMPLIES( | 2016 DCHECK_IMPLIES( |
| 2049 image_target == GL_TEXTURE_RECTANGLE_ARB, | 2017 image_target == GL_TEXTURE_RECTANGLE_ARB, |
| 2050 context_provider->ContextCapabilities().gpu.texture_rectangle); | 2018 context_provider->ContextCapabilities().gpu.texture_rectangle); |
| 2051 DCHECK_IMPLIES( | 2019 DCHECK_IMPLIES( |
| 2052 image_target == GL_TEXTURE_EXTERNAL_OES, | 2020 image_target == GL_TEXTURE_EXTERNAL_OES, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 | 2065 |
| 2098 void LayerTreeHostImpl::DestroyTileManager() { | 2066 void LayerTreeHostImpl::DestroyTileManager() { |
| 2099 tile_manager_ = nullptr; | 2067 tile_manager_ = nullptr; |
| 2100 resource_pool_ = nullptr; | 2068 resource_pool_ = nullptr; |
| 2101 staging_resource_pool_ = nullptr; | 2069 staging_resource_pool_ = nullptr; |
| 2102 tile_task_worker_pool_ = nullptr; | 2070 tile_task_worker_pool_ = nullptr; |
| 2103 rasterizer_ = nullptr; | 2071 rasterizer_ = nullptr; |
| 2104 single_thread_synchronous_task_graph_runner_ = nullptr; | 2072 single_thread_synchronous_task_graph_runner_ = nullptr; |
| 2105 } | 2073 } |
| 2106 | 2074 |
| 2107 bool LayerTreeHostImpl::UsePendingTreeForSync() const { | |
| 2108 // In impl-side painting, synchronize to the pending tree so that it has | |
| 2109 // time to raster before being displayed. | |
| 2110 return settings_.impl_side_painting; | |
| 2111 } | |
| 2112 | |
| 2113 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const { | 2075 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const { |
| 2114 return !proxy_->HasImplThread() && !settings_.single_thread_proxy_scheduler; | 2076 return !proxy_->HasImplThread() && !settings_.single_thread_proxy_scheduler; |
| 2115 } | 2077 } |
| 2116 | 2078 |
| 2117 void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) { | 2079 void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) { |
| 2118 SetManagedMemoryPolicy(cached_managed_memory_policy_, zero_budget); | 2080 SetManagedMemoryPolicy(cached_managed_memory_policy_, zero_budget); |
| 2119 } | 2081 } |
| 2120 | 2082 |
| 2121 bool LayerTreeHostImpl::InitializeRenderer( | 2083 bool LayerTreeHostImpl::InitializeRenderer( |
| 2122 scoped_ptr<OutputSurface> output_surface) { | 2084 scoped_ptr<OutputSurface> output_surface) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2291 } | 2253 } |
| 2292 | 2254 |
| 2293 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2255 void LayerTreeHostImpl::DidChangeTopControlsPosition() { |
| 2294 UpdateViewportContainerSizes(); | 2256 UpdateViewportContainerSizes(); |
| 2295 SetNeedsRedraw(); | 2257 SetNeedsRedraw(); |
| 2296 SetNeedsAnimate(); | 2258 SetNeedsAnimate(); |
| 2297 active_tree_->set_needs_update_draw_properties(); | 2259 active_tree_->set_needs_update_draw_properties(); |
| 2298 SetFullRootLayerDamage(); | 2260 SetFullRootLayerDamage(); |
| 2299 } | 2261 } |
| 2300 | 2262 |
| 2301 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { | 2263 float LayerTreeHostImpl::TopControlsHeight() const { |
| 2302 float current_top_offset = active_tree_->top_controls_content_offset() - | 2264 return active_tree_->top_controls_height(); |
| 2303 active_tree_->top_controls_height(); | |
| 2304 active_tree_->set_top_controls_delta(offset - current_top_offset); | |
| 2305 } | 2265 } |
| 2306 | 2266 |
| 2307 float LayerTreeHostImpl::ControlsTopOffset() const { | 2267 void LayerTreeHostImpl::SetCurrentTopControlsShownRatio(float ratio) { |
| 2308 return active_tree_->total_top_controls_content_offset() - | 2268 if (active_tree_->SetCurrentTopControlsShownRatio(ratio)) |
| 2309 active_tree_->top_controls_height(); | 2269 DidChangeTopControlsPosition(); |
| 2270 } |
| 2271 |
| 2272 float LayerTreeHostImpl::CurrentTopControlsShownRatio() const { |
| 2273 return active_tree_->CurrentTopControlsShownRatio(); |
| 2310 } | 2274 } |
| 2311 | 2275 |
| 2312 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2276 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 2313 DCHECK(input_handler_client_ == NULL); | 2277 DCHECK(input_handler_client_ == NULL); |
| 2314 input_handler_client_ = client; | 2278 input_handler_client_ = client; |
| 2315 } | 2279 } |
| 2316 | 2280 |
| 2317 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( | 2281 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
| 2318 const gfx::PointF& device_viewport_point, | 2282 const gfx::PointF& device_viewport_point, |
| 2319 InputHandler::ScrollInputType type, | 2283 InputHandler::ScrollInputType type, |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3052 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 3016 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
| 3053 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 3017 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
| 3054 } | 3018 } |
| 3055 | 3019 |
| 3056 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 3020 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
| 3057 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 3021 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
| 3058 | 3022 |
| 3059 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 3023 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
| 3060 scroll_info->page_scale_delta = | 3024 scroll_info->page_scale_delta = |
| 3061 active_tree_->page_scale_factor()->PullDeltaForMainThread(); | 3025 active_tree_->page_scale_factor()->PullDeltaForMainThread(); |
| 3026 scroll_info->top_controls_delta = |
| 3027 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread(); |
| 3062 scroll_info->elastic_overscroll_delta = | 3028 scroll_info->elastic_overscroll_delta = |
| 3063 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); | 3029 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); |
| 3064 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); | 3030 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); |
| 3065 scroll_info->top_controls_delta = active_tree()->top_controls_delta(); | |
| 3066 active_tree_->set_sent_top_controls_delta(scroll_info->top_controls_delta); | |
| 3067 | 3031 |
| 3068 return scroll_info.Pass(); | 3032 return scroll_info.Pass(); |
| 3069 } | 3033 } |
| 3070 | 3034 |
| 3071 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 3035 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
| 3072 SetViewportDamage(gfx::Rect(DrawViewportSize())); | 3036 SetViewportDamage(gfx::Rect(DrawViewportSize())); |
| 3073 } | 3037 } |
| 3074 | 3038 |
| 3075 void LayerTreeHostImpl::ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta) { | 3039 void LayerTreeHostImpl::ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta) { |
| 3076 DCHECK(InnerViewportScrollLayer()); | 3040 DCHECK(InnerViewportScrollLayer()); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3275 // Try to use the current frame time to keep animations non-jittery. But if | 3239 // Try to use the current frame time to keep animations non-jittery. But if |
| 3276 // we're not in a frame (because this is during an input event or a delayed | 3240 // we're not in a frame (because this is during an input event or a delayed |
| 3277 // task), fall back to physical time. This should still be monotonic. | 3241 // task), fall back to physical time. This should still be monotonic. |
| 3278 if (current_begin_frame_args_.IsValid()) | 3242 if (current_begin_frame_args_.IsValid()) |
| 3279 return current_begin_frame_args_; | 3243 return current_begin_frame_args_; |
| 3280 return BeginFrameArgs::Create( | 3244 return BeginFrameArgs::Create( |
| 3281 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), | 3245 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), |
| 3282 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); | 3246 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); |
| 3283 } | 3247 } |
| 3284 | 3248 |
| 3285 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3249 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 3286 LayerTreeHostImpl::AsValue() const { | 3250 LayerTreeHostImpl::AsValue() const { |
| 3287 return AsValueWithFrame(NULL); | 3251 return AsValueWithFrame(NULL); |
| 3288 } | 3252 } |
| 3289 | 3253 |
| 3290 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3254 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 3291 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { | 3255 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
| 3292 scoped_refptr<base::debug::TracedValue> state = | 3256 scoped_refptr<base::trace_event::TracedValue> state = |
| 3293 new base::debug::TracedValue(); | 3257 new base::trace_event::TracedValue(); |
| 3294 AsValueWithFrameInto(frame, state.get()); | 3258 AsValueWithFrameInto(frame, state.get()); |
| 3295 return state; | 3259 return state; |
| 3296 } | 3260 } |
| 3297 | 3261 |
| 3298 void LayerTreeHostImpl::AsValueInto(base::debug::TracedValue* value) const { | 3262 void LayerTreeHostImpl::AsValueInto( |
| 3263 base::trace_event::TracedValue* value) const { |
| 3299 return AsValueWithFrameInto(NULL, value); | 3264 return AsValueWithFrameInto(NULL, value); |
| 3300 } | 3265 } |
| 3301 | 3266 |
| 3302 void LayerTreeHostImpl::AsValueWithFrameInto( | 3267 void LayerTreeHostImpl::AsValueWithFrameInto( |
| 3303 FrameData* frame, | 3268 FrameData* frame, |
| 3304 base::debug::TracedValue* state) const { | 3269 base::trace_event::TracedValue* state) const { |
| 3305 if (this->pending_tree_) { | 3270 if (this->pending_tree_) { |
| 3306 state->BeginDictionary("activation_state"); | 3271 state->BeginDictionary("activation_state"); |
| 3307 ActivationStateAsValueInto(state); | 3272 ActivationStateAsValueInto(state); |
| 3308 state->EndDictionary(); | 3273 state->EndDictionary(); |
| 3309 } | 3274 } |
| 3310 MathUtil::AddToTracedValue("device_viewport_size", device_viewport_size_, | 3275 MathUtil::AddToTracedValue("device_viewport_size", device_viewport_size_, |
| 3311 state); | 3276 state); |
| 3312 | 3277 |
| 3313 std::set<const Tile*> tiles; | 3278 std::set<const Tile*> tiles; |
| 3314 active_tree_->GetAllTilesForTracing(&tiles); | 3279 active_tree_->GetAllTilesForTracing(&tiles); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3340 pending_tree_->AsValueInto(state); | 3305 pending_tree_->AsValueInto(state); |
| 3341 state->EndDictionary(); | 3306 state->EndDictionary(); |
| 3342 } | 3307 } |
| 3343 if (frame) { | 3308 if (frame) { |
| 3344 state->BeginDictionary("frame"); | 3309 state->BeginDictionary("frame"); |
| 3345 frame->AsValueInto(state); | 3310 frame->AsValueInto(state); |
| 3346 state->EndDictionary(); | 3311 state->EndDictionary(); |
| 3347 } | 3312 } |
| 3348 } | 3313 } |
| 3349 | 3314 |
| 3350 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3315 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 3351 LayerTreeHostImpl::ActivationStateAsValue() const { | 3316 LayerTreeHostImpl::ActivationStateAsValue() const { |
| 3352 scoped_refptr<base::debug::TracedValue> state = | 3317 scoped_refptr<base::trace_event::TracedValue> state = |
| 3353 new base::debug::TracedValue(); | 3318 new base::trace_event::TracedValue(); |
| 3354 ActivationStateAsValueInto(state.get()); | 3319 ActivationStateAsValueInto(state.get()); |
| 3355 return state; | 3320 return state; |
| 3356 } | 3321 } |
| 3357 | 3322 |
| 3358 void LayerTreeHostImpl::ActivationStateAsValueInto( | 3323 void LayerTreeHostImpl::ActivationStateAsValueInto( |
| 3359 base::debug::TracedValue* state) const { | 3324 base::trace_event::TracedValue* state) const { |
| 3360 TracedValue::SetIDRef(this, state, "lthi"); | 3325 TracedValue::SetIDRef(this, state, "lthi"); |
| 3361 if (tile_manager_) { | 3326 if (tile_manager_) { |
| 3362 state->BeginDictionary("tile_manager"); | 3327 state->BeginDictionary("tile_manager"); |
| 3363 tile_manager_->BasicStateAsValueInto(state); | 3328 tile_manager_->BasicStateAsValueInto(state); |
| 3364 state->EndDictionary(); | 3329 state->EndDictionary(); |
| 3365 } | 3330 } |
| 3366 } | 3331 } |
| 3367 | 3332 |
| 3368 void LayerTreeHostImpl::SetDebugState( | 3333 void LayerTreeHostImpl::SetDebugState( |
| 3369 const LayerTreeDebugState& new_debug_state) { | 3334 const LayerTreeDebugState& new_debug_state) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3502 for (; it != swap_promise_monitor_.end(); it++) | 3467 for (; it != swap_promise_monitor_.end(); it++) |
| 3503 (*it)->OnSetNeedsRedrawOnImpl(); | 3468 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3504 } | 3469 } |
| 3505 | 3470 |
| 3506 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3471 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
| 3507 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3472 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3508 for (; it != swap_promise_monitor_.end(); it++) | 3473 for (; it != swap_promise_monitor_.end(); it++) |
| 3509 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3474 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
| 3510 } | 3475 } |
| 3511 | 3476 |
| 3512 void LayerTreeHostImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { | |
| 3513 DCHECK(std::find(picture_layers_.begin(), picture_layers_.end(), layer) == | |
| 3514 picture_layers_.end()); | |
| 3515 picture_layers_.push_back(layer); | |
| 3516 } | |
| 3517 | |
| 3518 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | |
| 3519 std::vector<PictureLayerImpl*>::iterator it = | |
| 3520 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | |
| 3521 DCHECK(it != picture_layers_.end()); | |
| 3522 picture_layers_.erase(it); | |
| 3523 } | |
| 3524 | |
| 3525 } // namespace cc | 3477 } // namespace cc |
| OLD | NEW |