 Chromium Code Reviews
 Chromium Code Reviews Issue 375303002:
  cc: Refactor ResourceProvider.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 375303002:
  cc: Refactor ResourceProvider.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/image_copy_raster_worker_pool.h" | 5 #include "cc/resources/image_copy_raster_worker_pool.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 | 8 | 
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" | 
| 10 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" | 
| 11 #include "cc/resources/resource_pool.h" | 11 #include "cc/resources/resource_pool.h" | 
| 12 #include "cc/resources/scoped_resource.h" | 12 #include "cc/resources/scoped_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 | 18 | 
| 16 // static | 19 // static | 
| 17 scoped_ptr<RasterWorkerPool> ImageCopyRasterWorkerPool::Create( | 20 scoped_ptr<RasterWorkerPool> ImageCopyRasterWorkerPool::Create( | 
| 18 base::SequencedTaskRunner* task_runner, | 21 base::SequencedTaskRunner* task_runner, | 
| 19 TaskGraphRunner* task_graph_runner, | 22 TaskGraphRunner* task_graph_runner, | 
| 20 ResourceProvider* resource_provider, | 23 ResourceProvider* resource_provider, | 
| 21 ResourcePool* resource_pool) { | 24 ResourcePool* resource_pool) { | 
| 22 return make_scoped_ptr<RasterWorkerPool>(new ImageCopyRasterWorkerPool( | 25 return make_scoped_ptr<RasterWorkerPool>(new ImageCopyRasterWorkerPool( | 
| 23 task_runner, task_graph_runner, resource_provider, resource_pool)); | 26 task_runner, task_graph_runner, resource_provider, resource_pool)); | 
| 24 } | 27 } | 
| 25 | 28 | 
| 26 ImageCopyRasterWorkerPool::ImageCopyRasterWorkerPool( | 29 ImageCopyRasterWorkerPool::ImageCopyRasterWorkerPool( | 
| 
danakj
2014/07/10 17:01:43
We can pass the ContextProvider to this class, the
 
sohanjg
2014/07/11 16:43:32
Done.
 | |
| 27 base::SequencedTaskRunner* task_runner, | 30 base::SequencedTaskRunner* task_runner, | 
| 28 TaskGraphRunner* task_graph_runner, | 31 TaskGraphRunner* task_graph_runner, | 
| 29 ResourceProvider* resource_provider, | 32 ResourceProvider* resource_provider, | 
| 30 ResourcePool* resource_pool) | 33 ResourcePool* resource_pool) | 
| 31 : task_runner_(task_runner), | 34 : task_runner_(task_runner), | 
| 32 task_graph_runner_(task_graph_runner), | 35 task_graph_runner_(task_graph_runner), | 
| 33 namespace_token_(task_graph_runner->GetNamespaceToken()), | 36 namespace_token_(task_graph_runner->GetNamespaceToken()), | 
| 34 resource_provider_(resource_provider), | 37 resource_provider_(resource_provider), | 
| 35 resource_pool_(resource_pool), | 38 resource_pool_(resource_pool), | 
| 36 has_performed_copy_since_last_flush_(false), | 39 has_performed_copy_since_last_flush_(false), | 
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 "rasterizing", | 222 "rasterizing", | 
| 220 "state", | 223 "state", | 
| 221 TracedValue::FromValue(StateAsValue().release())); | 224 TracedValue::FromValue(StateAsValue().release())); | 
| 222 client_->DidFinishRunningTasksRequiredForActivation(); | 225 client_->DidFinishRunningTasksRequiredForActivation(); | 
| 223 } | 226 } | 
| 224 | 227 | 
| 225 void ImageCopyRasterWorkerPool::FlushCopies() { | 228 void ImageCopyRasterWorkerPool::FlushCopies() { | 
| 226 if (!has_performed_copy_since_last_flush_) | 229 if (!has_performed_copy_since_last_flush_) | 
| 227 return; | 230 return; | 
| 228 | 231 | 
| 229 resource_provider_->ShallowFlushIfSupported(); | 232 GLES2Interface* gl = resource_provider_->ContextGL(); | 
| 233 if (gl) | |
| 234 gl->ShallowFlushCHROMIUM(); | |
| 235 | |
| 230 has_performed_copy_since_last_flush_ = false; | 236 has_performed_copy_since_last_flush_ = false; | 
| 231 } | 237 } | 
| 232 | 238 | 
| 233 scoped_ptr<base::Value> ImageCopyRasterWorkerPool::StateAsValue() const { | 239 scoped_ptr<base::Value> ImageCopyRasterWorkerPool::StateAsValue() const { | 
| 234 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); | 240 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); | 
| 235 | 241 | 
| 236 state->SetInteger("pending_count", raster_task_states_.size()); | 242 state->SetInteger("pending_count", raster_task_states_.size()); | 
| 237 state->SetBoolean("tasks_required_for_activation_pending", | 243 state->SetBoolean("tasks_required_for_activation_pending", | 
| 238 raster_tasks_required_for_activation_pending_); | 244 raster_tasks_required_for_activation_pending_); | 
| 239 state->Set("staging_state", StagingStateAsValue().release()); | 245 state->Set("staging_state", StagingStateAsValue().release()); | 
| (...skipping 11 matching lines...) Expand all Loading... | |
| 251 resource_pool_->total_resource_count() - | 257 resource_pool_->total_resource_count() - | 
| 252 resource_pool_->acquired_resource_count()); | 258 resource_pool_->acquired_resource_count()); | 
| 253 staging_state->SetInteger("bytes_pending_copy", | 259 staging_state->SetInteger("bytes_pending_copy", | 
| 254 resource_pool_->total_memory_usage_bytes() - | 260 resource_pool_->total_memory_usage_bytes() - | 
| 255 resource_pool_->acquired_memory_usage_bytes()); | 261 resource_pool_->acquired_memory_usage_bytes()); | 
| 256 | 262 | 
| 257 return staging_state.PassAs<base::Value>(); | 263 return staging_state.PassAs<base::Value>(); | 
| 258 } | 264 } | 
| 259 | 265 | 
| 260 } // namespace cc | 266 } // namespace cc | 
| OLD | NEW |