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

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: remove helper class move api impl to callee. 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;
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,
30 ResourceProvider* resource_provider, 33 ResourceProvider* resource_provider,
31 size_t max_transfer_buffer_usage_bytes) { 34 size_t max_transfer_buffer_usage_bytes) {
32 return make_scoped_ptr<RasterWorkerPool>( 35 return make_scoped_ptr<RasterWorkerPool>(
33 new PixelBufferRasterWorkerPool(task_runner, 36 new PixelBufferRasterWorkerPool(task_runner,
34 task_graph_runner, 37 task_graph_runner,
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(
danakj 2014/07/10 17:01:43 We can pass the ContextProvider* to this class alo
sohanjg 2014/07/11 16:43:32 Done.
40 base::SequencedTaskRunner* task_runner, 43 base::SequencedTaskRunner* task_runner,
41 TaskGraphRunner* task_graph_runner, 44 TaskGraphRunner* task_graph_runner,
42 ResourceProvider* resource_provider, 45 ResourceProvider* resource_provider,
43 size_t max_transfer_buffer_usage_bytes) 46 size_t max_transfer_buffer_usage_bytes)
44 : task_runner_(task_runner), 47 : task_runner_(task_runner),
45 task_graph_runner_(task_graph_runner), 48 task_graph_runner_(task_graph_runner),
46 namespace_token_(task_graph_runner->GetNamespaceToken()), 49 namespace_token_(task_graph_runner->GetNamespaceToken()),
47 resource_provider_(resource_provider), 50 resource_provider_(resource_provider),
48 shutdown_(false), 51 shutdown_(false),
49 scheduled_raster_task_count_(0u), 52 scheduled_raster_task_count_(0u),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // This reduces latency between the time when all tasks required for 311 // This reduces latency between the time when all tasks required for
309 // activation have finished running and the time when the client is 312 // activation have finished running and the time when the client is
310 // notified. 313 // notified.
311 CheckForCompletedRasterTasks(); 314 CheckForCompletedRasterTasks();
312 } 315 }
313 316
314 void PixelBufferRasterWorkerPool::FlushUploads() { 317 void PixelBufferRasterWorkerPool::FlushUploads() {
315 if (!has_performed_uploads_since_last_flush_) 318 if (!has_performed_uploads_since_last_flush_)
316 return; 319 return;
317 320
318 resource_provider_->ShallowFlushIfSupported(); 321 GLES2Interface* gl = resource_provider_->ContextGL();
322 if (gl)
323 gl->ShallowFlushCHROMIUM();
319 has_performed_uploads_since_last_flush_ = false; 324 has_performed_uploads_since_last_flush_ = false;
320 } 325 }
321 326
322 void PixelBufferRasterWorkerPool::CheckForCompletedUploads() { 327 void PixelBufferRasterWorkerPool::CheckForCompletedUploads() {
323 RasterTask::Vector tasks_with_completed_uploads; 328 RasterTask::Vector tasks_with_completed_uploads;
324 329
325 // First check if any have completed. 330 // First check if any have completed.
326 while (!raster_tasks_with_pending_upload_.empty()) { 331 while (!raster_tasks_with_pending_upload_.empty()) {
327 RasterTask* task = raster_tasks_with_pending_upload_.front().get(); 332 RasterTask* task = raster_tasks_with_pending_upload_.front().get();
328 DCHECK(std::find_if(raster_task_states_.begin(), 333 DCHECK(std::find_if(raster_task_states_.begin(),
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 760
756 throttle_state->SetInteger("bytes_available_for_upload", 761 throttle_state->SetInteger("bytes_available_for_upload",
757 max_bytes_pending_upload_ - bytes_pending_upload_); 762 max_bytes_pending_upload_ - bytes_pending_upload_);
758 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 763 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
759 throttle_state->SetInteger("scheduled_raster_task_count", 764 throttle_state->SetInteger("scheduled_raster_task_count",
760 scheduled_raster_task_count_); 765 scheduled_raster_task_count_);
761 return throttle_state.PassAs<base::Value>(); 766 return throttle_state.PassAs<base::Value>();
762 } 767 }
763 768
764 } // namespace cc 769 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698