Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2253823002: cc: Remove all impl-side caps from RendererCapabilitiesImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delete-renderer-base-class
Patch Set: renderercaps: ennereview Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 // Use the most up-to-date version of device_scale_factor that we have. 1753 // Use the most up-to-date version of device_scale_factor that we have.
1754 float device_scale_factor = pending_tree_ 1754 float device_scale_factor = pending_tree_
1755 ? pending_tree_->device_scale_factor() 1755 ? pending_tree_->device_scale_factor()
1756 : active_tree_->device_scale_factor(); 1756 : active_tree_->device_scale_factor();
1757 return device_scale_factor >= 2.0f ? 4 : 8; 1757 return device_scale_factor >= 2.0f ? 4 : 8;
1758 } 1758 }
1759 1759
1760 return settings_.gpu_rasterization_msaa_sample_count; 1760 return settings_.gpu_rasterization_msaa_sample_count;
1761 } 1761 }
1762 1762
1763 void LayerTreeHostImpl::SetHasGpuRasterizationTrigger(bool flag) {
1764 if (has_gpu_rasterization_trigger_ != flag) {
1765 has_gpu_rasterization_trigger_ = flag;
1766 need_update_gpu_rasterization_status_ = true;
1767 }
1768 }
1769
1770 void LayerTreeHostImpl::SetContentIsSuitableForGpuRasterization(bool flag) {
1771 if (content_is_suitable_for_gpu_rasterization_ != flag) {
1772 content_is_suitable_for_gpu_rasterization_ = flag;
1773 need_update_gpu_rasterization_status_ = true;
1774 }
1775 }
1776
1763 bool LayerTreeHostImpl::CanUseGpuRasterization() { 1777 bool LayerTreeHostImpl::CanUseGpuRasterization() {
1764 if (!(output_surface_ && output_surface_->context_provider() && 1778 if (!(output_surface_ && output_surface_->context_provider() &&
1765 output_surface_->worker_context_provider())) 1779 output_surface_->worker_context_provider()))
1766 return false; 1780 return false;
1767 1781
1768 ContextProvider* context_provider = 1782 ContextProvider* context_provider =
1769 output_surface_->worker_context_provider(); 1783 output_surface_->worker_context_provider();
1770 ContextProvider::ScopedContextLock scoped_context(context_provider); 1784 ContextProvider::ScopedContextLock scoped_context(context_provider);
1771 if (!context_provider->GrContext()) 1785 if (!context_provider->GrContext())
1772 return false; 1786 return false;
1773 1787
1774 return true; 1788 return true;
1775 } 1789 }
1776 1790
1777 void LayerTreeHostImpl::UpdateGpuRasterizationStatus() { 1791 bool LayerTreeHostImpl::UpdateGpuRasterizationStatus() {
1792 // TODO(danakj): Can we avoid having this run when there's no output surface?
1793 // For now just early out and leave things unchanged, we'll come back here
1794 // when we get an output surface.
1795 if (!output_surface_)
1796 return false;
1797
1798 int requested_msaa_samples = RequestedMSAASampleCount();
1799 int max_msaa_samples = 0;
1800 ContextProvider* compositor_context_provider =
1801 output_surface_->context_provider();
1802 if (compositor_context_provider) {
1803 const auto& caps = compositor_context_provider->ContextCapabilities();
1804 if (!caps.msaa_is_slow)
1805 max_msaa_samples = caps.max_samples;
1806 }
1807
1778 bool use_gpu = false; 1808 bool use_gpu = false;
1779 bool use_msaa = false; 1809 bool use_msaa = false;
1780 bool using_msaa_for_complex_content = 1810 bool using_msaa_for_complex_content =
1781 renderer() && RequestedMSAASampleCount() > 0 && 1811 requested_msaa_samples > 0 && max_msaa_samples >= requested_msaa_samples;
1782 GetRendererCapabilities().max_msaa_samples >= RequestedMSAASampleCount();
1783 if (settings_.gpu_rasterization_forced) { 1812 if (settings_.gpu_rasterization_forced) {
1784 use_gpu = true; 1813 use_gpu = true;
1785 gpu_rasterization_status_ = GpuRasterizationStatus::ON_FORCED; 1814 gpu_rasterization_status_ = GpuRasterizationStatus::ON_FORCED;
1786 use_msaa = !content_is_suitable_for_gpu_rasterization_ && 1815 use_msaa = !content_is_suitable_for_gpu_rasterization_ &&
1787 using_msaa_for_complex_content; 1816 using_msaa_for_complex_content;
1788 if (use_msaa) { 1817 if (use_msaa) {
1789 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT; 1818 gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT;
1790 } 1819 }
1791 } else if (!settings_.gpu_rasterization_enabled) { 1820 } else if (!settings_.gpu_rasterization_enabled) {
1792 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; 1821 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE;
(...skipping 14 matching lines...) Expand all
1807 // If GPU rasterization is unusable, e.g. if GlContext could not 1836 // If GPU rasterization is unusable, e.g. if GlContext could not
1808 // be created due to losing the GL context, force use of software 1837 // be created due to losing the GL context, force use of software
1809 // raster. 1838 // raster.
1810 use_gpu = false; 1839 use_gpu = false;
1811 use_msaa = false; 1840 use_msaa = false;
1812 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE; 1841 gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE;
1813 } 1842 }
1814 } 1843 }
1815 1844
1816 if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_) 1845 if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_)
1817 return; 1846 return false;
1818 1847
1819 // Note that this must happen first, in case the rest of the calls want to 1848 // Note that this must happen first, in case the rest of the calls want to
1820 // query the new state of |use_gpu_rasterization_|. 1849 // query the new state of |use_gpu_rasterization_|.
1821 use_gpu_rasterization_ = use_gpu; 1850 use_gpu_rasterization_ = use_gpu;
1822 use_msaa_ = use_msaa; 1851 use_msaa_ = use_msaa;
1823 1852 return true;
1824 tree_resources_for_gpu_rasterization_dirty_ = true;
1825 } 1853 }
1826 1854
1827 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() { 1855 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() {
1828 if (!tree_resources_for_gpu_rasterization_dirty_) 1856 if (!need_update_gpu_rasterization_status_)
1857 return;
1858 if (!UpdateGpuRasterizationStatus())
1829 return; 1859 return;
1830 1860
1831 // Clean up and replace existing tile manager with another one that uses 1861 // Clean up and replace existing tile manager with another one that uses
1832 // appropriate rasterizer. Only do this however if we already have a 1862 // 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 1863 // resource pool, since otherwise we might not be able to create a new
1834 // one. 1864 // one.
1835 ReleaseTreeResources(); 1865 ReleaseTreeResources();
1836 if (resource_pool_) { 1866 if (resource_pool_) {
1837 CleanUpTileManagerAndUIResources(); 1867 CleanUpTileManagerAndUIResources();
1838 CreateTileManagerResources(); 1868 CreateTileManagerResources();
1839 } 1869 }
1840 RecreateTreeResources(); 1870 RecreateTreeResources();
1841 1871
1842 // We have released tilings for both active and pending tree. 1872 // 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. 1873 // We would not have any content to draw until the pending tree is activated.
1844 // Prevent the active tree from drawing until activation. 1874 // Prevent the active tree from drawing until activation.
1845 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. 1875 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw.
1846 SetRequiresHighResToDraw(); 1876 SetRequiresHighResToDraw();
1847
1848 tree_resources_for_gpu_rasterization_dirty_ = false;
1849 } 1877 }
1850 1878
1851 const RendererCapabilitiesImpl& LayerTreeHostImpl::GetRendererCapabilities() 1879 const RendererCapabilitiesImpl& LayerTreeHostImpl::GetRendererCapabilities()
1852 const { 1880 const {
1853 CHECK(renderer_); 1881 CHECK(renderer_);
1854 return renderer_->Capabilities(); 1882 return renderer_->Capabilities();
1855 } 1883 }
1856 1884
1857 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { 1885 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
1858 ResetRequiresHighResToDraw(); 1886 ResetRequiresHighResToDraw();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 2262
2235 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; 2263 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0;
2236 2264
2237 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( 2265 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>(
2238 compositor_context_provider, worker_context_provider, 2266 compositor_context_provider, worker_context_provider,
2239 resource_provider_.get(), settings_.use_distance_field_text, 2267 resource_provider_.get(), settings_.use_distance_field_text,
2240 msaa_sample_count, settings_.async_worker_context_enabled); 2268 msaa_sample_count, settings_.async_worker_context_enabled);
2241 return; 2269 return;
2242 } 2270 }
2243 2271
2244 DCHECK(GetRendererCapabilities().using_image); 2272 DCHECK(compositor_context_provider->ContextCapabilities().image);
2245 2273
2246 bool use_zero_copy = settings_.use_zero_copy; 2274 bool use_zero_copy = settings_.use_zero_copy;
2247 // TODO(reveman): Remove this when mojo supports worker contexts. 2275 // TODO(reveman): Remove this when mojo supports worker contexts.
2248 // crbug.com/522440 2276 // crbug.com/522440
2249 if (!use_zero_copy && !worker_context_provider) { 2277 if (!use_zero_copy && !worker_context_provider) {
2250 LOG(ERROR) 2278 LOG(ERROR)
2251 << "Forcing zero-copy tile initialization as worker context is missing"; 2279 << "Forcing zero-copy tile initialization as worker context is missing";
2252 use_zero_copy = true; 2280 use_zero_copy = true;
2253 } 2281 }
2254 2282
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 resource_provider_ = base::MakeUnique<ResourceProvider>( 2366 resource_provider_ = base::MakeUnique<ResourceProvider>(
2339 output_surface_->context_provider(), shared_bitmap_manager_, 2367 output_surface_->context_provider(), shared_bitmap_manager_,
2340 gpu_memory_buffer_manager_, 2368 gpu_memory_buffer_manager_,
2341 task_runner_provider_->blocking_main_thread_task_runner(), 2369 task_runner_provider_->blocking_main_thread_task_runner(),
2342 settings_.renderer_settings.highp_threshold_min, 2370 settings_.renderer_settings.highp_threshold_min,
2343 settings_.renderer_settings.texture_id_allocation_chunk_size, 2371 settings_.renderer_settings.texture_id_allocation_chunk_size,
2344 output_surface_->capabilities().delegated_sync_points_required, 2372 output_surface_->capabilities().delegated_sync_points_required,
2345 settings_.renderer_settings.use_gpu_memory_buffer_resources, 2373 settings_.renderer_settings.use_gpu_memory_buffer_resources,
2346 settings_.renderer_settings.buffer_to_texture_target_map); 2374 settings_.renderer_settings.buffer_to_texture_target_map);
2347 2375
2376 // Since the new context may be capable of MSAA, update status here. We don't
2377 // need to check the return value since we are recreating all resources
2378 // already.
2379 UpdateGpuRasterizationStatus();
2380
2348 CreateAndSetRenderer(); 2381 CreateAndSetRenderer();
2349 2382
2350 // Since the new renderer may be capable of MSAA, update status here.
2351 UpdateGpuRasterizationStatus();
2352
2353 CreateTileManagerResources(); 2383 CreateTileManagerResources();
2354 RecreateTreeResources(); 2384 RecreateTreeResources();
2355 2385
2356 // Initialize vsync parameters to sane values. 2386 // Initialize vsync parameters to sane values.
2357 const base::TimeDelta display_refresh_interval = 2387 const base::TimeDelta display_refresh_interval =
2358 base::TimeDelta::FromMicroseconds( 2388 base::TimeDelta::FromMicroseconds(
2359 base::Time::kMicrosecondsPerSecond / 2389 base::Time::kMicrosecondsPerSecond /
2360 settings_.renderer_settings.refresh_rate); 2390 settings_.renderer_settings.refresh_rate);
2361 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); 2391 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval);
2362 2392
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
4058 return task_runner_provider_->HasImplThread(); 4088 return task_runner_provider_->HasImplThread();
4059 } 4089 }
4060 4090
4061 bool LayerTreeHostImpl::CommitToActiveTree() const { 4091 bool LayerTreeHostImpl::CommitToActiveTree() const {
4062 // In single threaded mode we skip the pending tree and commit directly to the 4092 // In single threaded mode we skip the pending tree and commit directly to the
4063 // active tree. 4093 // active tree.
4064 return !task_runner_provider_->HasImplThread(); 4094 return !task_runner_provider_->HasImplThread();
4065 } 4095 }
4066 4096
4067 } // namespace cc 4097 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698