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

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

Issue 2683763003: cc: make resource keep video buffer format for hardware overlay.
Patch Set: make Resource keep video buffer format Created 3 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/resource_provider.h" 5 #include "cc/resources/resource_provider.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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 Resource* resource = InsertResource( 663 Resource* resource = InsertResource(
664 id, 664 id,
665 Resource(pixels, bitmap.release(), size, Resource::INTERNAL, GL_LINEAR)); 665 Resource(pixels, bitmap.release(), size, Resource::INTERNAL, GL_LINEAR));
666 resource->allocated = true; 666 resource->allocated = true;
667 resource->color_space = color_space; 667 resource->color_space = color_space;
668 return id; 668 return id;
669 } 669 }
670 670
671 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( 671 ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
672 const TextureMailbox& mailbox, 672 const TextureMailbox& mailbox,
673 gfx::BufferFormat buffer_format,
673 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl, 674 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl,
674 bool read_lock_fences_enabled) { 675 bool read_lock_fences_enabled) {
675 DCHECK(thread_checker_.CalledOnValidThread()); 676 DCHECK(thread_checker_.CalledOnValidThread());
676 // Just store the information. Mailbox will be consumed in LockForRead(). 677 // Just store the information. Mailbox will be consumed in LockForRead().
677 ResourceId id = next_id_++; 678 ResourceId id = next_id_++;
678 DCHECK(mailbox.IsValid()); 679 DCHECK(mailbox.IsValid());
679 Resource* resource = nullptr; 680 Resource* resource = nullptr;
680 if (mailbox.IsTexture()) { 681 if (mailbox.IsTexture()) {
681 resource = InsertResource( 682 resource = InsertResource(
682 id, 683 id,
683 Resource(0, mailbox.size_in_pixels(), Resource::EXTERNAL, 684 Resource(0, mailbox.size_in_pixels(), Resource::EXTERNAL,
684 mailbox.target(), 685 mailbox.target(),
685 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR, 686 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR,
686 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE, RGBA_8888)); 687 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE, RGBA_8888));
687 } else { 688 } else {
688 DCHECK(mailbox.IsSharedMemory()); 689 DCHECK(mailbox.IsSharedMemory());
689 SharedBitmap* shared_bitmap = mailbox.shared_bitmap(); 690 SharedBitmap* shared_bitmap = mailbox.shared_bitmap();
690 uint8_t* pixels = shared_bitmap->pixels(); 691 uint8_t* pixels = shared_bitmap->pixels();
691 DCHECK(pixels); 692 DCHECK(pixels);
692 resource = InsertResource( 693 resource = InsertResource(
693 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(), 694 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(),
694 Resource::EXTERNAL, GL_LINEAR)); 695 Resource::EXTERNAL, GL_LINEAR));
695 } 696 }
697 resource->buffer_format = buffer_format;
696 resource->allocated = true; 698 resource->allocated = true;
697 resource->set_mailbox(mailbox); 699 resource->set_mailbox(mailbox);
698 resource->color_space = mailbox.color_space(); 700 resource->color_space = mailbox.color_space();
699 resource->release_callback_impl = 701 resource->release_callback_impl =
700 base::Bind(&SingleReleaseCallbackImpl::Run, 702 base::Bind(&SingleReleaseCallbackImpl::Run,
701 base::Owned(release_callback_impl.release())); 703 base::Owned(release_callback_impl.release()));
702 resource->read_lock_fences_enabled = read_lock_fences_enabled; 704 resource->read_lock_fences_enabled = read_lock_fences_enabled;
703 resource->is_overlay_candidate = mailbox.is_overlay_candidate(); 705 resource->is_overlay_candidate = mailbox.is_overlay_candidate();
704 #if defined(OS_ANDROID) 706 #if defined(OS_ANDROID)
705 resource->is_backed_by_surface_texture = 707 resource->is_backed_by_surface_texture =
706 mailbox.is_backed_by_surface_texture(); 708 mailbox.is_backed_by_surface_texture();
707 resource->wants_promotion_hint = mailbox.wants_promotion_hint(); 709 resource->wants_promotion_hint = mailbox.wants_promotion_hint();
708 if (resource->wants_promotion_hint) 710 if (resource->wants_promotion_hint)
709 wants_promotion_hints_set_.insert(id); 711 wants_promotion_hints_set_.insert(id);
710 #endif 712 #endif
711 resource->color_space = mailbox.color_space(); 713 resource->color_space = mailbox.color_space();
712 714
713 return id; 715 return id;
714 } 716 }
715 717
716 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( 718 ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
717 const TextureMailbox& mailbox, 719 const TextureMailbox& mailbox,
718 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl) { 720 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl) {
719 return CreateResourceFromTextureMailbox( 721 return CreateResourceFromTextureMailbox(mailbox, gfx::BufferFormat::RGBA_8888,
720 mailbox, std::move(release_callback_impl), false); 722 std::move(release_callback_impl),
723 false);
721 } 724 }
722 725
723 void ResourceProvider::DeleteResource(ResourceId id) { 726 void ResourceProvider::DeleteResource(ResourceId id) {
724 DCHECK(thread_checker_.CalledOnValidThread()); 727 DCHECK(thread_checker_.CalledOnValidThread());
725 ResourceMap::iterator it = resources_.find(id); 728 ResourceMap::iterator it = resources_.find(id);
726 CHECK(it != resources_.end()); 729 CHECK(it != resources_.end());
727 Resource* resource = &it->second; 730 Resource* resource = &it->second;
728 DCHECK(!resource->marked_for_deletion); 731 DCHECK(!resource->marked_for_deletion);
729 DCHECK_EQ(resource->imported_count, 0); 732 DCHECK_EQ(resource->imported_count, 0);
730 DCHECK(!resource->locked_for_write); 733 DCHECK(!resource->locked_for_write);
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 2173
2171 const int kImportance = 2; 2174 const int kImportance = 2;
2172 pmd->CreateSharedGlobalAllocatorDump(guid); 2175 pmd->CreateSharedGlobalAllocatorDump(guid);
2173 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2176 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2174 } 2177 }
2175 2178
2176 return true; 2179 return true;
2177 } 2180 }
2178 2181
2179 } // namespace cc 2182 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698