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/raster/gpu_tile_task_worker_pool.h" | 5 #include "cc/raster/gpu_tile_task_worker_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/playback/raster_source.h" | 10 #include "cc/playback/raster_source.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 class RasterBufferImpl : public RasterBuffer { | 24 class RasterBufferImpl : public RasterBuffer { |
25 public: | 25 public: |
26 RasterBufferImpl(GpuRasterizer* rasterizer, const Resource* resource) | 26 RasterBufferImpl(GpuRasterizer* rasterizer, const Resource* resource) |
27 : rasterizer_(rasterizer), | 27 : rasterizer_(rasterizer), |
28 lock_(rasterizer->resource_provider(), resource->id()), | 28 lock_(rasterizer->resource_provider(), resource->id()), |
29 resource_(resource) {} | 29 resource_(resource) {} |
30 | 30 |
31 // Overridden from RasterBuffer: | 31 // Overridden from RasterBuffer: |
32 void Playback(const RasterSource* raster_source, | 32 void Playback(const RasterSource* raster_source, |
33 const gfx::Rect& rect, | 33 const gfx::Rect& raster_full_rect, |
| 34 const gfx::Rect& raster_dirty_rect, |
34 float scale) override { | 35 float scale) override { |
35 TRACE_EVENT0("cc", "RasterBufferImpl::Playback"); | 36 TRACE_EVENT0("cc", "RasterBufferImpl::Playback"); |
36 ContextProvider* context_provider = rasterizer_->resource_provider() | 37 ContextProvider* context_provider = rasterizer_->resource_provider() |
37 ->output_surface() | 38 ->output_surface() |
38 ->worker_context_provider(); | 39 ->worker_context_provider(); |
39 | 40 |
40 // The context lock must be held while accessing the context on a | 41 // The context lock must be held while accessing the context on a |
41 // worker thread. | 42 // worker thread. |
42 base::AutoLock context_lock(*context_provider->GetLock()); | 43 base::AutoLock context_lock(*context_provider->GetLock()); |
43 | 44 |
44 // Allow this worker thread to bind to context_provider. | 45 // Allow this worker thread to bind to context_provider. |
45 context_provider->DetachFromThread(); | 46 context_provider->DetachFromThread(); |
46 | 47 |
| 48 // TODO(danakj): Implement partial raster with raster_dirty_rect. |
47 // Rasterize source into resource. | 49 // Rasterize source into resource. |
48 rasterizer_->RasterizeSource(&lock_, raster_source, rect, scale); | 50 rasterizer_->RasterizeSource(&lock_, raster_source, raster_full_rect, |
| 51 scale); |
49 | 52 |
50 // Barrier to sync worker context output to cc context. | 53 // Barrier to sync worker context output to cc context. |
51 context_provider->ContextGL()->OrderingBarrierCHROMIUM(); | 54 context_provider->ContextGL()->OrderingBarrierCHROMIUM(); |
52 | 55 |
53 // Allow compositor thread to bind to context_provider. | 56 // Allow compositor thread to bind to context_provider. |
54 context_provider->DetachFromThread(); | 57 context_provider->DetachFromThread(); |
55 } | 58 } |
56 | 59 |
57 private: | 60 private: |
58 GpuRasterizer* rasterizer_; | 61 GpuRasterizer* rasterizer_; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 raster_task->WillComplete(); | 203 raster_task->WillComplete(); |
201 raster_task->CompleteOnOriginThread(this); | 204 raster_task->CompleteOnOriginThread(this); |
202 raster_task->DidComplete(); | 205 raster_task->DidComplete(); |
203 | 206 |
204 raster_task->RunReplyOnOriginThread(); | 207 raster_task->RunReplyOnOriginThread(); |
205 } | 208 } |
206 completed_tasks_.clear(); | 209 completed_tasks_.clear(); |
207 } | 210 } |
208 | 211 |
209 scoped_ptr<RasterBuffer> GpuTileTaskWorkerPool::AcquireBufferForRaster( | 212 scoped_ptr<RasterBuffer> GpuTileTaskWorkerPool::AcquireBufferForRaster( |
210 const Resource* resource) { | 213 const TileTaskData& data) { |
211 return make_scoped_ptr<RasterBuffer>( | 214 return make_scoped_ptr<RasterBuffer>( |
212 new RasterBufferImpl(rasterizer_.get(), resource)); | 215 new RasterBufferImpl(rasterizer_.get(), data.resource)); |
213 } | 216 } |
214 | 217 |
215 void GpuTileTaskWorkerPool::ReleaseBufferForRaster( | 218 void GpuTileTaskWorkerPool::ReleaseBufferForRaster( |
216 scoped_ptr<RasterBuffer> buffer) { | 219 scoped_ptr<RasterBuffer> buffer) { |
217 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 220 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
218 } | 221 } |
219 | 222 |
220 void GpuTileTaskWorkerPool::OnTaskSetFinished(TaskSet task_set) { | 223 void GpuTileTaskWorkerPool::OnTaskSetFinished(TaskSet task_set) { |
221 TRACE_EVENT1("cc", "GpuTileTaskWorkerPool::OnTaskSetFinished", "task_set", | 224 TRACE_EVENT1("cc", "GpuTileTaskWorkerPool::OnTaskSetFinished", "task_set", |
222 task_set); | 225 task_set); |
223 | 226 |
224 DCHECK(tasks_pending_[task_set]); | 227 DCHECK(tasks_pending_[task_set]); |
225 tasks_pending_[task_set] = false; | 228 tasks_pending_[task_set] = false; |
226 client_->DidFinishRunningTileTasks(task_set); | 229 client_->DidFinishRunningTileTasks(task_set); |
227 } | 230 } |
228 | 231 |
229 } // namespace cc | 232 } // namespace cc |
OLD | NEW |