| 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/gpu_raster_worker_pool.h" | 5 #include "cc/resources/gpu_raster_worker_pool.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "cc/output/context_provider.h" | 8 #include "cc/output/context_provider.h" |
| 9 #include "cc/resources/resource.h" | 9 #include "cc/resources/resource.h" |
| 10 #include "cc/resources/resource_provider.h" | 10 #include "cc/resources/resource_provider.h" |
| 11 #include "gpu/command_buffer/client/gles2_interface.h" | 11 #include "gpu/command_buffer/client/gles2_interface.h" |
| 12 #include "third_party/skia/include/gpu/GrContext.h" | 12 #include "third_party/skia/include/gpu/GrContext.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 scoped_ptr<RasterWorkerPool> GpuRasterWorkerPool::Create( | 17 scoped_ptr<RasterWorkerPool> GpuRasterWorkerPool::Create( |
| 18 base::SequencedTaskRunner* task_runner, | 18 base::SequencedTaskRunner* task_runner, |
| 19 ResourceProvider* resource_provider, | 19 ResourceProvider* resource_provider) { |
| 20 ContextProvider* context_provider) { | 20 return make_scoped_ptr<RasterWorkerPool>( |
| 21 return make_scoped_ptr<RasterWorkerPool>(new GpuRasterWorkerPool( | 21 new GpuRasterWorkerPool(task_runner, resource_provider)); |
| 22 task_runner, resource_provider, context_provider)); | |
| 23 } | 22 } |
| 24 | 23 |
| 25 GpuRasterWorkerPool::GpuRasterWorkerPool(base::SequencedTaskRunner* task_runner, | 24 GpuRasterWorkerPool::GpuRasterWorkerPool(base::SequencedTaskRunner* task_runner, |
| 26 ResourceProvider* resource_provider, | 25 ResourceProvider* resource_provider) |
| 27 ContextProvider* context_provider) | |
| 28 : task_runner_(task_runner), | 26 : task_runner_(task_runner), |
| 29 task_graph_runner_(new TaskGraphRunner), | 27 task_graph_runner_(new TaskGraphRunner), |
| 30 namespace_token_(task_graph_runner_->GetNamespaceToken()), | 28 namespace_token_(task_graph_runner_->GetNamespaceToken()), |
| 31 resource_provider_(resource_provider), | 29 resource_provider_(resource_provider), |
| 32 context_provider_(context_provider), | |
| 33 run_tasks_on_origin_thread_pending_(false), | 30 run_tasks_on_origin_thread_pending_(false), |
| 34 raster_tasks_pending_(false), | 31 raster_tasks_pending_(false), |
| 35 raster_tasks_required_for_activation_pending_(false), | 32 raster_tasks_required_for_activation_pending_(false), |
| 36 raster_finished_weak_ptr_factory_(this), | 33 raster_finished_weak_ptr_factory_(this), |
| 37 weak_ptr_factory_(this) { | 34 weak_ptr_factory_(this) { |
| 38 DCHECK(context_provider_); | |
| 39 } | 35 } |
| 40 | 36 |
| 41 GpuRasterWorkerPool::~GpuRasterWorkerPool() { | 37 GpuRasterWorkerPool::~GpuRasterWorkerPool() { |
| 42 DCHECK_EQ(0u, completed_tasks_.size()); | 38 DCHECK_EQ(0u, completed_tasks_.size()); |
| 43 } | 39 } |
| 44 | 40 |
| 45 Rasterizer* GpuRasterWorkerPool::AsRasterizer() { | 41 Rasterizer* GpuRasterWorkerPool::AsRasterizer() { |
| 46 return this; | 42 return this; |
| 47 } | 43 } |
| 48 | 44 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 weak_ptr_factory_.GetWeakPtr())); | 178 weak_ptr_factory_.GetWeakPtr())); |
| 183 run_tasks_on_origin_thread_pending_ = true; | 179 run_tasks_on_origin_thread_pending_ = true; |
| 184 } | 180 } |
| 185 | 181 |
| 186 void GpuRasterWorkerPool::RunTasksOnOriginThread() { | 182 void GpuRasterWorkerPool::RunTasksOnOriginThread() { |
| 187 TRACE_EVENT0("cc", "GpuRasterWorkerPool::RunTasksOnOriginThread"); | 183 TRACE_EVENT0("cc", "GpuRasterWorkerPool::RunTasksOnOriginThread"); |
| 188 | 184 |
| 189 DCHECK(run_tasks_on_origin_thread_pending_); | 185 DCHECK(run_tasks_on_origin_thread_pending_); |
| 190 run_tasks_on_origin_thread_pending_ = false; | 186 run_tasks_on_origin_thread_pending_ = false; |
| 191 | 187 |
| 192 DCHECK(context_provider_->ContextGL()); | |
| 193 // TODO(alokp): Use a trace macro to push/pop markers. | 188 // TODO(alokp): Use a trace macro to push/pop markers. |
| 194 // Using push/pop functions directly incurs cost to evaluate function | 189 // Using push/pop functions directly incurs cost to evaluate function |
| 195 // arguments even when tracing is disabled. | 190 // arguments even when tracing is disabled. |
| 196 context_provider_->ContextGL()->PushGroupMarkerEXT( | 191 resource_provider_->PushGroupMarker( |
| 197 0, "GpuRasterWorkerPool::RunTasksOnOriginThread"); | 192 "GpuRasterWorkerPool::RunTasksOnOriginThread"); |
| 198 | 193 |
| 199 GrContext* gr_context = context_provider_->GrContext(); | 194 resource_provider_->ResetGpuContext(); |
| 200 // TODO(alokp): Implement TestContextProvider::GrContext(). | |
| 201 if (gr_context) | |
| 202 gr_context->resetContext(); | |
| 203 | 195 |
| 204 task_graph_runner_->RunUntilIdle(); | 196 task_graph_runner_->RunUntilIdle(); |
| 205 | 197 |
| 206 // TODO(alokp): Implement TestContextProvider::GrContext(). | 198 resource_provider_->FlushGpuContext(); |
| 207 if (gr_context) | |
| 208 gr_context->flush(); | |
| 209 | 199 |
| 210 context_provider_->ContextGL()->PopGroupMarkerEXT(); | 200 resource_provider_->PopGroupMarker(); |
| 211 } | 201 } |
| 212 | 202 |
| 213 } // namespace cc | 203 } // namespace cc |
| OLD | NEW |