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