| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/zero_copy_tile_task_worker_pool.h" | 5 #include "cc/raster/zero_copy_tile_task_worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); | 58 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 // static | 63 // static |
| 64 scoped_ptr<TileTaskWorkerPool> ZeroCopyTileTaskWorkerPool::Create( | 64 scoped_ptr<TileTaskWorkerPool> ZeroCopyTileTaskWorkerPool::Create( |
| 65 base::SequencedTaskRunner* task_runner, | 65 base::SequencedTaskRunner* task_runner, |
| 66 TaskGraphRunner* task_graph_runner, | 66 TaskGraphRunner* task_graph_runner, |
| 67 ResourceProvider* resource_provider, | 67 ResourceProvider* resource_provider, |
| 68 bool use_rgba_4444_texture_format) { | 68 ResourceFormat memory_efficient_format, |
| 69 ResourceFormat memory_efficient_format_with_alpha) { |
| 69 return make_scoped_ptr<TileTaskWorkerPool>(new ZeroCopyTileTaskWorkerPool( | 70 return make_scoped_ptr<TileTaskWorkerPool>(new ZeroCopyTileTaskWorkerPool( |
| 70 task_runner, task_graph_runner, resource_provider, | 71 task_runner, task_graph_runner, resource_provider, |
| 71 use_rgba_4444_texture_format)); | 72 memory_efficient_format, memory_efficient_format_with_alpha)); |
| 72 } | 73 } |
| 73 | 74 |
| 74 ZeroCopyTileTaskWorkerPool::ZeroCopyTileTaskWorkerPool( | 75 ZeroCopyTileTaskWorkerPool::ZeroCopyTileTaskWorkerPool( |
| 75 base::SequencedTaskRunner* task_runner, | 76 base::SequencedTaskRunner* task_runner, |
| 76 TaskGraphRunner* task_graph_runner, | 77 TaskGraphRunner* task_graph_runner, |
| 77 ResourceProvider* resource_provider, | 78 ResourceProvider* resource_provider, |
| 78 bool use_rgba_4444_texture_format) | 79 ResourceFormat memory_efficient_format, |
| 80 ResourceFormat memory_efficient_format_with_alpha) |
| 79 : task_runner_(task_runner), | 81 : task_runner_(task_runner), |
| 80 task_graph_runner_(task_graph_runner), | 82 task_graph_runner_(task_graph_runner), |
| 81 namespace_token_(task_graph_runner->GetNamespaceToken()), | 83 namespace_token_(task_graph_runner->GetNamespaceToken()), |
| 82 resource_provider_(resource_provider), | 84 resource_provider_(resource_provider), |
| 83 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), | 85 memory_efficient_format_(memory_efficient_format), |
| 86 memory_efficient_format_with_alpha_(memory_efficient_format_with_alpha), |
| 84 task_set_finished_weak_ptr_factory_(this) {} | 87 task_set_finished_weak_ptr_factory_(this) {} |
| 85 | 88 |
| 86 ZeroCopyTileTaskWorkerPool::~ZeroCopyTileTaskWorkerPool() { | 89 ZeroCopyTileTaskWorkerPool::~ZeroCopyTileTaskWorkerPool() { |
| 87 } | 90 } |
| 88 | 91 |
| 89 TileTaskRunner* ZeroCopyTileTaskWorkerPool::AsTileTaskRunner() { | 92 TileTaskRunner* ZeroCopyTileTaskWorkerPool::AsTileTaskRunner() { |
| 90 return this; | 93 return this; |
| 91 } | 94 } |
| 92 | 95 |
| 93 void ZeroCopyTileTaskWorkerPool::SetClient(TileTaskRunnerClient* client) { | 96 void ZeroCopyTileTaskWorkerPool::SetClient(TileTaskRunnerClient* client) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 179 |
| 177 task->WillComplete(); | 180 task->WillComplete(); |
| 178 task->CompleteOnOriginThread(this); | 181 task->CompleteOnOriginThread(this); |
| 179 task->DidComplete(); | 182 task->DidComplete(); |
| 180 } | 183 } |
| 181 completed_tasks_.clear(); | 184 completed_tasks_.clear(); |
| 182 } | 185 } |
| 183 | 186 |
| 184 ResourceFormat ZeroCopyTileTaskWorkerPool::GetResourceFormat( | 187 ResourceFormat ZeroCopyTileTaskWorkerPool::GetResourceFormat( |
| 185 bool must_support_alpha) const { | 188 bool must_support_alpha) const { |
| 186 return use_rgba_4444_texture_format_ | 189 if (memory_efficient_format_with_alpha_ != RGBA_8888 && must_support_alpha) |
| 187 ? RGBA_4444 | 190 return memory_efficient_format_with_alpha_; |
| 188 : resource_provider_->best_texture_format(); | 191 |
| 192 if (memory_efficient_format_ != RGBA_8888 && !must_support_alpha) |
| 193 return memory_efficient_format_; |
| 194 |
| 195 return resource_provider_->best_texture_format(); |
| 189 } | 196 } |
| 190 | 197 |
| 191 bool ZeroCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( | 198 bool ZeroCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( |
| 192 bool must_support_alpha) const { | 199 bool must_support_alpha) const { |
| 193 return !PlatformColor::SameComponentOrder( | 200 return !PlatformColor::SameComponentOrder( |
| 194 GetResourceFormat(must_support_alpha)); | 201 GetResourceFormat(must_support_alpha)); |
| 195 } | 202 } |
| 196 | 203 |
| 197 scoped_ptr<RasterBuffer> ZeroCopyTileTaskWorkerPool::AcquireBufferForRaster( | 204 scoped_ptr<RasterBuffer> ZeroCopyTileTaskWorkerPool::AcquireBufferForRaster( |
| 198 const Resource* resource, | 205 const Resource* resource, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 228 new base::trace_event::TracedValue(); | 235 new base::trace_event::TracedValue(); |
| 229 | 236 |
| 230 state->BeginArray("tasks_pending"); | 237 state->BeginArray("tasks_pending"); |
| 231 for (TaskSet task_set = 0; task_set < kNumberOfTaskSets; ++task_set) | 238 for (TaskSet task_set = 0; task_set < kNumberOfTaskSets; ++task_set) |
| 232 state->AppendBoolean(tasks_pending_[task_set]); | 239 state->AppendBoolean(tasks_pending_[task_set]); |
| 233 state->EndArray(); | 240 state->EndArray(); |
| 234 return state; | 241 return state; |
| 235 } | 242 } |
| 236 | 243 |
| 237 } // namespace cc | 244 } // namespace cc |
| OLD | NEW |