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

Unified Diff: cc/raster/raster_buffer_provider_unittest.cc

Issue 1866043006: cc: Remove ScheduleOnOriginThread() and CompleteOnOriginThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 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
« no previous file with comments | « cc/raster/raster_buffer_provider_perftest.cc ('k') | cc/raster/task.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/raster/raster_buffer_provider_unittest.cc
diff --git a/cc/raster/raster_buffer_provider_unittest.cc b/cc/raster/raster_buffer_provider_unittest.cc
index ffdb710b0e43df2048a2b7f86ab6af2d8edff3d6..a3f07c72aa1afeb91b7e38d72092cfc0c315bcf5 100644
--- a/cc/raster/raster_buffer_provider_unittest.cc
+++ b/cc/raster/raster_buffer_provider_unittest.cc
@@ -51,16 +51,26 @@ enum RasterBufferProviderType {
RASTER_BUFFER_PROVIDER_TYPE_BITMAP
};
-class TestRasterTaskImpl : public TileTask {
+class TestRasterTaskCompletionHandler {
public:
- typedef base::Callback<void(bool was_canceled)> Reply;
+ virtual void OnRasterTaskCompleted(
+ std::unique_ptr<RasterBuffer> raster_buffer,
+ unsigned id,
+ bool was_canceled) = 0;
+};
- TestRasterTaskImpl(const Resource* resource,
- const Reply& reply,
+class TestRasterTaskImpl : public TileTask {
+ public:
+ TestRasterTaskImpl(TestRasterTaskCompletionHandler* completion_handler,
+ std::unique_ptr<ScopedResource> resource,
+ unsigned id,
+ std::unique_ptr<RasterBuffer> raster_buffer,
TileTask::Vector* dependencies)
: TileTask(true, dependencies),
- resource_(resource),
- reply_(reply),
+ completion_handler_(completion_handler),
+ resource_(std::move(resource)),
+ id_(id),
+ raster_buffer_(std::move(raster_buffer)),
raster_source_(FakeRasterSource::CreateFilled(gfx::Size(1, 1))) {}
// Overridden from Task:
@@ -72,22 +82,18 @@ class TestRasterTaskImpl : public TileTask {
}
// Overridden from TileTask:
- void ScheduleOnOriginThread(RasterBufferProvider* provider) 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_ = provider->AcquireBufferForRaster(resource_, 0, 0);
- }
- void CompleteOnOriginThread(RasterBufferProvider* provider) override {
- provider->ReleaseBufferForRaster(std::move(raster_buffer_));
- reply_.Run(!state().IsFinished());
+ void OnTaskCompleted() override {
+ completion_handler_->OnRasterTaskCompleted(std::move(raster_buffer_), id_,
+ state().IsCanceled());
}
protected:
~TestRasterTaskImpl() override {}
private:
- const Resource* resource_;
- const Reply reply_;
+ TestRasterTaskCompletionHandler* completion_handler_;
+ std::unique_ptr<ScopedResource> resource_;
+ unsigned id_;
std::unique_ptr<RasterBuffer> raster_buffer_;
scoped_refptr<RasterSource> raster_source_;
@@ -96,11 +102,19 @@ class TestRasterTaskImpl : public TileTask {
class BlockingTestRasterTaskImpl : public TestRasterTaskImpl {
public:
- BlockingTestRasterTaskImpl(const Resource* resource,
- const Reply& reply,
- base::Lock* lock,
- TileTask::Vector* dependencies)
- : TestRasterTaskImpl(resource, reply, dependencies), lock_(lock) {}
+ BlockingTestRasterTaskImpl(
+ TestRasterTaskCompletionHandler* completion_handler,
+ std::unique_ptr<ScopedResource> resource,
+ unsigned id,
+ std::unique_ptr<RasterBuffer> raster_buffer,
+ base::Lock* lock,
+ TileTask::Vector* dependencies)
+ : TestRasterTaskImpl(completion_handler,
+ std::move(resource),
+ id,
+ std::move(raster_buffer),
+ dependencies),
+ lock_(lock) {}
// Overridden from Task:
void RunOnWorkerThread() override {
@@ -118,7 +132,8 @@ class BlockingTestRasterTaskImpl : public TestRasterTaskImpl {
};
class RasterBufferProviderTest
- : public testing::TestWithParam<RasterBufferProviderType> {
+ : public TestRasterTaskCompletionHandler,
+ public testing::TestWithParam<RasterBufferProviderType> {
public:
struct RasterTaskResult {
unsigned id;
@@ -207,14 +222,15 @@ class RasterBufferProviderTest
ScopedResource::Create(resource_provider_.get()));
resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
RGBA_8888);
- const Resource* const_resource = resource.get();
+ // The raster buffer has no tile ids associated with it for partial update,
+ // so doesn't need to provide a valid dirty rect.
+ std::unique_ptr<RasterBuffer> raster_buffer =
+ tile_task_manager_->GetRasterBufferProvider()->AcquireBufferForRaster(
+ resource.get(), 0, 0);
TileTask::Vector empty;
- tasks_.push_back(new TestRasterTaskImpl(
- const_resource,
- base::Bind(&RasterBufferProviderTest::OnTaskCompleted,
- base::Unretained(this), base::Passed(&resource), id),
- &empty));
+ tasks_.push_back(new TestRasterTaskImpl(this, std::move(resource), id,
+ std::move(raster_buffer), &empty));
}
void AppendTask(unsigned id) { AppendTask(id, gfx::Size(1, 1)); }
@@ -226,14 +242,13 @@ class RasterBufferProviderTest
ScopedResource::Create(resource_provider_.get()));
resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
RGBA_8888);
- const Resource* const_resource = resource.get();
+ std::unique_ptr<RasterBuffer> raster_buffer =
+ tile_task_manager_->GetRasterBufferProvider()->AcquireBufferForRaster(
+ resource.get(), 0, 0);
TileTask::Vector empty;
tasks_.push_back(new BlockingTestRasterTaskImpl(
- const_resource,
- base::Bind(&RasterBufferProviderTest::OnTaskCompleted,
- base::Unretained(this), base::Passed(&resource), id),
- lock, &empty));
+ this, std::move(resource), id, std::move(raster_buffer), lock, &empty));
}
const std::vector<RasterTaskResult>& completed_tasks() const {
@@ -248,6 +263,17 @@ class RasterBufferProviderTest
context_provider->ContextGL()->Flush();
}
+ void OnRasterTaskCompleted(std::unique_ptr<RasterBuffer> raster_buffer,
+ unsigned id,
+ bool was_canceled) override {
+ tile_task_manager_->GetRasterBufferProvider()->ReleaseBufferForRaster(
+ std::move(raster_buffer));
+ RasterTaskResult result;
+ result.id = id;
+ result.canceled = was_canceled;
+ completed_tasks_.push_back(result);
+ }
+
private:
void Create3dOutputSurfaceAndResourceProvider() {
output_surface_ = FakeOutputSurface::Create3d(context_provider_,
@@ -267,15 +293,6 @@ class RasterBufferProviderTest
output_surface_.get(), &shared_bitmap_manager_, nullptr);
}
- void OnTaskCompleted(std::unique_ptr<ScopedResource> resource,
- unsigned id,
- bool was_canceled) {
- RasterTaskResult result;
- result.id = id;
- result.canceled = was_canceled;
- completed_tasks_.push_back(result);
- }
-
void OnTimeout() {
timed_out_ = true;
base::MessageLoop::current()->QuitWhenIdle();
« no previous file with comments | « cc/raster/raster_buffer_provider_perftest.cc ('k') | cc/raster/task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698