Chromium Code Reviews| 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_raster_buffer_provider.h" | 5 #include "cc/raster/gpu_raster_buffer_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "cc/base/histograms.h" | 15 #include "cc/base/histograms.h" |
| 16 #include "cc/playback/image_hijack_canvas.h" | 16 #include "cc/playback/image_hijack_canvas.h" |
| 17 #include "cc/playback/raster_source.h" | 17 #include "cc/playback/raster_source.h" |
| 18 #include "cc/raster/scoped_gpu_raster.h" | 18 #include "cc/raster/scoped_gpu_raster.h" |
| 19 #include "cc/resources/resource.h" | 19 #include "cc/resources/resource.h" |
| 20 #include "gpu/command_buffer/client/context_support.h" | |
| 20 #include "gpu/command_buffer/client/gles2_interface.h" | 21 #include "gpu/command_buffer/client/gles2_interface.h" |
| 21 #include "third_party/skia/include/core/SkMultiPictureDraw.h" | 22 #include "third_party/skia/include/core/SkMultiPictureDraw.h" |
| 22 #include "third_party/skia/include/core/SkPictureRecorder.h" | 23 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 23 #include "third_party/skia/include/core/SkSurface.h" | 24 #include "third_party/skia/include/core/SkSurface.h" |
| 24 #include "third_party/skia/include/gpu/GrContext.h" | 25 #include "third_party/skia/include/gpu/GrContext.h" |
| 25 | 26 |
| 26 namespace cc { | 27 namespace cc { |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 static void RasterizeSource( | 30 static void RasterizeSource( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 return false; | 180 return false; |
| 180 } | 181 } |
| 181 | 182 |
| 182 bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { | 183 bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { |
| 183 // Partial raster doesn't support MSAA, as the MSAA resolve is unaware of clip | 184 // Partial raster doesn't support MSAA, as the MSAA resolve is unaware of clip |
| 184 // rects. | 185 // rects. |
| 185 // TODO(crbug.com/629683): See if we can work around this limitation. | 186 // TODO(crbug.com/629683): See if we can work around this limitation. |
| 186 return msaa_sample_count_ == 0; | 187 return msaa_sample_count_ == 0; |
| 187 } | 188 } |
| 188 | 189 |
| 190 bool GpuRasterBufferProvider::IsResourceReadyToDraw( | |
| 191 ResourceId resource_id) const { | |
| 192 if (!async_worker_context_enabled_) | |
| 193 return true; | |
| 194 | |
| 195 gpu::SyncToken sync_token = | |
| 196 resource_provider_->GetSyncTokenForResource(resource_id); | |
| 197 if (!sync_token.HasData()) | |
| 198 return true; | |
| 199 | |
| 200 // IsSyncTokenSignalled is threadsafe, no need for worker context lock. | |
| 201 return worker_context_provider_->ContextSupport()->IsSyncTokenSignalled( | |
| 202 sync_token); | |
| 203 } | |
| 204 | |
| 205 uint64_t GpuRasterBufferProvider::SetReadyToDrawCallback( | |
| 206 const ResourceProvider::ResourceIdArray& resource_ids, | |
| 207 const base::Closure& callback, | |
| 208 uint64_t pending_callback_id) const { | |
| 209 if (!async_worker_context_enabled_) | |
| 210 return 0; | |
| 211 | |
| 212 gpu::SyncToken sync_token = | |
| 213 resource_provider_->GetSyncTokenForResources(resource_ids); | |
| 214 uint64_t callback_id = sync_token.release_count(); | |
| 215 DCHECK_NE(callback_id, 0u); | |
| 216 | |
| 217 // If the callback we are about to request has the same ID as the one which | |
|
vmpstr
2017/01/05 22:00:46
It's a bit awkward that this comment is talking ab
ericrk
2017/01/09 23:05:21
Done.
| |
| 218 // our caller is waiting on, then the request is redundant. | |
| 219 if (callback_id != pending_callback_id) { | |
| 220 // SignalSyncToken is threadsafe, no need for worker context lock. | |
| 221 worker_context_provider_->ContextSupport()->SignalSyncToken(sync_token, | |
| 222 callback); | |
| 223 } | |
| 224 | |
| 225 return callback_id; | |
| 226 } | |
| 227 | |
| 189 void GpuRasterBufferProvider::Shutdown() { | 228 void GpuRasterBufferProvider::Shutdown() { |
| 190 pending_raster_buffers_.clear(); | 229 pending_raster_buffers_.clear(); |
| 191 } | 230 } |
| 192 | 231 |
| 193 void GpuRasterBufferProvider::PlaybackOnWorkerThread( | 232 void GpuRasterBufferProvider::PlaybackOnWorkerThread( |
| 194 ResourceProvider::ScopedWriteLockGL* resource_lock, | 233 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 195 const gpu::SyncToken& sync_token, | 234 const gpu::SyncToken& sync_token, |
| 196 bool resource_has_previous_content, | 235 bool resource_has_previous_content, |
| 197 const RasterSource* raster_source, | 236 const RasterSource* raster_source, |
| 198 const gfx::Rect& raster_full_rect, | 237 const gfx::Rect& raster_full_rect, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 225 gl->OrderingBarrierCHROMIUM(); | 264 gl->OrderingBarrierCHROMIUM(); |
| 226 | 265 |
| 227 // Generate sync token after the barrier for cross context synchronization. | 266 // Generate sync token after the barrier for cross context synchronization. |
| 228 gpu::SyncToken resource_sync_token; | 267 gpu::SyncToken resource_sync_token; |
| 229 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); | 268 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); |
| 230 resource_lock->set_sync_token(resource_sync_token); | 269 resource_lock->set_sync_token(resource_sync_token); |
| 231 resource_lock->set_synchronized(!async_worker_context_enabled_); | 270 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 232 } | 271 } |
| 233 | 272 |
| 234 } // namespace cc | 273 } // namespace cc |
| OLD | NEW |