Commit bdb6fd20 authored by enne's avatar enne Committed by Commit bot

cc: Add raster_enabled setting

In order to support impl-side painting plus an embedder without a
message loop, cc needs a setting to disable raster.  Rastering with
impl-side painting requires a task runner (and DCHECKs this).  This
setting notifies cc that there's no need for a tile manager.

Thankfully, tile manager is already considered optional in almost all
contexts, and so just a few more callsites needed to be cleaned up to
fix a few crashes.

With this patch, all cc unittests pass with impl-side painting on by
default.

Review URL: https://codereview.chromium.org/984113004

Cr-Commit-Position: refs/heads/master@{#319840}
parent 843e610b
......@@ -79,20 +79,23 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
Layer::SetLayerTreeHost(host);
if (host) {
if (!recording_source_) {
if (host->settings().use_display_lists) {
recording_source_.reset(new DisplayListRecordingSource);
} else {
recording_source_.reset(
new PicturePile(host->settings().minimum_contents_scale,
host->settings().default_tile_grid_size));
}
if (!host)
return;
if (!recording_source_) {
if (host->settings().use_display_lists) {
recording_source_.reset(new DisplayListRecordingSource);
} else {
recording_source_.reset(
new PicturePile(host->settings().minimum_contents_scale,
host->settings().default_tile_grid_size));
}
recording_source_->DidMoveToNewCompositor();
recording_source_->SetSlowdownRasterScaleFactor(
host->debug_state().slow_down_raster_scale_factor);
}
recording_source_->DidMoveToNewCompositor();
recording_source_->SetSlowdownRasterScaleFactor(
host->debug_state().slow_down_raster_scale_factor);
DCHECK(host->settings().raster_enabled);
}
void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) {
......
......@@ -1055,7 +1055,7 @@ DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) {
// This will cause NotifyTileStateChanged() to be called for any visible tiles
// that completed, which will add damage to the frame for them so they appear
// as part of the current frame being drawn.
if (settings().impl_side_painting)
if (tile_manager_)
tile_manager_->UpdateVisibleTiles(global_tile_state_);
frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList();
......@@ -1705,7 +1705,8 @@ void LayerTreeHostImpl::UpdateViewportContainerSizes() {
void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() {
// Only valid for the single-threaded non-scheduled/synchronous case
// using the zero copy raster worker pool.
single_thread_synchronous_task_graph_runner_->RunUntilIdle();
if (tile_manager_)
single_thread_synchronous_task_graph_runner_->RunUntilIdle();
}
void LayerTreeHostImpl::DidLoseOutputSurface() {
......@@ -2136,7 +2137,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
CreateAndSetRenderer();
if (settings_.impl_side_painting)
if (settings_.impl_side_painting && settings_.raster_enabled)
CreateAndSetTileManager();
RecreateTreeResources();
......
......@@ -610,6 +610,7 @@ class CC_EXPORT LayerTreeHostImpl
// |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
// free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
// |tile_manager_| can also be NULL when raster_enabled is false.
scoped_ptr<ResourceProvider> resource_provider_;
scoped_ptr<TileManager> tile_manager_;
bool use_gpu_rasterization_;
......
......@@ -104,6 +104,7 @@ class LayerTreeHostNoMessageLoopTest
LayerTreeSettings settings;
settings.single_thread_proxy_scheduler = false;
settings.verify_property_trees = true;
settings.raster_enabled = false;
layer_tree_host_ = LayerTreeHost::CreateSingleThreaded(
this, this, nullptr, nullptr, settings, nullptr, nullptr);
layer_tree_host_->SetViewportSize(size_);
......
......@@ -15,6 +15,7 @@ namespace cc {
LayerTreeSettings::LayerTreeSettings()
: impl_side_painting(false),
raster_enabled(true),
throttle_frame_production(true),
single_thread_proxy_scheduler(true),
use_external_begin_frame_source(false),
......
......@@ -21,6 +21,7 @@ class CC_EXPORT LayerTreeSettings {
RendererSettings renderer_settings;
bool impl_side_painting;
bool raster_enabled;
bool throttle_frame_production;
bool single_thread_proxy_scheduler;
bool use_external_begin_frame_source;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment