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/one_copy_tile_task_worker_pool.h" | 5 #include "cc/raster/one_copy_tile_task_worker_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "base/trace_event/trace_event_argument.h" | 12 #include "base/trace_event/trace_event_argument.h" |
13 #include "cc/base/math_util.h" | 13 #include "cc/base/math_util.h" |
14 #include "cc/debug/traced_value.h" | 14 #include "cc/debug/traced_value.h" |
15 #include "cc/raster/raster_buffer.h" | 15 #include "cc/raster/raster_buffer.h" |
| 16 #include "cc/resources/platform_color.h" |
16 #include "cc/resources/resource_pool.h" | 17 #include "cc/resources/resource_pool.h" |
17 #include "cc/resources/scoped_resource.h" | 18 #include "cc/resources/scoped_resource.h" |
18 #include "gpu/command_buffer/client/gles2_interface.h" | 19 #include "gpu/command_buffer/client/gles2_interface.h" |
19 #include "ui/gfx/gpu_memory_buffer.h" | 20 #include "ui/gfx/gpu_memory_buffer.h" |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
22 namespace { | 23 namespace { |
23 | 24 |
24 class RasterBufferImpl : public RasterBuffer { | 25 class RasterBufferImpl : public RasterBuffer { |
25 public: | 26 public: |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 289 |
289 task->WillComplete(); | 290 task->WillComplete(); |
290 task->CompleteOnOriginThread(this); | 291 task->CompleteOnOriginThread(this); |
291 task->DidComplete(); | 292 task->DidComplete(); |
292 | 293 |
293 task->RunReplyOnOriginThread(); | 294 task->RunReplyOnOriginThread(); |
294 } | 295 } |
295 completed_tasks_.clear(); | 296 completed_tasks_.clear(); |
296 } | 297 } |
297 | 298 |
298 ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat() { | 299 ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat() const { |
299 return resource_provider_->best_texture_format(); | 300 return resource_provider_->best_texture_format(); |
300 } | 301 } |
301 | 302 |
| 303 bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle() const { |
| 304 return !PlatformColor::SameComponentOrder(GetResourceFormat()); |
| 305 } |
| 306 |
302 scoped_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster( | 307 scoped_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster( |
303 const Resource* resource, | 308 const Resource* resource, |
304 uint64_t resource_content_id, | 309 uint64_t resource_content_id, |
305 uint64_t previous_content_id) { | 310 uint64_t previous_content_id) { |
306 // TODO(danakj): If resource_content_id != 0, we only need to copy/upload | 311 // TODO(danakj): If resource_content_id != 0, we only need to copy/upload |
307 // the dirty rect. | 312 // the dirty rect. |
308 DCHECK_EQ(resource->format(), resource_provider_->best_texture_format()); | 313 DCHECK_EQ(resource->format(), resource_provider_->best_texture_format()); |
309 return make_scoped_ptr<RasterBuffer>( | 314 return make_scoped_ptr<RasterBuffer>( |
310 new RasterBufferImpl(this, resource_provider_, resource_pool_, | 315 new RasterBufferImpl(this, resource_provider_, resource_pool_, |
311 resource_provider_->best_texture_format(), resource, | 316 resource_provider_->best_texture_format(), resource, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 "pending_copy_count", | 581 "pending_copy_count", |
577 static_cast<int>(resource_pool_->total_resource_count() - | 582 static_cast<int>(resource_pool_->total_resource_count() - |
578 resource_pool_->acquired_resource_count())); | 583 resource_pool_->acquired_resource_count())); |
579 staging_state->SetInteger( | 584 staging_state->SetInteger( |
580 "bytes_pending_copy", | 585 "bytes_pending_copy", |
581 static_cast<int>(resource_pool_->total_memory_usage_bytes() - | 586 static_cast<int>(resource_pool_->total_memory_usage_bytes() - |
582 resource_pool_->acquired_memory_usage_bytes())); | 587 resource_pool_->acquired_memory_usage_bytes())); |
583 } | 588 } |
584 | 589 |
585 } // namespace cc | 590 } // namespace cc |
OLD | NEW |