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

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

Issue 2965103003: Test
Patch Set: c Created 3 years, 5 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/resources/resource_provider.h ('k') | cc/resources/shared_bitmap.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 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 652
653 ResourceId ResourceProvider::CreateBitmap(const gfx::Size& size, 653 ResourceId ResourceProvider::CreateBitmap(const gfx::Size& size,
654 const gfx::ColorSpace& color_space) { 654 const gfx::ColorSpace& color_space) {
655 DCHECK(thread_checker_.CalledOnValidThread()); 655 DCHECK(thread_checker_.CalledOnValidThread());
656 656
657 std::unique_ptr<SharedBitmap> bitmap = 657 std::unique_ptr<SharedBitmap> bitmap =
658 shared_bitmap_manager_->AllocateSharedBitmap(size); 658 shared_bitmap_manager_->AllocateSharedBitmap(size);
659 uint8_t* pixels = bitmap->pixels(); 659 uint8_t* pixels = bitmap->pixels();
660 DCHECK(pixels); 660 DCHECK(pixels);
661 661
662 shared_bitmaps_to_register_.push_back(bitmap.get());
663
662 ResourceId id = next_id_++; 664 ResourceId id = next_id_++;
663 Resource* resource = InsertResource( 665 Resource* resource = InsertResource(
664 id, 666 id,
665 Resource(pixels, bitmap.release(), size, Resource::INTERNAL, GL_LINEAR)); 667 Resource(pixels, bitmap.release(), size, Resource::INTERNAL, GL_LINEAR));
666 resource->allocated = true; 668 resource->allocated = true;
667 resource->color_space = color_space; 669 resource->color_space = color_space;
668 return id; 670 return id;
669 } 671 }
670 672
671 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( 673 ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
672 const TextureMailbox& mailbox, 674 const TextureMailbox& mailbox,
673 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl, 675 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl,
674 bool read_lock_fences_enabled) { 676 bool read_lock_fences_enabled) {
675 DCHECK(thread_checker_.CalledOnValidThread()); 677 DCHECK(thread_checker_.CalledOnValidThread());
676 // Just store the information. Mailbox will be consumed in LockForRead(). 678 // Just store the information. Mailbox will be consumed in LockForRead().
677 ResourceId id = next_id_++; 679 ResourceId id = next_id_++;
678 DCHECK(mailbox.IsValid()); 680 DCHECK(mailbox.IsValid());
679 Resource* resource = nullptr; 681 Resource* resource = nullptr;
680 if (mailbox.IsTexture()) { 682 if (mailbox.IsTexture()) {
681 resource = InsertResource( 683 resource = InsertResource(
682 id, 684 id,
683 Resource(0, mailbox.size_in_pixels(), Resource::EXTERNAL, 685 Resource(0, mailbox.size_in_pixels(), Resource::EXTERNAL,
684 mailbox.target(), 686 mailbox.target(),
685 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR, 687 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR,
686 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE, RGBA_8888)); 688 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE, RGBA_8888));
687 } else { 689 } else {
688 DCHECK(mailbox.IsSharedMemory()); 690 DCHECK(mailbox.IsSharedMemory());
689 SharedBitmap* shared_bitmap = mailbox.shared_bitmap(); 691 SharedBitmap* shared_bitmap = mailbox.shared_bitmap();
692 shared_bitmaps_to_register_.push_back(shared_bitmap);
690 uint8_t* pixels = shared_bitmap->pixels(); 693 uint8_t* pixels = shared_bitmap->pixels();
691 DCHECK(pixels); 694 DCHECK(pixels);
692 resource = InsertResource( 695 resource = InsertResource(
693 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(), 696 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(),
694 Resource::EXTERNAL, GL_LINEAR)); 697 Resource::EXTERNAL, GL_LINEAR));
698
695 } 699 }
696 resource->allocated = true; 700 resource->allocated = true;
697 resource->set_mailbox(mailbox); 701 resource->set_mailbox(mailbox);
698 resource->color_space = mailbox.color_space(); 702 resource->color_space = mailbox.color_space();
699 resource->release_callback_impl = 703 resource->release_callback_impl =
700 base::Bind(&SingleReleaseCallbackImpl::Run, 704 base::Bind(&SingleReleaseCallbackImpl::Run,
701 base::Owned(release_callback_impl.release())); 705 base::Owned(release_callback_impl.release()));
702 resource->read_lock_fences_enabled = read_lock_fences_enabled; 706 resource->read_lock_fences_enabled = read_lock_fences_enabled;
703 resource->is_overlay_candidate = mailbox.is_overlay_candidate(); 707 resource->is_overlay_candidate = mailbox.is_overlay_candidate();
704 #if defined(OS_ANDROID) 708 #if defined(OS_ANDROID)
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 } else { 2211 } else {
2208 pmd->CreateSharedGlobalAllocatorDump(guid); 2212 pmd->CreateSharedGlobalAllocatorDump(guid);
2209 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2213 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2210 } 2214 }
2211 } 2215 }
2212 2216
2213 return true; 2217 return true;
2214 } 2218 }
2215 2219
2216 } // namespace cc 2220 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/shared_bitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698