diff options
-rw-r--r-- | cc/output/direct_renderer.cc | 27 | ||||
-rw-r--r-- | cc/output/direct_renderer.h | 4 | ||||
-rw-r--r-- | cc/output/gl_renderer.cc | 2 | ||||
-rw-r--r-- | cc/output/overlay_unittest.cc | 1 | ||||
-rw-r--r-- | cc/output/renderer.h | 2 | ||||
-rw-r--r-- | cc/output/software_renderer.cc | 2 | ||||
-rw-r--r-- | cc/output/software_renderer_unittest.cc | 1 | ||||
-rw-r--r-- | cc/resources/raster_worker_pool.cc | 7 | ||||
-rw-r--r-- | cc/surfaces/display.h | 1 | ||||
-rw-r--r-- | cc/test/fake_renderer_client.h | 1 | ||||
-rw-r--r-- | cc/test/pixel_test.cc | 25 | ||||
-rw-r--r-- | cc/test/pixel_test.h | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 34 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc | 21 |
15 files changed, 96 insertions, 38 deletions
diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 08fe2571..ccde85b 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -415,33 +415,6 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame, return BindFramebufferToTexture(frame, texture, render_pass->output_rect); } -void DirectRenderer::RunOnDemandRasterTask(Task* on_demand_raster_task) { - TaskGraphRunner* task_graph_runner = RasterWorkerPool::GetTaskGraphRunner(); - DCHECK(task_graph_runner); - - // Make sure we have a unique task namespace token. - if (!on_demand_task_namespace_.IsValid()) - on_demand_task_namespace_ = task_graph_runner->GetNamespaceToken(); - - // Construct a task graph that contains this single raster task. - TaskGraph graph; - graph.nodes.push_back( - TaskGraph::Node(on_demand_raster_task, - RasterWorkerPool::kOnDemandRasterTaskPriority, - 0u)); - - // Schedule task and wait for task graph runner to finish running it. - task_graph_runner->ScheduleTasks(on_demand_task_namespace_, &graph); - task_graph_runner->WaitForTasksToFinishRunning(on_demand_task_namespace_); - - // Collect task now that it has finished running. - Task::Vector completed_tasks; - task_graph_runner->CollectCompletedTasks(on_demand_task_namespace_, - &completed_tasks); - DCHECK_EQ(1u, completed_tasks.size()); - DCHECK_EQ(completed_tasks[0], on_demand_raster_task); -} - bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPass::Id id) const { ScopedResource* texture = render_pass_textures_.get(id); diff --git a/cc/output/direct_renderer.h b/cc/output/direct_renderer.h index 0035ec2..1a84a87 100644 --- a/cc/output/direct_renderer.h +++ b/cc/output/direct_renderer.h @@ -91,8 +91,6 @@ class CC_EXPORT DirectRenderer : public Renderer { void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); - void RunOnDemandRasterTask(Task* on_demand_raster_task); - virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; virtual bool BindFramebufferToTexture(DrawingFrame* frame, const ScopedResource* resource, @@ -134,8 +132,6 @@ class CC_EXPORT DirectRenderer : public Renderer { private: gfx::Vector2d enlarge_pass_texture_amount_; - NamespaceToken on_demand_task_namespace_; - DISALLOW_COPY_AND_ASSIGN(DirectRenderer); }; diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 68bc291..b58a4d1 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -1907,7 +1907,7 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, &on_demand_tile_raster_bitmap_, quad->content_rect, quad->contents_scale)); - RunOnDemandRasterTask(on_demand_raster_task.get()); + client_->RunOnDemandRasterTask(on_demand_raster_task.get()); uint8_t* bitmap_pixels = NULL; SkBitmap on_demand_tile_raster_bitmap_dest; diff --git a/cc/output/overlay_unittest.cc b/cc/output/overlay_unittest.cc index 69c11c0..932ad7a 100644 --- a/cc/output/overlay_unittest.cc +++ b/cc/output/overlay_unittest.cc @@ -491,6 +491,7 @@ class FakeRendererClient : public RendererClient { public: // RendererClient methods. virtual void SetFullRootLayerDamage() OVERRIDE {} + virtual void RunOnDemandRasterTask(Task* on_demand_raster_task) OVERRIDE {} }; class MockOverlayScheduler { diff --git a/cc/output/renderer.h b/cc/output/renderer.h index af77cbb..d95a747 100644 --- a/cc/output/renderer.h +++ b/cc/output/renderer.h @@ -15,6 +15,7 @@ namespace cc { class CompositorFrameAck; class CompositorFrameMetadata; class ScopedResource; +class Task; struct RendererCapabilitiesImpl { RendererCapabilitiesImpl(); @@ -40,6 +41,7 @@ struct RendererCapabilitiesImpl { class CC_EXPORT RendererClient { public: virtual void SetFullRootLayerDamage() = 0; + virtual void RunOnDemandRasterTask(Task* on_demand_raster_task) = 0; }; class CC_EXPORT Renderer { diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc index d0f97c0..61b3253 100644 --- a/cc/output/software_renderer.cc +++ b/cc/output/software_renderer.cc @@ -395,7 +395,7 @@ void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame, current_canvas_, quad->content_rect, quad->contents_scale)); - RunOnDemandRasterTask(on_demand_raster_task.get()); + client_->RunOnDemandRasterTask(on_demand_raster_task.get()); current_canvas_->setDrawFilter(NULL); } diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc index 52ff828..536b2ef1 100644 --- a/cc/output/software_renderer_unittest.cc +++ b/cc/output/software_renderer_unittest.cc @@ -52,6 +52,7 @@ class SoftwareRendererTest : public testing::Test, public RendererClient { // RendererClient implementation. virtual void SetFullRootLayerDamage() OVERRIDE {} + virtual void RunOnDemandRasterTask(Task* on_demand_raster_task) OVERRIDE {} scoped_ptr<SkBitmap> DrawAndCopyOutput(RenderPassList* list, float device_scale_factor, diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc index 8f71b2e..d01bdc8 100644 --- a/cc/resources/raster_worker_pool.cc +++ b/cc/resources/raster_worker_pool.cc @@ -46,15 +46,14 @@ class RasterTaskGraphRunner : public TaskGraphRunner, #endif workers_.push_back(worker.Pass()); } - - // Use index 0 for origin thread. - current_tls_.Set(new ThreadLocalState(0)); } virtual ~RasterTaskGraphRunner() { NOTREACHED(); } size_t GetPictureCloneIndexForCurrentThread() { - return current_tls_.Get()->picture_clone_index; + // Use index 0 if called on non-raster thread. + ThreadLocalState* thread_local_state = current_tls_.Get(); + return thread_local_state ? current_tls_.Get()->picture_clone_index : 0; } private: diff --git a/cc/surfaces/display.h b/cc/surfaces/display.h index 85b172a..191b28d 100644 --- a/cc/surfaces/display.h +++ b/cc/surfaces/display.h @@ -64,6 +64,7 @@ class CC_SURFACES_EXPORT Display : public SurfaceClient, // RendererClient implementation. virtual void SetFullRootLayerDamage() OVERRIDE {} + virtual void RunOnDemandRasterTask(Task* on_demand_raster_task) OVERRIDE {} // SurfaceClient implementation. virtual void ReturnResources(const ReturnedResourceArray& resources) OVERRIDE; diff --git a/cc/test/fake_renderer_client.h b/cc/test/fake_renderer_client.h index 9854b01..41ff5bc 100644 --- a/cc/test/fake_renderer_client.h +++ b/cc/test/fake_renderer_client.h @@ -15,6 +15,7 @@ class FakeRendererClient : public RendererClient { // RendererClient methods. virtual void SetFullRootLayerDamage() OVERRIDE; + virtual void RunOnDemandRasterTask(Task* on_demand_raster_task) OVERRIDE {} // Methods added for test. int set_full_root_layer_damage_count() const { diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index ae2e998..73abc1c 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc @@ -15,6 +15,7 @@ #include "cc/output/gl_renderer.h" #include "cc/output/output_surface_client.h" #include "cc/output/software_renderer.h" +#include "cc/resources/raster_worker_pool.h" #include "cc/resources/resource_provider.h" #include "cc/resources/texture_mailbox_deleter.h" #include "cc/test/fake_output_surface_client.h" @@ -146,6 +147,30 @@ void PixelTest::EnableExternalStencilTest() { ->set_has_external_stencil_test(true); } +void PixelTest::RunOnDemandRasterTask(Task* on_demand_raster_task) { + TaskGraphRunner task_graph_runner; + NamespaceToken on_demand_task_namespace = + task_graph_runner.GetNamespaceToken(); + + // Construct a task graph that contains this single raster task. + TaskGraph graph; + graph.nodes.push_back( + TaskGraph::Node(on_demand_raster_task, + RasterWorkerPool::kOnDemandRasterTaskPriority, + 0u)); + + // Schedule task and wait for task graph runner to finish running it. + task_graph_runner.ScheduleTasks(on_demand_task_namespace, &graph); + task_graph_runner.RunUntilIdle(); + + // Collect task now that it has finished running. + Task::Vector completed_tasks; + task_graph_runner.CollectCompletedTasks(on_demand_task_namespace, + &completed_tasks); + DCHECK_EQ(1u, completed_tasks.size()); + DCHECK_EQ(completed_tasks[0], on_demand_raster_task); +} + void PixelTest::SetUpSoftwareRenderer() { scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice()); output_surface_.reset(new PixelTestOutputSurface(device.Pass())); diff --git a/cc/test/pixel_test.h b/cc/test/pixel_test.h index bb4c13d..46c9bf7 100644 --- a/cc/test/pixel_test.h +++ b/cc/test/pixel_test.h @@ -62,6 +62,7 @@ class PixelTest : public testing::Test, RendererClient { // RendererClient implementation. virtual void SetFullRootLayerDamage() OVERRIDE {} + virtual void RunOnDemandRasterTask(Task* on_demand_raster_task) OVERRIDE; private: void ReadbackResult(base::Closure quit_run_loop, diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index c3ea500..790613a 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -216,6 +216,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( : client_(client), proxy_(proxy), use_gpu_rasterization_(false), + on_demand_task_graph_runner_(NULL), input_handler_client_(NULL), did_lock_scrolling_layer_(false), should_bubble_scrolls_(false), @@ -1883,6 +1884,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { DirectRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), resource_provider_.get(), context_provider); + on_demand_task_graph_runner_ = &synchronous_task_graph_runner_; } else if (UseZeroCopyTextureUpload()) { resource_pool_ = ResourcePool::Create(resource_provider_.get(), @@ -1893,6 +1895,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { ImageRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), RasterWorkerPool::GetTaskGraphRunner(), resource_provider_.get()); + on_demand_task_graph_runner_ = RasterWorkerPool::GetTaskGraphRunner(); } else if (UseOneCopyTextureUpload()) { // We need to create a staging resource pool when using copy rasterizer. staging_resource_pool_ = @@ -1909,6 +1912,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { RasterWorkerPool::GetTaskGraphRunner(), resource_provider_.get(), staging_resource_pool_.get()); + on_demand_task_graph_runner_ = RasterWorkerPool::GetTaskGraphRunner(); } else { resource_pool_ = ResourcePool::Create( resource_provider_.get(), @@ -1920,6 +1924,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { RasterWorkerPool::GetTaskGraphRunner(), resource_provider_.get(), transfer_buffer_memory_limit_); + on_demand_task_graph_runner_ = RasterWorkerPool::GetTaskGraphRunner(); } tile_manager_ = @@ -1931,6 +1936,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); need_to_update_visible_tiles_before_draw_ = false; + on_demand_task_namespace_ = on_demand_task_graph_runner_->GetNamespaceToken(); } void LayerTreeHostImpl::DestroyTileManager() { @@ -2761,6 +2767,34 @@ void LayerTreeHostImpl::SetFullRootLayerDamage() { SetViewportDamage(gfx::Rect(DrawViewportSize())); } +void LayerTreeHostImpl::RunOnDemandRasterTask(Task* on_demand_raster_task) { + DCHECK(on_demand_task_graph_runner_); + + // Construct a task graph that contains this single raster task. + TaskGraph graph; + graph.nodes.push_back( + TaskGraph::Node(on_demand_raster_task, + RasterWorkerPool::kOnDemandRasterTaskPriority, + 0u)); + + // Schedule task and wait for task graph runner to finish running it. + on_demand_task_graph_runner_->ScheduleTasks(on_demand_task_namespace_, + &graph); + + if (on_demand_task_graph_runner_ == &synchronous_task_graph_runner_) + on_demand_task_graph_runner_->RunUntilIdle(); + + on_demand_task_graph_runner_->WaitForTasksToFinishRunning( + on_demand_task_namespace_); + + // Collect task now that it has finished running. + Task::Vector completed_tasks; + on_demand_task_graph_runner_->CollectCompletedTasks(on_demand_task_namespace_, + &completed_tasks); + DCHECK_EQ(1u, completed_tasks.size()); + DCHECK_EQ(completed_tasks[0], on_demand_raster_task); +} + void LayerTreeHostImpl::ScrollViewportBy(gfx::Vector2dF scroll_delta) { DCHECK(InnerViewportScrollLayer()); LayerImpl* scroll_layer = OuterViewportScrollLayer() diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 3d8a9a2..fe9afc2 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -229,6 +229,7 @@ class CC_EXPORT LayerTreeHostImpl // RendererClient implementation. virtual void SetFullRootLayerDamage() OVERRIDE; + virtual void RunOnDemandRasterTask(Task* on_demand_raster_task) OVERRIDE; // TileManagerClient implementation. virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() OVERRIDE; @@ -573,6 +574,10 @@ class CC_EXPORT LayerTreeHostImpl scoped_ptr<ResourcePool> staging_resource_pool_; scoped_ptr<Renderer> renderer_; + TaskGraphRunner synchronous_task_graph_runner_; + TaskGraphRunner* on_demand_task_graph_runner_; + NamespaceToken on_demand_task_namespace_; + GlobalStateThatImpactsTilePriority global_tile_state_; // Tree currently being drawn. diff --git a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc index 0d31709..b7eb516 100644 --- a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc +++ b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc @@ -54,6 +54,8 @@ class LayerTreeHostOnDemandRasterPixelTest : public LayerTreePixelTest { // Triggers pixel readback and ends the test. LayerTreePixelTest::SwapBuffersOnThread(host_impl, result); } + + void RunOnDemandRasterPixelTest(); }; class BlueYellowLayerClient : public ContentLayerClient { @@ -91,7 +93,7 @@ class BlueYellowLayerClient : public ContentLayerClient { gfx::Rect layer_rect_; }; -TEST_F(LayerTreeHostOnDemandRasterPixelTest, RasterPictureLayer) { +void LayerTreeHostOnDemandRasterPixelTest::RunOnDemandRasterPixelTest() { // Use multiple colors in a single layer to prevent bypassing on-demand // rasterization if a single solid color is detected in picture analysis. gfx::Rect layer_rect(200, 200); @@ -107,6 +109,23 @@ TEST_F(LayerTreeHostOnDemandRasterPixelTest, RasterPictureLayer) { base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); } +TEST_F(LayerTreeHostOnDemandRasterPixelTest, RasterPictureLayer) { + RunOnDemandRasterPixelTest(); +} + +class LayerTreeHostOnDemandRasterPixelTestWithGpuRasterizationForced + : public LayerTreeHostOnDemandRasterPixelTest { + virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { + LayerTreeHostOnDemandRasterPixelTest::InitializeSettings(settings); + settings->gpu_rasterization_forced = true; + } +}; + +TEST_F(LayerTreeHostOnDemandRasterPixelTestWithGpuRasterizationForced, + RasterPictureLayer) { + RunOnDemandRasterPixelTest(); +} + } // namespace } // namespace cc |