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/resources/one_copy_raster_worker_pool.h" | 5 #include "cc/resources/one_copy_raster_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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Return raster resource to pool so it can be used by another RasterBuffer | 48 // Return raster resource to pool so it can be used by another RasterBuffer |
49 // instance. | 49 // instance. |
50 if (raster_resource_) | 50 if (raster_resource_) |
51 resource_pool_->ReleaseResource(raster_resource_.Pass()); | 51 resource_pool_->ReleaseResource(raster_resource_.Pass()); |
52 } | 52 } |
53 | 53 |
54 // Overridden from RasterBuffer: | 54 // Overridden from RasterBuffer: |
55 void Playback(const RasterSource* raster_source, | 55 void Playback(const RasterSource* raster_source, |
56 const gfx::Rect& rect, | 56 const gfx::Rect& rect, |
57 float scale, | 57 float scale) override { |
58 RenderingStatsInstrumentation* stats) override { | |
59 sequence_ = worker_pool_->PlaybackAndScheduleCopyOnWorkerThread( | 58 sequence_ = worker_pool_->PlaybackAndScheduleCopyOnWorkerThread( |
60 lock_.Pass(), | 59 lock_.Pass(), raster_resource_.Pass(), resource_, raster_source, rect, |
61 raster_resource_.Pass(), | 60 scale); |
62 resource_, | |
63 raster_source, | |
64 rect, | |
65 scale, | |
66 stats); | |
67 } | 61 } |
68 | 62 |
69 private: | 63 private: |
70 OneCopyRasterWorkerPool* worker_pool_; | 64 OneCopyRasterWorkerPool* worker_pool_; |
71 ResourceProvider* resource_provider_; | 65 ResourceProvider* resource_provider_; |
72 ResourcePool* resource_pool_; | 66 ResourcePool* resource_pool_; |
73 const Resource* resource_; | 67 const Resource* resource_; |
74 scoped_ptr<ScopedResource> raster_resource_; | 68 scoped_ptr<ScopedResource> raster_resource_; |
75 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> lock_; | 69 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> lock_; |
76 CopySequenceNumber sequence_; | 70 CopySequenceNumber sequence_; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 267 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
274 } | 268 } |
275 | 269 |
276 CopySequenceNumber | 270 CopySequenceNumber |
277 OneCopyRasterWorkerPool::PlaybackAndScheduleCopyOnWorkerThread( | 271 OneCopyRasterWorkerPool::PlaybackAndScheduleCopyOnWorkerThread( |
278 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> write_lock, | 272 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> write_lock, |
279 scoped_ptr<ScopedResource> src, | 273 scoped_ptr<ScopedResource> src, |
280 const Resource* dst, | 274 const Resource* dst, |
281 const RasterSource* raster_source, | 275 const RasterSource* raster_source, |
282 const gfx::Rect& rect, | 276 const gfx::Rect& rect, |
283 float scale, | 277 float scale) { |
284 RenderingStatsInstrumentation* stats) { | |
285 CopySequenceNumber sequence; | 278 CopySequenceNumber sequence; |
286 | 279 |
287 { | 280 { |
288 base::AutoLock lock(lock_); | 281 base::AutoLock lock(lock_); |
289 | 282 |
290 int failed_attempts = 0; | 283 int failed_attempts = 0; |
291 while ((scheduled_copy_operation_count_ + issued_copy_operation_count_) >= | 284 while ((scheduled_copy_operation_count_ + issued_copy_operation_count_) >= |
292 kMaxCopyOperations) { | 285 kMaxCopyOperations) { |
293 // Ignore limit when shutdown is set. | 286 // Ignore limit when shutdown is set. |
294 if (shutdown_) | 287 if (shutdown_) |
(...skipping 22 matching lines...) Expand all Loading... |
317 | 310 |
318 // There may be more work available, so wake up another worker thread. | 311 // There may be more work available, so wake up another worker thread. |
319 copy_operation_count_cv_.Signal(); | 312 copy_operation_count_cv_.Signal(); |
320 | 313 |
321 { | 314 { |
322 base::AutoUnlock unlock(lock_); | 315 base::AutoUnlock unlock(lock_); |
323 | 316 |
324 gfx::GpuMemoryBuffer* gpu_memory_buffer = | 317 gfx::GpuMemoryBuffer* gpu_memory_buffer = |
325 write_lock->GetGpuMemoryBuffer(); | 318 write_lock->GetGpuMemoryBuffer(); |
326 if (gpu_memory_buffer) { | 319 if (gpu_memory_buffer) { |
327 RasterWorkerPool::PlaybackToMemory(gpu_memory_buffer->Map(), | 320 RasterWorkerPool::PlaybackToMemory( |
328 src->format(), | 321 gpu_memory_buffer->Map(), src->format(), src->size(), |
329 src->size(), | 322 gpu_memory_buffer->GetStride(), raster_source, rect, scale); |
330 gpu_memory_buffer->GetStride(), | |
331 raster_source, | |
332 rect, | |
333 scale, | |
334 stats); | |
335 gpu_memory_buffer->Unmap(); | 323 gpu_memory_buffer->Unmap(); |
336 } | 324 } |
337 } | 325 } |
338 | 326 |
339 // Acquire a sequence number for this copy operation. | 327 // Acquire a sequence number for this copy operation. |
340 sequence = next_copy_operation_sequence_++; | 328 sequence = next_copy_operation_sequence_++; |
341 | 329 |
342 pending_copy_operations_.push_back( | 330 pending_copy_operations_.push_back( |
343 make_scoped_ptr(new CopyOperation(write_lock.Pass(), src.Pass(), dst))); | 331 make_scoped_ptr(new CopyOperation(write_lock.Pass(), src.Pass(), dst))); |
344 } | 332 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 resource_pool_->total_memory_usage_bytes()); | 498 resource_pool_->total_memory_usage_bytes()); |
511 staging_state->SetInteger("pending_copy_count", | 499 staging_state->SetInteger("pending_copy_count", |
512 resource_pool_->total_resource_count() - | 500 resource_pool_->total_resource_count() - |
513 resource_pool_->acquired_resource_count()); | 501 resource_pool_->acquired_resource_count()); |
514 staging_state->SetInteger("bytes_pending_copy", | 502 staging_state->SetInteger("bytes_pending_copy", |
515 resource_pool_->total_memory_usage_bytes() - | 503 resource_pool_->total_memory_usage_bytes() - |
516 resource_pool_->acquired_memory_usage_bytes()); | 504 resource_pool_->acquired_memory_usage_bytes()); |
517 } | 505 } |
518 | 506 |
519 } // namespace cc | 507 } // namespace cc |
OLD | NEW |