OLD | NEW |
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 if (resource_id == 0) | 212 if (resource_id == 0) |
213 return all_resources_.end(); | 213 return all_resources_.end(); |
214 | 214 |
215 gpu::Mailbox mailbox; | 215 gpu::Mailbox mailbox; |
216 if (has_mailbox) { | 216 if (has_mailbox) { |
217 DCHECK(context_provider_); | 217 DCHECK(context_provider_); |
218 | 218 |
219 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 219 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
220 | 220 |
221 gl->GenMailboxCHROMIUM(mailbox.name); | 221 gl->GenMailboxCHROMIUM(mailbox.name); |
222 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id); | 222 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id, |
| 223 false); |
223 gl->ProduceTextureDirectCHROMIUM( | 224 gl->ProduceTextureDirectCHROMIUM( |
224 lock.texture_id(), | 225 lock.ProduceTextureId(), |
225 resource_provider_->GetResourceTextureTarget(resource_id), | 226 resource_provider_->GetResourceTextureTarget(resource_id), |
226 mailbox.name); | 227 mailbox.name); |
| 228 lock.ReleaseTextureId(); |
227 } | 229 } |
228 all_resources_.push_front( | 230 all_resources_.push_front( |
229 PlaneResource(resource_id, plane_size, format, mailbox)); | 231 PlaneResource(resource_id, plane_size, format, mailbox)); |
230 return all_resources_.begin(); | 232 return all_resources_.begin(); |
231 } | 233 } |
232 | 234 |
233 void VideoResourceUpdater::DeleteResource(ResourceList::iterator resource_it) { | 235 void VideoResourceUpdater::DeleteResource(ResourceList::iterator resource_it) { |
234 DCHECK_EQ(resource_it->ref_count, 0); | 236 DCHECK_EQ(resource_it->ref_count, 0); |
235 resource_provider_->DeleteResource(resource_it->resource_id); | 237 resource_provider_->DeleteResource(resource_it->resource_id); |
236 all_resources_.erase(resource_it); | 238 all_resources_.erase(resource_it); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 // Otherwise allocate a new resource. | 624 // Otherwise allocate a new resource. |
623 if (resource == all_resources_.end()) { | 625 if (resource == all_resources_.end()) { |
624 const bool is_immutable = false; | 626 const bool is_immutable = false; |
625 resource = AllocateResource(output_plane_resource_size, copy_target_format, | 627 resource = AllocateResource(output_plane_resource_size, copy_target_format, |
626 true, is_immutable); | 628 true, is_immutable); |
627 } | 629 } |
628 | 630 |
629 ++resource->ref_count; | 631 ++resource->ref_count; |
630 | 632 |
631 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, | 633 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, |
632 resource->resource_id); | 634 resource->resource_id, false); |
633 uint32_t texture_id = lock.texture_id(); | 635 uint32_t texture_id = lock.ProduceTextureId(); |
634 | 636 |
635 DCHECK_EQ(resource_provider_->GetResourceTextureTarget(resource->resource_id), | 637 DCHECK_EQ(resource_provider_->GetResourceTextureTarget(resource->resource_id), |
636 (GLenum)GL_TEXTURE_2D); | 638 (GLenum)GL_TEXTURE_2D); |
637 | 639 |
638 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); | 640 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); |
639 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM( | 641 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM( |
640 mailbox_holder.texture_target, mailbox_holder.mailbox.name); | 642 mailbox_holder.texture_target, mailbox_holder.mailbox.name); |
641 gl->CopySubTextureCHROMIUM(src_texture_id, texture_id, 0, 0, 0, 0, | 643 gl->CopySubTextureCHROMIUM(src_texture_id, texture_id, 0, 0, 0, 0, |
642 output_plane_resource_size.width(), | 644 output_plane_resource_size.width(), |
643 output_plane_resource_size.height(), false, false, | 645 output_plane_resource_size.height(), false, false, |
644 false); | 646 false); |
645 gl->DeleteTextures(1, &src_texture_id); | 647 gl->DeleteTextures(1, &src_texture_id); |
646 | 648 |
647 // Sync point for use of frame copy. | 649 // Sync point for use of frame copy. |
648 gpu::SyncToken sync_token; | 650 gpu::SyncToken sync_token; |
649 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 651 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
650 gl->ShallowFlushCHROMIUM(); | 652 gl->ShallowFlushCHROMIUM(); |
651 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 653 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
652 | 654 |
| 655 lock.ReleaseTextureId(); |
| 656 |
653 // Done with the source video frame texture at this point. | 657 // Done with the source video frame texture at this point. |
654 video_frame->UpdateReleaseSyncToken(&client); | 658 video_frame->UpdateReleaseSyncToken(&client); |
655 | 659 |
656 external_resources->mailboxes.push_back( | 660 external_resources->mailboxes.push_back( |
657 TextureMailbox(resource->mailbox, sync_token, GL_TEXTURE_2D, | 661 TextureMailbox(resource->mailbox, sync_token, GL_TEXTURE_2D, |
658 video_frame->coded_size(), false, false)); | 662 video_frame->coded_size(), false, false)); |
659 | 663 |
660 external_resources->release_callbacks.push_back( | 664 external_resources->release_callbacks.push_back( |
661 base::Bind(&RecycleResource, AsWeakPtr(), resource->resource_id)); | 665 base::Bind(&RecycleResource, AsWeakPtr(), resource->resource_id)); |
662 } | 666 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 plane_resource.plane_index == 0; | 761 plane_resource.plane_index == 0; |
758 }); | 762 }); |
759 if (resource_it == updater->all_resources_.end()) | 763 if (resource_it == updater->all_resources_.end()) |
760 return; | 764 return; |
761 | 765 |
762 resource_it->destructed = true; | 766 resource_it->destructed = true; |
763 } | 767 } |
764 #endif | 768 #endif |
765 | 769 |
766 } // namespace cc | 770 } // namespace cc |
OLD | NEW |