Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: cc/raster/one_copy_raster_buffer_provider.cc

Issue 2885533002: cc: Allocate resources on worker context.
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/raster/gpu_raster_buffer_provider.cc ('k') | cc/resources/resource_format.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 const RasterSource* raster_source, 225 const RasterSource* raster_source,
226 const gfx::Rect& raster_full_rect, 226 const gfx::Rect& raster_full_rect,
227 const gfx::Rect& raster_dirty_rect, 227 const gfx::Rect& raster_dirty_rect,
228 const gfx::AxisTransform2d& transform, 228 const gfx::AxisTransform2d& transform,
229 const RasterSource::PlaybackSettings& playback_settings, 229 const RasterSource::PlaybackSettings& playback_settings,
230 uint64_t previous_content_id, 230 uint64_t previous_content_id,
231 uint64_t new_content_id) { 231 uint64_t new_content_id) {
232 if (async_worker_context_enabled_) { 232 if (async_worker_context_enabled_) {
233 // Early out if sync token is invalid. This happens if the compositor 233 // Early out if sync token is invalid. This happens if the compositor
234 // context was lost before ScheduleTasks was called. 234 // context was lost before ScheduleTasks was called.
235 if (!sync_token.HasData()) 235 if (!sync_token.HasData()) {
236 DLOG(ERROR) << "Context destroyed while scheduling raster tasks";
236 return; 237 return;
238 }
237 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_); 239 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_);
238 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); 240 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
239 DCHECK(gl); 241 DCHECK(gl);
240 // Synchronize with compositor. 242 // Synchronize with compositor.
241 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); 243 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
242 } 244 }
243 245
244 std::unique_ptr<StagingBuffer> staging_buffer = 246 std::unique_ptr<StagingBuffer> staging_buffer =
245 staging_pool_.AcquireStagingBuffer(resource, previous_content_id); 247 staging_pool_.AcquireStagingBuffer(resource, previous_content_id);
246 248
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 void OneCopyRasterBufferProvider::CopyOnWorkerThread( 322 void OneCopyRasterBufferProvider::CopyOnWorkerThread(
321 StagingBuffer* staging_buffer, 323 StagingBuffer* staging_buffer,
322 ResourceProvider::ScopedWriteLockGL* resource_lock, 324 ResourceProvider::ScopedWriteLockGL* resource_lock,
323 const gpu::SyncToken& sync_token, 325 const gpu::SyncToken& sync_token,
324 const RasterSource* raster_source, 326 const RasterSource* raster_source,
325 const gfx::Rect& rect_to_copy) { 327 const gfx::Rect& rect_to_copy) {
326 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_); 328 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_);
327 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); 329 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
328 DCHECK(gl); 330 DCHECK(gl);
329 331
330 // Create texture after synchronizing with compositor. 332 unsigned resource_texture_id = resource_lock->texture_id();
331 ResourceProvider::ScopedTextureProvider scoped_texture( 333 if (async_worker_context_enabled_)
332 gl, resource_lock, async_worker_context_enabled_); 334 resource_texture_id = resource_lock->ConsumeTexture(gl);
333 335
334 unsigned resource_texture_id = scoped_texture.texture_id();
335 unsigned image_target = resource_provider_->GetImageTextureTarget( 336 unsigned image_target = resource_provider_->GetImageTextureTarget(
336 StagingBufferUsage(), staging_buffer->format); 337 StagingBufferUsage(), staging_buffer->format);
337 338
338 // Create and bind staging texture. 339 // Create and bind staging texture.
339 if (!staging_buffer->texture_id) { 340 if (!staging_buffer->texture_id) {
340 gl->GenTextures(1, &staging_buffer->texture_id); 341 gl->GenTextures(1, &staging_buffer->texture_id);
341 gl->BindTexture(image_target, staging_buffer->texture_id); 342 gl->BindTexture(image_target, staging_buffer->texture_id);
342 gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 343 gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
343 gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 344 gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
344 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 345 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 414 }
414 415
415 if (resource_provider_->use_sync_query()) { 416 if (resource_provider_->use_sync_query()) {
416 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 417 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
417 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); 418 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
418 #else 419 #else
419 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 420 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
420 #endif 421 #endif
421 } 422 }
422 423
424 if (async_worker_context_enabled_)
425 gl->DeleteTextures(1, &resource_texture_id);
426
423 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); 427 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
424 428
425 // Barrier to sync worker context output to cc context. 429 // Barrier to sync worker context output to cc context.
426 gl->OrderingBarrierCHROMIUM(); 430 gl->OrderingBarrierCHROMIUM();
427 431
428 // Generate sync token after the barrier for cross context synchronization. 432 // Generate sync token after the barrier for cross context synchronization.
429 gpu::SyncToken resource_sync_token; 433 gpu::SyncToken resource_sync_token;
430 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); 434 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData());
431 resource_lock->set_sync_token(resource_sync_token); 435 resource_lock->set_sync_token(resource_sync_token);
432 resource_lock->set_synchronized(!async_worker_context_enabled_);
433 } 436 }
434 437
435 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { 438 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const {
436 return use_partial_raster_ 439 return use_partial_raster_
437 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT 440 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT
438 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; 441 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE;
439 } 442 }
440 443
441 } // namespace cc 444 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/gpu_raster_buffer_provider.cc ('k') | cc/resources/resource_format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698