Chromium Code Reviews

Side by Side Diff: cc/resources/pixel_buffer_raster_worker_pool.cc

Issue 454843002: cc: Do bitmap conversion for RasterBuffer in the worker thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code refactoring. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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/resources/pixel_buffer_raster_worker_pool.h" 5 #include "cc/resources/pixel_buffer_raster_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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 249 matching lines...)
260 } 260 }
261 completed_raster_tasks_.clear(); 261 completed_raster_tasks_.clear();
262 } 262 }
263 263
264 RasterBuffer* PixelBufferRasterWorkerPool::AcquireBufferForRaster( 264 RasterBuffer* PixelBufferRasterWorkerPool::AcquireBufferForRaster(
265 RasterTask* task) { 265 RasterTask* task) {
266 DCHECK(std::find_if(raster_task_states_.begin(), 266 DCHECK(std::find_if(raster_task_states_.begin(),
267 raster_task_states_.end(), 267 raster_task_states_.end(),
268 RasterTaskState::TaskComparator(task)) != 268 RasterTaskState::TaskComparator(task)) !=
269 raster_task_states_.end()); 269 raster_task_states_.end());
270 resource_provider_->AcquirePixelRasterBuffer(task->resource()->id()); 270 return resource_provider_->AcquirePixelRasterBuffer(task->resource()->id());
271 return resource_provider_->MapPixelRasterBuffer(task->resource()->id());
272 } 271 }
273 272
274 void PixelBufferRasterWorkerPool::ReleaseBufferForRaster(RasterTask* task) { 273 void PixelBufferRasterWorkerPool::ReleaseBufferForRaster(RasterTask* task) {
275 DCHECK(std::find_if(raster_task_states_.begin(), 274 DCHECK(std::find_if(raster_task_states_.begin(),
276 raster_task_states_.end(), 275 raster_task_states_.end(),
277 RasterTaskState::TaskComparator(task)) != 276 RasterTaskState::TaskComparator(task)) !=
278 raster_task_states_.end()); 277 raster_task_states_.end());
279 resource_provider_->ReleasePixelRasterBuffer(task->resource()->id()); 278 resource_provider_->ReleasePixelRasterBuffer(task->resource()->id());
280 } 279 }
281 280
(...skipping 394 matching lines...)
676 675
677 RasterTaskState::Vector::iterator state_it = 676 RasterTaskState::Vector::iterator state_it =
678 std::find_if(raster_task_states_.begin(), 677 std::find_if(raster_task_states_.begin(),
679 raster_task_states_.end(), 678 raster_task_states_.end(),
680 RasterTaskState::TaskComparator(raster_task)); 679 RasterTaskState::TaskComparator(raster_task));
681 DCHECK(state_it != raster_task_states_.end()); 680 DCHECK(state_it != raster_task_states_.end());
682 681
683 RasterTaskState& state = *state_it; 682 RasterTaskState& state = *state_it;
684 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type); 683 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type);
685 684
686 // Balanced with MapPixelRasterBuffer() call in AcquireBufferForRaster().
687 bool content_has_changed = resource_provider_->UnmapPixelRasterBuffer(
688 raster_task->resource()->id());
689
690 // |content_has_changed| can be false as result of task being canceled or 685 // |content_has_changed| can be false as result of task being canceled or
691 // task implementation deciding not to modify bitmap (ie. analysis of raster 686 // task implementation deciding not to modify bitmap (ie. analysis of raster
692 // commands detected content as a solid color). 687 // commands detected content as a solid color).
693 if (!content_has_changed) { 688 if (!raster_task->content_has_changed()) {
reveman 2014/08/13 19:19:49 Let's keep things simple and remove all this condi
auygun 2014/08/14 10:35:42 Unittests assume that BeginSetPixels always upload
reveman 2014/08/14 12:26:36 Can we instead fix the unit tests and have PixelBu
auygun 2014/08/15 09:20:40 Done.
694 raster_task->WillComplete(); 689 raster_task->WillComplete();
695 raster_task->CompleteOnOriginThread(this); 690 raster_task->CompleteOnOriginThread(this);
696 raster_task->DidComplete(); 691 raster_task->DidComplete();
697 692
698 if (!raster_task->HasFinishedRunning()) { 693 if (!raster_task->HasFinishedRunning()) {
699 // When priorites change, a raster task can be canceled as a result of 694 // When priorites change, a raster task can be canceled as a result of
700 // no longer being of high enough priority to fit in our throttled 695 // no longer being of high enough priority to fit in our throttled
701 // raster task budget. The task has not yet completed in this case. 696 // raster task budget. The task has not yet completed in this case.
702 RasterTaskQueue::Item::Vector::const_iterator item_it = 697 RasterTaskQueue::Item::Vector::const_iterator item_it =
703 std::find_if(raster_tasks_.items.begin(), 698 std::find_if(raster_tasks_.items.begin(),
(...skipping 48 matching lines...)
752 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( 747 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto(
753 base::debug::TracedValue* throttle_state) const { 748 base::debug::TracedValue* throttle_state) const {
754 throttle_state->SetInteger("bytes_available_for_upload", 749 throttle_state->SetInteger("bytes_available_for_upload",
755 max_bytes_pending_upload_ - bytes_pending_upload_); 750 max_bytes_pending_upload_ - bytes_pending_upload_);
756 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 751 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
757 throttle_state->SetInteger("scheduled_raster_task_count", 752 throttle_state->SetInteger("scheduled_raster_task_count",
758 scheduled_raster_task_count_); 753 scheduled_raster_task_count_);
759 } 754 }
760 755
761 } // namespace cc 756 } // namespace cc
OLDNEW

Powered by Google App Engine