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

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

Issue 1148413007: cc: Use max_bytes_per_copy_operation setting to determine one-copy flush interval. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/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"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 ResourceProvider* resource_provider_; 67 ResourceProvider* resource_provider_;
68 ResourcePool* resource_pool_; 68 ResourcePool* resource_pool_;
69 const Resource* resource_; 69 const Resource* resource_;
70 scoped_ptr<ScopedResource> raster_resource_; 70 scoped_ptr<ScopedResource> raster_resource_;
71 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> lock_; 71 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> lock_;
72 CopySequenceNumber sequence_; 72 CopySequenceNumber sequence_;
73 73
74 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); 74 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
75 }; 75 };
76 76
77 // Flush interval when performing copy operations.
78 const int kCopyFlushPeriod = 4;
79
80 // Number of in-flight copy operations to allow. 77 // Number of in-flight copy operations to allow.
81 const int kMaxCopyOperations = 32; 78 const int kMaxCopyOperations = 32;
82 79
83 // Minimum number of rows per copy operation. 4 or greater is required to 80 // Minimum number of rows per copy operation. 4 or greater is required to
84 // support compressed texture formats. 81 // support compressed texture formats.
85 const size_t kMinRowsPerCopyOperation = 4; 82 const size_t kMinRowsPerCopyOperation = 4;
86 83
87 // Delay been checking for copy operations to complete. 84 // Delay been checking for copy operations to complete.
88 const int kCheckForCompletedCopyOperationsTickRateMs = 1; 85 const int kCheckForCompletedCopyOperationsTickRateMs = 1;
89 86
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 task_graph_runner_(task_graph_runner), 125 task_graph_runner_(task_graph_runner),
129 namespace_token_(task_graph_runner->GetNamespaceToken()), 126 namespace_token_(task_graph_runner->GetNamespaceToken()),
130 context_provider_(context_provider), 127 context_provider_(context_provider),
131 resource_provider_(resource_provider), 128 resource_provider_(resource_provider),
132 resource_pool_(resource_pool), 129 resource_pool_(resource_pool),
133 max_bytes_per_copy_operation_(max_bytes_per_copy_operation), 130 max_bytes_per_copy_operation_(max_bytes_per_copy_operation),
134 last_issued_copy_operation_(0), 131 last_issued_copy_operation_(0),
135 last_flushed_copy_operation_(0), 132 last_flushed_copy_operation_(0),
136 lock_(), 133 lock_(),
137 copy_operation_count_cv_(&lock_), 134 copy_operation_count_cv_(&lock_),
135 bytes_scheduled_since_last_flush_(0),
138 issued_copy_operation_count_(0), 136 issued_copy_operation_count_(0),
139 next_copy_operation_sequence_(1), 137 next_copy_operation_sequence_(1),
140 check_for_completed_copy_operations_pending_(false), 138 check_for_completed_copy_operations_pending_(false),
141 shutdown_(false), 139 shutdown_(false),
142 weak_ptr_factory_(this), 140 weak_ptr_factory_(this),
143 task_set_finished_weak_ptr_factory_(this) { 141 task_set_finished_weak_ptr_factory_(this) {
144 DCHECK(context_provider_); 142 DCHECK(context_provider_);
145 } 143 }
146 144
147 OneCopyTileTaskWorkerPool::~OneCopyTileTaskWorkerPool() { 145 OneCopyTileTaskWorkerPool::~OneCopyTileTaskWorkerPool() {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // released before we can issue a copy. 345 // released before we can issue a copy.
348 pending_copy_operations_.push_back(make_scoped_ptr( 346 pending_copy_operations_.push_back(make_scoped_ptr(
349 new CopyOperation(write_lock.Pass(), src, dst, 347 new CopyOperation(write_lock.Pass(), src, dst,
350 gfx::Rect(0, y, src->size().width(), rows_to_copy)))); 348 gfx::Rect(0, y, src->size().width(), rows_to_copy))));
351 349
352 y += rows_to_copy; 350 y += rows_to_copy;
353 351
354 // Acquire a sequence number for this copy operation. 352 // Acquire a sequence number for this copy operation.
355 sequence = next_copy_operation_sequence_++; 353 sequence = next_copy_operation_sequence_++;
356 354
355 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory
356 // used for this copy operation.
357 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row;
vmpstr 2015/06/01 18:35:52 So for big tiles (that are split up into several c
reveman 2015/06/04 01:19:51 Yup, that's the behavior we want.
358
357 // Post task that will advance last flushed copy operation to |sequence| 359 // Post task that will advance last flushed copy operation to |sequence|
358 // if we have reached the flush period. 360 // when |bytes_scheduled_since_last_flush_| has reached
359 if ((sequence % kCopyFlushPeriod) == 0) { 361 // |max_bytes_per_copy_operation_|.
362 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) {
vmpstr 2015/06/02 23:23:27 I think you need to DCHECK that max_bytes_per_copy
reveman 2015/06/04 01:19:51 A flush here is not required for correct behavior.
360 task_runner_->PostTask( 363 task_runner_->PostTask(
361 FROM_HERE, 364 FROM_HERE,
362 base::Bind(&OneCopyTileTaskWorkerPool::AdvanceLastFlushedCopyTo, 365 base::Bind(&OneCopyTileTaskWorkerPool::AdvanceLastFlushedCopyTo,
363 weak_ptr_factory_.GetWeakPtr(), sequence)); 366 weak_ptr_factory_.GetWeakPtr(), sequence));
367 bytes_scheduled_since_last_flush_ = 0;
364 } 368 }
365 } 369 }
366 370
367 return sequence; 371 return sequence;
368 } 372 }
369 373
370 void OneCopyTileTaskWorkerPool::AdvanceLastIssuedCopyTo( 374 void OneCopyTileTaskWorkerPool::AdvanceLastIssuedCopyTo(
371 CopySequenceNumber sequence) { 375 CopySequenceNumber sequence) {
372 if (last_issued_copy_operation_ >= sequence) 376 if (last_issued_copy_operation_ >= sequence)
373 return; 377 return;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 resource_pool_->total_memory_usage_bytes()); 517 resource_pool_->total_memory_usage_bytes());
514 staging_state->SetInteger("pending_copy_count", 518 staging_state->SetInteger("pending_copy_count",
515 resource_pool_->total_resource_count() - 519 resource_pool_->total_resource_count() -
516 resource_pool_->acquired_resource_count()); 520 resource_pool_->acquired_resource_count());
517 staging_state->SetInteger("bytes_pending_copy", 521 staging_state->SetInteger("bytes_pending_copy",
518 resource_pool_->total_memory_usage_bytes() - 522 resource_pool_->total_memory_usage_bytes() -
519 resource_pool_->acquired_memory_usage_bytes()); 523 resource_pool_->acquired_memory_usage_bytes());
520 } 524 }
521 525
522 } // namespace cc 526 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698