diff options
author | vmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 20:05:02 +0000 |
---|---|---|
committer | vmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 20:05:02 +0000 |
commit | b013dd8718d92a394e9d72b307bf6123fdaf1c04 (patch) | |
tree | c94034ca0ebd1e57fbae727d17c4c3e930f21efa /cc | |
parent | 36cacf98954a43494664328e8fa13a5ec6c20c85 (diff) | |
download | chromium_src-b013dd8718d92a394e9d72b307bf6123fdaf1c04.zip chromium_src-b013dd8718d92a394e9d72b307bf6123fdaf1c04.tar.gz chromium_src-b013dd8718d92a394e9d72b307bf6123fdaf1c04.tar.bz2 |
cc: Run rasterize benchmark on the worker thread.
Since the change to reuse the original picture for one of the threads,
the rasterize_and_record_micro benchmark code is no longer correct, as
it is using the original picture to rasterize on the impl thread.
This patch changes the behaviour to run the benchmark on one of the
worker threads.
BUG=350684
R=reveman@chromium.org
Review URL: https://codereview.chromium.org/198053003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark_impl.cc | 100 | ||||
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark_impl.h | 2 | ||||
-rw-r--r-- | cc/resources/raster_worker_pool.cc | 3 | ||||
-rw-r--r-- | cc/resources/raster_worker_pool.h | 1 |
4 files changed, 87 insertions, 19 deletions
diff --git a/cc/debug/rasterize_and_record_benchmark_impl.cc b/cc/debug/rasterize_and_record_benchmark_impl.cc index 6e0a46a..e6c831a 100644 --- a/cc/debug/rasterize_and_record_benchmark_impl.cc +++ b/cc/debug/rasterize_and_record_benchmark_impl.cc @@ -11,6 +11,7 @@ #include "base/values.h" #include "cc/layers/layer_impl.h" #include "cc/layers/picture_layer_impl.h" +#include "cc/resources/raster_worker_pool.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_host_impl.h" #include "ui/gfx/rect.h" @@ -27,6 +28,59 @@ base::TimeTicks Now() { : base::TimeTicks::HighResNow(); } +class BenchmarkRasterTask : public internal::Task { + public: + BenchmarkRasterTask(PicturePileImpl* picture_pile, + const gfx::Rect& content_rect, + float contents_scale, + size_t repeat_count) + : picture_pile_(picture_pile), + content_rect_(content_rect), + contents_scale_(contents_scale), + repeat_count_(repeat_count), + is_solid_color_(false), + best_time_(base::TimeDelta::Max()) {} + + // Overridden from internal::Task: + virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { + PicturePileImpl* picture_pile = + picture_pile_->GetCloneForDrawingOnThread(thread_index); + + for (size_t i = 0; i < repeat_count_; ++i) { + SkBitmap bitmap; + bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect_.width(), + content_rect_.height())); + SkCanvas canvas(bitmap); + PicturePileImpl::Analysis analysis; + + base::TimeTicks start = Now(); + picture_pile->AnalyzeInRect( + content_rect_, contents_scale_, &analysis, NULL); + picture_pile->RasterToBitmap( + &canvas, content_rect_, contents_scale_, NULL); + base::TimeTicks end = Now(); + base::TimeDelta duration = end - start; + if (duration < best_time_) + best_time_ = duration; + + is_solid_color_ = analysis.is_solid_color; + } + } + + bool IsSolidColor() const { return is_solid_color_; } + base::TimeDelta GetBestTime() const { return best_time_; } + + private: + virtual ~BenchmarkRasterTask() {} + + PicturePileImpl* picture_pile_; + gfx::Rect content_rect_; + float contents_scale_; + size_t repeat_count_; + bool is_solid_color_; + base::TimeDelta best_time_; +}; + } // namespace RasterizeAndRecordBenchmarkImpl::RasterizeAndRecordBenchmarkImpl( @@ -88,6 +142,13 @@ void RasterizeAndRecordBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) { return; } + internal::TaskGraphRunner* task_graph_runner = + RasterWorkerPool::GetTaskGraphRunner(); + DCHECK(task_graph_runner); + + if (!task_namespace_.IsValid()) + task_namespace_ = task_graph_runner->GetNamespaceToken(); + PictureLayerTilingSet tiling_set(layer, layer->content_bounds()); PictureLayerTiling* tiling = tiling_set.AddTiling(layer->contents_scale_x()); @@ -102,29 +163,30 @@ void RasterizeAndRecordBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) { gfx::Rect content_rect = (*it)->content_rect(); float contents_scale = (*it)->contents_scale(); - int tile_size = content_rect.width() * content_rect.height(); + scoped_refptr<BenchmarkRasterTask> benchmark_raster_task( + new BenchmarkRasterTask(picture_pile, + content_rect, + contents_scale, + rasterize_repeat_count_)); - base::TimeDelta min_time = base::TimeDelta::Max(); + internal::TaskGraph graph; - bool is_solid_color = false; - for (int i = 0; i < rasterize_repeat_count_; ++i) { - SkBitmap bitmap; - bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect.width(), - content_rect.height())); - SkCanvas canvas(bitmap); - PicturePileImpl::Analysis analysis; + graph.nodes.push_back(internal::TaskGraph::Node( + benchmark_raster_task, + RasterWorkerPool::kBenchmarkRasterTaskPriority, + 0u)); - base::TimeTicks start = Now(); - picture_pile->AnalyzeInRect( - content_rect, contents_scale, &analysis, NULL); - picture_pile->RasterToBitmap(&canvas, content_rect, contents_scale, NULL); - base::TimeTicks end = Now(); - base::TimeDelta duration = end - start; - if (duration < min_time) - min_time = duration; + task_graph_runner->SetTaskGraph(task_namespace_, &graph); + task_graph_runner->WaitForTasksToFinishRunning(task_namespace_); - is_solid_color = analysis.is_solid_color; - } + internal::Task::Vector completed_tasks; + task_graph_runner->CollectCompletedTasks(task_namespace_, &completed_tasks); + DCHECK_EQ(1u, completed_tasks.size()); + DCHECK_EQ(completed_tasks[0], benchmark_raster_task); + + int tile_size = content_rect.width() * content_rect.height(); + base::TimeDelta min_time = benchmark_raster_task->GetBestTime(); + bool is_solid_color = benchmark_raster_task->IsSolidColor(); if (layer->contents_opaque()) rasterize_results_.pixels_rasterized_as_opaque += tile_size; diff --git a/cc/debug/rasterize_and_record_benchmark_impl.h b/cc/debug/rasterize_and_record_benchmark_impl.h index 98b6592..985df7b 100644 --- a/cc/debug/rasterize_and_record_benchmark_impl.h +++ b/cc/debug/rasterize_and_record_benchmark_impl.h @@ -11,6 +11,7 @@ #include "base/time/time.h" #include "cc/debug/micro_benchmark_impl.h" +#include "cc/resources/task_graph_runner.h" namespace cc { @@ -48,6 +49,7 @@ class RasterizeAndRecordBenchmarkImpl : public MicroBenchmarkImpl { RasterizeResults rasterize_results_; int rasterize_repeat_count_; + internal::NamespaceToken task_namespace_; }; } // namespace cc diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc index e1470c4..825f67b 100644 --- a/cc/resources/raster_worker_pool.cc +++ b/cc/resources/raster_worker_pool.cc @@ -471,6 +471,9 @@ void RasterTaskQueue::Reset() { // This allows an external rasterize on-demand system to run raster tasks // with highest priority using the same task graph runner instance. unsigned RasterWorkerPool::kOnDemandRasterTaskPriority = 0u; +// This allows a micro benchmark system to run tasks with highest priority, +// since it should finish as quickly as possible. +unsigned RasterWorkerPool::kBenchmarkRasterTaskPriority = 0u; // Task priorities that make sure raster finished tasks run before any // remaining raster tasks. unsigned RasterWorkerPool::kRasterFinishedTaskPriority = 2u; diff --git a/cc/resources/raster_worker_pool.h b/cc/resources/raster_worker_pool.h index 520efba..52e853e 100644 --- a/cc/resources/raster_worker_pool.h +++ b/cc/resources/raster_worker_pool.h @@ -138,6 +138,7 @@ class CC_EXPORT RasterWorkerPool : public internal::WorkerPoolTaskClient { static internal::TaskGraphRunner* GetTaskGraphRunner(); static unsigned kOnDemandRasterTaskPriority; + static unsigned kBenchmarkRasterTaskPriority; static unsigned kRasterFinishedTaskPriority; static unsigned kRasterRequiredForActivationFinishedTaskPriority; static unsigned kRasterTaskPriorityBase; |