| 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 ResourceProvider::ResourceIdArray resources; |
| 196 resources.push_back(resource_id); |
| 197 gpu::SyncToken sync_token = |
| 198 resource_provider_->GetSyncTokenForResources(resources); |
| 199 if (!sync_token.HasData()) |
| 200 return true; |
| 201 |
| 202 // IsSyncTokenSignalled is threadsafe, no need for worker context lock. |
| 203 return worker_context_provider_->ContextSupport()->IsSyncTokenSignalled( |
| 204 sync_token); |
| 205 } |
| 206 |
| 207 uint64_t GpuRasterBufferProvider::SetReadyToDrawCallback( |
| 208 const ResourceProvider::ResourceIdArray& resource_ids, |
| 209 const base::Closure& callback, |
| 210 uint64_t pending_callback_id) const { |
| 211 if (!async_worker_context_enabled_) |
| 212 return 0; |
| 213 |
| 214 gpu::SyncToken sync_token = |
| 215 resource_provider_->GetSyncTokenForResources(resource_ids); |
| 216 uint64_t callback_id = sync_token.release_count(); |
| 217 DCHECK_NE(callback_id, 0u); |
| 218 |
| 219 // If the callback is different from the one the caller is already waiting on, |
| 220 // pass the callback through to SignalSinkToken. Otherwise the request is |
| 221 // redundant. |
| 222 if (callback_id != pending_callback_id) { |
| 223 // SignalSyncToken is threadsafe, no need for worker context lock. |
| 224 worker_context_provider_->ContextSupport()->SignalSyncToken(sync_token, |
| 225 callback); |
| 226 } |
| 227 |
| 228 return callback_id; |
| 229 } |
| 230 |
| 189 void GpuRasterBufferProvider::Shutdown() { | 231 void GpuRasterBufferProvider::Shutdown() { |
| 190 pending_raster_buffers_.clear(); | 232 pending_raster_buffers_.clear(); |
| 191 } | 233 } |
| 192 | 234 |
| 193 void GpuRasterBufferProvider::PlaybackOnWorkerThread( | 235 void GpuRasterBufferProvider::PlaybackOnWorkerThread( |
| 194 ResourceProvider::ScopedWriteLockGL* resource_lock, | 236 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 195 const gpu::SyncToken& sync_token, | 237 const gpu::SyncToken& sync_token, |
| 196 bool resource_has_previous_content, | 238 bool resource_has_previous_content, |
| 197 const RasterSource* raster_source, | 239 const RasterSource* raster_source, |
| 198 const gfx::Rect& raster_full_rect, | 240 const gfx::Rect& raster_full_rect, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 225 gl->OrderingBarrierCHROMIUM(); | 267 gl->OrderingBarrierCHROMIUM(); |
| 226 | 268 |
| 227 // Generate sync token after the barrier for cross context synchronization. | 269 // Generate sync token after the barrier for cross context synchronization. |
| 228 gpu::SyncToken resource_sync_token; | 270 gpu::SyncToken resource_sync_token; |
| 229 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); | 271 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); |
| 230 resource_lock->set_sync_token(resource_sync_token); | 272 resource_lock->set_sync_token(resource_sync_token); |
| 231 resource_lock->set_synchronized(!async_worker_context_enabled_); | 273 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 232 } | 274 } |
| 233 | 275 |
| 234 } // namespace cc | 276 } // namespace cc |
| OLD | NEW |