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

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: 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (resource_id == 0) 184 if (resource_id == 0)
185 return all_resources_.end(); 185 return all_resources_.end();
186 186
187 gpu::Mailbox mailbox; 187 gpu::Mailbox mailbox;
188 if (has_mailbox) { 188 if (has_mailbox) {
189 DCHECK(context_provider_); 189 DCHECK(context_provider_);
190 190
191 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); 191 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
192 192
193 gl->GenMailboxCHROMIUM(mailbox.name); 193 gl->GenMailboxCHROMIUM(mailbox.name);
194 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id); 194 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id,
195 false);
195 gl->ProduceTextureDirectCHROMIUM( 196 gl->ProduceTextureDirectCHROMIUM(
196 lock.texture_id(), 197 lock.texture_id(),
197 resource_provider_->GetResourceTextureTarget(resource_id), 198 resource_provider_->GetResourceTextureTarget(resource_id),
198 mailbox.name); 199 mailbox.name);
199 } 200 }
200 all_resources_.push_front( 201 all_resources_.push_front(
201 PlaneResource(resource_id, plane_size, format, mailbox)); 202 PlaneResource(resource_id, plane_size, format, mailbox));
202 return all_resources_.begin(); 203 return all_resources_.begin();
203 } 204 }
204 205
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // Otherwise allocate a new resource. 578 // Otherwise allocate a new resource.
578 if (resource == all_resources_.end()) { 579 if (resource == all_resources_.end()) {
579 const bool is_immutable = false; 580 const bool is_immutable = false;
580 resource = AllocateResource(output_plane_resource_size, copy_target_format, 581 resource = AllocateResource(output_plane_resource_size, copy_target_format,
581 true, is_immutable); 582 true, is_immutable);
582 } 583 }
583 584
584 resource->add_ref(); 585 resource->add_ref();
585 586
586 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 587 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
587 resource->resource_id()); 588 resource->resource_id(), false);
588 uint32_t texture_id = lock.texture_id();
589
590 DCHECK_EQ( 589 DCHECK_EQ(
591 resource_provider_->GetResourceTextureTarget(resource->resource_id()), 590 resource_provider_->GetResourceTextureTarget(resource->resource_id()),
592 (GLenum)GL_TEXTURE_2D); 591 (GLenum)GL_TEXTURE_2D);
593 592
594 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); 593 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData());
595 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM( 594 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM(
596 mailbox_holder.texture_target, mailbox_holder.mailbox.name); 595 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
597 gl->CopySubTextureCHROMIUM(src_texture_id, texture_id, 0, 0, 0, 0, 596 gl->CopySubTextureCHROMIUM(src_texture_id, lock.texture_id(), 0, 0, 0, 0,
598 output_plane_resource_size.width(), 597 output_plane_resource_size.width(),
599 output_plane_resource_size.height(), false, false, 598 output_plane_resource_size.height(), false, false,
600 false); 599 false);
601 gl->DeleteTextures(1, &src_texture_id); 600 gl->DeleteTextures(1, &src_texture_id);
602 601
603 // Sync point for use of frame copy. 602 // Sync point for use of frame copy.
604 gpu::SyncToken sync_token; 603 gpu::SyncToken sync_token;
605 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); 604 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
606 gl->ShallowFlushCHROMIUM(); 605 gl->ShallowFlushCHROMIUM();
607 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 606 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 if (lost_resource) { 690 if (lost_resource) {
692 resource_it->clear_refs(); 691 resource_it->clear_refs();
693 updater->DeleteResource(resource_it); 692 updater->DeleteResource(resource_it);
694 return; 693 return;
695 } 694 }
696 695
697 resource_it->remove_ref(); 696 resource_it->remove_ref();
698 } 697 }
699 698
700 } // namespace cc 699 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698