Index: cc/raster/raster_buffer_provider_perftest.cc |
diff --git a/cc/raster/raster_buffer_provider_perftest.cc b/cc/raster/raster_buffer_provider_perftest.cc |
index 662a24a595839036942293ed686e0024410e6dd5..c136c6f47f05c36a915bc6ffcd1055a5b7667339 100644 |
--- a/cc/raster/raster_buffer_provider_perftest.cc |
+++ b/cc/raster/raster_buffer_provider_perftest.cc |
@@ -129,15 +129,7 @@ class PerfImageDecodeTaskImpl : public TileTask { |
void RunOnWorkerThread() override {} |
// Overridden from TileTask: |
- void ScheduleOnOriginThread(RasterBufferProvider* provider) override {} |
- void CompleteOnOriginThread(RasterBufferProvider* provider) override { |
- Reset(); |
- } |
- |
- void Reset() { |
- state().Reset(); |
- did_complete_ = false; |
- } |
+ void OnTaskCompleted() override { state().Reset(); } |
protected: |
~PerfImageDecodeTaskImpl() override {} |
@@ -146,34 +138,42 @@ class PerfImageDecodeTaskImpl : public TileTask { |
DISALLOW_COPY_AND_ASSIGN(PerfImageDecodeTaskImpl); |
}; |
+class PerfRasterBufferProviderHelper { |
+ public: |
+ virtual std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
+ const Resource* resource, |
+ uint64_t resource_content_id, |
+ uint64_t previous_content_id) = 0; |
+ virtual void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) = 0; |
+}; |
+ |
class PerfRasterTaskImpl : public TileTask { |
public: |
- PerfRasterTaskImpl(std::unique_ptr<ScopedResource> resource, |
+ PerfRasterTaskImpl(PerfRasterBufferProviderHelper* helper, |
+ std::unique_ptr<ScopedResource> resource, |
+ std::unique_ptr<RasterBuffer> raster_buffer, |
TileTask::Vector* dependencies) |
- : TileTask(true, dependencies), resource_(std::move(resource)) {} |
+ : TileTask(true, dependencies), |
+ helper_(helper), |
+ resource_(std::move(resource)), |
+ raster_buffer_(std::move(raster_buffer)) {} |
// Overridden from Task: |
void RunOnWorkerThread() override {} |
// Overridden from TileTask: |
- void ScheduleOnOriginThread(RasterBufferProvider* provider) override { |
- // No tile ids are given to support partial updates. |
- raster_buffer_ = provider->AcquireBufferForRaster(resource_.get(), 0, 0); |
- } |
- void CompleteOnOriginThread(RasterBufferProvider* provider) override { |
- provider->ReleaseBufferForRaster(std::move(raster_buffer_)); |
- Reset(); |
- } |
+ void OnTaskCompleted() override { |
+ if (helper_) |
+ helper_->ReleaseBufferForRaster(std::move(raster_buffer_)); |
- void Reset() { |
state().Reset(); |
- did_complete_ = false; |
} |
protected: |
~PerfRasterTaskImpl() override {} |
private: |
+ PerfRasterBufferProviderHelper* helper_; |
std::unique_ptr<ScopedResource> resource_; |
std::unique_ptr<RasterBuffer> raster_buffer_; |
@@ -200,7 +200,8 @@ class RasterBufferProviderPerfTestBase { |
image_decode_tasks->push_back(new PerfImageDecodeTaskImpl); |
} |
- void CreateRasterTasks(unsigned num_raster_tasks, |
+ void CreateRasterTasks(PerfRasterBufferProviderHelper* helper, |
+ unsigned num_raster_tasks, |
const TileTask::Vector& image_decode_tasks, |
RasterTaskVector* raster_tasks) { |
const gfx::Size size(1, 1); |
@@ -211,9 +212,14 @@ class RasterBufferProviderPerfTestBase { |
resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
RGBA_8888); |
+ // No tile ids are given to support partial updates. |
+ std::unique_ptr<RasterBuffer> raster_buffer; |
+ if (helper) |
+ raster_buffer = helper->AcquireBufferForRaster(resource.get(), 0, 0); |
TileTask::Vector dependencies = image_decode_tasks; |
raster_tasks->push_back( |
- new PerfRasterTaskImpl(std::move(resource), &dependencies)); |
+ new PerfRasterTaskImpl(helper, std::move(resource), |
+ std::move(raster_buffer), &dependencies)); |
} |
} |
@@ -259,6 +265,7 @@ class RasterBufferProviderPerfTestBase { |
class RasterBufferProviderPerfTest |
: public RasterBufferProviderPerfTestBase, |
+ public PerfRasterBufferProviderHelper, |
public testing::TestWithParam<RasterBufferProviderType> { |
public: |
// Overridden from testing::Test: |
@@ -300,6 +307,20 @@ class RasterBufferProviderPerfTest |
tile_task_manager_->CheckForCompletedTasks(); |
} |
+ // Overridden from PerfRasterBufferProviderHelper: |
+ std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
+ const Resource* resource, |
+ uint64_t resource_content_id, |
+ uint64_t previous_content_id) override { |
+ return tile_task_manager_->GetRasterBufferProvider() |
+ ->AcquireBufferForRaster(resource, resource_content_id, |
+ previous_content_id); |
+ } |
+ void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override { |
+ tile_task_manager_->GetRasterBufferProvider()->ReleaseBufferForRaster( |
+ std::move(buffer)); |
+ } |
+ |
void RunMessageLoopUntilAllTasksHaveCompleted() { |
task_graph_runner_->RunUntilIdle(); |
task_runner_->RunUntilIdle(); |
@@ -311,7 +332,8 @@ class RasterBufferProviderPerfTest |
TileTask::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(this, num_raster_tasks, image_decode_tasks, |
+ &raster_tasks); |
// Avoid unnecessary heap allocations by reusing the same graph. |
TaskGraph graph; |
@@ -341,7 +363,7 @@ class RasterBufferProviderPerfTest |
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(this, num_raster_tasks, image_decode_tasks[i], |
&raster_tasks[i]); |
} |
@@ -373,7 +395,8 @@ class RasterBufferProviderPerfTest |
TileTask::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(this, num_raster_tasks, image_decode_tasks, |
+ &raster_tasks); |
// Avoid unnecessary heap allocations by reusing the same graph. |
TaskGraph graph; |
@@ -483,7 +506,8 @@ class RasterBufferProviderCommonPerfTest |
TileTask::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(nullptr, num_raster_tasks, image_decode_tasks, |
+ &raster_tasks); |
// Avoid unnecessary heap allocations by reusing the same graph. |
TaskGraph graph; |