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

Side by Side Diff: cc/resources/one_copy_tile_task_worker_pool.cc

Issue 860813002: Remove the default format from ResourcePool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error in perftest. Created 5 years, 11 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 unified diff | Download patch
OLDNEW
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/resources/one_copy_tile_task_worker_pool.h" 5 #include "cc/resources/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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/debug/trace_event_argument.h" 11 #include "base/debug/trace_event_argument.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "cc/debug/traced_value.h" 13 #include "cc/debug/traced_value.h"
14 #include "cc/resources/raster_buffer.h" 14 #include "cc/resources/raster_buffer.h"
15 #include "cc/resources/resource_pool.h" 15 #include "cc/resources/resource_pool.h"
16 #include "cc/resources/scoped_resource.h" 16 #include "cc/resources/scoped_resource.h"
17 #include "gpu/command_buffer/client/gles2_interface.h" 17 #include "gpu/command_buffer/client/gles2_interface.h"
18 #include "ui/gfx/gpu_memory_buffer.h" 18 #include "ui/gfx/gpu_memory_buffer.h"
19 19
20 namespace cc { 20 namespace cc {
21 namespace { 21 namespace {
22 22
23 class RasterBufferImpl : public RasterBuffer { 23 class RasterBufferImpl : public RasterBuffer {
24 public: 24 public:
25 RasterBufferImpl(OneCopyTileTaskWorkerPool* worker_pool, 25 RasterBufferImpl(OneCopyTileTaskWorkerPool* worker_pool,
26 ResourceProvider* resource_provider, 26 ResourceProvider* resource_provider,
27 ResourcePool* resource_pool, 27 ResourcePool* resource_pool,
28 ResourceFormat resource_format,
28 const Resource* resource) 29 const Resource* resource)
29 : worker_pool_(worker_pool), 30 : worker_pool_(worker_pool),
30 resource_provider_(resource_provider), 31 resource_provider_(resource_provider),
31 resource_pool_(resource_pool), 32 resource_pool_(resource_pool),
32 resource_(resource), 33 resource_(resource),
33 raster_resource_( 34 raster_resource_(
34 resource_pool->AcquireResource(resource->size(), 35 resource_pool->AcquireResource(resource->size(), resource_format)),
35 resource_pool->default_format())),
36 lock_(new ResourceProvider::ScopedWriteLockGpuMemoryBuffer( 36 lock_(new ResourceProvider::ScopedWriteLockGpuMemoryBuffer(
37 resource_provider_, 37 resource_provider_,
38 raster_resource_->id())), 38 raster_resource_->id())),
39 sequence_(0) {} 39 sequence_(0) {}
40 40
41 ~RasterBufferImpl() override { 41 ~RasterBufferImpl() override {
42 // Release write lock in case a copy was never scheduled. 42 // Release write lock in case a copy was never scheduled.
43 lock_.reset(); 43 lock_.reset();
44 44
45 // Make sure any scheduled copy operations are issued before we release the 45 // Make sure any scheduled copy operations are issued before we release the
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 lock_(), 128 lock_(),
129 copy_operation_count_cv_(&lock_), 129 copy_operation_count_cv_(&lock_),
130 scheduled_copy_operation_count_(0), 130 scheduled_copy_operation_count_(0),
131 issued_copy_operation_count_(0), 131 issued_copy_operation_count_(0),
132 next_copy_operation_sequence_(1), 132 next_copy_operation_sequence_(1),
133 check_for_completed_copy_operations_pending_(false), 133 check_for_completed_copy_operations_pending_(false),
134 shutdown_(false), 134 shutdown_(false),
135 weak_ptr_factory_(this), 135 weak_ptr_factory_(this),
136 task_set_finished_weak_ptr_factory_(this) { 136 task_set_finished_weak_ptr_factory_(this) {
137 DCHECK(context_provider_); 137 DCHECK(context_provider_);
138 DCHECK(resource_provider_);
139 resource_format_ = resource_provider_->best_texture_format();
138 } 140 }
139 141
140 OneCopyTileTaskWorkerPool::~OneCopyTileTaskWorkerPool() { 142 OneCopyTileTaskWorkerPool::~OneCopyTileTaskWorkerPool() {
141 DCHECK_EQ(scheduled_copy_operation_count_, 0u); 143 DCHECK_EQ(scheduled_copy_operation_count_, 0u);
142 } 144 }
143 145
144 TileTaskRunner* OneCopyTileTaskWorkerPool::AsTileTaskRunner() { 146 TileTaskRunner* OneCopyTileTaskWorkerPool::AsTileTaskRunner() {
145 return this; 147 return this;
146 } 148 }
147 149
150 ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat() {
151 return resource_format_;
152 }
153
148 void OneCopyTileTaskWorkerPool::SetClient(TileTaskRunnerClient* client) { 154 void OneCopyTileTaskWorkerPool::SetClient(TileTaskRunnerClient* client) {
149 client_ = client; 155 client_ = client;
150 } 156 }
151 157
152 void OneCopyTileTaskWorkerPool::Shutdown() { 158 void OneCopyTileTaskWorkerPool::Shutdown() {
153 TRACE_EVENT0("cc", "OneCopyTileTaskWorkerPool::Shutdown"); 159 TRACE_EVENT0("cc", "OneCopyTileTaskWorkerPool::Shutdown");
154 160
155 { 161 {
156 base::AutoLock lock(lock_); 162 base::AutoLock lock(lock_);
157 163
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 task->CompleteOnOriginThread(this); 250 task->CompleteOnOriginThread(this);
245 task->DidComplete(); 251 task->DidComplete();
246 252
247 task->RunReplyOnOriginThread(); 253 task->RunReplyOnOriginThread();
248 } 254 }
249 completed_tasks_.clear(); 255 completed_tasks_.clear();
250 } 256 }
251 257
252 scoped_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster( 258 scoped_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster(
253 const Resource* resource) { 259 const Resource* resource) {
254 DCHECK_EQ(resource->format(), resource_pool_->default_format()); 260 DCHECK_EQ(resource->format(), resource_format_);
255 return make_scoped_ptr<RasterBuffer>( 261 return make_scoped_ptr<RasterBuffer>(
256 new RasterBufferImpl(this, resource_provider_, resource_pool_, resource)); 262 new RasterBufferImpl(this, resource_provider_, resource_pool_,
263 resource_format_, resource));
257 } 264 }
258 265
259 void OneCopyTileTaskWorkerPool::ReleaseBufferForRaster( 266 void OneCopyTileTaskWorkerPool::ReleaseBufferForRaster(
260 scoped_ptr<RasterBuffer> buffer) { 267 scoped_ptr<RasterBuffer> buffer) {
261 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. 268 // Nothing to do here. RasterBufferImpl destructor cleans up after itself.
262 } 269 }
263 270
264 CopySequenceNumber 271 CopySequenceNumber
265 OneCopyTileTaskWorkerPool::PlaybackAndScheduleCopyOnWorkerThread( 272 OneCopyTileTaskWorkerPool::PlaybackAndScheduleCopyOnWorkerThread(
266 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> write_lock, 273 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> write_lock,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 resource_pool_->total_memory_usage_bytes()); 491 resource_pool_->total_memory_usage_bytes());
485 staging_state->SetInteger("pending_copy_count", 492 staging_state->SetInteger("pending_copy_count",
486 resource_pool_->total_resource_count() - 493 resource_pool_->total_resource_count() -
487 resource_pool_->acquired_resource_count()); 494 resource_pool_->acquired_resource_count());
488 staging_state->SetInteger("bytes_pending_copy", 495 staging_state->SetInteger("bytes_pending_copy",
489 resource_pool_->total_memory_usage_bytes() - 496 resource_pool_->total_memory_usage_bytes() -
490 resource_pool_->acquired_memory_usage_bytes()); 497 resource_pool_->acquired_memory_usage_bytes());
491 } 498 }
492 499
493 } // namespace cc 500 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698