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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 image_id(0), | 225 image_id(0), |
226 bound_image_id(0), | 226 bound_image_id(0), |
227 dirty_image(false), | 227 dirty_image(false), |
228 texture_pool(0), | 228 texture_pool(0), |
229 wrap_mode(0), | 229 wrap_mode(0), |
230 lost(false), | 230 lost(false), |
231 hint(TextureUsageAny), | 231 hint(TextureUsageAny), |
232 type(InvalidType), | 232 type(InvalidType), |
233 format(RGBA_8888), | 233 format(RGBA_8888), |
234 has_shared_bitmap_id(false), | 234 has_shared_bitmap_id(false), |
| 235 has_native_buffer_backing(false), |
235 shared_bitmap(NULL) {} | 236 shared_bitmap(NULL) {} |
236 | 237 |
237 ResourceProvider::Resource::~Resource() {} | 238 ResourceProvider::Resource::~Resource() {} |
238 | 239 |
239 ResourceProvider::Resource::Resource(GLuint texture_id, | 240 ResourceProvider::Resource::Resource(GLuint texture_id, |
240 const gfx::Size& size, | 241 const gfx::Size& size, |
241 Origin origin, | 242 Origin origin, |
242 GLenum target, | 243 GLenum target, |
243 GLenum filter, | 244 GLenum filter, |
244 GLenum texture_pool, | 245 GLenum texture_pool, |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 Resource* resource = GetResource(id); | 598 Resource* resource = GetResource(id); |
598 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || | 599 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || |
599 resource->lost; | 600 resource->lost; |
600 } | 601 } |
601 | 602 |
602 bool ResourceProvider::IsLost(ResourceId id) { | 603 bool ResourceProvider::IsLost(ResourceId id) { |
603 Resource* resource = GetResource(id); | 604 Resource* resource = GetResource(id); |
604 return resource->lost; | 605 return resource->lost; |
605 } | 606 } |
606 | 607 |
| 608 bool ResourceProvider::HasNativeBufferBacking(ResourceId id) { |
| 609 Resource* resource = GetResource(id); |
| 610 return resource->has_native_buffer_backing; |
| 611 } |
| 612 |
607 ResourceProvider::ResourceId ResourceProvider::CreateResource( | 613 ResourceProvider::ResourceId ResourceProvider::CreateResource( |
608 const gfx::Size& size, | 614 const gfx::Size& size, |
609 GLint wrap_mode, | 615 GLint wrap_mode, |
610 TextureUsageHint hint, | 616 TextureUsageHint hint, |
611 ResourceFormat format) { | 617 ResourceFormat format) { |
612 DCHECK(!size.IsEmpty()); | 618 DCHECK(!size.IsEmpty()); |
613 switch (default_resource_type_) { | 619 switch (default_resource_type_) { |
614 case GLTexture: | 620 case GLTexture: |
615 return CreateGLTexture(size, | 621 return CreateGLTexture(size, |
616 GL_TEXTURE_2D, | 622 GL_TEXTURE_2D, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 mailbox.shared_memory_size(), | 777 mailbox.shared_memory_size(), |
772 Resource::External, | 778 Resource::External, |
773 GL_LINEAR, | 779 GL_LINEAR, |
774 GL_CLAMP_TO_EDGE); | 780 GL_CLAMP_TO_EDGE); |
775 } | 781 } |
776 resource.allocated = true; | 782 resource.allocated = true; |
777 resource.mailbox = mailbox; | 783 resource.mailbox = mailbox; |
778 resource.release_callback = | 784 resource.release_callback = |
779 base::Bind(&SingleReleaseCallback::Run, | 785 base::Bind(&SingleReleaseCallback::Run, |
780 base::Owned(release_callback.release())); | 786 base::Owned(release_callback.release())); |
| 787 resource.has_native_buffer_backing = mailbox.hw_backed(); |
781 return id; | 788 return id; |
782 } | 789 } |
783 | 790 |
784 void ResourceProvider::DeleteResource(ResourceId id) { | 791 void ResourceProvider::DeleteResource(ResourceId id) { |
785 DCHECK(thread_checker_.CalledOnValidThread()); | 792 DCHECK(thread_checker_.CalledOnValidThread()); |
786 ResourceMap::iterator it = resources_.find(id); | 793 ResourceMap::iterator it = resources_.find(id); |
787 CHECK(it != resources_.end()); | 794 CHECK(it != resources_.end()); |
788 Resource* resource = &it->second; | 795 Resource* resource = &it->second; |
789 DCHECK(!resource->lock_for_read_count); | 796 DCHECK(!resource->lock_for_read_count); |
790 DCHECK(!resource->marked_for_deletion); | 797 DCHECK(!resource->marked_for_deletion); |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 ContextProvider* context_provider = output_surface_->context_provider(); | 2187 ContextProvider* context_provider = output_surface_->context_provider(); |
2181 return context_provider ? context_provider->ContextGL() : NULL; | 2188 return context_provider ? context_provider->ContextGL() : NULL; |
2182 } | 2189 } |
2183 | 2190 |
2184 class GrContext* ResourceProvider::GrContext() const { | 2191 class GrContext* ResourceProvider::GrContext() const { |
2185 ContextProvider* context_provider = output_surface_->context_provider(); | 2192 ContextProvider* context_provider = output_surface_->context_provider(); |
2186 return context_provider ? context_provider->GrContext() : NULL; | 2193 return context_provider ? context_provider->GrContext() : NULL; |
2187 } | 2194 } |
2188 | 2195 |
2189 } // namespace cc | 2196 } // namespace cc |
OLD | NEW |