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 return compositor_context_provider_->ContextSupport()->IsFenceSyncReleased( | |
| 201 sync_token.release_count()); | |
|
vmiura
2017/01/05 01:54:41
This should be checking the release count on worke
ericrk
2017/01/05 21:20:40
Good catch. Thanks!
| |
| 202 } | |
| 203 | |
| 204 uint64_t GpuRasterBufferProvider::SetReadyToDrawCallback( | |
| 205 const ResourceProvider::ResourceIdArray& resource_ids, | |
| 206 const base::Closure& callback, | |
| 207 uint64_t pending_callback_id) const { | |
| 208 if (!async_worker_context_enabled_) | |
| 209 return 0; | |
| 210 | |
| 211 gpu::SyncToken sync_token = | |
| 212 resource_provider_->GetSyncTokenForResources(resource_ids); | |
| 213 uint64_t callback_id = sync_token.release_count(); | |
| 214 DCHECK_NE(callback_id, 0u); | |
| 215 | |
| 216 // If the callback we are about to request has the same ID as the one which | |
| 217 // our caller is waiting on, then the request is redundant. | |
| 218 if (callback_id != pending_callback_id) { | |
| 219 compositor_context_provider_->ContextSupport()->SignalSyncToken(sync_token, | |
| 220 callback); | |
| 221 } | |
| 222 | |
| 223 return callback_id; | |
| 224 } | |
| 225 | |
| 189 void GpuRasterBufferProvider::Shutdown() { | 226 void GpuRasterBufferProvider::Shutdown() { |
| 190 pending_raster_buffers_.clear(); | 227 pending_raster_buffers_.clear(); |
| 191 } | 228 } |
| 192 | 229 |
| 193 void GpuRasterBufferProvider::PlaybackOnWorkerThread( | 230 void GpuRasterBufferProvider::PlaybackOnWorkerThread( |
| 194 ResourceProvider::ScopedWriteLockGL* resource_lock, | 231 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 195 const gpu::SyncToken& sync_token, | 232 const gpu::SyncToken& sync_token, |
| 196 bool resource_has_previous_content, | 233 bool resource_has_previous_content, |
| 197 const RasterSource* raster_source, | 234 const RasterSource* raster_source, |
| 198 const gfx::Rect& raster_full_rect, | 235 const gfx::Rect& raster_full_rect, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 gl->OrderingBarrierCHROMIUM(); | 267 gl->OrderingBarrierCHROMIUM(); |
| 231 | 268 |
| 232 // Generate sync token after the barrier for cross context synchronization. | 269 // Generate sync token after the barrier for cross context synchronization. |
| 233 gpu::SyncToken resource_sync_token; | 270 gpu::SyncToken resource_sync_token; |
| 234 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); | 271 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); |
| 235 resource_lock->set_sync_token(resource_sync_token); | 272 resource_lock->set_sync_token(resource_sync_token); |
| 236 resource_lock->set_synchronized(!async_worker_context_enabled_); | 273 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 237 } | 274 } |
| 238 | 275 |
| 239 } // namespace cc | 276 } // namespace cc |
| OLD | NEW |