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

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

Issue 1379783002: Allow one-copy task tile worker pool to use compressed textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 // static 170 // static
171 scoped_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create( 171 scoped_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create(
172 base::SequencedTaskRunner* task_runner, 172 base::SequencedTaskRunner* task_runner,
173 TaskGraphRunner* task_graph_runner, 173 TaskGraphRunner* task_graph_runner,
174 ContextProvider* context_provider, 174 ContextProvider* context_provider,
175 ResourceProvider* resource_provider, 175 ResourceProvider* resource_provider,
176 int max_copy_texture_chromium_size, 176 int max_copy_texture_chromium_size,
177 bool use_persistent_gpu_memory_buffers, 177 bool use_persistent_gpu_memory_buffers,
178 int max_staging_buffer_usage_in_bytes, 178 int max_staging_buffer_usage_in_bytes,
179 bool use_rgba_4444_texture_format) { 179 bool use_rgba_4444_texture_format,
180 bool use_compressed_texture_formats) {
180 return make_scoped_ptr<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool( 181 return make_scoped_ptr<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool(
181 task_runner, task_graph_runner, resource_provider, 182 task_runner, task_graph_runner, resource_provider,
182 max_copy_texture_chromium_size, use_persistent_gpu_memory_buffers, 183 max_copy_texture_chromium_size, use_persistent_gpu_memory_buffers,
183 max_staging_buffer_usage_in_bytes, use_rgba_4444_texture_format)); 184 max_staging_buffer_usage_in_bytes, use_rgba_4444_texture_format,
185 use_compressed_texture_formats));
184 } 186 }
185 187
186 OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( 188 OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
187 base::SequencedTaskRunner* task_runner, 189 base::SequencedTaskRunner* task_runner,
188 TaskGraphRunner* task_graph_runner, 190 TaskGraphRunner* task_graph_runner,
189 ResourceProvider* resource_provider, 191 ResourceProvider* resource_provider,
190 int max_copy_texture_chromium_size, 192 int max_copy_texture_chromium_size,
191 bool use_persistent_gpu_memory_buffers, 193 bool use_persistent_gpu_memory_buffers,
192 int max_staging_buffer_usage_in_bytes, 194 int max_staging_buffer_usage_in_bytes,
193 bool use_rgba_4444_texture_format) 195 bool use_rgba_4444_texture_format,
196 bool use_compressed_texture_formats)
194 : task_runner_(task_runner), 197 : task_runner_(task_runner),
195 task_graph_runner_(task_graph_runner), 198 task_graph_runner_(task_graph_runner),
196 namespace_token_(task_graph_runner->GetNamespaceToken()), 199 namespace_token_(task_graph_runner->GetNamespaceToken()),
197 resource_provider_(resource_provider), 200 resource_provider_(resource_provider),
198 max_bytes_per_copy_operation_( 201 max_bytes_per_copy_operation_(
199 max_copy_texture_chromium_size 202 max_copy_texture_chromium_size
200 ? std::min(kMaxBytesPerCopyOperation, 203 ? std::min(kMaxBytesPerCopyOperation,
201 max_copy_texture_chromium_size) 204 max_copy_texture_chromium_size)
202 : kMaxBytesPerCopyOperation), 205 : kMaxBytesPerCopyOperation),
203 use_persistent_gpu_memory_buffers_(use_persistent_gpu_memory_buffers), 206 use_persistent_gpu_memory_buffers_(use_persistent_gpu_memory_buffers),
204 bytes_scheduled_since_last_flush_(0), 207 bytes_scheduled_since_last_flush_(0),
205 max_staging_buffer_usage_in_bytes_(max_staging_buffer_usage_in_bytes), 208 max_staging_buffer_usage_in_bytes_(max_staging_buffer_usage_in_bytes),
206 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), 209 use_rgba_4444_texture_format_(use_rgba_4444_texture_format),
210 use_compressed_texture_formats_(use_compressed_texture_formats),
207 staging_buffer_usage_in_bytes_(0), 211 staging_buffer_usage_in_bytes_(0),
208 free_staging_buffer_usage_in_bytes_(0), 212 free_staging_buffer_usage_in_bytes_(0),
209 staging_buffer_expiration_delay_( 213 staging_buffer_expiration_delay_(
210 base::TimeDelta::FromMilliseconds(kStagingBufferExpirationDelayMs)), 214 base::TimeDelta::FromMilliseconds(kStagingBufferExpirationDelayMs)),
211 reduce_memory_usage_pending_(false), 215 reduce_memory_usage_pending_(false),
212 weak_ptr_factory_(this), 216 weak_ptr_factory_(this),
213 task_set_finished_weak_ptr_factory_(this) { 217 task_set_finished_weak_ptr_factory_(this) {
214 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 218 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
215 this, base::ThreadTaskRunnerHandle::Get()); 219 this, base::ThreadTaskRunnerHandle::Get());
216 reduce_memory_usage_callback_ = 220 reduce_memory_usage_callback_ =
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 334
331 task->WillComplete(); 335 task->WillComplete();
332 task->CompleteOnOriginThread(this); 336 task->CompleteOnOriginThread(this);
333 task->DidComplete(); 337 task->DidComplete();
334 } 338 }
335 completed_tasks_.clear(); 339 completed_tasks_.clear();
336 } 340 }
337 341
338 ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat( 342 ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat(
339 bool must_support_alpha) const { 343 bool must_support_alpha) const {
344 if (use_compressed_texture_formats_ && !must_support_alpha)
345 return ETC1;
reveman 2015/09/30 09:55:15 Can we include zero-copy support in this patch too
christiank 2015/11/26 15:35:35 Sure!
346
340 return use_rgba_4444_texture_format_ 347 return use_rgba_4444_texture_format_
341 ? RGBA_4444 348 ? RGBA_4444
342 : resource_provider_->best_texture_format(); 349 : resource_provider_->best_texture_format();
343 } 350 }
344 351
345 bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( 352 bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle(
346 bool must_support_alpha) const { 353 bool must_support_alpha) const {
347 return !PlatformColor::SameComponentOrder( 354 return !PlatformColor::SameComponentOrder(
348 GetResourceFormat(must_support_alpha)); 355 GetResourceFormat(must_support_alpha));
349 } 356 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); 495 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row);
489 // Align chunk size to 4. Required to support compressed texture formats. 496 // Align chunk size to 4. Required to support compressed texture formats.
490 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); 497 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4);
491 int y = 0; 498 int y = 0;
492 int height = resource->size().height(); 499 int height = resource->size().height();
493 while (y < height) { 500 while (y < height) {
494 // Copy at most |chunk_size_in_rows|. 501 // Copy at most |chunk_size_in_rows|.
495 int rows_to_copy = std::min(chunk_size_in_rows, height - y); 502 int rows_to_copy = std::min(chunk_size_in_rows, height - y);
496 DCHECK_GT(rows_to_copy, 0); 503 DCHECK_GT(rows_to_copy, 0);
497 504
498 gl->CopySubTextureCHROMIUM(GL_TEXTURE_2D, staging_buffer->texture_id, 505 if (IsResourceFormatCompressed(resource->format())) {
499 resource_lock->texture_id(), 0, y, 0, y, 506 // TODO(christiank): Should use CompressedCopySubTextureCHROMIUM.
christiank 2015/09/30 07:49:42 reveman (cited from 1197423003): "Let's fix this T
reveman 2015/09/30 09:55:15 ResourceProvider::LazyAllocate seem wrong. If it c
christiank 2015/11/26 15:35:35 Actually these are two different Resource classes.
reveman 2015/11/27 16:46:49 Ok, I think it's fine to make the use of SubCopy c
christiank 2015/11/30 15:41:08 Ahh good, that'll be better. Fixed now.
500 resource->size().width(), rows_to_copy, false, 507 gl->CompressedCopyTextureCHROMIUM(GL_TEXTURE_2D,
501 false, false); 508 staging_buffer->texture_id,
509 resource_lock->texture_id());
510 } else {
511 gl->CopySubTextureCHROMIUM(GL_TEXTURE_2D, staging_buffer->texture_id,
512 resource_lock->texture_id(), 0, y, 0, y,
513 resource->size().width(), rows_to_copy,
514 false, false, false);
515 }
502 y += rows_to_copy; 516 y += rows_to_copy;
503 517
504 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory 518 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory
505 // used for this copy operation. 519 // used for this copy operation.
506 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; 520 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row;
507 521
508 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) { 522 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) {
509 gl->ShallowFlushCHROMIUM(); 523 gl->ShallowFlushCHROMIUM();
510 bytes_scheduled_since_last_flush_ = 0; 524 bytes_scheduled_since_last_flush_ = 0;
511 } 525 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 825
812 staging_state->SetInteger("staging_buffer_count", 826 staging_state->SetInteger("staging_buffer_count",
813 static_cast<int>(buffers_.size())); 827 static_cast<int>(buffers_.size()));
814 staging_state->SetInteger("busy_count", 828 staging_state->SetInteger("busy_count",
815 static_cast<int>(busy_buffers_.size())); 829 static_cast<int>(busy_buffers_.size()));
816 staging_state->SetInteger("free_count", 830 staging_state->SetInteger("free_count",
817 static_cast<int>(free_buffers_.size())); 831 static_cast<int>(free_buffers_.size()));
818 } 832 }
819 833
820 } // namespace cc 834 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698