Chromium Code Reviews| 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 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 shared_bitmap_manager_->GetSharedBitmapFromId( | 1053 shared_bitmap_manager_->GetSharedBitmapFromId( |
| 1054 resource->size, resource->shared_bitmap_id); | 1054 resource->size, resource->shared_bitmap_id); |
| 1055 if (bitmap) { | 1055 if (bitmap) { |
| 1056 resource->shared_bitmap = bitmap.release(); | 1056 resource->shared_bitmap = bitmap.release(); |
| 1057 resource->pixels = resource->shared_bitmap->pixels(); | 1057 resource->pixels = resource->shared_bitmap->pixels(); |
| 1058 } | 1058 } |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 resource->lock_for_read_count++; | 1061 resource->lock_for_read_count++; |
| 1062 if (resource->read_lock_fences_enabled) { | 1062 if (resource->read_lock_fences_enabled) { |
| 1063 if (current_read_lock_fence_) | 1063 if (current_read_lock_fence_.get()) |
| 1064 current_read_lock_fence_->Set(); | 1064 current_read_lock_fence_->Set(); |
| 1065 resource->read_lock_fence = current_read_lock_fence_; | 1065 resource->read_lock_fence = current_read_lock_fence_; |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 return resource; | 1068 return resource; |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 void ResourceProvider::UnlockForRead(ResourceId id) { | 1071 void ResourceProvider::UnlockForRead(ResourceId id) { |
| 1072 DCHECK(thread_checker_.CalledOnValidThread()); | 1072 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1073 ResourceMap::iterator it = resources_.find(id); | 1073 ResourceMap::iterator it = resources_.find(id); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1517 | 1517 |
| 1518 CHECK_GE(resource->exported_count, returned.count); | 1518 CHECK_GE(resource->exported_count, returned.count); |
| 1519 resource->exported_count -= returned.count; | 1519 resource->exported_count -= returned.count; |
| 1520 resource->lost |= returned.lost; | 1520 resource->lost |= returned.lost; |
| 1521 if (resource->exported_count) | 1521 if (resource->exported_count) |
| 1522 continue; | 1522 continue; |
| 1523 | 1523 |
| 1524 // Need to wait for the current read lock fence to pass before we can | 1524 // Need to wait for the current read lock fence to pass before we can |
| 1525 // recycle this resource. | 1525 // recycle this resource. |
| 1526 if (resource->read_lock_fences_enabled) { | 1526 if (resource->read_lock_fences_enabled) { |
| 1527 if (current_read_lock_fence_) | 1527 if (current_read_lock_fence_.get()) |
| 1528 current_read_lock_fence_->Set(); | 1528 current_read_lock_fence_->Set(); |
| 1529 resource->read_lock_fence = current_read_lock_fence_; | 1529 resource->read_lock_fence = current_read_lock_fence_; |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 if (returned.sync_point) { | 1532 if (returned.sync_point) { |
| 1533 DCHECK(!resource->has_shared_bitmap_id); | 1533 DCHECK(!resource->has_shared_bitmap_id); |
| 1534 if (resource->origin == Resource::Internal) { | 1534 if (resource->origin == Resource::Internal) { |
| 1535 DCHECK(resource->gl_id); | 1535 DCHECK(resource->gl_id); |
| 1536 GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point)); | 1536 GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point)); |
| 1537 } else { | 1537 } else { |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2254 resource->mailbox.set_sync_point(0); | 2254 resource->mailbox.set_sync_point(0); |
| 2255 } | 2255 } |
| 2256 | 2256 |
| 2257 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 2257 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
| 2258 GLint active_unit = 0; | 2258 GLint active_unit = 0; |
| 2259 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 2259 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
| 2260 return active_unit; | 2260 return active_unit; |
| 2261 } | 2261 } |
| 2262 | 2262 |
| 2263 GLES2Interface* ResourceProvider::ContextGL() const { | 2263 GLES2Interface* ResourceProvider::ContextGL() const { |
| 2264 ContextProvider* context_provider = output_surface_->context_provider(); | 2264 scoped_refptr<ContextProvider> context_provider = |
|
enne (OOO)
2014/08/25 23:39:12
This is a local alias, not an ownership transfer.
dcheng
2014/08/25 23:44:56
Done.
| |
| 2265 output_surface_->context_provider(); | |
| 2265 return context_provider ? context_provider->ContextGL() : NULL; | 2266 return context_provider ? context_provider->ContextGL() : NULL; |
| 2266 } | 2267 } |
| 2267 | 2268 |
| 2268 class GrContext* ResourceProvider::GrContext() const { | 2269 class GrContext* ResourceProvider::GrContext() const { |
| 2269 ContextProvider* context_provider = output_surface_->context_provider(); | 2270 scoped_refptr<ContextProvider> context_provider = |
|
enne (OOO)
2014/08/25 23:39:11
This is a local alias, not an ownership transfer.
enne (OOO)
2014/08/25 23:39:12
Same here.
dcheng
2014/08/25 23:44:56
Done.
| |
| 2271 output_surface_->context_provider(); | |
| 2270 return context_provider ? context_provider->GrContext() : NULL; | 2272 return context_provider ? context_provider->GrContext() : NULL; |
| 2271 } | 2273 } |
| 2272 | 2274 |
| 2273 } // namespace cc | 2275 } // namespace cc |
| OLD | NEW |