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

Unified Diff: cc/raster/tile_task_worker_pool_perftest.cc

Issue 1854723002: cc: Simplify task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected scope of dependencies. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: cc/raster/tile_task_worker_pool_perftest.cc
diff --git a/cc/raster/tile_task_worker_pool_perftest.cc b/cc/raster/tile_task_worker_pool_perftest.cc
index 086d7b192dcf06d1239e17e6effeb12c04f52d7a..6397120e1109ba5fb000bf5f834fc90008bb8bac 100644
--- a/cc/raster/tile_task_worker_pool_perftest.cc
+++ b/cc/raster/tile_task_worker_pool_perftest.cc
@@ -16,7 +16,6 @@
#include "cc/raster/gpu_rasterizer.h"
#include "cc/raster/gpu_tile_task_worker_pool.h"
#include "cc/raster/one_copy_tile_task_worker_pool.h"
-#include "cc/raster/raster_buffer.h"
#include "cc/raster/synchronous_task_graph_runner.h"
#include "cc/raster/tile_task_runner.h"
#include "cc/raster/zero_copy_tile_task_worker_pool.h"
@@ -124,17 +123,15 @@ static const int kTimeLimitMillis = 2000;
static const int kWarmupRuns = 5;
static const int kTimeCheckInterval = 10;
-class PerfImageDecodeTaskImpl : public ImageDecodeTask {
+class PerfImageDecodeTaskImpl : public Task {
public:
PerfImageDecodeTaskImpl() {}
// Overridden from Task:
+ void ScheduleOnOriginThread() override {}
+ void CompleteOnOriginThread() override { Reset(); }
void RunOnWorkerThread() override {}
- // Overridden from TileTask:
- void ScheduleOnOriginThread(TileTaskClient* client) override {}
- void CompleteOnOriginThread(TileTaskClient* client) override { Reset(); }
-
void Reset() {
did_run_ = false;
did_complete_ = false;
@@ -147,24 +144,29 @@ class PerfImageDecodeTaskImpl : public ImageDecodeTask {
DISALLOW_COPY_AND_ASSIGN(PerfImageDecodeTaskImpl);
};
-class PerfRasterTaskImpl : public RasterTask {
+class PerfRasterTaskImpl : public Task {
public:
- PerfRasterTaskImpl(scoped_ptr<ScopedResource> resource,
- ImageDecodeTask::Vector* dependencies)
- : RasterTask(dependencies), resource_(std::move(resource)) {}
+ PerfRasterTaskImpl(RasterBufferProvider* raster_buffer_provider,
+ scoped_ptr<ScopedResource> resource,
+ Task::Vector* dependencies)
+ : raster_buffer_provider_(raster_buffer_provider),
+ resource_(std::move(resource)) {
+ dependencies_ = std::move(*dependencies);
+ }
- // Overridden from Task:
- void RunOnWorkerThread() override {}
+ const Task::Vector& dependencies() const { return dependencies_; }
- // Overridden from TileTask:
- void ScheduleOnOriginThread(TileTaskClient* client) override {
+ // Overridden from Task:
+ void ScheduleOnOriginThread() override {
// No tile ids are given to support partial updates.
- raster_buffer_ = client->AcquireBufferForRaster(resource_.get(), 0, 0);
+ raster_buffer_ =
+ raster_buffer_provider_->AcquireBufferForRaster(resource_.get(), 0, 0);
}
- void CompleteOnOriginThread(TileTaskClient* client) override {
- client->ReleaseBufferForRaster(std::move(raster_buffer_));
+ void CompleteOnOriginThread() override {
+ raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer_));
Reset();
}
+ void RunOnWorkerThread() override {}
void Reset() {
did_run_ = false;
@@ -175,15 +177,17 @@ class PerfRasterTaskImpl : public RasterTask {
~PerfRasterTaskImpl() override {}
private:
+ RasterBufferProvider* raster_buffer_provider_;
scoped_ptr<ScopedResource> resource_;
scoped_ptr<RasterBuffer> raster_buffer_;
+ Task::Vector dependencies_;
DISALLOW_COPY_AND_ASSIGN(PerfRasterTaskImpl);
};
class TileTaskWorkerPoolPerfTestBase {
public:
- typedef std::vector<scoped_refptr<RasterTask>> RasterTaskVector;
+ typedef std::vector<scoped_refptr<PerfRasterTaskImpl>> RasterTaskVector;
enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL };
@@ -196,13 +200,14 @@ class TileTaskWorkerPoolPerfTestBase {
kTimeCheckInterval) {}
void CreateImageDecodeTasks(unsigned num_image_decode_tasks,
- ImageDecodeTask::Vector* image_decode_tasks) {
+ Task::Vector* image_decode_tasks) {
for (unsigned i = 0; i < num_image_decode_tasks; ++i)
image_decode_tasks->push_back(new PerfImageDecodeTaskImpl);
}
- void CreateRasterTasks(unsigned num_raster_tasks,
- const ImageDecodeTask::Vector& image_decode_tasks,
+ void CreateRasterTasks(RasterBufferProvider* raster_buffer_provider,
+ unsigned num_raster_tasks,
+ const Task::Vector& image_decode_tasks,
RasterTaskVector* raster_tasks) {
const gfx::Size size(1, 1);
@@ -212,9 +217,9 @@ class TileTaskWorkerPoolPerfTestBase {
resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
RGBA_8888);
- ImageDecodeTask::Vector dependencies = image_decode_tasks;
- raster_tasks->push_back(
- new PerfRasterTaskImpl(std::move(resource), &dependencies));
+ Task::Vector dependencies = image_decode_tasks;
+ raster_tasks->push_back(new PerfRasterTaskImpl(
+ raster_buffer_provider, std::move(resource), &dependencies));
}
}
@@ -299,10 +304,11 @@ class TileTaskWorkerPoolPerfTest
void RunScheduleTasksTest(const std::string& test_name,
unsigned num_raster_tasks,
unsigned num_image_decode_tasks) {
- ImageDecodeTask::Vector image_decode_tasks;
+ Task::Vector image_decode_tasks;
RasterTaskVector raster_tasks;
CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
- CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks);
+ CreateRasterTasks(tile_task_worker_pool_->AsTileTaskRunner(),
+ num_raster_tasks, image_decode_tasks, &raster_tasks);
// Avoid unnecessary heap allocations by reusing the same graph.
TaskGraph graph;
@@ -328,11 +334,12 @@ class TileTaskWorkerPoolPerfTest
unsigned num_raster_tasks,
unsigned num_image_decode_tasks) {
const size_t kNumVersions = 2;
- ImageDecodeTask::Vector image_decode_tasks[kNumVersions];
+ Task::Vector image_decode_tasks[kNumVersions];
RasterTaskVector raster_tasks[kNumVersions];
for (size_t i = 0; i < kNumVersions; ++i) {
CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks[i]);
- CreateRasterTasks(num_raster_tasks, image_decode_tasks[i],
+ CreateRasterTasks(tile_task_worker_pool_->AsTileTaskRunner(),
+ num_raster_tasks, image_decode_tasks[i],
&raster_tasks[i]);
}
@@ -361,10 +368,11 @@ class TileTaskWorkerPoolPerfTest
void RunScheduleAndExecuteTasksTest(const std::string& test_name,
unsigned num_raster_tasks,
unsigned num_image_decode_tasks) {
- ImageDecodeTask::Vector image_decode_tasks;
+ Task::Vector image_decode_tasks;
RasterTaskVector raster_tasks;
CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
- CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks);
+ CreateRasterTasks(tile_task_worker_pool_->AsTileTaskRunner(),
+ num_raster_tasks, image_decode_tasks, &raster_tasks);
// Avoid unnecessary heap allocations by reusing the same graph.
TaskGraph graph;
@@ -470,10 +478,12 @@ class TileTaskWorkerPoolCommonPerfTest : public TileTaskWorkerPoolPerfTestBase,
void RunBuildTileTaskGraphTest(const std::string& test_name,
unsigned num_raster_tasks,
unsigned num_image_decode_tasks) {
- ImageDecodeTask::Vector image_decode_tasks;
+ Task::Vector image_decode_tasks;
RasterTaskVector raster_tasks;
CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
- CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks);
+ // TODO(prashant.n): Pass real RasterBufferProvider instead of nullptr.
+ CreateRasterTasks(nullptr, num_raster_tasks, image_decode_tasks,
+ &raster_tasks);
// Avoid unnecessary heap allocations by reusing the same graph.
TaskGraph graph;

Powered by Google App Engine
This is Rietveld 408576698