| 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/one_copy_raster_buffer_provider.h" | 5 #include "cc/raster/one_copy_raster_buffer_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 DCHECK(gl); | 186 DCHECK(gl); |
| 187 // Synchronize with compositor. | 187 // Synchronize with compositor. |
| 188 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); | 188 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 std::unique_ptr<StagingBuffer> staging_buffer = | 191 std::unique_ptr<StagingBuffer> staging_buffer = |
| 192 staging_pool_.AcquireStagingBuffer(resource, previous_content_id); | 192 staging_pool_.AcquireStagingBuffer(resource, previous_content_id); |
| 193 | 193 |
| 194 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source, | 194 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source, |
| 195 raster_full_rect, raster_dirty_rect, scale, | 195 raster_full_rect, raster_dirty_rect, scale, |
| 196 playback_settings, previous_content_id, | 196 resource_lock->sk_color_space(), playback_settings, |
| 197 new_content_id); | 197 previous_content_id, new_content_id); |
| 198 | 198 |
| 199 CopyOnWorkerThread(staging_buffer.get(), resource_lock, sync_token, | 199 CopyOnWorkerThread(staging_buffer.get(), resource_lock, sync_token, |
| 200 raster_source, previous_content_id, new_content_id); | 200 raster_source, previous_content_id, new_content_id); |
| 201 | 201 |
| 202 staging_pool_.ReleaseStagingBuffer(std::move(staging_buffer)); | 202 staging_pool_.ReleaseStagingBuffer(std::move(staging_buffer)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void OneCopyRasterBufferProvider::PlaybackToStagingBuffer( | 205 void OneCopyRasterBufferProvider::PlaybackToStagingBuffer( |
| 206 StagingBuffer* staging_buffer, | 206 StagingBuffer* staging_buffer, |
| 207 const Resource* resource, | 207 const Resource* resource, |
| 208 const RasterSource* raster_source, | 208 const RasterSource* raster_source, |
| 209 const gfx::Rect& raster_full_rect, | 209 const gfx::Rect& raster_full_rect, |
| 210 const gfx::Rect& raster_dirty_rect, | 210 const gfx::Rect& raster_dirty_rect, |
| 211 float scale, | 211 float scale, |
| 212 sk_sp<SkColorSpace> dst_color_space, |
| 212 const RasterSource::PlaybackSettings& playback_settings, | 213 const RasterSource::PlaybackSettings& playback_settings, |
| 213 uint64_t previous_content_id, | 214 uint64_t previous_content_id, |
| 214 uint64_t new_content_id) { | 215 uint64_t new_content_id) { |
| 215 // Allocate GpuMemoryBuffer if necessary. If using partial raster, we | 216 // Allocate GpuMemoryBuffer if necessary. If using partial raster, we |
| 216 // must allocate a buffer with BufferUsage CPU_READ_WRITE_PERSISTENT. | 217 // must allocate a buffer with BufferUsage CPU_READ_WRITE_PERSISTENT. |
| 217 if (!staging_buffer->gpu_memory_buffer) { | 218 if (!staging_buffer->gpu_memory_buffer) { |
| 218 staging_buffer->gpu_memory_buffer = | 219 staging_buffer->gpu_memory_buffer = |
| 219 resource_provider_->gpu_memory_buffer_manager() | 220 resource_provider_->gpu_memory_buffer_manager() |
| 220 ->AllocateGpuMemoryBuffer( | 221 ->AllocateGpuMemoryBuffer( |
| 221 staging_buffer->size, BufferFormat(resource->format()), | 222 staging_buffer->size, BufferFormat(resource->format()), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 251 DCHECK(rv); | 252 DCHECK(rv); |
| 252 DCHECK(buffer->memory(0)); | 253 DCHECK(buffer->memory(0)); |
| 253 // RasterBufferProvider::PlaybackToMemory only supports unsigned strides. | 254 // RasterBufferProvider::PlaybackToMemory only supports unsigned strides. |
| 254 DCHECK_GE(buffer->stride(0), 0); | 255 DCHECK_GE(buffer->stride(0), 0); |
| 255 | 256 |
| 256 DCHECK(!playback_rect.IsEmpty()) | 257 DCHECK(!playback_rect.IsEmpty()) |
| 257 << "Why are we rastering a tile that's not dirty?"; | 258 << "Why are we rastering a tile that's not dirty?"; |
| 258 RasterBufferProvider::PlaybackToMemory( | 259 RasterBufferProvider::PlaybackToMemory( |
| 259 buffer->memory(0), resource->format(), staging_buffer->size, | 260 buffer->memory(0), resource->format(), staging_buffer->size, |
| 260 buffer->stride(0), raster_source, raster_full_rect, playback_rect, | 261 buffer->stride(0), raster_source, raster_full_rect, playback_rect, |
| 261 scale, playback_settings); | 262 scale, dst_color_space, playback_settings); |
| 262 buffer->Unmap(); | 263 buffer->Unmap(); |
| 263 staging_buffer->content_id = new_content_id; | 264 staging_buffer->content_id = new_content_id; |
| 264 } | 265 } |
| 265 } | 266 } |
| 266 | 267 |
| 267 void OneCopyRasterBufferProvider::CopyOnWorkerThread( | 268 void OneCopyRasterBufferProvider::CopyOnWorkerThread( |
| 268 StagingBuffer* staging_buffer, | 269 StagingBuffer* staging_buffer, |
| 269 ResourceProvider::ScopedWriteLockGL* resource_lock, | 270 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 270 const gpu::SyncToken& sync_token, | 271 const gpu::SyncToken& sync_token, |
| 271 const RasterSource* raster_source, | 272 const RasterSource* raster_source, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 resource_lock->set_synchronized(!async_worker_context_enabled_); | 381 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 381 } | 382 } |
| 382 | 383 |
| 383 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { | 384 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { |
| 384 return use_partial_raster_ | 385 return use_partial_raster_ |
| 385 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT | 386 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT |
| 386 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; | 387 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; |
| 387 } | 388 } |
| 388 | 389 |
| 389 } // namespace cc | 390 } // namespace cc |
| OLD | NEW |