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

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

Issue 375303002: cc: Refactor ResourceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 6 years, 5 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 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"
11 #include "cc/debug/traced_value.h" 11 #include "cc/debug/traced_value.h"
12 #include "cc/resources/resource.h" 12 #include "cc/resources/resource.h"
13 #include "gpu/command_buffer/client/gles2_interface.h"
14
15 using gpu::gles2::GLES2Interface;
danakj 2014/07/14 15:29:11 not needed?
sohanjg 2014/07/14 15:59:28 Done.
13 16
14 namespace cc { 17 namespace cc {
15 namespace { 18 namespace {
16 19
17 const int kCheckForCompletedRasterTasksDelayMs = 6; 20 const int kCheckForCompletedRasterTasksDelayMs = 6;
18 21
19 const size_t kMaxScheduledRasterTasks = 48; 22 const size_t kMaxScheduledRasterTasks = 48;
20 23
21 typedef base::StackVector<RasterTask*, kMaxScheduledRasterTasks> 24 typedef base::StackVector<RasterTask*, kMaxScheduledRasterTasks>
22 RasterTaskVector; 25 RasterTaskVector;
23 26
24 } // namespace 27 } // namespace
25 28
26 // static 29 // static
27 scoped_ptr<RasterWorkerPool> PixelBufferRasterWorkerPool::Create( 30 scoped_ptr<RasterWorkerPool> PixelBufferRasterWorkerPool::Create(
28 base::SequencedTaskRunner* task_runner, 31 base::SequencedTaskRunner* task_runner,
29 TaskGraphRunner* task_graph_runner, 32 TaskGraphRunner* task_graph_runner,
33 ContextProvider* context_provider,
30 ResourceProvider* resource_provider, 34 ResourceProvider* resource_provider,
31 size_t max_transfer_buffer_usage_bytes) { 35 size_t max_transfer_buffer_usage_bytes) {
32 return make_scoped_ptr<RasterWorkerPool>( 36 return make_scoped_ptr<RasterWorkerPool>(
33 new PixelBufferRasterWorkerPool(task_runner, 37 new PixelBufferRasterWorkerPool(task_runner,
34 task_graph_runner, 38 task_graph_runner,
39 context_provider,
35 resource_provider, 40 resource_provider,
36 max_transfer_buffer_usage_bytes)); 41 max_transfer_buffer_usage_bytes));
37 } 42 }
38 43
39 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( 44 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool(
40 base::SequencedTaskRunner* task_runner, 45 base::SequencedTaskRunner* task_runner,
41 TaskGraphRunner* task_graph_runner, 46 TaskGraphRunner* task_graph_runner,
47 ContextProvider* context_provider,
42 ResourceProvider* resource_provider, 48 ResourceProvider* resource_provider,
43 size_t max_transfer_buffer_usage_bytes) 49 size_t max_transfer_buffer_usage_bytes)
44 : task_runner_(task_runner), 50 : task_runner_(task_runner),
45 task_graph_runner_(task_graph_runner), 51 task_graph_runner_(task_graph_runner),
46 namespace_token_(task_graph_runner->GetNamespaceToken()), 52 namespace_token_(task_graph_runner->GetNamespaceToken()),
53 context_provider_(context_provider),
47 resource_provider_(resource_provider), 54 resource_provider_(resource_provider),
48 shutdown_(false), 55 shutdown_(false),
49 scheduled_raster_task_count_(0u), 56 scheduled_raster_task_count_(0u),
50 raster_tasks_required_for_activation_count_(0u), 57 raster_tasks_required_for_activation_count_(0u),
51 bytes_pending_upload_(0u), 58 bytes_pending_upload_(0u),
52 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), 59 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes),
53 has_performed_uploads_since_last_flush_(false), 60 has_performed_uploads_since_last_flush_(false),
54 should_notify_client_if_no_tasks_are_pending_(false), 61 should_notify_client_if_no_tasks_are_pending_(false),
55 should_notify_client_if_no_tasks_required_for_activation_are_pending_( 62 should_notify_client_if_no_tasks_required_for_activation_are_pending_(
56 false), 63 false),
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // This reduces latency between the time when all tasks required for 315 // This reduces latency between the time when all tasks required for
309 // activation have finished running and the time when the client is 316 // activation have finished running and the time when the client is
310 // notified. 317 // notified.
311 CheckForCompletedRasterTasks(); 318 CheckForCompletedRasterTasks();
312 } 319 }
313 320
314 void PixelBufferRasterWorkerPool::FlushUploads() { 321 void PixelBufferRasterWorkerPool::FlushUploads() {
315 if (!has_performed_uploads_since_last_flush_) 322 if (!has_performed_uploads_since_last_flush_)
316 return; 323 return;
317 324
318 resource_provider_->ShallowFlushIfSupported(); 325 if (context_provider_)
326 context_provider_->ContextGL()->ShallowFlushCHROMIUM();
319 has_performed_uploads_since_last_flush_ = false; 327 has_performed_uploads_since_last_flush_ = false;
320 } 328 }
321 329
322 void PixelBufferRasterWorkerPool::CheckForCompletedUploads() { 330 void PixelBufferRasterWorkerPool::CheckForCompletedUploads() {
323 RasterTask::Vector tasks_with_completed_uploads; 331 RasterTask::Vector tasks_with_completed_uploads;
324 332
325 // First check if any have completed. 333 // First check if any have completed.
326 while (!raster_tasks_with_pending_upload_.empty()) { 334 while (!raster_tasks_with_pending_upload_.empty()) {
327 RasterTask* task = raster_tasks_with_pending_upload_.front().get(); 335 RasterTask* task = raster_tasks_with_pending_upload_.front().get();
328 DCHECK(std::find_if(raster_task_states_.begin(), 336 DCHECK(std::find_if(raster_task_states_.begin(),
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 763
756 throttle_state->SetInteger("bytes_available_for_upload", 764 throttle_state->SetInteger("bytes_available_for_upload",
757 max_bytes_pending_upload_ - bytes_pending_upload_); 765 max_bytes_pending_upload_ - bytes_pending_upload_);
758 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 766 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
759 throttle_state->SetInteger("scheduled_raster_task_count", 767 throttle_state->SetInteger("scheduled_raster_task_count",
760 scheduled_raster_task_count_); 768 scheduled_raster_task_count_);
761 return throttle_state.PassAs<base::Value>(); 769 return throttle_state.PassAs<base::Value>();
762 } 770 }
763 771
764 } // namespace cc 772 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698