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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 221 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
222 SharedBitmapManager* shared_bitmap_manager, | 222 SharedBitmapManager* shared_bitmap_manager, |
223 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 223 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
224 TaskGraphRunner* task_graph_runner, | 224 TaskGraphRunner* task_graph_runner, |
225 std::unique_ptr<AnimationHost> animation_host, | 225 std::unique_ptr<AnimationHost> animation_host, |
226 int id) | 226 int id) |
227 : client_(client), | 227 : client_(client), |
228 task_runner_provider_(task_runner_provider), | 228 task_runner_provider_(task_runner_provider), |
229 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | 229 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
230 output_surface_(nullptr), | 230 output_surface_(nullptr), |
231 need_update_gpu_rasterization_status_(false), | |
231 content_is_suitable_for_gpu_rasterization_(true), | 232 content_is_suitable_for_gpu_rasterization_(true), |
232 has_gpu_rasterization_trigger_(false), | 233 has_gpu_rasterization_trigger_(false), |
233 use_gpu_rasterization_(false), | 234 use_gpu_rasterization_(false), |
234 use_msaa_(false), | 235 use_msaa_(false), |
235 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), | 236 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), |
236 tree_resources_for_gpu_rasterization_dirty_(false), | |
237 input_handler_client_(NULL), | 237 input_handler_client_(NULL), |
238 did_lock_scrolling_layer_(false), | 238 did_lock_scrolling_layer_(false), |
239 wheel_scrolling_(false), | 239 wheel_scrolling_(false), |
240 scroll_affects_scroll_handler_(false), | 240 scroll_affects_scroll_handler_(false), |
241 scroll_layer_id_when_mouse_over_scrollbar_(Layer::INVALID_ID), | 241 scroll_layer_id_when_mouse_over_scrollbar_(Layer::INVALID_ID), |
242 tile_priorities_dirty_(false), | 242 tile_priorities_dirty_(false), |
243 settings_(settings), | 243 settings_(settings), |
244 visible_(false), | 244 visible_(false), |
245 cached_managed_memory_policy_(settings.memory_policy_), | 245 cached_managed_memory_policy_(settings.memory_policy_), |
246 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() && | 246 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() && |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1767 | 1767 |
1768 ContextProvider* context_provider = | 1768 ContextProvider* context_provider = |
1769 output_surface_->worker_context_provider(); | 1769 output_surface_->worker_context_provider(); |
1770 ContextProvider::ScopedContextLock scoped_context(context_provider); | 1770 ContextProvider::ScopedContextLock scoped_context(context_provider); |
1771 if (!context_provider->GrContext()) | 1771 if (!context_provider->GrContext()) |
1772 return false; | 1772 return false; |
1773 | 1773 |
1774 return true; | 1774 return true; |
1775 } | 1775 } |
1776 | 1776 |
1777 void LayerTreeHostImpl::UpdateGpuRasterizationStatus() { | 1777 bool LayerTreeHostImpl::UpdateGpuRasterizationStatus() { |
1778 int requested_msaa_samples = RequestedMSAASampleCount(); | |
1779 int max_msaa_samples = 0; | |
1780 ContextProvider* compositor_context_provider = nullptr; | |
1781 // TODO(danakj): Can we avoid having this run when there's no output surface? | |
enne (OOO)
2016/08/17 17:48:42
Maybe it should early out when there's no output s
danakj
2016/08/17 18:16:41
Good idea.
| |
1782 if (output_surface_) | |
1783 compositor_context_provider = output_surface_->context_provider(); | |
1784 if (compositor_context_provider) { | |
1785 const auto& caps = compositor_context_provider->ContextCapabilities(); | |
1786 if (!caps.msaa_is_slow) | |
1787 max_msaa_samples = caps.max_samples; | |
1788 } | |
1789 | |
1778 bool use_gpu = false; | 1790 bool use_gpu = false; |
1779 bool use_msaa = false; | 1791 bool use_msaa = false; |
1780 bool using_msaa_for_complex_content = | 1792 bool using_msaa_for_complex_content = |
1781 renderer() && RequestedMSAASampleCount() > 0 && | 1793 requested_msaa_samples > 0 && max_msaa_samples >= requested_msaa_samples; |
1782 GetRendererCapabilities().max_msaa_samples >= RequestedMSAASampleCount(); | |
1783 if (settings_.gpu_rasterization_forced) { | 1794 if (settings_.gpu_rasterization_forced) { |
1784 use_gpu = true; | 1795 use_gpu = true; |
1785 gpu_rasterization_status_ = GpuRasterizationStatus::ON_FORCED; | 1796 gpu_rasterization_status_ = GpuRasterizationStatus::ON_FORCED; |
1786 use_msaa = !content_is_suitable_for_gpu_rasterization_ && | 1797 use_msaa = !content_is_suitable_for_gpu_rasterization_ && |
1787 using_msaa_for_complex_content; | 1798 using_msaa_for_complex_content; |
1788 if (use_msaa) { | 1799 if (use_msaa) { |
1789 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT; | 1800 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT; |
1790 } | 1801 } |
1791 } else if (!settings_.gpu_rasterization_enabled) { | 1802 } else if (!settings_.gpu_rasterization_enabled) { |
1792 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; | 1803 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; |
(...skipping 14 matching lines...) Expand all Loading... | |
1807 // If GPU rasterization is unusable, e.g. if GlContext could not | 1818 // If GPU rasterization is unusable, e.g. if GlContext could not |
1808 // be created due to losing the GL context, force use of software | 1819 // be created due to losing the GL context, force use of software |
1809 // raster. | 1820 // raster. |
1810 use_gpu = false; | 1821 use_gpu = false; |
1811 use_msaa = false; | 1822 use_msaa = false; |
1812 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; | 1823 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; |
1813 } | 1824 } |
1814 } | 1825 } |
1815 | 1826 |
1816 if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_) | 1827 if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_) |
1817 return; | 1828 return false; |
1818 | 1829 |
1819 // Note that this must happen first, in case the rest of the calls want to | 1830 // Note that this must happen first, in case the rest of the calls want to |
1820 // query the new state of |use_gpu_rasterization_|. | 1831 // query the new state of |use_gpu_rasterization_|. |
1821 use_gpu_rasterization_ = use_gpu; | 1832 use_gpu_rasterization_ = use_gpu; |
1822 use_msaa_ = use_msaa; | 1833 use_msaa_ = use_msaa; |
1823 | 1834 return true; |
1824 tree_resources_for_gpu_rasterization_dirty_ = true; | |
1825 } | 1835 } |
1826 | 1836 |
1827 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() { | 1837 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() { |
1828 if (!tree_resources_for_gpu_rasterization_dirty_) | 1838 if (!need_update_gpu_rasterization_status_) |
1839 return; | |
1840 if (!UpdateGpuRasterizationStatus()) | |
1829 return; | 1841 return; |
1830 | 1842 |
1831 // Clean up and replace existing tile manager with another one that uses | 1843 // Clean up and replace existing tile manager with another one that uses |
1832 // appropriate rasterizer. Only do this however if we already have a | 1844 // appropriate rasterizer. Only do this however if we already have a |
1833 // resource pool, since otherwise we might not be able to create a new | 1845 // resource pool, since otherwise we might not be able to create a new |
1834 // one. | 1846 // one. |
1835 ReleaseTreeResources(); | 1847 ReleaseTreeResources(); |
1836 if (resource_pool_) { | 1848 if (resource_pool_) { |
1837 CleanUpTileManagerAndUIResources(); | 1849 CleanUpTileManagerAndUIResources(); |
1838 CreateTileManagerResources(); | 1850 CreateTileManagerResources(); |
1839 } | 1851 } |
1840 RecreateTreeResources(); | 1852 RecreateTreeResources(); |
1841 | 1853 |
1842 // We have released tilings for both active and pending tree. | 1854 // We have released tilings for both active and pending tree. |
1843 // We would not have any content to draw until the pending tree is activated. | 1855 // We would not have any content to draw until the pending tree is activated. |
1844 // Prevent the active tree from drawing until activation. | 1856 // Prevent the active tree from drawing until activation. |
1845 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. | 1857 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. |
1846 SetRequiresHighResToDraw(); | 1858 SetRequiresHighResToDraw(); |
1847 | |
1848 tree_resources_for_gpu_rasterization_dirty_ = false; | |
1849 } | 1859 } |
1850 | 1860 |
1851 const RendererCapabilitiesImpl& LayerTreeHostImpl::GetRendererCapabilities() | 1861 const RendererCapabilitiesImpl& LayerTreeHostImpl::GetRendererCapabilities() |
1852 const { | 1862 const { |
1853 CHECK(renderer_); | 1863 CHECK(renderer_); |
1854 return renderer_->Capabilities(); | 1864 return renderer_->Capabilities(); |
1855 } | 1865 } |
1856 | 1866 |
1857 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1867 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1858 ResetRequiresHighResToDraw(); | 1868 ResetRequiresHighResToDraw(); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2234 | 2244 |
2235 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; | 2245 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; |
2236 | 2246 |
2237 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( | 2247 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( |
2238 compositor_context_provider, worker_context_provider, | 2248 compositor_context_provider, worker_context_provider, |
2239 resource_provider_.get(), settings_.use_distance_field_text, | 2249 resource_provider_.get(), settings_.use_distance_field_text, |
2240 msaa_sample_count, settings_.async_worker_context_enabled); | 2250 msaa_sample_count, settings_.async_worker_context_enabled); |
2241 return; | 2251 return; |
2242 } | 2252 } |
2243 | 2253 |
2244 DCHECK(GetRendererCapabilities().using_image); | 2254 DCHECK(compositor_context_provider->ContextCapabilities().image); |
2245 | 2255 |
2246 bool use_zero_copy = settings_.use_zero_copy; | 2256 bool use_zero_copy = settings_.use_zero_copy; |
2247 // TODO(reveman): Remove this when mojo supports worker contexts. | 2257 // TODO(reveman): Remove this when mojo supports worker contexts. |
2248 // crbug.com/522440 | 2258 // crbug.com/522440 |
2249 if (!use_zero_copy && !worker_context_provider) { | 2259 if (!use_zero_copy && !worker_context_provider) { |
2250 LOG(ERROR) | 2260 LOG(ERROR) |
2251 << "Forcing zero-copy tile initialization as worker context is missing"; | 2261 << "Forcing zero-copy tile initialization as worker context is missing"; |
2252 use_zero_copy = true; | 2262 use_zero_copy = true; |
2253 } | 2263 } |
2254 | 2264 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2338 resource_provider_ = base::MakeUnique<ResourceProvider>( | 2348 resource_provider_ = base::MakeUnique<ResourceProvider>( |
2339 output_surface_->context_provider(), shared_bitmap_manager_, | 2349 output_surface_->context_provider(), shared_bitmap_manager_, |
2340 gpu_memory_buffer_manager_, | 2350 gpu_memory_buffer_manager_, |
2341 task_runner_provider_->blocking_main_thread_task_runner(), | 2351 task_runner_provider_->blocking_main_thread_task_runner(), |
2342 settings_.renderer_settings.highp_threshold_min, | 2352 settings_.renderer_settings.highp_threshold_min, |
2343 settings_.renderer_settings.texture_id_allocation_chunk_size, | 2353 settings_.renderer_settings.texture_id_allocation_chunk_size, |
2344 output_surface_->capabilities().delegated_sync_points_required, | 2354 output_surface_->capabilities().delegated_sync_points_required, |
2345 settings_.renderer_settings.use_gpu_memory_buffer_resources, | 2355 settings_.renderer_settings.use_gpu_memory_buffer_resources, |
2346 settings_.renderer_settings.buffer_to_texture_target_map); | 2356 settings_.renderer_settings.buffer_to_texture_target_map); |
2347 | 2357 |
2358 // Since the new context may be capable of MSAA, update status here. We don't | |
2359 // need to check the return value since we are recreating all resources | |
2360 // already. | |
2361 UpdateGpuRasterizationStatus(); | |
2362 | |
2348 CreateAndSetRenderer(); | 2363 CreateAndSetRenderer(); |
2349 | 2364 |
2350 // Since the new renderer may be capable of MSAA, update status here. | |
2351 UpdateGpuRasterizationStatus(); | |
2352 | |
2353 CreateTileManagerResources(); | 2365 CreateTileManagerResources(); |
2354 RecreateTreeResources(); | 2366 RecreateTreeResources(); |
2355 | 2367 |
2356 // Initialize vsync parameters to sane values. | 2368 // Initialize vsync parameters to sane values. |
2357 const base::TimeDelta display_refresh_interval = | 2369 const base::TimeDelta display_refresh_interval = |
2358 base::TimeDelta::FromMicroseconds( | 2370 base::TimeDelta::FromMicroseconds( |
2359 base::Time::kMicrosecondsPerSecond / | 2371 base::Time::kMicrosecondsPerSecond / |
2360 settings_.renderer_settings.refresh_rate); | 2372 settings_.renderer_settings.refresh_rate); |
2361 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); | 2373 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); |
2362 | 2374 |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4058 return task_runner_provider_->HasImplThread(); | 4070 return task_runner_provider_->HasImplThread(); |
4059 } | 4071 } |
4060 | 4072 |
4061 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4073 bool LayerTreeHostImpl::CommitToActiveTree() const { |
4062 // In single threaded mode we skip the pending tree and commit directly to the | 4074 // In single threaded mode we skip the pending tree and commit directly to the |
4063 // active tree. | 4075 // active tree. |
4064 return !task_runner_provider_->HasImplThread(); | 4076 return !task_runner_provider_->HasImplThread(); |
4065 } | 4077 } |
4066 | 4078 |
4067 } // namespace cc | 4079 } // namespace cc |
OLD | NEW |