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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 ResourceId id, | 856 ResourceId id, |
857 const Resource& resource) { | 857 const Resource& resource) { |
858 std::pair<ResourceMap::iterator, bool> result = | 858 std::pair<ResourceMap::iterator, bool> result = |
859 resources_.insert(ResourceMap::value_type(id, resource)); | 859 resources_.insert(ResourceMap::value_type(id, resource)); |
860 DCHECK(result.second); | 860 DCHECK(result.second); |
861 return &result.first->second; | 861 return &result.first->second; |
862 } | 862 } |
863 | 863 |
864 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { | 864 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { |
865 DCHECK(thread_checker_.CalledOnValidThread()); | 865 DCHECK(thread_checker_.CalledOnValidThread()); |
866 // TODO(danakj): crbug.com/455931 | 866 DCHECK(id); |
867 CHECK(id); | |
868 ResourceMap::iterator it = resources_.find(id); | 867 ResourceMap::iterator it = resources_.find(id); |
869 CHECK(it != resources_.end()); | 868 CHECK(it != resources_.end()); |
piman
2015/04/23 22:55:10
I wonder if this still triggers now. If not we cou
danakj
2015/04/23 22:57:12
We'll just crash later on *it->second, so ya we co
| |
870 return &it->second; | 869 return &it->second; |
871 } | 870 } |
872 | 871 |
873 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { | 872 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { |
874 Resource* resource = GetResource(id); | 873 Resource* resource = GetResource(id); |
875 DCHECK(!resource->locked_for_write || | 874 DCHECK(!resource->locked_for_write || |
876 resource->set_pixels_completion_forced) << | 875 resource->set_pixels_completion_forced) << |
877 "locked for write: " << resource->locked_for_write << | 876 "locked for write: " << resource->locked_for_write << |
878 " pixels completion forced: " << resource->set_pixels_completion_forced; | 877 " pixels completion forced: " << resource->set_pixels_completion_forced; |
879 DCHECK_EQ(resource->exported_count, 0); | 878 DCHECK_EQ(resource->exported_count, 0); |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2037 | 2036 |
2038 resource->read_lock_fence->Wait(); | 2037 resource->read_lock_fence->Wait(); |
2039 } | 2038 } |
2040 | 2039 |
2041 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 2040 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
2042 GLint active_unit = 0; | 2041 GLint active_unit = 0; |
2043 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 2042 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
2044 return active_unit; | 2043 return active_unit; |
2045 } | 2044 } |
2046 | 2045 |
2047 void ResourceProvider::ValidateResource(ResourceId id) { | 2046 void ResourceProvider::ValidateResource(ResourceId id) const { |
2048 DCHECK(thread_checker_.CalledOnValidThread()); | 2047 DCHECK(thread_checker_.CalledOnValidThread()); |
2049 DCHECK(id); | 2048 DCHECK(id); |
2050 DCHECK(resources_.find(id) != resources_.end()); | 2049 DCHECK(resources_.find(id) != resources_.end()); |
2051 } | 2050 } |
2052 | 2051 |
2053 GLES2Interface* ResourceProvider::ContextGL() const { | 2052 GLES2Interface* ResourceProvider::ContextGL() const { |
2054 ContextProvider* context_provider = output_surface_->context_provider(); | 2053 ContextProvider* context_provider = output_surface_->context_provider(); |
2055 return context_provider ? context_provider->ContextGL() : NULL; | 2054 return context_provider ? context_provider->ContextGL() : NULL; |
2056 } | 2055 } |
2057 | 2056 |
2058 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 2057 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
2059 ContextProvider* context_provider = | 2058 ContextProvider* context_provider = |
2060 worker_context ? output_surface_->worker_context_provider() | 2059 worker_context ? output_surface_->worker_context_provider() |
2061 : output_surface_->context_provider(); | 2060 : output_surface_->context_provider(); |
2062 return context_provider ? context_provider->GrContext() : NULL; | 2061 return context_provider ? context_provider->GrContext() : NULL; |
2063 } | 2062 } |
2064 | 2063 |
2065 } // namespace cc | 2064 } // namespace cc |
OLD | NEW |