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

Side by Side Diff: cc/resources/video_resource_updater.cc

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: compile error fix Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/resources/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 if (resource_id == 0) 219 if (resource_id == 0)
220 return all_resources_.end(); 220 return all_resources_.end();
221 221
222 gpu::Mailbox mailbox; 222 gpu::Mailbox mailbox;
223 if (has_mailbox) { 223 if (has_mailbox) {
224 DCHECK(context_provider_); 224 DCHECK(context_provider_);
225 225
226 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); 226 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
227 227
228 gl->GenMailboxCHROMIUM(mailbox.name); 228 gl->GenMailboxCHROMIUM(mailbox.name);
229 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id); 229 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id,
230 false);
230 gl->ProduceTextureDirectCHROMIUM( 231 gl->ProduceTextureDirectCHROMIUM(
231 lock.texture_id(), 232 lock.texture_id(),
232 resource_provider_->GetResourceTextureTarget(resource_id), 233 resource_provider_->GetResourceTextureTarget(resource_id),
233 mailbox.name); 234 mailbox.name);
234 } 235 }
235 all_resources_.push_front( 236 all_resources_.push_front(
236 PlaneResource(resource_id, plane_size, format, mailbox)); 237 PlaneResource(resource_id, plane_size, format, mailbox));
237 return all_resources_.begin(); 238 return all_resources_.begin();
238 } 239 }
239 240
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // Otherwise allocate a new resource. 630 // Otherwise allocate a new resource.
630 if (resource == all_resources_.end()) { 631 if (resource == all_resources_.end()) {
631 const bool is_immutable = false; 632 const bool is_immutable = false;
632 resource = AllocateResource(output_plane_resource_size, copy_target_format, 633 resource = AllocateResource(output_plane_resource_size, copy_target_format,
633 true, is_immutable); 634 true, is_immutable);
634 } 635 }
635 636
636 ++resource->ref_count; 637 ++resource->ref_count;
637 638
638 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 639 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
639 resource->resource_id); 640 resource->resource_id, false);
640 uint32_t texture_id = lock.texture_id();
641
642 DCHECK_EQ(resource_provider_->GetResourceTextureTarget(resource->resource_id), 641 DCHECK_EQ(resource_provider_->GetResourceTextureTarget(resource->resource_id),
643 (GLenum)GL_TEXTURE_2D); 642 (GLenum)GL_TEXTURE_2D);
644 643
645 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); 644 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData());
646 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM( 645 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM(
647 mailbox_holder.texture_target, mailbox_holder.mailbox.name); 646 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
648 gl->CopySubTextureCHROMIUM(src_texture_id, texture_id, 0, 0, 0, 0, 647 gl->CopySubTextureCHROMIUM(src_texture_id, lock.texture_id(), 0, 0, 0, 0,
649 output_plane_resource_size.width(), 648 output_plane_resource_size.width(),
650 output_plane_resource_size.height(), false, false, 649 output_plane_resource_size.height(), false, false,
651 false); 650 false);
652 gl->DeleteTextures(1, &src_texture_id); 651 gl->DeleteTextures(1, &src_texture_id);
653 652
654 // Sync point for use of frame copy. 653 // Sync point for use of frame copy.
655 gpu::SyncToken sync_token; 654 gpu::SyncToken sync_token;
656 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); 655 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
657 gl->ShallowFlushCHROMIUM(); 656 gl->ShallowFlushCHROMIUM();
658 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 657 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 plane_resource.plane_index == 0; 764 plane_resource.plane_index == 0;
766 }); 765 });
767 if (resource_it == updater->all_resources_.end()) 766 if (resource_it == updater->all_resources_.end())
768 return; 767 return;
769 768
770 resource_it->destructed = true; 769 resource_it->destructed = true;
771 } 770 }
772 #endif 771 #endif
773 772
774 } // namespace cc 773 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698