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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 base::TimeDelta::FromMicroseconds( | 863 base::TimeDelta::FromMicroseconds( |
864 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / | 864 base::Time::kMicrosecondsPerSecond * kTextureUploadTickRate) / |
865 uploads_per_tick; | 865 uploads_per_tick; |
866 | 866 |
867 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; | 867 size_t total_uploads = NumBlockingUploads() + uploads_per_tick; |
868 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; | 868 return gfx::FrameTime::Now() + upload_one_texture_time * total_uploads; |
869 } | 869 } |
870 | 870 |
871 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { | 871 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { |
872 DCHECK(thread_checker_.CalledOnValidThread()); | 872 DCHECK(thread_checker_.CalledOnValidThread()); |
873 // Try to differentiate GetResource with a bad id vs with no id. | 873 // TODO(danakj): crbug.com/455931 |
874 CHECK(id); | 874 CHECK(id); |
875 ResourceMap::iterator it = resources_.find(id); | 875 ResourceMap::iterator it = resources_.find(id); |
876 CHECK(it != resources_.end()); | 876 CHECK(it != resources_.end()); |
877 return &it->second; | 877 return &it->second; |
878 } | 878 } |
879 | 879 |
880 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { | 880 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { |
881 Resource* resource = GetResource(id); | 881 Resource* resource = GetResource(id); |
882 DCHECK(!resource->locked_for_write || | 882 DCHECK(!resource->locked_for_write || |
883 resource->set_pixels_completion_forced) << | 883 resource->set_pixels_completion_forced) << |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2127 | 2127 |
2128 resource->read_lock_fence->Wait(); | 2128 resource->read_lock_fence->Wait(); |
2129 } | 2129 } |
2130 | 2130 |
2131 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 2131 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
2132 GLint active_unit = 0; | 2132 GLint active_unit = 0; |
2133 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 2133 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
2134 return active_unit; | 2134 return active_unit; |
2135 } | 2135 } |
2136 | 2136 |
| 2137 void ResourceProvider::ValidateResource(ResourceId id) { |
| 2138 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2139 CHECK(id); |
| 2140 ResourceMap::iterator it = resources_.find(id); |
| 2141 CHECK(it != resources_.end()); |
| 2142 } |
| 2143 |
2137 GLES2Interface* ResourceProvider::ContextGL() const { | 2144 GLES2Interface* ResourceProvider::ContextGL() const { |
2138 ContextProvider* context_provider = output_surface_->context_provider(); | 2145 ContextProvider* context_provider = output_surface_->context_provider(); |
2139 return context_provider ? context_provider->ContextGL() : NULL; | 2146 return context_provider ? context_provider->ContextGL() : NULL; |
2140 } | 2147 } |
2141 | 2148 |
2142 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 2149 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
2143 ContextProvider* context_provider = | 2150 ContextProvider* context_provider = |
2144 worker_context ? output_surface_->worker_context_provider() | 2151 worker_context ? output_surface_->worker_context_provider() |
2145 : output_surface_->context_provider(); | 2152 : output_surface_->context_provider(); |
2146 return context_provider ? context_provider->GrContext() : NULL; | 2153 return context_provider ? context_provider->GrContext() : NULL; |
2147 } | 2154 } |
2148 | 2155 |
2149 } // namespace cc | 2156 } // namespace cc |
OLD | NEW |