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

Unified Diff: cc/tiles/tile_manager.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
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/tile_manager.cc
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index 68408e4ded02b983d804ccd6e9f0bfea2b3a7abc..723bb033595b2f4fca7bc2b29afe78793315886c 100644
--- a/cc/tiles/tile_manager.cc
+++ b/cc/tiles/tile_manager.cc
@@ -23,7 +23,6 @@
#include "cc/debug/frame_viewer_instrumentation.h"
#include "cc/debug/traced_value.h"
#include "cc/layers/picture_layer_impl.h"
-#include "cc/raster/raster_buffer.h"
#include "cc/raster/task_category.h"
#include "cc/raster/tile_task_runner.h"
#include "cc/tiles/tile.h"
@@ -41,9 +40,10 @@ DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(
"Compositing.%s.RasterTask.RasterUs",
"Compositing.%s.RasterTask.RasterPixelsPerMs");
-class RasterTaskImpl : public RasterTask {
+class RasterTaskImpl : public Task {
public:
- RasterTaskImpl(const Resource* resource,
+ RasterTaskImpl(RasterBufferProvider* raster_buffer_provider,
+ const Resource* resource,
scoped_refptr<RasterSource> raster_source,
const gfx::Rect& content_rect,
const gfx::Rect& invalid_content_rect,
@@ -58,8 +58,8 @@ class RasterTaskImpl : public RasterTask {
uint64_t resource_content_id,
int source_frame_number,
const base::Callback<void(bool)>& reply,
- ImageDecodeTask::Vector* dependencies)
- : RasterTask(dependencies),
+ Task::Vector* dependencies)
+ : raster_buffer_provider_(raster_buffer_provider),
resource_(resource),
raster_source_(std::move(raster_source)),
content_rect_(content_rect),
@@ -74,9 +74,24 @@ class RasterTaskImpl : public RasterTask {
previous_content_id_(previous_content_id),
resource_content_id_(resource_content_id),
source_frame_number_(source_frame_number),
- reply_(reply) {}
+ reply_(reply) {
+ dependencies_ = std::move(*dependencies);
+ }
// Overridden from Task:
+ void ScheduleOnOriginThread() override {
+ DCHECK(raster_buffer_provider_);
+ DCHECK(!raster_buffer_);
+ raster_buffer_ = raster_buffer_provider_->AcquireBufferForRaster(
+ resource_, resource_content_id_, previous_content_id_);
+ }
+
+ void CompleteOnOriginThread() override {
+ DCHECK(raster_buffer_provider_);
+ raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer_));
+ reply_.Run(!HasFinishedRunning());
prashant.n 2016/04/07 09:22:13 Due to this, we need to keep scheduling and comple
+ }
+
void RunOnWorkerThread() override {
TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread",
"source_prepare_tiles_id", source_prepare_tiles_id_);
@@ -96,21 +111,14 @@ class RasterTaskImpl : public RasterTask {
contents_scale_, playback_settings_);
}
- // Overridden from TileTask:
- void ScheduleOnOriginThread(TileTaskClient* client) override {
- DCHECK(!raster_buffer_);
- raster_buffer_ = client->AcquireBufferForRaster(
- resource_, resource_content_id_, previous_content_id_);
- }
- void CompleteOnOriginThread(TileTaskClient* client) override {
- client->ReleaseBufferForRaster(std::move(raster_buffer_));
- reply_.Run(!HasFinishedRunning());
- }
+ const Task::Vector& dependencies() const { return dependencies_; }
protected:
~RasterTaskImpl() override { DCHECK(!raster_buffer_); }
private:
+ Task::Vector dependencies_;
+ RasterBufferProvider* raster_buffer_provider_;
const Resource* resource_;
scoped_refptr<RasterSource> raster_source_;
gfx::Rect content_rect_;
@@ -142,7 +150,7 @@ const size_t kAllDoneTaskPriority = 3u;
size_t kTileTaskPriorityBase = 10u;
void InsertNodeForTask(TaskGraph* graph,
- TileTask* task,
+ Task* task,
uint16_t category,
uint16_t priority,
size_t dependencies) {
@@ -155,8 +163,8 @@ void InsertNodeForTask(TaskGraph* graph,
}
void InsertNodesForRasterTask(TaskGraph* graph,
- RasterTask* raster_task,
- const ImageDecodeTask::Vector& decode_tasks,
+ Task* raster_task,
+ const Task::Vector& decode_tasks,
size_t priority,
bool use_gpu_rasterization,
bool high_priority) {
@@ -180,9 +188,9 @@ void InsertNodesForRasterTask(TaskGraph* graph,
high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND;
// Insert image decode tasks.
- for (ImageDecodeTask::Vector::const_iterator it = decode_tasks.begin();
+ for (Task::Vector::const_iterator it = decode_tasks.begin();
it != decode_tasks.end(); ++it) {
- ImageDecodeTask* decode_task = it->get();
+ Task* decode_task = it->get();
// Skip if already decoded.
if (decode_task->HasCompleted())
@@ -218,7 +226,7 @@ void InsertNodesForRasterTask(TaskGraph* graph,
dependencies);
}
-class TaskSetFinishedTaskImpl : public TileTask {
+class TaskSetFinishedTaskImpl : public Task {
public:
explicit TaskSetFinishedTaskImpl(
base::SequencedTaskRunner* task_runner,
@@ -227,15 +235,13 @@ class TaskSetFinishedTaskImpl : public TileTask {
on_task_set_finished_callback_(on_task_set_finished_callback) {}
// Overridden from Task:
+ void ScheduleOnOriginThread() override {}
+ void CompleteOnOriginThread() override {}
void RunOnWorkerThread() override {
TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread");
TaskSetFinished();
}
- // Overridden from TileTask:
- void ScheduleOnOriginThread(TileTaskClient* client) override {}
- void CompleteOnOriginThread(TileTaskClient* client) override {}
-
protected:
~TaskSetFinishedTaskImpl() override {}
@@ -740,13 +746,12 @@ void TileManager::ScheduleTasks(
graph_.Reset();
- scoped_refptr<TileTask> required_for_activation_done_task =
+ scoped_refptr<Task> required_for_activation_done_task =
CreateTaskSetFinishedTask(
&TileManager::DidFinishRunningTileTasksRequiredForActivation);
- scoped_refptr<TileTask> required_for_draw_done_task =
- CreateTaskSetFinishedTask(
- &TileManager::DidFinishRunningTileTasksRequiredForDraw);
- scoped_refptr<TileTask> all_done_task =
+ scoped_refptr<Task> required_for_draw_done_task = CreateTaskSetFinishedTask(
+ &TileManager::DidFinishRunningTileTasksRequiredForDraw);
+ scoped_refptr<Task> all_done_task =
CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks);
// Build a new task queue containing all task currently needed. Tasks
@@ -760,7 +765,8 @@ void TileManager::ScheduleTasks(
if (!tile->raster_task_)
tile->raster_task_ = CreateRasterTask(prioritized_tile);
- RasterTask* task = tile->raster_task_.get();
+ RasterTaskImpl* task =
+ static_cast<RasterTaskImpl*>(tile->raster_task_.get());
DCHECK(!task->HasCompleted());
if (tile->required_for_activation()) {
@@ -826,7 +832,7 @@ void TileManager::ScheduleTasks(
ScheduledTasksStateAsValue());
}
-scoped_refptr<RasterTask> TileManager::CreateRasterTask(
+scoped_refptr<Task> TileManager::CreateRasterTask(
const PrioritizedTile& prioritized_tile) {
Tile* tile = prioritized_tile.tile();
@@ -853,7 +859,7 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(
prioritized_tile.priority().resolution == LOW_RESOLUTION;
// Create and queue all image decode tasks that this tile depends on.
- ImageDecodeTask::Vector decode_tasks;
+ Task::Vector decode_tasks;
std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()];
images.clear();
if (!playback_settings.skip_images) {
@@ -865,7 +871,7 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(
// |playback_settings| here if |images| is empty.
for (auto it = images.begin(); it != images.end();) {
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_to_unref_when_finished =
image_decode_controller_->GetTaskForImageAndRef(
*it, prepare_tiles_count_, &task);
@@ -879,12 +885,12 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(
}
return make_scoped_refptr(new RasterTaskImpl(
- resource, prioritized_tile.raster_source(), tile->content_rect(),
- tile->invalidated_content_rect(), tile->contents_scale(),
- playback_settings, prioritized_tile.priority().resolution,
- tile->layer_id(), prepare_tiles_count_, static_cast<const void*>(tile),
- tile->id(), tile->invalidated_id(), resource_content_id,
- tile->source_frame_number(),
+ tile_task_runner_, resource, prioritized_tile.raster_source(),
+ tile->content_rect(), tile->invalidated_content_rect(),
+ tile->contents_scale(), playback_settings,
+ prioritized_tile.priority().resolution, tile->layer_id(),
+ prepare_tiles_count_, static_cast<const void*>(tile), tile->id(),
+ tile->invalidated_id(), resource_content_id, tile->source_frame_number(),
base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this),
tile->id(), resource),
&decode_tasks));
@@ -1140,7 +1146,7 @@ TileManager::ScheduledTasksStateAsValue() const {
// Utility function that can be used to create a "Task set finished" task that
// posts |callback| to |task_runner| when run.
-scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask(
+scoped_refptr<Task> TileManager::CreateTaskSetFinishedTask(
void (TileManager::*callback)()) {
return make_scoped_refptr(new TaskSetFinishedTaskImpl(
task_runner_.get(),
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698