OLD | NEW |
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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 DCHECK(pixels); | 622 DCHECK(pixels); |
623 | 623 |
624 ResourceId id = next_id_++; | 624 ResourceId id = next_id_++; |
625 Resource* resource = InsertResource( | 625 Resource* resource = InsertResource( |
626 id, | 626 id, |
627 Resource(pixels, bitmap.release(), size, Resource::INTERNAL, GL_LINEAR)); | 627 Resource(pixels, bitmap.release(), size, Resource::INTERNAL, GL_LINEAR)); |
628 resource->allocated = true; | 628 resource->allocated = true; |
629 return id; | 629 return id; |
630 } | 630 } |
631 | 631 |
632 ResourceId ResourceProvider::CreateResourceFromIOSurface( | |
633 const gfx::Size& size, | |
634 unsigned io_surface_id) { | |
635 DCHECK(thread_checker_.CalledOnValidThread()); | |
636 | |
637 ResourceId id = next_id_++; | |
638 Resource* resource = InsertResource( | |
639 id, Resource(0, gfx::Size(), Resource::INTERNAL, GL_TEXTURE_RECTANGLE_ARB, | |
640 GL_LINEAR, TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE, | |
641 RGBA_8888)); | |
642 LazyCreate(resource); | |
643 GLES2Interface* gl = ContextGL(); | |
644 DCHECK(gl); | |
645 gl->BindTexture(GL_TEXTURE_RECTANGLE_ARB, resource->gl_id); | |
646 gl->TexImageIOSurface2DCHROMIUM( | |
647 GL_TEXTURE_RECTANGLE_ARB, size.width(), size.height(), io_surface_id, 0); | |
648 resource->allocated = true; | |
649 return id; | |
650 } | |
651 | |
652 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( | 632 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( |
653 const TextureMailbox& mailbox, | 633 const TextureMailbox& mailbox, |
654 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl, | 634 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl, |
655 bool read_lock_fences_enabled) { | 635 bool read_lock_fences_enabled) { |
656 DCHECK(thread_checker_.CalledOnValidThread()); | 636 DCHECK(thread_checker_.CalledOnValidThread()); |
657 // Just store the information. Mailbox will be consumed in LockForRead(). | 637 // Just store the information. Mailbox will be consumed in LockForRead(). |
658 ResourceId id = next_id_++; | 638 ResourceId id = next_id_++; |
659 DCHECK(mailbox.IsValid()); | 639 DCHECK(mailbox.IsValid()); |
660 Resource* resource = nullptr; | 640 Resource* resource = nullptr; |
661 if (mailbox.IsTexture()) { | 641 if (mailbox.IsTexture()) { |
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 | 1959 |
1980 const int kImportance = 2; | 1960 const int kImportance = 2; |
1981 pmd->CreateSharedGlobalAllocatorDump(guid); | 1961 pmd->CreateSharedGlobalAllocatorDump(guid); |
1982 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1962 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1983 } | 1963 } |
1984 | 1964 |
1985 return true; | 1965 return true; |
1986 } | 1966 } |
1987 | 1967 |
1988 } // namespace cc | 1968 } // namespace cc |
OLD | NEW |