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

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

Issue 1266103005: cc: Handle overflow/underflow in MathUtil::RoundUp/RoundDown functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small nit. Created 5 years, 4 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
« no previous file with comments | « cc/playback/pixel_ref_map.cc ('k') | cc/resources/resource_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 base::AutoLock lock(lock_); 360 base::AutoLock lock(lock_);
361 361
362 CopySequenceNumber sequence = 0; 362 CopySequenceNumber sequence = 0;
363 int bytes_per_row = (BitsPerPixel(raster_resource->format()) * 363 int bytes_per_row = (BitsPerPixel(raster_resource->format()) *
364 raster_resource->size().width()) / 364 raster_resource->size().width()) /
365 8; 365 8;
366 int chunk_size_in_rows = 366 int chunk_size_in_rows =
367 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); 367 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row);
368 // Align chunk size to 4. Required to support compressed texture formats. 368 // Align chunk size to 4. Required to support compressed texture formats.
369 chunk_size_in_rows = MathUtil::RoundUp(chunk_size_in_rows, 4); 369 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4);
370 int y = 0; 370 int y = 0;
371 int height = raster_resource->size().height(); 371 int height = raster_resource->size().height();
372 while (y < height) { 372 while (y < height) {
373 int failed_attempts = 0; 373 int failed_attempts = 0;
374 while ((pending_copy_operations_.size() + issued_copy_operation_count_) >= 374 while ((pending_copy_operations_.size() + issued_copy_operation_count_) >=
375 kMaxCopyOperations) { 375 kMaxCopyOperations) {
376 // Ignore limit when shutdown is set. 376 // Ignore limit when shutdown is set.
377 if (shutdown_) 377 if (shutdown_)
378 break; 378 break;
379 379
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 "pending_copy_count", 581 "pending_copy_count",
582 static_cast<int>(resource_pool_->total_resource_count() - 582 static_cast<int>(resource_pool_->total_resource_count() -
583 resource_pool_->acquired_resource_count())); 583 resource_pool_->acquired_resource_count()));
584 staging_state->SetInteger( 584 staging_state->SetInteger(
585 "bytes_pending_copy", 585 "bytes_pending_copy",
586 static_cast<int>(resource_pool_->total_memory_usage_bytes() - 586 static_cast<int>(resource_pool_->total_memory_usage_bytes() -
587 resource_pool_->acquired_memory_usage_bytes())); 587 resource_pool_->acquired_memory_usage_bytes()));
588 } 588 }
589 589
590 } // namespace cc 590 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/pixel_ref_map.cc ('k') | cc/resources/resource_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698