Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/numerics/safe_conversions.h" | 19 #include "base/numerics/safe_conversions.h" |
| 20 #include "base/trace_event/trace_event_argument.h" | 20 #include "base/trace_event/trace_event_argument.h" |
| 21 #include "cc/base/histograms.h" | 21 #include "cc/base/histograms.h" |
| 22 #include "cc/debug/devtools_instrumentation.h" | 22 #include "cc/debug/devtools_instrumentation.h" |
| 23 #include "cc/debug/frame_viewer_instrumentation.h" | 23 #include "cc/debug/frame_viewer_instrumentation.h" |
| 24 #include "cc/debug/traced_value.h" | 24 #include "cc/debug/traced_value.h" |
| 25 #include "cc/layers/picture_layer_impl.h" | 25 #include "cc/layers/picture_layer_impl.h" |
| 26 #include "cc/raster/raster_buffer.h" | |
| 27 #include "cc/raster/task_category.h" | 26 #include "cc/raster/task_category.h" |
| 28 #include "cc/raster/tile_task_runner.h" | 27 #include "cc/raster/tile_task_runner.h" |
| 29 #include "cc/tiles/tile.h" | 28 #include "cc/tiles/tile.h" |
| 30 #include "ui/gfx/geometry/rect_conversions.h" | 29 #include "ui/gfx/geometry/rect_conversions.h" |
| 31 | 30 |
| 32 namespace cc { | 31 namespace cc { |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 // Flag to indicate whether we should try and detect that | 34 // Flag to indicate whether we should try and detect that |
| 36 // a tile is of solid color. | 35 // a tile is of solid color. |
| 37 const bool kUseColorEstimator = true; | 36 const bool kUseColorEstimator = true; |
| 38 | 37 |
| 39 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | 38 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
| 40 ScopedRasterTaskTimer, | 39 ScopedRasterTaskTimer, |
| 41 "Compositing.%s.RasterTask.RasterUs", | 40 "Compositing.%s.RasterTask.RasterUs", |
| 42 "Compositing.%s.RasterTask.RasterPixelsPerMs"); | 41 "Compositing.%s.RasterTask.RasterPixelsPerMs"); |
| 43 | 42 |
| 44 class RasterTaskImpl : public RasterTask { | 43 class RasterTaskImpl : public Task { |
| 45 public: | 44 public: |
| 46 RasterTaskImpl(const Resource* resource, | 45 RasterTaskImpl(RasterBufferProvider* raster_buffer_provider, |
| 46 const Resource* resource, | |
| 47 scoped_refptr<RasterSource> raster_source, | 47 scoped_refptr<RasterSource> raster_source, |
| 48 const gfx::Rect& content_rect, | 48 const gfx::Rect& content_rect, |
| 49 const gfx::Rect& invalid_content_rect, | 49 const gfx::Rect& invalid_content_rect, |
| 50 float contents_scale, | 50 float contents_scale, |
| 51 const RasterSource::PlaybackSettings& playback_settings, | 51 const RasterSource::PlaybackSettings& playback_settings, |
| 52 TileResolution tile_resolution, | 52 TileResolution tile_resolution, |
| 53 int layer_id, | 53 int layer_id, |
| 54 uint64_t source_prepare_tiles_id, | 54 uint64_t source_prepare_tiles_id, |
| 55 const void* tile, | 55 const void* tile, |
| 56 uint64_t new_content_id, | 56 uint64_t new_content_id, |
| 57 uint64_t previous_content_id, | 57 uint64_t previous_content_id, |
| 58 uint64_t resource_content_id, | 58 uint64_t resource_content_id, |
| 59 int source_frame_number, | 59 int source_frame_number, |
| 60 const base::Callback<void(bool)>& reply, | 60 const base::Callback<void(bool)>& reply, |
| 61 ImageDecodeTask::Vector* dependencies) | 61 Task::Vector* dependencies) |
| 62 : RasterTask(dependencies), | 62 : raster_buffer_provider_(raster_buffer_provider), |
| 63 resource_(resource), | 63 resource_(resource), |
| 64 raster_source_(std::move(raster_source)), | 64 raster_source_(std::move(raster_source)), |
| 65 content_rect_(content_rect), | 65 content_rect_(content_rect), |
| 66 invalid_content_rect_(invalid_content_rect), | 66 invalid_content_rect_(invalid_content_rect), |
| 67 contents_scale_(contents_scale), | 67 contents_scale_(contents_scale), |
| 68 playback_settings_(playback_settings), | 68 playback_settings_(playback_settings), |
| 69 tile_resolution_(tile_resolution), | 69 tile_resolution_(tile_resolution), |
| 70 layer_id_(layer_id), | 70 layer_id_(layer_id), |
| 71 source_prepare_tiles_id_(source_prepare_tiles_id), | 71 source_prepare_tiles_id_(source_prepare_tiles_id), |
| 72 tile_(tile), | 72 tile_(tile), |
| 73 new_content_id_(new_content_id), | 73 new_content_id_(new_content_id), |
| 74 previous_content_id_(previous_content_id), | 74 previous_content_id_(previous_content_id), |
| 75 resource_content_id_(resource_content_id), | 75 resource_content_id_(resource_content_id), |
| 76 source_frame_number_(source_frame_number), | 76 source_frame_number_(source_frame_number), |
| 77 reply_(reply) {} | 77 reply_(reply) { |
| 78 dependencies_ = std::move(*dependencies); | |
| 79 } | |
| 78 | 80 |
| 79 // Overridden from Task: | 81 // Overridden from Task: |
| 82 void ScheduleOnOriginThread() override { | |
| 83 DCHECK(raster_buffer_provider_); | |
| 84 DCHECK(!raster_buffer_); | |
| 85 raster_buffer_ = raster_buffer_provider_->AcquireBufferForRaster( | |
| 86 resource_, resource_content_id_, previous_content_id_); | |
| 87 } | |
| 88 | |
| 89 void CompleteOnOriginThread() override { | |
| 90 DCHECK(raster_buffer_provider_); | |
| 91 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer_)); | |
| 92 reply_.Run(!HasFinishedRunning()); | |
|
prashant.n
2016/04/07 09:22:13
Due to this, we need to keep scheduling and comple
| |
| 93 } | |
| 94 | |
| 80 void RunOnWorkerThread() override { | 95 void RunOnWorkerThread() override { |
| 81 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 96 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
| 82 "source_prepare_tiles_id", source_prepare_tiles_id_); | 97 "source_prepare_tiles_id", source_prepare_tiles_id_); |
| 83 | 98 |
| 84 DCHECK(raster_source_.get()); | 99 DCHECK(raster_source_.get()); |
| 85 DCHECK(raster_buffer_); | 100 DCHECK(raster_buffer_); |
| 86 | 101 |
| 87 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 102 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
| 88 tile_, tile_resolution_, source_frame_number_, layer_id_); | 103 tile_, tile_resolution_, source_frame_number_, layer_id_); |
| 89 ScopedRasterTaskTimer timer; | 104 ScopedRasterTaskTimer timer; |
| 90 timer.SetArea(content_rect_.size().GetArea()); | 105 timer.SetArea(content_rect_.size().GetArea()); |
| 91 | 106 |
| 92 DCHECK(raster_source_); | 107 DCHECK(raster_source_); |
| 93 | 108 |
| 94 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 109 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
| 95 invalid_content_rect_, new_content_id_, | 110 invalid_content_rect_, new_content_id_, |
| 96 contents_scale_, playback_settings_); | 111 contents_scale_, playback_settings_); |
| 97 } | 112 } |
| 98 | 113 |
| 99 // Overridden from TileTask: | 114 const Task::Vector& dependencies() const { return dependencies_; } |
| 100 void ScheduleOnOriginThread(TileTaskClient* client) override { | |
| 101 DCHECK(!raster_buffer_); | |
| 102 raster_buffer_ = client->AcquireBufferForRaster( | |
| 103 resource_, resource_content_id_, previous_content_id_); | |
| 104 } | |
| 105 void CompleteOnOriginThread(TileTaskClient* client) override { | |
| 106 client->ReleaseBufferForRaster(std::move(raster_buffer_)); | |
| 107 reply_.Run(!HasFinishedRunning()); | |
| 108 } | |
| 109 | 115 |
| 110 protected: | 116 protected: |
| 111 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } | 117 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } |
| 112 | 118 |
| 113 private: | 119 private: |
| 120 Task::Vector dependencies_; | |
| 121 RasterBufferProvider* raster_buffer_provider_; | |
| 114 const Resource* resource_; | 122 const Resource* resource_; |
| 115 scoped_refptr<RasterSource> raster_source_; | 123 scoped_refptr<RasterSource> raster_source_; |
| 116 gfx::Rect content_rect_; | 124 gfx::Rect content_rect_; |
| 117 gfx::Rect invalid_content_rect_; | 125 gfx::Rect invalid_content_rect_; |
| 118 float contents_scale_; | 126 float contents_scale_; |
| 119 RasterSource::PlaybackSettings playback_settings_; | 127 RasterSource::PlaybackSettings playback_settings_; |
| 120 TileResolution tile_resolution_; | 128 TileResolution tile_resolution_; |
| 121 int layer_id_; | 129 int layer_id_; |
| 122 uint64_t source_prepare_tiles_id_; | 130 uint64_t source_prepare_tiles_id_; |
| 123 const void* tile_; | 131 const void* tile_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 135 // other remaining tasks. | 143 // other remaining tasks. |
| 136 const size_t kRequiredForActivationDoneTaskPriority = 1u; | 144 const size_t kRequiredForActivationDoneTaskPriority = 1u; |
| 137 const size_t kRequiredForDrawDoneTaskPriority = 2u; | 145 const size_t kRequiredForDrawDoneTaskPriority = 2u; |
| 138 const size_t kAllDoneTaskPriority = 3u; | 146 const size_t kAllDoneTaskPriority = 3u; |
| 139 | 147 |
| 140 // For correctness, |kTileTaskPriorityBase| must be greater than | 148 // For correctness, |kTileTaskPriorityBase| must be greater than |
| 141 // all task set done task priorities. | 149 // all task set done task priorities. |
| 142 size_t kTileTaskPriorityBase = 10u; | 150 size_t kTileTaskPriorityBase = 10u; |
| 143 | 151 |
| 144 void InsertNodeForTask(TaskGraph* graph, | 152 void InsertNodeForTask(TaskGraph* graph, |
| 145 TileTask* task, | 153 Task* task, |
| 146 uint16_t category, | 154 uint16_t category, |
| 147 uint16_t priority, | 155 uint16_t priority, |
| 148 size_t dependencies) { | 156 size_t dependencies) { |
| 149 DCHECK(std::find_if(graph->nodes.begin(), graph->nodes.end(), | 157 DCHECK(std::find_if(graph->nodes.begin(), graph->nodes.end(), |
| 150 [task](const TaskGraph::Node& node) { | 158 [task](const TaskGraph::Node& node) { |
| 151 return node.task == task; | 159 return node.task == task; |
| 152 }) == graph->nodes.end()); | 160 }) == graph->nodes.end()); |
| 153 graph->nodes.push_back( | 161 graph->nodes.push_back( |
| 154 TaskGraph::Node(task, category, priority, dependencies)); | 162 TaskGraph::Node(task, category, priority, dependencies)); |
| 155 } | 163 } |
| 156 | 164 |
| 157 void InsertNodesForRasterTask(TaskGraph* graph, | 165 void InsertNodesForRasterTask(TaskGraph* graph, |
| 158 RasterTask* raster_task, | 166 Task* raster_task, |
| 159 const ImageDecodeTask::Vector& decode_tasks, | 167 const Task::Vector& decode_tasks, |
| 160 size_t priority, | 168 size_t priority, |
| 161 bool use_gpu_rasterization, | 169 bool use_gpu_rasterization, |
| 162 bool high_priority) { | 170 bool high_priority) { |
| 163 size_t dependencies = 0u; | 171 size_t dependencies = 0u; |
| 164 | 172 |
| 165 // Determine the TaskCategory for raster tasks - if a task uses GPU, it | 173 // Determine the TaskCategory for raster tasks - if a task uses GPU, it |
| 166 // cannot run concurrently and is assigned | 174 // cannot run concurrently and is assigned |
| 167 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND, regardless of its priority. | 175 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND, regardless of its priority. |
| 168 // Otherwise its category is based on its priority. | 176 // Otherwise its category is based on its priority. |
| 169 TaskCategory raster_task_category; | 177 TaskCategory raster_task_category; |
| 170 if (use_gpu_rasterization) { | 178 if (use_gpu_rasterization) { |
| 171 raster_task_category = TASK_CATEGORY_NONCONCURRENT_FOREGROUND; | 179 raster_task_category = TASK_CATEGORY_NONCONCURRENT_FOREGROUND; |
| 172 } else { | 180 } else { |
| 173 raster_task_category = | 181 raster_task_category = |
| 174 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; | 182 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; |
| 175 } | 183 } |
| 176 | 184 |
| 177 // Determine the TaskCategory for decode tasks. This category is based on | 185 // Determine the TaskCategory for decode tasks. This category is based on |
| 178 // the priority of the raster task which depends on it. | 186 // the priority of the raster task which depends on it. |
| 179 TaskCategory decode_task_category = | 187 TaskCategory decode_task_category = |
| 180 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; | 188 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; |
| 181 | 189 |
| 182 // Insert image decode tasks. | 190 // Insert image decode tasks. |
| 183 for (ImageDecodeTask::Vector::const_iterator it = decode_tasks.begin(); | 191 for (Task::Vector::const_iterator it = decode_tasks.begin(); |
| 184 it != decode_tasks.end(); ++it) { | 192 it != decode_tasks.end(); ++it) { |
| 185 ImageDecodeTask* decode_task = it->get(); | 193 Task* decode_task = it->get(); |
| 186 | 194 |
| 187 // Skip if already decoded. | 195 // Skip if already decoded. |
| 188 if (decode_task->HasCompleted()) | 196 if (decode_task->HasCompleted()) |
| 189 continue; | 197 continue; |
| 190 | 198 |
| 191 dependencies++; | 199 dependencies++; |
| 192 | 200 |
| 193 // Add decode task if it doesn't already exists in graph. | 201 // Add decode task if it doesn't already exists in graph. |
| 194 TaskGraph::Node::Vector::iterator decode_it = | 202 TaskGraph::Node::Vector::iterator decode_it = |
| 195 std::find_if(graph->nodes.begin(), graph->nodes.end(), | 203 std::find_if(graph->nodes.begin(), graph->nodes.end(), |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 211 InsertNodeForTask(graph, decode_task, decode_task_category, priority, 0u); | 219 InsertNodeForTask(graph, decode_task, decode_task_category, priority, 0u); |
| 212 } | 220 } |
| 213 | 221 |
| 214 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); | 222 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); |
| 215 } | 223 } |
| 216 | 224 |
| 217 InsertNodeForTask(graph, raster_task, raster_task_category, priority, | 225 InsertNodeForTask(graph, raster_task, raster_task_category, priority, |
| 218 dependencies); | 226 dependencies); |
| 219 } | 227 } |
| 220 | 228 |
| 221 class TaskSetFinishedTaskImpl : public TileTask { | 229 class TaskSetFinishedTaskImpl : public Task { |
| 222 public: | 230 public: |
| 223 explicit TaskSetFinishedTaskImpl( | 231 explicit TaskSetFinishedTaskImpl( |
| 224 base::SequencedTaskRunner* task_runner, | 232 base::SequencedTaskRunner* task_runner, |
| 225 const base::Closure& on_task_set_finished_callback) | 233 const base::Closure& on_task_set_finished_callback) |
| 226 : task_runner_(task_runner), | 234 : task_runner_(task_runner), |
| 227 on_task_set_finished_callback_(on_task_set_finished_callback) {} | 235 on_task_set_finished_callback_(on_task_set_finished_callback) {} |
| 228 | 236 |
| 229 // Overridden from Task: | 237 // Overridden from Task: |
| 238 void ScheduleOnOriginThread() override {} | |
| 239 void CompleteOnOriginThread() override {} | |
| 230 void RunOnWorkerThread() override { | 240 void RunOnWorkerThread() override { |
| 231 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread"); | 241 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread"); |
| 232 TaskSetFinished(); | 242 TaskSetFinished(); |
| 233 } | 243 } |
| 234 | 244 |
| 235 // Overridden from TileTask: | |
| 236 void ScheduleOnOriginThread(TileTaskClient* client) override {} | |
| 237 void CompleteOnOriginThread(TileTaskClient* client) override {} | |
| 238 | |
| 239 protected: | 245 protected: |
| 240 ~TaskSetFinishedTaskImpl() override {} | 246 ~TaskSetFinishedTaskImpl() override {} |
| 241 | 247 |
| 242 void TaskSetFinished() { | 248 void TaskSetFinished() { |
| 243 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); | 249 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); |
| 244 } | 250 } |
| 245 | 251 |
| 246 private: | 252 private: |
| 247 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 253 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 248 const base::Closure on_task_set_finished_callback_; | 254 const base::Closure on_task_set_finished_callback_; |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 | 739 |
| 734 // Track the number of dependents for each *_done task. | 740 // Track the number of dependents for each *_done task. |
| 735 size_t required_for_activate_count = 0; | 741 size_t required_for_activate_count = 0; |
| 736 size_t required_for_draw_count = 0; | 742 size_t required_for_draw_count = 0; |
| 737 size_t all_count = 0; | 743 size_t all_count = 0; |
| 738 | 744 |
| 739 size_t priority = kTileTaskPriorityBase; | 745 size_t priority = kTileTaskPriorityBase; |
| 740 | 746 |
| 741 graph_.Reset(); | 747 graph_.Reset(); |
| 742 | 748 |
| 743 scoped_refptr<TileTask> required_for_activation_done_task = | 749 scoped_refptr<Task> required_for_activation_done_task = |
| 744 CreateTaskSetFinishedTask( | 750 CreateTaskSetFinishedTask( |
| 745 &TileManager::DidFinishRunningTileTasksRequiredForActivation); | 751 &TileManager::DidFinishRunningTileTasksRequiredForActivation); |
| 746 scoped_refptr<TileTask> required_for_draw_done_task = | 752 scoped_refptr<Task> required_for_draw_done_task = CreateTaskSetFinishedTask( |
| 747 CreateTaskSetFinishedTask( | 753 &TileManager::DidFinishRunningTileTasksRequiredForDraw); |
| 748 &TileManager::DidFinishRunningTileTasksRequiredForDraw); | 754 scoped_refptr<Task> all_done_task = |
| 749 scoped_refptr<TileTask> all_done_task = | |
| 750 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); | 755 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); |
| 751 | 756 |
| 752 // Build a new task queue containing all task currently needed. Tasks | 757 // Build a new task queue containing all task currently needed. Tasks |
| 753 // are added in order of priority, highest priority task first. | 758 // are added in order of priority, highest priority task first. |
| 754 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { | 759 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { |
| 755 Tile* tile = prioritized_tile.tile(); | 760 Tile* tile = prioritized_tile.tile(); |
| 756 | 761 |
| 757 DCHECK(tile->draw_info().requires_resource()); | 762 DCHECK(tile->draw_info().requires_resource()); |
| 758 DCHECK(!tile->draw_info().resource_); | 763 DCHECK(!tile->draw_info().resource_); |
| 759 | 764 |
| 760 if (!tile->raster_task_) | 765 if (!tile->raster_task_) |
| 761 tile->raster_task_ = CreateRasterTask(prioritized_tile); | 766 tile->raster_task_ = CreateRasterTask(prioritized_tile); |
| 762 | 767 |
| 763 RasterTask* task = tile->raster_task_.get(); | 768 RasterTaskImpl* task = |
| 769 static_cast<RasterTaskImpl*>(tile->raster_task_.get()); | |
| 764 DCHECK(!task->HasCompleted()); | 770 DCHECK(!task->HasCompleted()); |
| 765 | 771 |
| 766 if (tile->required_for_activation()) { | 772 if (tile->required_for_activation()) { |
| 767 required_for_activate_count++; | 773 required_for_activate_count++; |
| 768 graph_.edges.push_back( | 774 graph_.edges.push_back( |
| 769 TaskGraph::Edge(task, required_for_activation_done_task.get())); | 775 TaskGraph::Edge(task, required_for_activation_done_task.get())); |
| 770 } | 776 } |
| 771 if (tile->required_for_draw()) { | 777 if (tile->required_for_draw()) { |
| 772 required_for_draw_count++; | 778 required_for_draw_count++; |
| 773 graph_.edges.push_back( | 779 graph_.edges.push_back( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 std::move(required_for_activation_done_task); | 825 std::move(required_for_activation_done_task); |
| 820 required_for_draw_done_task_ = std::move(required_for_draw_done_task); | 826 required_for_draw_done_task_ = std::move(required_for_draw_done_task); |
| 821 all_done_task_ = std::move(all_done_task); | 827 all_done_task_ = std::move(all_done_task); |
| 822 | 828 |
| 823 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; | 829 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; |
| 824 | 830 |
| 825 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 831 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
| 826 ScheduledTasksStateAsValue()); | 832 ScheduledTasksStateAsValue()); |
| 827 } | 833 } |
| 828 | 834 |
| 829 scoped_refptr<RasterTask> TileManager::CreateRasterTask( | 835 scoped_refptr<Task> TileManager::CreateRasterTask( |
| 830 const PrioritizedTile& prioritized_tile) { | 836 const PrioritizedTile& prioritized_tile) { |
| 831 Tile* tile = prioritized_tile.tile(); | 837 Tile* tile = prioritized_tile.tile(); |
| 832 | 838 |
| 833 // Get the resource. | 839 // Get the resource. |
| 834 uint64_t resource_content_id = 0; | 840 uint64_t resource_content_id = 0; |
| 835 Resource* resource = nullptr; | 841 Resource* resource = nullptr; |
| 836 if (use_partial_raster_ && tile->invalidated_id()) { | 842 if (use_partial_raster_ && tile->invalidated_id()) { |
| 837 // TODO(danakj): For resources that are in use, we should still grab them | 843 // TODO(danakj): For resources that are in use, we should still grab them |
| 838 // and copy from them instead of rastering everything. crbug.com/492754 | 844 // and copy from them instead of rastering everything. crbug.com/492754 |
| 839 resource = | 845 resource = |
| 840 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id()); | 846 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id()); |
| 841 } | 847 } |
| 842 if (resource) { | 848 if (resource) { |
| 843 resource_content_id = tile->invalidated_id(); | 849 resource_content_id = tile->invalidated_id(); |
| 844 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); | 850 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); |
| 845 } else { | 851 } else { |
| 846 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), | 852 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), |
| 847 DetermineResourceFormat(tile)); | 853 DetermineResourceFormat(tile)); |
| 848 } | 854 } |
| 849 | 855 |
| 850 // For LOW_RESOLUTION tiles, we don't draw or predecode images. | 856 // For LOW_RESOLUTION tiles, we don't draw or predecode images. |
| 851 RasterSource::PlaybackSettings playback_settings; | 857 RasterSource::PlaybackSettings playback_settings; |
| 852 playback_settings.skip_images = | 858 playback_settings.skip_images = |
| 853 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 859 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
| 854 | 860 |
| 855 // Create and queue all image decode tasks that this tile depends on. | 861 // Create and queue all image decode tasks that this tile depends on. |
| 856 ImageDecodeTask::Vector decode_tasks; | 862 Task::Vector decode_tasks; |
| 857 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 863 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
| 858 images.clear(); | 864 images.clear(); |
| 859 if (!playback_settings.skip_images) { | 865 if (!playback_settings.skip_images) { |
| 860 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 866 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 861 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 867 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
| 862 } | 868 } |
| 863 | 869 |
| 864 // TODO(vmpstr): We should disable image hijack canvas in | 870 // TODO(vmpstr): We should disable image hijack canvas in |
| 865 // |playback_settings| here if |images| is empty. | 871 // |playback_settings| here if |images| is empty. |
| 866 | 872 |
| 867 for (auto it = images.begin(); it != images.end();) { | 873 for (auto it = images.begin(); it != images.end();) { |
| 868 scoped_refptr<ImageDecodeTask> task; | 874 scoped_refptr<Task> task; |
| 869 bool need_to_unref_when_finished = | 875 bool need_to_unref_when_finished = |
| 870 image_decode_controller_->GetTaskForImageAndRef( | 876 image_decode_controller_->GetTaskForImageAndRef( |
| 871 *it, prepare_tiles_count_, &task); | 877 *it, prepare_tiles_count_, &task); |
| 872 if (task) | 878 if (task) |
| 873 decode_tasks.push_back(task); | 879 decode_tasks.push_back(task); |
| 874 | 880 |
| 875 if (need_to_unref_when_finished) | 881 if (need_to_unref_when_finished) |
| 876 ++it; | 882 ++it; |
| 877 else | 883 else |
| 878 it = images.erase(it); | 884 it = images.erase(it); |
| 879 } | 885 } |
| 880 | 886 |
| 881 return make_scoped_refptr(new RasterTaskImpl( | 887 return make_scoped_refptr(new RasterTaskImpl( |
| 882 resource, prioritized_tile.raster_source(), tile->content_rect(), | 888 tile_task_runner_, resource, prioritized_tile.raster_source(), |
| 883 tile->invalidated_content_rect(), tile->contents_scale(), | 889 tile->content_rect(), tile->invalidated_content_rect(), |
| 884 playback_settings, prioritized_tile.priority().resolution, | 890 tile->contents_scale(), playback_settings, |
| 885 tile->layer_id(), prepare_tiles_count_, static_cast<const void*>(tile), | 891 prioritized_tile.priority().resolution, tile->layer_id(), |
| 886 tile->id(), tile->invalidated_id(), resource_content_id, | 892 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), |
| 887 tile->source_frame_number(), | 893 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), |
| 888 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), | 894 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), |
| 889 tile->id(), resource), | 895 tile->id(), resource), |
| 890 &decode_tasks)); | 896 &decode_tasks)); |
| 891 } | 897 } |
| 892 | 898 |
| 893 void TileManager::OnRasterTaskCompleted( | 899 void TileManager::OnRasterTaskCompleted( |
| 894 Tile::Id tile_id, | 900 Tile::Id tile_id, |
| 895 Resource* resource, | 901 Resource* resource, |
| 896 bool was_canceled) { | 902 bool was_canceled) { |
| 897 DCHECK(tiles_.find(tile_id) != tiles_.end()); | 903 DCHECK(tiles_.find(tile_id) != tiles_.end()); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1133 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); | 1139 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); |
| 1134 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); | 1140 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); |
| 1135 state->SetBoolean("all_tile_tasks_completed", | 1141 state->SetBoolean("all_tile_tasks_completed", |
| 1136 signals_.all_tile_tasks_completed); | 1142 signals_.all_tile_tasks_completed); |
| 1137 state->EndDictionary(); | 1143 state->EndDictionary(); |
| 1138 return std::move(state); | 1144 return std::move(state); |
| 1139 } | 1145 } |
| 1140 | 1146 |
| 1141 // Utility function that can be used to create a "Task set finished" task that | 1147 // Utility function that can be used to create a "Task set finished" task that |
| 1142 // posts |callback| to |task_runner| when run. | 1148 // posts |callback| to |task_runner| when run. |
| 1143 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( | 1149 scoped_refptr<Task> TileManager::CreateTaskSetFinishedTask( |
| 1144 void (TileManager::*callback)()) { | 1150 void (TileManager::*callback)()) { |
| 1145 return make_scoped_refptr(new TaskSetFinishedTaskImpl( | 1151 return make_scoped_refptr(new TaskSetFinishedTaskImpl( |
| 1146 task_runner_.get(), | 1152 task_runner_.get(), |
| 1147 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); | 1153 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); |
| 1148 } | 1154 } |
| 1149 | 1155 |
| 1150 TileManager::MemoryUsage::MemoryUsage() | 1156 TileManager::MemoryUsage::MemoryUsage() |
| 1151 : memory_bytes_(0), resource_count_(0) {} | 1157 : memory_bytes_(0), resource_count_(0) {} |
| 1152 | 1158 |
| 1153 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, | 1159 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1217 void TileManager::Signals::reset() { | 1223 void TileManager::Signals::reset() { |
| 1218 ready_to_activate = false; | 1224 ready_to_activate = false; |
| 1219 did_notify_ready_to_activate = false; | 1225 did_notify_ready_to_activate = false; |
| 1220 ready_to_draw = false; | 1226 ready_to_draw = false; |
| 1221 did_notify_ready_to_draw = false; | 1227 did_notify_ready_to_draw = false; |
| 1222 all_tile_tasks_completed = false; | 1228 all_tile_tasks_completed = false; |
| 1223 did_notify_all_tile_tasks_completed = false; | 1229 did_notify_all_tile_tasks_completed = false; |
| 1224 } | 1230 } |
| 1225 | 1231 |
| 1226 } // namespace cc | 1232 } // namespace cc |
| OLD | NEW |