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 <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 resource->read_lock_fence = current_read_lock_fence_; | 463 resource->read_lock_fence = current_read_lock_fence_; |
464 | 464 |
465 return resource; | 465 return resource; |
466 } | 466 } |
467 | 467 |
468 void ResourceProvider::UnlockForRead(ResourceId id) { | 468 void ResourceProvider::UnlockForRead(ResourceId id) { |
469 DCHECK(thread_checker_.CalledOnValidThread()); | 469 DCHECK(thread_checker_.CalledOnValidThread()); |
470 ResourceMap::iterator it = resources_.find(id); | 470 ResourceMap::iterator it = resources_.find(id); |
471 CHECK(it != resources_.end()); | 471 CHECK(it != resources_.end()); |
472 Resource* resource = &it->second; | 472 Resource* resource = &it->second; |
473 DCHECK(resource->lock_for_read_count > 0); | 473 DCHECK_GT(resource->lock_for_read_count, 0); |
474 DCHECK(!resource->exported); | 474 DCHECK(!resource->exported); |
475 resource->lock_for_read_count--; | 475 resource->lock_for_read_count--; |
476 } | 476 } |
477 | 477 |
478 const ResourceProvider::Resource* ResourceProvider::LockForWrite( | 478 const ResourceProvider::Resource* ResourceProvider::LockForWrite( |
479 ResourceId id) { | 479 ResourceId id) { |
480 DCHECK(thread_checker_.CalledOnValidThread()); | 480 DCHECK(thread_checker_.CalledOnValidThread()); |
481 ResourceMap::iterator it = resources_.find(id); | 481 ResourceMap::iterator it = resources_.find(id); |
482 CHECK(it != resources_.end()); | 482 CHECK(it != resources_.end()); |
483 Resource* resource = &it->second; | 483 Resource* resource = &it->second; |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 gfx::Size& size = resource->size; | 1180 gfx::Size& size = resource->size; |
1181 GLenum format = resource->format; | 1181 GLenum format = resource->format; |
1182 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); | 1182 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); |
1183 if (use_texture_storage_ext_ && IsTextureFormatSupportedForStorage(format)) { | 1183 if (use_texture_storage_ext_ && IsTextureFormatSupportedForStorage(format)) { |
1184 GLenum storage_format = TextureToStorageFormat(format); | 1184 GLenum storage_format = TextureToStorageFormat(format); |
1185 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, | 1185 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, |
1186 1, | 1186 1, |
1187 storage_format, | 1187 storage_format, |
1188 size.width(), | 1188 size.width(), |
1189 size.height())); | 1189 size.height())); |
1190 } else | 1190 } else { |
1191 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, | 1191 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, |
1192 0, | 1192 0, |
1193 format, | 1193 format, |
1194 size.width(), | 1194 size.width(), |
1195 size.height(), | 1195 size.height(), |
1196 0, | 1196 0, |
1197 format, | 1197 format, |
1198 GL_UNSIGNED_BYTE, | 1198 GL_UNSIGNED_BYTE, |
1199 NULL)); | 1199 NULL)); |
| 1200 } |
1200 } | 1201 } |
1201 | 1202 |
1202 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, | 1203 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, |
1203 bool enable) { | 1204 bool enable) { |
1204 DCHECK(thread_checker_.CalledOnValidThread()); | 1205 DCHECK(thread_checker_.CalledOnValidThread()); |
1205 ResourceMap::iterator it = resources_.find(id); | 1206 ResourceMap::iterator it = resources_.find(id); |
1206 CHECK(it != resources_.end()); | 1207 CHECK(it != resources_.end()); |
1207 Resource* resource = &it->second; | 1208 Resource* resource = &it->second; |
1208 resource->enable_read_lock_fences = enable; | 1209 resource->enable_read_lock_fences = enable; |
1209 } | 1210 } |
1210 | 1211 |
1211 } // namespace cc | 1212 } // namespace cc |
OLD | NEW |