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

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

Issue 1154393003: cc: Use CheckedNumeric for resource size calculations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: initialize var 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
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster/tile_task_worker_pool_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/pixel_buffer_tile_task_worker_pool.h" 5 #include "cc/raster/pixel_buffer_tile_task_worker_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/containers/stack_container.h" 9 #include "base/containers/stack_container.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 for (RasterTask::Vector::const_iterator it = 424 for (RasterTask::Vector::const_iterator it =
425 tasks_with_completed_uploads.begin(); 425 tasks_with_completed_uploads.begin();
426 it != tasks_with_completed_uploads.end(); ++it) { 426 it != tasks_with_completed_uploads.end(); ++it) {
427 RasterTask* task = it->get(); 427 RasterTask* task = it->get();
428 RasterTaskState::Vector::iterator state_it = 428 RasterTaskState::Vector::iterator state_it =
429 std::find_if(raster_task_states_.begin(), raster_task_states_.end(), 429 std::find_if(raster_task_states_.begin(), raster_task_states_.end(),
430 RasterTaskState::TaskComparator(task)); 430 RasterTaskState::TaskComparator(task));
431 DCHECK(state_it != raster_task_states_.end()); 431 DCHECK(state_it != raster_task_states_.end());
432 RasterTaskState& state = *state_it; 432 RasterTaskState& state = *state_it;
433 433
434 bytes_pending_upload_ -= task->resource()->bytes(); 434 // We can use UncheckedMemorySizeBytes here, since these tasks come from
435 // tiles, the size of which is controlled by the compositor.
436 bytes_pending_upload_ -= Resource::UncheckedMemorySizeBytes(
437 task->resource()->size(), task->resource()->format());
435 438
436 task->WillComplete(); 439 task->WillComplete();
437 task->CompleteOnOriginThread(this); 440 task->CompleteOnOriginThread(this);
438 task->DidComplete(); 441 task->DidComplete();
439 442
440 DCHECK(std::find(completed_raster_tasks_.begin(), 443 DCHECK(std::find(completed_raster_tasks_.begin(),
441 completed_raster_tasks_.end(), 444 completed_raster_tasks_.end(),
442 task) == completed_raster_tasks_.end()); 445 task) == completed_raster_tasks_.end());
443 completed_raster_tasks_.push_back(task); 446 completed_raster_tasks_.push_back(task);
444 state.type = RasterTaskState::COMPLETED; 447 state.type = RasterTaskState::COMPLETED;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 DCHECK(std::find(completed_raster_tasks_.begin(), 533 DCHECK(std::find(completed_raster_tasks_.begin(),
531 completed_raster_tasks_.end(), 534 completed_raster_tasks_.end(),
532 task) != completed_raster_tasks_.end()); 535 task) != completed_raster_tasks_.end());
533 continue; 536 continue;
534 } 537 }
535 538
536 // All raster tasks need to be throttled by bytes of pending uploads, 539 // All raster tasks need to be throttled by bytes of pending uploads,
537 // but if it's the only task allow it to complete no matter what its size, 540 // but if it's the only task allow it to complete no matter what its size,
538 // to prevent starvation of the task queue. 541 // to prevent starvation of the task queue.
539 size_t new_bytes_pending_upload = bytes_pending_upload; 542 size_t new_bytes_pending_upload = bytes_pending_upload;
540 new_bytes_pending_upload += task->resource()->bytes(); 543 // We can use UncheckedMemorySizeBytes here, since these tasks come from
544 // tiles, the size of which is controlled by the compositor.
545 new_bytes_pending_upload += Resource::UncheckedMemorySizeBytes(
546 task->resource()->size(), task->resource()->format());
541 if (new_bytes_pending_upload > max_bytes_pending_upload_ && 547 if (new_bytes_pending_upload > max_bytes_pending_upload_ &&
542 bytes_pending_upload) { 548 bytes_pending_upload) {
543 did_throttle_raster_tasks |= item.task_sets; 549 did_throttle_raster_tasks |= item.task_sets;
544 continue; 550 continue;
545 } 551 }
546 552
547 // If raster has finished, just update |bytes_pending_upload|. 553 // If raster has finished, just update |bytes_pending_upload|.
548 if (state.type == RasterTaskState::UPLOADING) { 554 if (state.type == RasterTaskState::UPLOADING) {
549 DCHECK(!task->HasCompleted()); 555 DCHECK(!task->HasCompleted());
550 bytes_pending_upload = new_bytes_pending_upload; 556 bytes_pending_upload = new_bytes_pending_upload;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 // Triggers if the current task belongs to a set that should be empty. 700 // Triggers if the current task belongs to a set that should be empty.
695 DCHECK((state.task_sets & ~NonEmptyTaskSetsFromTaskCounts(task_counts_)) 701 DCHECK((state.task_sets & ~NonEmptyTaskSetsFromTaskCounts(task_counts_))
696 .none()); 702 .none());
697 RemoveTaskSetsFromTaskCounts(task_counts_, state.task_sets); 703 RemoveTaskSetsFromTaskCounts(task_counts_, state.task_sets);
698 continue; 704 continue;
699 } 705 }
700 706
701 resource_provider_->BeginSetPixels(raster_task->resource()->id()); 707 resource_provider_->BeginSetPixels(raster_task->resource()->id());
702 has_performed_uploads_since_last_flush_ = true; 708 has_performed_uploads_since_last_flush_ = true;
703 709
704 bytes_pending_upload_ += raster_task->resource()->bytes(); 710 // We can use UncheckedMemorySizeBytes here, since these tasks come from
711 // tiles, the size of which is controlled by the compositor.
712 bytes_pending_upload_ += Resource::UncheckedMemorySizeBytes(
713 raster_task->resource()->size(), raster_task->resource()->format());
705 raster_tasks_with_pending_upload_.push_back(raster_task); 714 raster_tasks_with_pending_upload_.push_back(raster_task);
706 state.type = RasterTaskState::UPLOADING; 715 state.type = RasterTaskState::UPLOADING;
707 } 716 }
708 completed_tasks_.clear(); 717 completed_tasks_.clear();
709 } 718 }
710 719
711 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 720 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
712 PixelBufferTileTaskWorkerPool::StateAsValue() const { 721 PixelBufferTileTaskWorkerPool::StateAsValue() const {
713 scoped_refptr<base::trace_event::TracedValue> state = 722 scoped_refptr<base::trace_event::TracedValue> state =
714 new base::trace_event::TracedValue(); 723 new base::trace_event::TracedValue();
(...skipping 16 matching lines...) Expand all
731 throttle_state->SetInteger( 740 throttle_state->SetInteger(
732 "bytes_available_for_upload", 741 "bytes_available_for_upload",
733 static_cast<int>(max_bytes_pending_upload_ - bytes_pending_upload_)); 742 static_cast<int>(max_bytes_pending_upload_ - bytes_pending_upload_));
734 throttle_state->SetInteger("bytes_pending_upload", 743 throttle_state->SetInteger("bytes_pending_upload",
735 static_cast<int>(bytes_pending_upload_)); 744 static_cast<int>(bytes_pending_upload_));
736 throttle_state->SetInteger("scheduled_raster_task_count", 745 throttle_state->SetInteger("scheduled_raster_task_count",
737 static_cast<int>(scheduled_raster_task_count_)); 746 static_cast<int>(scheduled_raster_task_count_));
738 } 747 }
739 748
740 } // namespace cc 749 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster/tile_task_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698