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