| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 delta = outer_->ScrollBy(delta); | 109 delta = outer_->ScrollBy(delta); |
| 110 inner_->ScrollBy(delta); | 110 inner_->ScrollBy(delta); |
| 111 } | 111 } |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 LayerImpl* inner_; | 114 LayerImpl* inner_; |
| 115 LayerImpl* outer_; | 115 LayerImpl* outer_; |
| 116 gfx::ScrollOffset viewport_in_content_coordinates_; | 116 gfx::ScrollOffset viewport_in_content_coordinates_; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 | |
| 120 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) { | 119 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) { |
| 121 if (visible) { | 120 if (visible) { |
| 122 TRACE_EVENT_ASYNC_BEGIN1("webkit", | 121 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id, |
| 123 "LayerTreeHostImpl::SetVisible", | 122 "LayerTreeHostImpl", id); |
| 124 id, | |
| 125 "LayerTreeHostImpl", | |
| 126 id); | |
| 127 return; | 123 return; |
| 128 } | 124 } |
| 129 | 125 |
| 130 TRACE_EVENT_ASYNC_END0("webkit", "LayerTreeHostImpl::SetVisible", id); | 126 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id); |
| 131 } | 127 } |
| 132 | 128 |
| 133 size_t GetMaxTransferBufferUsageBytes( | 129 size_t GetMaxTransferBufferUsageBytes( |
| 134 const ContextProvider::Capabilities& context_capabilities, | 130 const ContextProvider::Capabilities& context_capabilities, |
| 135 double refresh_rate) { | 131 double refresh_rate) { |
| 136 // We want to make sure the default transfer buffer size is equal to the | 132 // We want to make sure the default transfer buffer size is equal to the |
| 137 // amount of data that can be uploaded by the compositor to avoid stalling | 133 // amount of data that can be uploaded by the compositor to avoid stalling |
| 138 // the pipeline. | 134 // the pipeline. |
| 139 // For reference Chromebook Pixel can upload 1MB in about 0.5ms. | 135 // For reference Chromebook Pixel can upload 1MB in about 0.5ms. |
| 140 const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2; | 136 const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 device_scale_factor_(1.f), | 218 device_scale_factor_(1.f), |
| 223 resourceless_software_draw_(false), | 219 resourceless_software_draw_(false), |
| 224 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 220 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 225 animation_registrar_(AnimationRegistrar::Create()), | 221 animation_registrar_(AnimationRegistrar::Create()), |
| 226 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 222 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 227 micro_benchmark_controller_(this), | 223 micro_benchmark_controller_(this), |
| 228 shared_bitmap_manager_(shared_bitmap_manager), | 224 shared_bitmap_manager_(shared_bitmap_manager), |
| 229 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 225 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 230 id_(id), | 226 id_(id), |
| 231 requires_high_res_to_draw_(false), | 227 requires_high_res_to_draw_(false), |
| 232 is_likely_to_require_a_draw_(false) { | 228 is_likely_to_require_a_draw_(false), |
| 229 frame_timing_tracker_(FrameTimingTracker::Create()) { |
| 233 DCHECK(proxy_->IsImplThread()); | 230 DCHECK(proxy_->IsImplThread()); |
| 234 DidVisibilityChange(this, visible_); | 231 DidVisibilityChange(this, visible_); |
| 235 animation_registrar_->set_supports_scroll_animations( | 232 animation_registrar_->set_supports_scroll_animations( |
| 236 proxy_->SupportsImplScrolling()); | 233 proxy_->SupportsImplScrolling()); |
| 237 | 234 |
| 238 SetDebugState(settings.initial_debug_state); | 235 SetDebugState(settings.initial_debug_state); |
| 239 | 236 |
| 240 // LTHI always has an active tree. | 237 // LTHI always has an active tree. |
| 241 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), | 238 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), |
| 242 new SyncedElasticOverscroll); | 239 new SyncedElasticOverscroll); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 gfx::PointF device_viewport_point = | 459 gfx::PointF device_viewport_point = |
| 463 gfx::ScalePoint(viewport_point, device_scale_factor_); | 460 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 464 | 461 |
| 465 LayerImpl* layer_impl = | 462 LayerImpl* layer_impl = |
| 466 active_tree_->FindLayerWithWheelHandlerThatIsHitByPoint( | 463 active_tree_->FindLayerWithWheelHandlerThatIsHitByPoint( |
| 467 device_viewport_point); | 464 device_viewport_point); |
| 468 | 465 |
| 469 return layer_impl != NULL; | 466 return layer_impl != NULL; |
| 470 } | 467 } |
| 471 | 468 |
| 472 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( | 469 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
| 470 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
| 471 return scroll_parent; |
| 472 return layer->parent(); |
| 473 } |
| 474 |
| 475 static ScrollBlocksOn EffectiveScrollBlocksOn(LayerImpl* layer) { |
| 476 ScrollBlocksOn blocks = ScrollBlocksOnNone; |
| 477 for (; layer; layer = NextScrollLayer(layer)) { |
| 478 blocks |= layer->scroll_blocks_on(); |
| 479 } |
| 480 return blocks; |
| 481 } |
| 482 |
| 483 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( |
| 473 const gfx::Point& viewport_point) { | 484 const gfx::Point& viewport_point) { |
| 474 | |
| 475 gfx::PointF device_viewport_point = | 485 gfx::PointF device_viewport_point = |
| 476 gfx::ScalePoint(viewport_point, device_scale_factor_); | 486 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 477 | 487 |
| 488 // First check if scrolling at this point is required to block on any |
| 489 // touch event handlers. Note that we must start at the innermost layer |
| 490 // (as opposed to only the layer found to contain a touch handler region |
| 491 // below) to ensure all relevant scroll-blocks-on values are applied. |
| 478 LayerImpl* layer_impl = | 492 LayerImpl* layer_impl = |
| 479 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 493 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 480 device_viewport_point); | 494 ScrollBlocksOn blocking = EffectiveScrollBlocksOn(layer_impl); |
| 495 if (!(blocking & ScrollBlocksOnStartTouch)) |
| 496 return false; |
| 481 | 497 |
| 498 // Now determine if there are actually any handlers at that point. |
| 499 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 500 layer_impl = active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 501 device_viewport_point); |
| 482 return layer_impl != NULL; | 502 return layer_impl != NULL; |
| 483 } | 503 } |
| 484 | 504 |
| 485 scoped_ptr<SwapPromiseMonitor> | 505 scoped_ptr<SwapPromiseMonitor> |
| 486 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 506 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 487 ui::LatencyInfo* latency) { | 507 ui::LatencyInfo* latency) { |
| 488 return make_scoped_ptr( | 508 return make_scoped_ptr( |
| 489 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 509 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 490 } | 510 } |
| 491 | 511 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 bool root_surface_has_no_visible_damage = | 687 bool root_surface_has_no_visible_damage = |
| 668 !root_surface->damage_tracker()->current_damage_rect().Intersects( | 688 !root_surface->damage_tracker()->current_damage_rect().Intersects( |
| 669 root_surface->content_rect()); | 689 root_surface->content_rect()); |
| 670 bool root_surface_has_contributing_layers = | 690 bool root_surface_has_contributing_layers = |
| 671 !root_surface->layer_list().empty(); | 691 !root_surface->layer_list().empty(); |
| 672 bool hud_wants_to_draw_ = active_tree_->hud_layer() && | 692 bool hud_wants_to_draw_ = active_tree_->hud_layer() && |
| 673 active_tree_->hud_layer()->IsAnimatingHUDContents(); | 693 active_tree_->hud_layer()->IsAnimatingHUDContents(); |
| 674 if (root_surface_has_contributing_layers && | 694 if (root_surface_has_contributing_layers && |
| 675 root_surface_has_no_visible_damage && | 695 root_surface_has_no_visible_damage && |
| 676 active_tree_->LayersWithCopyOutputRequest().empty() && | 696 active_tree_->LayersWithCopyOutputRequest().empty() && |
| 697 !output_surface_->capabilities().can_force_reclaim_resources && |
| 677 !hud_wants_to_draw_) { | 698 !hud_wants_to_draw_) { |
| 678 TRACE_EVENT0("cc", | 699 TRACE_EVENT0("cc", |
| 679 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); | 700 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); |
| 680 frame->has_no_damage = true; | 701 frame->has_no_damage = true; |
| 681 DCHECK(!output_surface_->capabilities() | 702 DCHECK(!output_surface_->capabilities() |
| 682 .draw_and_swap_full_viewport_every_frame); | 703 .draw_and_swap_full_viewport_every_frame); |
| 683 return DRAW_SUCCESS; | 704 return DRAW_SUCCESS; |
| 684 } | 705 } |
| 685 | 706 |
| 686 TRACE_EVENT1("cc", | 707 TRACE_EVENT1("cc", |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 | 827 |
| 807 contributing_render_pass_id = | 828 contributing_render_pass_id = |
| 808 it->NextContributingRenderPassId(contributing_render_pass_id); | 829 it->NextContributingRenderPassId(contributing_render_pass_id); |
| 809 } | 830 } |
| 810 } | 831 } |
| 811 | 832 |
| 812 AppendQuadsForLayer(target_render_pass, | 833 AppendQuadsForLayer(target_render_pass, |
| 813 *it, | 834 *it, |
| 814 occlusion_tracker, | 835 occlusion_tracker, |
| 815 &append_quads_data); | 836 &append_quads_data); |
| 837 |
| 838 // For layers that represent themselves, add composite frame timing |
| 839 // requests if the visible rect intersects the requested rect. |
| 840 for (const auto& request : it->frame_timing_requests()) { |
| 841 const gfx::Rect& request_content_rect = |
| 842 it->LayerRectToContentRect(request.rect()); |
| 843 if (request_content_rect.Intersects(it->visible_content_rect())) { |
| 844 frame->composite_events.push_back( |
| 845 FrameTimingTracker::FrameAndRectIds( |
| 846 active_tree_->source_frame_number(), request.id())); |
| 847 } |
| 848 } |
| 816 } | 849 } |
| 817 | 850 |
| 818 ++layers_drawn; | 851 ++layers_drawn; |
| 819 } | 852 } |
| 820 | 853 |
| 821 rendering_stats_instrumentation_->AddVisibleContentArea( | 854 rendering_stats_instrumentation_->AddVisibleContentArea( |
| 822 append_quads_data.visible_content_area); | 855 append_quads_data.visible_content_area); |
| 823 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( | 856 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( |
| 824 append_quads_data.approximated_visible_content_area); | 857 append_quads_data.approximated_visible_content_area); |
| 825 | 858 |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 | 1464 |
| 1432 static void LayerTreeHostImplDidBeginTracingCallback(LayerImpl* layer) { | 1465 static void LayerTreeHostImplDidBeginTracingCallback(LayerImpl* layer) { |
| 1433 layer->DidBeginTracing(); | 1466 layer->DidBeginTracing(); |
| 1434 } | 1467 } |
| 1435 | 1468 |
| 1436 void LayerTreeHostImpl::DrawLayers(FrameData* frame, | 1469 void LayerTreeHostImpl::DrawLayers(FrameData* frame, |
| 1437 base::TimeTicks frame_begin_time) { | 1470 base::TimeTicks frame_begin_time) { |
| 1438 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); | 1471 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); |
| 1439 DCHECK(CanDraw()); | 1472 DCHECK(CanDraw()); |
| 1440 | 1473 |
| 1474 if (!frame->composite_events.empty()) { |
| 1475 frame_timing_tracker_->SaveTimeStamps(frame_begin_time, |
| 1476 frame->composite_events); |
| 1477 } |
| 1478 |
| 1441 if (frame->has_no_damage) { | 1479 if (frame->has_no_damage) { |
| 1442 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); | 1480 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); |
| 1443 DCHECK(!output_surface_->capabilities() | 1481 DCHECK(!output_surface_->capabilities() |
| 1444 .draw_and_swap_full_viewport_every_frame); | 1482 .draw_and_swap_full_viewport_every_frame); |
| 1445 return; | 1483 return; |
| 1446 } | 1484 } |
| 1447 | 1485 |
| 1448 DCHECK(!frame->render_passes.empty()); | 1486 DCHECK(!frame->render_passes.empty()); |
| 1449 | 1487 |
| 1450 fps_counter_->SaveTimeStamp(frame_begin_time, | 1488 fps_counter_->SaveTimeStamp(frame_begin_time, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 // query the new state of |use_gpu_rasterization_|. | 1608 // query the new state of |use_gpu_rasterization_|. |
| 1571 use_gpu_rasterization_ = use_gpu; | 1609 use_gpu_rasterization_ = use_gpu; |
| 1572 | 1610 |
| 1573 // Clean up and replace existing tile manager with another one that uses | 1611 // Clean up and replace existing tile manager with another one that uses |
| 1574 // appropriate rasterizer. | 1612 // appropriate rasterizer. |
| 1575 ReleaseTreeResources(); | 1613 ReleaseTreeResources(); |
| 1576 if (tile_manager_) { | 1614 if (tile_manager_) { |
| 1577 DestroyTileManager(); | 1615 DestroyTileManager(); |
| 1578 CreateAndSetTileManager(); | 1616 CreateAndSetTileManager(); |
| 1579 } | 1617 } |
| 1618 RecreateTreeResources(); |
| 1580 | 1619 |
| 1581 // We have released tilings for both active and pending tree. | 1620 // We have released tilings for both active and pending tree. |
| 1582 // We would not have any content to draw until the pending tree is activated. | 1621 // We would not have any content to draw until the pending tree is activated. |
| 1583 // Prevent the active tree from drawing until activation. | 1622 // Prevent the active tree from drawing until activation. |
| 1584 SetRequiresHighResToDraw(); | 1623 SetRequiresHighResToDraw(); |
| 1585 } | 1624 } |
| 1586 | 1625 |
| 1587 const RendererCapabilitiesImpl& | 1626 const RendererCapabilitiesImpl& |
| 1588 LayerTreeHostImpl::GetRendererCapabilities() const { | 1627 LayerTreeHostImpl::GetRendererCapabilities() const { |
| 1589 return renderer_->Capabilities(); | 1628 return renderer_->Capabilities(); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 void LayerTreeHostImpl::ReleaseTreeResources() { | 1927 void LayerTreeHostImpl::ReleaseTreeResources() { |
| 1889 active_tree_->ReleaseResources(); | 1928 active_tree_->ReleaseResources(); |
| 1890 if (pending_tree_) | 1929 if (pending_tree_) |
| 1891 pending_tree_->ReleaseResources(); | 1930 pending_tree_->ReleaseResources(); |
| 1892 if (recycle_tree_) | 1931 if (recycle_tree_) |
| 1893 recycle_tree_->ReleaseResources(); | 1932 recycle_tree_->ReleaseResources(); |
| 1894 | 1933 |
| 1895 EvictAllUIResources(); | 1934 EvictAllUIResources(); |
| 1896 } | 1935 } |
| 1897 | 1936 |
| 1937 void LayerTreeHostImpl::RecreateTreeResources() { |
| 1938 active_tree_->RecreateResources(); |
| 1939 if (pending_tree_) |
| 1940 pending_tree_->RecreateResources(); |
| 1941 if (recycle_tree_) |
| 1942 recycle_tree_->RecreateResources(); |
| 1943 } |
| 1944 |
| 1898 void LayerTreeHostImpl::CreateAndSetRenderer() { | 1945 void LayerTreeHostImpl::CreateAndSetRenderer() { |
| 1899 DCHECK(!renderer_); | 1946 DCHECK(!renderer_); |
| 1900 DCHECK(output_surface_); | 1947 DCHECK(output_surface_); |
| 1901 DCHECK(resource_provider_); | 1948 DCHECK(resource_provider_); |
| 1902 | 1949 |
| 1903 if (output_surface_->capabilities().delegated_rendering) { | 1950 if (output_surface_->capabilities().delegated_rendering) { |
| 1904 renderer_ = DelegatingRenderer::Create(this, &settings_.renderer_settings, | 1951 renderer_ = DelegatingRenderer::Create(this, &settings_.renderer_settings, |
| 1905 output_surface_.get(), | 1952 output_surface_.get(), |
| 1906 resource_provider_.get()); | 1953 resource_provider_.get()); |
| 1907 } else if (output_surface_->context_provider()) { | 1954 } else if (output_surface_->context_provider()) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 tile_task_worker_pool_->AsTileTaskRunner(), | 1999 tile_task_worker_pool_->AsTileTaskRunner(), |
| 1953 rasterizer_.get(), scheduled_raster_task_limit); | 2000 rasterizer_.get(), scheduled_raster_task_limit); |
| 1954 | 2001 |
| 1955 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 2002 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
| 1956 } | 2003 } |
| 1957 | 2004 |
| 1958 scoped_ptr<Rasterizer> LayerTreeHostImpl::CreateRasterizer() { | 2005 scoped_ptr<Rasterizer> LayerTreeHostImpl::CreateRasterizer() { |
| 1959 ContextProvider* context_provider = output_surface_->context_provider(); | 2006 ContextProvider* context_provider = output_surface_->context_provider(); |
| 1960 if (use_gpu_rasterization_ && context_provider) { | 2007 if (use_gpu_rasterization_ && context_provider) { |
| 1961 return GpuRasterizer::Create(context_provider, resource_provider_.get(), | 2008 return GpuRasterizer::Create(context_provider, resource_provider_.get(), |
| 1962 settings_.use_distance_field_text, false, | 2009 settings_.use_distance_field_text, |
| 2010 settings_.threaded_gpu_rasterization_enabled, |
| 1963 settings_.gpu_rasterization_msaa_sample_count); | 2011 settings_.gpu_rasterization_msaa_sample_count); |
| 1964 } | 2012 } |
| 1965 return SoftwareRasterizer::Create(); | 2013 return SoftwareRasterizer::Create(); |
| 1966 } | 2014 } |
| 1967 | 2015 |
| 1968 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( | 2016 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( |
| 1969 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 2017 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
| 1970 scoped_ptr<ResourcePool>* resource_pool, | 2018 scoped_ptr<ResourcePool>* resource_pool, |
| 1971 scoped_ptr<ResourcePool>* staging_resource_pool) { | 2019 scoped_ptr<ResourcePool>* staging_resource_pool) { |
| 1972 base::SingleThreadTaskRunner* task_runner = | 2020 base::SingleThreadTaskRunner* task_runner = |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 2126 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
| 2079 // before we destroy the old resource provider. | 2127 // before we destroy the old resource provider. |
| 2080 ReleaseTreeResources(); | 2128 ReleaseTreeResources(); |
| 2081 | 2129 |
| 2082 // Note: order is important here. | 2130 // Note: order is important here. |
| 2083 renderer_ = nullptr; | 2131 renderer_ = nullptr; |
| 2084 DestroyTileManager(); | 2132 DestroyTileManager(); |
| 2085 resource_provider_ = nullptr; | 2133 resource_provider_ = nullptr; |
| 2086 output_surface_ = nullptr; | 2134 output_surface_ = nullptr; |
| 2087 | 2135 |
| 2088 if (!output_surface->BindToClient(this)) | 2136 if (!output_surface->BindToClient(this)) { |
| 2137 // Avoid recreating tree resources because we might not have enough |
| 2138 // information to do this yet (eg. we don't have a TileManager at this |
| 2139 // point). |
| 2089 return false; | 2140 return false; |
| 2141 } |
| 2090 | 2142 |
| 2091 output_surface_ = output_surface.Pass(); | 2143 output_surface_ = output_surface.Pass(); |
| 2092 resource_provider_ = ResourceProvider::Create( | 2144 resource_provider_ = ResourceProvider::Create( |
| 2093 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_, | 2145 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_, |
| 2094 proxy_->blocking_main_thread_task_runner(), | 2146 proxy_->blocking_main_thread_task_runner(), |
| 2095 settings_.renderer_settings.highp_threshold_min, | 2147 settings_.renderer_settings.highp_threshold_min, |
| 2096 settings_.renderer_settings.use_rgba_4444_textures, | 2148 settings_.renderer_settings.use_rgba_4444_textures, |
| 2097 settings_.renderer_settings.texture_id_allocation_chunk_size); | 2149 settings_.renderer_settings.texture_id_allocation_chunk_size); |
| 2098 | 2150 |
| 2099 if (output_surface_->capabilities().deferred_gl_initialization) | 2151 if (output_surface_->capabilities().deferred_gl_initialization) |
| 2100 EnforceZeroBudget(true); | 2152 EnforceZeroBudget(true); |
| 2101 | 2153 |
| 2102 CreateAndSetRenderer(); | 2154 CreateAndSetRenderer(); |
| 2103 | 2155 |
| 2104 if (settings_.impl_side_painting) | 2156 if (settings_.impl_side_painting) |
| 2105 CreateAndSetTileManager(); | 2157 CreateAndSetTileManager(); |
| 2158 RecreateTreeResources(); |
| 2106 | 2159 |
| 2107 // Initialize vsync parameters to sane values. | 2160 // Initialize vsync parameters to sane values. |
| 2108 const base::TimeDelta display_refresh_interval = | 2161 const base::TimeDelta display_refresh_interval = |
| 2109 base::TimeDelta::FromMicroseconds( | 2162 base::TimeDelta::FromMicroseconds( |
| 2110 base::Time::kMicrosecondsPerSecond / | 2163 base::Time::kMicrosecondsPerSecond / |
| 2111 settings_.renderer_settings.refresh_rate); | 2164 settings_.renderer_settings.refresh_rate); |
| 2112 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); | 2165 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); |
| 2113 | 2166 |
| 2114 // TODO(brianderson): Don't use a hard-coded parent draw time. | 2167 // TODO(brianderson): Don't use a hard-coded parent draw time. |
| 2115 base::TimeDelta parent_draw_time = | 2168 base::TimeDelta parent_draw_time = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2145 | 2198 |
| 2146 ReleaseTreeResources(); | 2199 ReleaseTreeResources(); |
| 2147 renderer_ = nullptr; | 2200 renderer_ = nullptr; |
| 2148 DestroyTileManager(); | 2201 DestroyTileManager(); |
| 2149 | 2202 |
| 2150 resource_provider_->InitializeGL(); | 2203 resource_provider_->InitializeGL(); |
| 2151 | 2204 |
| 2152 CreateAndSetRenderer(); | 2205 CreateAndSetRenderer(); |
| 2153 EnforceZeroBudget(false); | 2206 EnforceZeroBudget(false); |
| 2154 CreateAndSetTileManager(); | 2207 CreateAndSetTileManager(); |
| 2208 RecreateTreeResources(); |
| 2155 | 2209 |
| 2156 client_->SetNeedsCommitOnImplThread(); | 2210 client_->SetNeedsCommitOnImplThread(); |
| 2157 } | 2211 } |
| 2158 | 2212 |
| 2159 void LayerTreeHostImpl::ReleaseGL() { | 2213 void LayerTreeHostImpl::ReleaseGL() { |
| 2160 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | 2214 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
| 2161 DCHECK(settings_.impl_side_painting); | 2215 DCHECK(settings_.impl_side_painting); |
| 2162 DCHECK(output_surface_->context_provider()); | 2216 DCHECK(output_surface_->context_provider()); |
| 2163 | 2217 |
| 2164 ReleaseTreeResources(); | 2218 ReleaseTreeResources(); |
| 2165 renderer_ = nullptr; | 2219 renderer_ = nullptr; |
| 2166 DestroyTileManager(); | 2220 DestroyTileManager(); |
| 2167 | 2221 |
| 2168 resource_provider_->InitializeSoftware(); | 2222 resource_provider_->InitializeSoftware(); |
| 2169 output_surface_->ReleaseContextProvider(); | 2223 output_surface_->ReleaseContextProvider(); |
| 2170 | 2224 |
| 2171 CreateAndSetRenderer(); | 2225 CreateAndSetRenderer(); |
| 2172 EnforceZeroBudget(true); | 2226 EnforceZeroBudget(true); |
| 2173 CreateAndSetTileManager(); | 2227 CreateAndSetTileManager(); |
| 2228 RecreateTreeResources(); |
| 2174 | 2229 |
| 2175 client_->SetNeedsCommitOnImplThread(); | 2230 client_->SetNeedsCommitOnImplThread(); |
| 2176 } | 2231 } |
| 2177 | 2232 |
| 2178 void LayerTreeHostImpl::SetViewportSize(const gfx::Size& device_viewport_size) { | 2233 void LayerTreeHostImpl::SetViewportSize(const gfx::Size& device_viewport_size) { |
| 2179 if (device_viewport_size == device_viewport_size_) | 2234 if (device_viewport_size == device_viewport_size_) |
| 2180 return; | 2235 return; |
| 2236 TRACE_EVENT_INSTANT2("cc", "LayerTreeHostImpl::SetViewportSize", |
| 2237 TRACE_EVENT_SCOPE_THREAD, "width", |
| 2238 device_viewport_size.width(), "height", |
| 2239 device_viewport_size.height()); |
| 2181 | 2240 |
| 2182 if (pending_tree_) | 2241 if (pending_tree_) |
| 2183 active_tree_->SetViewportSizeInvalid(); | 2242 active_tree_->SetViewportSizeInvalid(); |
| 2184 | 2243 |
| 2185 device_viewport_size_ = device_viewport_size; | 2244 device_viewport_size_ = device_viewport_size; |
| 2186 | 2245 |
| 2187 UpdateViewportContainerSizes(); | 2246 UpdateViewportContainerSizes(); |
| 2188 client_->OnCanDrawStateChanged(CanDraw()); | 2247 client_->OnCanDrawStateChanged(CanDraw()); |
| 2189 SetFullRootLayerDamage(); | 2248 SetFullRootLayerDamage(); |
| 2190 active_tree_->set_needs_update_draw_properties(); | 2249 active_tree_->set_needs_update_draw_properties(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 float LayerTreeHostImpl::ControlsTopOffset() const { | 2307 float LayerTreeHostImpl::ControlsTopOffset() const { |
| 2249 return active_tree_->total_top_controls_content_offset() - | 2308 return active_tree_->total_top_controls_content_offset() - |
| 2250 active_tree_->top_controls_height(); | 2309 active_tree_->top_controls_height(); |
| 2251 } | 2310 } |
| 2252 | 2311 |
| 2253 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2312 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 2254 DCHECK(input_handler_client_ == NULL); | 2313 DCHECK(input_handler_client_ == NULL); |
| 2255 input_handler_client_ = client; | 2314 input_handler_client_ = client; |
| 2256 } | 2315 } |
| 2257 | 2316 |
| 2258 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | |
| 2259 if (LayerImpl* scroll_parent = layer->scroll_parent()) | |
| 2260 return scroll_parent; | |
| 2261 return layer->parent(); | |
| 2262 } | |
| 2263 | |
| 2264 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( | 2317 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
| 2265 const gfx::PointF& device_viewport_point, | 2318 const gfx::PointF& device_viewport_point, |
| 2266 InputHandler::ScrollInputType type, | 2319 InputHandler::ScrollInputType type, |
| 2267 LayerImpl* layer_impl, | 2320 LayerImpl* layer_impl, |
| 2268 bool* scroll_on_main_thread, | 2321 bool* scroll_on_main_thread, |
| 2269 bool* optional_has_ancestor_scroll_handler) const { | 2322 bool* optional_has_ancestor_scroll_handler) const { |
| 2270 DCHECK(scroll_on_main_thread); | 2323 DCHECK(scroll_on_main_thread); |
| 2271 | 2324 |
| 2325 ScrollBlocksOn block_mode = EffectiveScrollBlocksOn(layer_impl); |
| 2326 |
| 2272 // Walk up the hierarchy and look for a scrollable layer. | 2327 // Walk up the hierarchy and look for a scrollable layer. |
| 2273 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2328 LayerImpl* potentially_scrolling_layer_impl = NULL; |
| 2274 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { | 2329 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { |
| 2275 // The content layer can also block attempts to scroll outside the main | 2330 // The content layer can also block attempts to scroll outside the main |
| 2276 // thread. | 2331 // thread. |
| 2277 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 2332 ScrollStatus status = |
| 2333 layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2278 if (status == ScrollOnMainThread) { | 2334 if (status == ScrollOnMainThread) { |
| 2279 *scroll_on_main_thread = true; | 2335 *scroll_on_main_thread = true; |
| 2280 return NULL; | 2336 return NULL; |
| 2281 } | 2337 } |
| 2282 | 2338 |
| 2283 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 2339 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
| 2284 if (!scroll_layer_impl) | 2340 if (!scroll_layer_impl) |
| 2285 continue; | 2341 continue; |
| 2286 | 2342 |
| 2287 status = scroll_layer_impl->TryScroll(device_viewport_point, type); | 2343 status = |
| 2344 scroll_layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2288 // If any layer wants to divert the scroll event to the main thread, abort. | 2345 // If any layer wants to divert the scroll event to the main thread, abort. |
| 2289 if (status == ScrollOnMainThread) { | 2346 if (status == ScrollOnMainThread) { |
| 2290 *scroll_on_main_thread = true; | 2347 *scroll_on_main_thread = true; |
| 2291 return NULL; | 2348 return NULL; |
| 2292 } | 2349 } |
| 2293 | 2350 |
| 2294 if (optional_has_ancestor_scroll_handler && | 2351 if (optional_has_ancestor_scroll_handler && |
| 2295 scroll_layer_impl->have_scroll_event_handlers()) | 2352 scroll_layer_impl->have_scroll_event_handlers()) |
| 2296 *optional_has_ancestor_scroll_handler = true; | 2353 *optional_has_ancestor_scroll_handler = true; |
| 2297 | 2354 |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 3038 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
| 2982 LayerImpl* layer_impl) { | 3039 LayerImpl* layer_impl) { |
| 2983 if (!layer_impl) | 3040 if (!layer_impl) |
| 2984 return; | 3041 return; |
| 2985 | 3042 |
| 2986 gfx::ScrollOffset scroll_delta = layer_impl->PullDeltaForMainThread(); | 3043 gfx::ScrollOffset scroll_delta = layer_impl->PullDeltaForMainThread(); |
| 2987 | 3044 |
| 2988 if (!scroll_delta.IsZero()) { | 3045 if (!scroll_delta.IsZero()) { |
| 2989 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 3046 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
| 2990 scroll.layer_id = layer_impl->id(); | 3047 scroll.layer_id = layer_impl->id(); |
| 2991 scroll.scroll_delta = gfx::Vector2d(scroll_delta.x(), scroll_delta.y()); | 3048 scroll.scroll_delta = gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 2992 scroll_info->scrolls.push_back(scroll); | 3049 scroll_info->scrolls.push_back(scroll); |
| 2993 } | 3050 } |
| 2994 | 3051 |
| 2995 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 3052 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
| 2996 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 3053 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
| 2997 } | 3054 } |
| 2998 | 3055 |
| 2999 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 3056 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
| 3000 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 3057 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
| 3001 | 3058 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3459 } | 3516 } |
| 3460 | 3517 |
| 3461 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3518 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3462 std::vector<PictureLayerImpl*>::iterator it = | 3519 std::vector<PictureLayerImpl*>::iterator it = |
| 3463 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3520 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3464 DCHECK(it != picture_layers_.end()); | 3521 DCHECK(it != picture_layers_.end()); |
| 3465 picture_layers_.erase(it); | 3522 picture_layers_.erase(it); |
| 3466 } | 3523 } |
| 3467 | 3524 |
| 3468 } // namespace cc | 3525 } // namespace cc |
| OLD | NEW |