| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/raster/bitmap_tile_task_worker_pool.h" | 5 #include "cc/raster/bitmap_tile_task_worker_pool.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 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "base/trace_event/trace_event_argument.h" | 15 #include "base/trace_event/trace_event_argument.h" |
| 16 #include "cc/debug/traced_value.h" | 16 #include "cc/debug/traced_value.h" |
| 17 #include "cc/playback/raster_source.h" | 17 #include "cc/playback/raster_source.h" |
| 18 #include "cc/raster/raster_buffer.h" | |
| 19 #include "cc/resources/platform_color.h" | 18 #include "cc/resources/platform_color.h" |
| 20 #include "cc/resources/resource.h" | 19 #include "cc/resources/resource.h" |
| 21 | 20 |
| 22 namespace cc { | 21 namespace cc { |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 class RasterBufferImpl : public RasterBuffer { | 24 class RasterBufferImpl : public RasterBuffer { |
| 26 public: | 25 public: |
| 27 RasterBufferImpl(ResourceProvider* resource_provider, | 26 RasterBufferImpl(ResourceProvider* resource_provider, |
| 28 const Resource* resource, | 27 const Resource* resource, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::Shutdown"); | 94 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::Shutdown"); |
| 96 | 95 |
| 97 TaskGraph empty; | 96 TaskGraph empty; |
| 98 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 97 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
| 99 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | 98 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
| 100 } | 99 } |
| 101 | 100 |
| 102 void BitmapTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { | 101 void BitmapTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { |
| 103 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::ScheduleTasks"); | 102 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::ScheduleTasks"); |
| 104 | 103 |
| 105 ScheduleTasksOnOriginThread(this, graph); | 104 ScheduleTasksOnOriginThread(graph); |
| 106 task_graph_runner_->ScheduleTasks(namespace_token_, graph); | 105 task_graph_runner_->ScheduleTasks(namespace_token_, graph); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void BitmapTileTaskWorkerPool::CheckForCompletedTasks() { | 108 void BitmapTileTaskWorkerPool::CheckForCompletedTasks() { |
| 110 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::CheckForCompletedTasks"); | 109 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::CheckForCompletedTasks"); |
| 111 | 110 |
| 112 task_graph_runner_->CollectCompletedTasks(namespace_token_, | 111 task_graph_runner_->CollectCompletedTasks(namespace_token_, |
| 113 &completed_tasks_); | 112 &completed_tasks_); |
| 114 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | 113 for (Task::Vector::const_iterator it = completed_tasks_.begin(); |
| 115 it != completed_tasks_.end(); ++it) { | 114 it != completed_tasks_.end(); ++it) { |
| 116 TileTask* task = static_cast<TileTask*>(it->get()); | 115 Task* task = it->get(); |
| 117 | 116 |
| 118 task->WillComplete(); | 117 task->WillComplete(); |
| 119 task->CompleteOnOriginThread(this); | 118 task->CompleteOnOriginThread(); |
| 120 task->DidComplete(); | 119 task->DidComplete(); |
| 121 } | 120 } |
| 122 completed_tasks_.clear(); | 121 completed_tasks_.clear(); |
| 123 } | 122 } |
| 124 | 123 |
| 125 ResourceFormat BitmapTileTaskWorkerPool::GetResourceFormat( | 124 ResourceFormat BitmapTileTaskWorkerPool::GetResourceFormat( |
| 126 bool must_support_alpha) const { | 125 bool must_support_alpha) const { |
| 127 return resource_provider_->best_texture_format(); | 126 return resource_provider_->best_texture_format(); |
| 128 } | 127 } |
| 129 | 128 |
| 130 bool BitmapTileTaskWorkerPool::GetResourceRequiresSwizzle( | 129 bool BitmapTileTaskWorkerPool::GetResourceRequiresSwizzle( |
| 131 bool must_support_alpha) const { | 130 bool must_support_alpha) const { |
| 132 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | 131 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); |
| 133 } | 132 } |
| 134 | 133 |
| 135 scoped_ptr<RasterBuffer> BitmapTileTaskWorkerPool::AcquireBufferForRaster( | 134 scoped_ptr<RasterBuffer> BitmapTileTaskWorkerPool::AcquireBufferForRaster( |
| 136 const Resource* resource, | 135 const Resource* resource, |
| 137 uint64_t resource_content_id, | 136 uint64_t resource_content_id, |
| 138 uint64_t previous_content_id) { | 137 uint64_t previous_content_id) { |
| 139 return scoped_ptr<RasterBuffer>(new RasterBufferImpl( | 138 return scoped_ptr<RasterBuffer>(new RasterBufferImpl( |
| 140 resource_provider_, resource, resource_content_id, previous_content_id)); | 139 resource_provider_, resource, resource_content_id, previous_content_id)); |
| 141 } | 140 } |
| 142 | 141 |
| 143 void BitmapTileTaskWorkerPool::ReleaseBufferForRaster( | 142 void BitmapTileTaskWorkerPool::ReleaseBufferForRaster( |
| 144 scoped_ptr<RasterBuffer> buffer) { | 143 scoped_ptr<RasterBuffer> buffer) { |
| 145 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 144 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
| 146 } | 145 } |
| 147 | 146 |
| 148 } // namespace cc | 147 } // namespace cc |
| OLD | NEW |