summaryrefslogtreecommitdiffstats
path: root/cc/output
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-12 09:35:04 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-12 09:35:04 +0000
commitf136f935e2ac3c4d3fd6a36c518a45c707d9a365 (patch)
tree8db30c46f9d19a26005d3048e9c0fc2f00dc3099 /cc/output
parent2507e4432bb790530b89985da9cd2bf922477cf3 (diff)
downloadchromium_src-f136f935e2ac3c4d3fd6a36c518a45c707d9a365.zip
chromium_src-f136f935e2ac3c4d3fd6a36c518a45c707d9a365.tar.gz
chromium_src-f136f935e2ac3c4d3fd6a36c518a45c707d9a365.tar.bz2
cc: Only make num_threads - 1 SkPicture clones.
Run on-demand raster on worker threads. This allows us to create one fewer SkPicture clone as raster will never be done on the compositor thread. BUG=333855 TEST=cc_unittests --gtest_filter=LayerTreeHostOnDemandRasterPixelTest.RasterPictureLayer Review URL: https://codereview.chromium.org/160023002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output')
-rw-r--r--cc/output/direct_renderer.cc30
-rw-r--r--cc/output/direct_renderer.h5
-rw-r--r--cc/output/gl_renderer.cc47
-rw-r--r--cc/output/software_renderer.cc42
4 files changed, 117 insertions, 7 deletions
diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc
index c077ffe..d508869 100644
--- a/cc/output/direct_renderer.cc
+++ b/cc/output/direct_renderer.cc
@@ -14,6 +14,7 @@
#include "cc/base/math_util.h"
#include "cc/output/copy_output_request.h"
#include "cc/quads/draw_quad.h"
+#include "cc/resources/raster_worker_pool.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/transform.h"
@@ -417,6 +418,35 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame,
return BindFramebufferToTexture(frame, texture, render_pass->output_rect);
}
+void DirectRenderer::RunOnDemandRasterTask(
+ internal::Task* on_demand_raster_task) {
+ internal::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.
+ internal::TaskGraph graph;
+ graph.nodes.push_back(
+ internal::TaskGraph::Node(on_demand_raster_task,
+ RasterWorkerPool::kOnDemandRasterTaskPriority,
+ 0u));
+
+ // Schedule task and wait for task graph runner to finish running it.
+ task_graph_runner->SetTaskGraph(on_demand_task_namespace_, &graph);
+ task_graph_runner->WaitForTasksToFinishRunning(on_demand_task_namespace_);
+
+ // Collect task now that it has finished running.
+ internal::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 451c7d7..46bfb56 100644
--- a/cc/output/direct_renderer.h
+++ b/cc/output/direct_renderer.h
@@ -12,6 +12,7 @@
#include "cc/output/renderer.h"
#include "cc/resources/resource_provider.h"
#include "cc/resources/scoped_resource.h"
+#include "cc/resources/task_graph_runner.h"
namespace cc {
@@ -96,6 +97,8 @@ class CC_EXPORT DirectRenderer : public Renderer {
bool allow_partial_swap);
bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass);
+ void RunOnDemandRasterTask(internal::Task* on_demand_raster_task);
+
virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0;
virtual bool BindFramebufferToTexture(DrawingFrame* frame,
const ScopedResource* resource,
@@ -136,6 +139,8 @@ class CC_EXPORT DirectRenderer : public Renderer {
private:
gfx::Vector2d enlarge_pass_texture_amount_;
+ internal::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 e09d004..371f714 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -78,6 +78,41 @@ class SimpleSwapFence : public ResourceProvider::Fence {
bool has_passed_;
};
+class OnDemandRasterTaskImpl : public internal::Task {
+ public:
+ OnDemandRasterTaskImpl(PicturePileImpl* picture_pile,
+ SkBitmap* bitmap,
+ gfx::Rect content_rect,
+ float contents_scale)
+ : picture_pile_(picture_pile),
+ bitmap_(bitmap),
+ content_rect_(content_rect),
+ contents_scale_(contents_scale) {
+ DCHECK(picture_pile_);
+ DCHECK(bitmap_);
+ }
+
+ // Overridden from internal::Task:
+ virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE {
+ TRACE_EVENT0("cc", "OnDemandRasterTaskImpl::RunOnWorkerThread");
+ SkBitmapDevice device(*bitmap_);
+ SkCanvas canvas(&device);
+ picture_pile_->RasterToBitmap(
+ &canvas, content_rect_, contents_scale_, NULL);
+ }
+
+ protected:
+ virtual ~OnDemandRasterTaskImpl() {}
+
+ private:
+ PicturePileImpl* picture_pile_;
+ SkBitmap* bitmap_;
+ const gfx::Rect content_rect_;
+ const float contents_scale_;
+
+ DISALLOW_COPY_AND_ASSIGN(OnDemandRasterTaskImpl);
+};
+
bool NeedsIOSurfaceReadbackWorkaround() {
#if defined(OS_MACOSX)
// This isn't strictly required in DumpRenderTree-mode when Mesa is used,
@@ -1717,11 +1752,13 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame,
quad->texture_format);
}
- SkBitmapDevice device(on_demand_tile_raster_bitmap_);
- SkCanvas canvas(&device);
-
- quad->picture_pile->RasterToBitmap(
- &canvas, quad->content_rect, quad->contents_scale, NULL);
+ // Create and run on-demand raster task for tile.
+ scoped_refptr<internal::Task> on_demand_raster_task(
+ new OnDemandRasterTaskImpl(quad->picture_pile,
+ &on_demand_tile_raster_bitmap_,
+ quad->content_rect,
+ quad->contents_scale));
+ RunOnDemandRasterTask(on_demand_raster_task.get());
uint8_t* bitmap_pixels = NULL;
SkBitmap on_demand_tile_raster_bitmap_dest;
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index 23f574b..5495b89 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -35,6 +35,38 @@ namespace cc {
namespace {
+class OnDemandRasterTaskImpl : public internal::Task {
+ public:
+ OnDemandRasterTaskImpl(PicturePileImpl* picture_pile,
+ SkCanvas* canvas,
+ gfx::Rect content_rect,
+ float contents_scale)
+ : picture_pile_(picture_pile),
+ canvas_(canvas),
+ content_rect_(content_rect),
+ contents_scale_(contents_scale) {
+ DCHECK(picture_pile_);
+ DCHECK(canvas_);
+ }
+
+ // Overridden from internal::Task:
+ virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE {
+ TRACE_EVENT0("cc", "OnDemandRasterTaskImpl::RunOnWorkerThread");
+ picture_pile_->RasterDirect(canvas_, content_rect_, contents_scale_, NULL);
+ }
+
+ protected:
+ virtual ~OnDemandRasterTaskImpl() {}
+
+ private:
+ PicturePileImpl* picture_pile_;
+ SkCanvas* canvas_;
+ const gfx::Rect content_rect_;
+ const float contents_scale_;
+
+ DISALLOW_COPY_AND_ASSIGN(OnDemandRasterTaskImpl);
+};
+
static inline bool IsScalarNearlyInteger(SkScalar scalar) {
return SkScalarNearlyZero(scalar - SkScalarRoundToScalar(scalar));
}
@@ -349,8 +381,14 @@ void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame,
TRACE_EVENT0("cc",
"SoftwareRenderer::DrawPictureQuad");
- quad->picture_pile->RasterDirect(
- current_canvas_, quad->content_rect, quad->contents_scale, NULL);
+
+ // Create and run on-demand raster task for tile.
+ scoped_refptr<internal::Task> on_demand_raster_task(
+ new OnDemandRasterTaskImpl(quad->picture_pile,
+ current_canvas_,
+ quad->content_rect,
+ quad->contents_scale));
+ RunOnDemandRasterTask(on_demand_raster_task.get());
current_canvas_->setDrawFilter(NULL);
}