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

Unified Diff: cc/raster/tile_task_worker_pool_unittest.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_unittest.cc
diff --git a/cc/raster/tile_task_worker_pool_unittest.cc b/cc/raster/tile_task_worker_pool_unittest.cc
index f7613856351ab366ca22483de47a74c169122694..bb9d67c1fda823ec92f645bc2855a7b4bb7579b3 100644
--- a/cc/raster/tile_task_worker_pool_unittest.cc
+++ b/cc/raster/tile_task_worker_pool_unittest.cc
@@ -21,7 +21,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"
@@ -51,19 +50,29 @@ enum TileTaskWorkerPoolType {
TILE_TASK_WORKER_POOL_TYPE_BITMAP
};
-class TestRasterTaskImpl : public RasterTask {
+class TestRasterTaskImpl : public Task {
public:
typedef base::Callback<void(bool was_canceled)> Reply;
- TestRasterTaskImpl(const Resource* resource,
- const Reply& reply,
- ImageDecodeTask::Vector* dependencies)
- : RasterTask(dependencies),
+ TestRasterTaskImpl(RasterBufferProvider* raster_buffer_provider,
+ const Resource* resource,
+ const Reply& reply)
+ : raster_buffer_provider_(raster_buffer_provider),
resource_(resource),
reply_(reply),
raster_source_(FakeRasterSource::CreateFilled(gfx::Size(1, 1))) {}
// Overridden from Task:
+ void ScheduleOnOriginThread() override {
+ // The raster buffer has no tile ids associated with it for partial update,
+ // so doesn't need to provide a valid dirty rect.
+ raster_buffer_ =
+ raster_buffer_provider_->AcquireBufferForRaster(resource_, 0, 0);
+ }
+ void CompleteOnOriginThread() override {
+ raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer_));
+ reply_.Run(!HasFinishedRunning());
+ }
void RunOnWorkerThread() override {
uint64_t new_content_id = 0;
raster_buffer_->Playback(raster_source_.get(), gfx::Rect(1, 1),
@@ -71,21 +80,11 @@ class TestRasterTaskImpl : public RasterTask {
RasterSource::PlaybackSettings());
}
- // Overridden from TileTask:
- void ScheduleOnOriginThread(TileTaskClient* client) override {
- // The raster buffer has no tile ids associated with it for partial update,
- // so doesn't need to provide a valid dirty rect.
- raster_buffer_ = client->AcquireBufferForRaster(resource_, 0, 0);
- }
- void CompleteOnOriginThread(TileTaskClient* client) override {
- client->ReleaseBufferForRaster(std::move(raster_buffer_));
- reply_.Run(!HasFinishedRunning());
- }
-
protected:
~TestRasterTaskImpl() override {}
private:
+ RasterBufferProvider* raster_buffer_provider_;
const Resource* resource_;
const Reply reply_;
scoped_ptr<RasterBuffer> raster_buffer_;
@@ -96,11 +95,12 @@ class TestRasterTaskImpl : public RasterTask {
class BlockingTestRasterTaskImpl : public TestRasterTaskImpl {
public:
- BlockingTestRasterTaskImpl(const Resource* resource,
+ BlockingTestRasterTaskImpl(RasterBufferProvider* raster_buffer_provider,
+ const Resource* resource,
const Reply& reply,
- base::Lock* lock,
- ImageDecodeTask::Vector* dependencies)
- : TestRasterTaskImpl(resource, reply, dependencies), lock_(lock) {}
+ base::Lock* lock)
+ : TestRasterTaskImpl(raster_buffer_provider, resource, reply),
+ lock_(lock) {}
// Overridden from Task:
void RunOnWorkerThread() override {
@@ -125,7 +125,7 @@ class TileTaskWorkerPoolTest
bool canceled;
};
- typedef std::vector<scoped_refptr<RasterTask>> RasterTaskVector;
+ typedef std::vector<scoped_refptr<Task>> RasterTaskVector;
enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL };
@@ -210,12 +210,10 @@ class TileTaskWorkerPoolTest
RGBA_8888);
const Resource* const_resource = resource.get();
- ImageDecodeTask::Vector empty;
tasks_.push_back(new TestRasterTaskImpl(
- const_resource,
+ tile_task_worker_pool_->AsTileTaskRunner(), const_resource,
base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted,
- base::Unretained(this), base::Passed(&resource), id),
- &empty));
+ base::Unretained(this), base::Passed(&resource), id)));
}
void AppendTask(unsigned id) { AppendTask(id, gfx::Size(1, 1)); }
@@ -229,12 +227,11 @@ class TileTaskWorkerPoolTest
RGBA_8888);
const Resource* const_resource = resource.get();
- ImageDecodeTask::Vector empty;
tasks_.push_back(new BlockingTestRasterTaskImpl(
- const_resource,
+ tile_task_worker_pool_->AsTileTaskRunner(), const_resource,
base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted,
base::Unretained(this), base::Passed(&resource), id),
- lock, &empty));
+ lock));
}
const std::vector<RasterTaskResult>& completed_tasks() const {

Powered by Google App Engine
This is Rietveld 408576698