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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 const RasterSource::PlaybackSettings& playback_settings, | 212 const RasterSource::PlaybackSettings& playback_settings, |
213 uint64_t previous_content_id, | 213 uint64_t previous_content_id, |
214 uint64_t new_content_id) { | 214 uint64_t new_content_id) { |
215 // Allocate GpuMemoryBuffer if necessary. If using partial raster, we | 215 // Allocate GpuMemoryBuffer if necessary. If using partial raster, we |
216 // must allocate a buffer with BufferUsage CPU_READ_WRITE_PERSISTENT. | 216 // must allocate a buffer with BufferUsage CPU_READ_WRITE_PERSISTENT. |
217 if (!staging_buffer->gpu_memory_buffer) { | 217 if (!staging_buffer->gpu_memory_buffer) { |
218 staging_buffer->gpu_memory_buffer = | 218 staging_buffer->gpu_memory_buffer = |
219 resource_provider_->gpu_memory_buffer_manager() | 219 resource_provider_->gpu_memory_buffer_manager() |
220 ->AllocateGpuMemoryBuffer( | 220 ->AllocateGpuMemoryBuffer( |
221 staging_buffer->size, BufferFormat(resource->format()), | 221 staging_buffer->size, BufferFormat(resource->format()), |
222 use_partial_raster_ | 222 StagingBufferUsage(), gpu::kNullSurfaceHandle); |
223 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT | |
224 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | |
225 gpu::kNullSurfaceHandle); | |
226 } | 223 } |
227 | 224 |
228 gfx::Rect playback_rect = raster_full_rect; | 225 gfx::Rect playback_rect = raster_full_rect; |
229 if (use_partial_raster_ && previous_content_id) { | 226 if (use_partial_raster_ && previous_content_id) { |
230 // Reduce playback rect to dirty region if the content id of the staging | 227 // Reduce playback rect to dirty region if the content id of the staging |
231 // buffer matches the prevous content id. | 228 // buffer matches the prevous content id. |
232 if (previous_content_id == staging_buffer->content_id) | 229 if (previous_content_id == staging_buffer->content_id) |
233 playback_rect.Intersect(raster_dirty_rect); | 230 playback_rect.Intersect(raster_dirty_rect); |
234 } | 231 } |
235 | 232 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 uint64_t new_content_id) { | 273 uint64_t new_content_id) { |
277 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_); | 274 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_); |
278 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); | 275 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); |
279 DCHECK(gl); | 276 DCHECK(gl); |
280 | 277 |
281 // Create texture after synchronizing with compositor. | 278 // Create texture after synchronizing with compositor. |
282 ResourceProvider::ScopedTextureProvider scoped_texture( | 279 ResourceProvider::ScopedTextureProvider scoped_texture( |
283 gl, resource_lock, async_worker_context_enabled_); | 280 gl, resource_lock, async_worker_context_enabled_); |
284 | 281 |
285 unsigned resource_texture_id = scoped_texture.texture_id(); | 282 unsigned resource_texture_id = scoped_texture.texture_id(); |
286 unsigned image_target = | 283 unsigned image_target = resource_provider_->GetImageTextureTarget( |
287 resource_provider_->GetImageTextureTarget(resource_lock->format()); | 284 StagingBufferUsage(), staging_buffer->format); |
288 | 285 |
289 // Create and bind staging texture. | 286 // Create and bind staging texture. |
290 if (!staging_buffer->texture_id) { | 287 if (!staging_buffer->texture_id) { |
291 gl->GenTextures(1, &staging_buffer->texture_id); | 288 gl->GenTextures(1, &staging_buffer->texture_id); |
292 gl->BindTexture(image_target, staging_buffer->texture_id); | 289 gl->BindTexture(image_target, staging_buffer->texture_id); |
293 gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 290 gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
294 gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 291 gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
295 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 292 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
296 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 293 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
297 } else { | 294 } else { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // Barrier to sync worker context output to cc context. | 373 // Barrier to sync worker context output to cc context. |
377 gl->OrderingBarrierCHROMIUM(); | 374 gl->OrderingBarrierCHROMIUM(); |
378 | 375 |
379 // Generate sync token after the barrier for cross context synchronization. | 376 // Generate sync token after the barrier for cross context synchronization. |
380 gpu::SyncToken resource_sync_token; | 377 gpu::SyncToken resource_sync_token; |
381 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); | 378 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); |
382 resource_lock->set_sync_token(resource_sync_token); | 379 resource_lock->set_sync_token(resource_sync_token); |
383 resource_lock->set_synchronized(!async_worker_context_enabled_); | 380 resource_lock->set_synchronized(!async_worker_context_enabled_); |
384 } | 381 } |
385 | 382 |
| 383 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { |
| 384 return use_partial_raster_ |
| 385 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT |
| 386 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; |
| 387 } |
| 388 |
386 } // namespace cc | 389 } // namespace cc |
OLD | NEW |