| 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 25 matching lines...) Expand all Loading... |
| 36 // Overridden from RasterBuffer: | 36 // Overridden from RasterBuffer: |
| 37 void Playback(const RasterSource* raster_source, | 37 void Playback(const RasterSource* raster_source, |
| 38 const gfx::Rect& raster_full_rect, | 38 const gfx::Rect& raster_full_rect, |
| 39 const gfx::Rect& raster_dirty_rect, | 39 const gfx::Rect& raster_dirty_rect, |
| 40 uint64_t new_content_id, | 40 uint64_t new_content_id, |
| 41 float scale) override { | 41 float scale) override { |
| 42 TRACE_EVENT0("cc", "RasterBufferImpl::Playback"); | 42 TRACE_EVENT0("cc", "RasterBufferImpl::Playback"); |
| 43 ContextProvider* context_provider = rasterizer_->resource_provider() | 43 ContextProvider* context_provider = rasterizer_->resource_provider() |
| 44 ->output_surface() | 44 ->output_surface() |
| 45 ->worker_context_provider(); | 45 ->worker_context_provider(); |
| 46 DCHECK(context_provider); |
| 46 | 47 |
| 47 // The context lock must be held while accessing the context on a | 48 ContextProvider::ScopedContextGL scoped_context(context_provider); |
| 48 // worker thread. | |
| 49 base::AutoLock context_lock(*context_provider->GetLock()); | |
| 50 | |
| 51 // Allow this worker thread to bind to context_provider. | |
| 52 context_provider->DetachFromThread(); | |
| 53 | 49 |
| 54 gfx::Rect playback_rect = raster_full_rect; | 50 gfx::Rect playback_rect = raster_full_rect; |
| 55 if (resource_has_previous_content_) { | 51 if (resource_has_previous_content_) { |
| 56 playback_rect.Intersect(raster_dirty_rect); | 52 playback_rect.Intersect(raster_dirty_rect); |
| 57 } | 53 } |
| 58 DCHECK(!playback_rect.IsEmpty()) | 54 DCHECK(!playback_rect.IsEmpty()) |
| 59 << "Why are we rastering a tile that's not dirty?"; | 55 << "Why are we rastering a tile that's not dirty?"; |
| 60 | 56 |
| 61 // TODO(danakj): Implement partial raster with raster_dirty_rect. | 57 // TODO(danakj): Implement partial raster with raster_dirty_rect. |
| 62 // Rasterize source into resource. | 58 // Rasterize source into resource. |
| 63 rasterizer_->RasterizeSource(&lock_, raster_source, raster_full_rect, | 59 rasterizer_->RasterizeSource(&lock_, raster_source, raster_full_rect, |
| 64 playback_rect, scale); | 60 playback_rect, scale); |
| 65 | 61 |
| 66 // Barrier to sync worker context output to cc context. | 62 // Barrier to sync worker context output to cc context. |
| 67 context_provider->ContextGL()->OrderingBarrierCHROMIUM(); | 63 scoped_context.ContextGL()->OrderingBarrierCHROMIUM(); |
| 68 | |
| 69 // Allow compositor thread to bind to context_provider. | |
| 70 context_provider->DetachFromThread(); | |
| 71 } | 64 } |
| 72 | 65 |
| 73 private: | 66 private: |
| 74 GpuRasterizer* rasterizer_; | 67 GpuRasterizer* rasterizer_; |
| 75 ResourceProvider::ScopedWriteLockGr lock_; | 68 ResourceProvider::ScopedWriteLockGr lock_; |
| 76 bool resource_has_previous_content_; | 69 bool resource_has_previous_content_; |
| 77 | 70 |
| 78 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); | 71 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); |
| 79 }; | 72 }; |
| 80 | 73 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void GpuTileTaskWorkerPool::OnTaskSetFinished(TaskSet task_set) { | 236 void GpuTileTaskWorkerPool::OnTaskSetFinished(TaskSet task_set) { |
| 244 TRACE_EVENT1("cc", "GpuTileTaskWorkerPool::OnTaskSetFinished", "task_set", | 237 TRACE_EVENT1("cc", "GpuTileTaskWorkerPool::OnTaskSetFinished", "task_set", |
| 245 task_set); | 238 task_set); |
| 246 | 239 |
| 247 DCHECK(tasks_pending_[task_set]); | 240 DCHECK(tasks_pending_[task_set]); |
| 248 tasks_pending_[task_set] = false; | 241 tasks_pending_[task_set] = false; |
| 249 client_->DidFinishRunningTileTasks(task_set); | 242 client_->DidFinishRunningTileTasks(task_set); |
| 250 } | 243 } |
| 251 | 244 |
| 252 } // namespace cc | 245 } // namespace cc |
| OLD | NEW |