| 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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 " pixels completion forced: " << resource->set_pixels_completion_forced; | 1032 " pixels completion forced: " << resource->set_pixels_completion_forced; |
| 1033 DCHECK_EQ(resource->exported_count, 0); | 1033 DCHECK_EQ(resource->exported_count, 0); |
| 1034 // Uninitialized! Call SetPixels or LockForWrite first. | 1034 // Uninitialized! Call SetPixels or LockForWrite first. |
| 1035 DCHECK(resource->allocated); | 1035 DCHECK(resource->allocated); |
| 1036 | 1036 |
| 1037 LazyCreate(resource); | 1037 LazyCreate(resource); |
| 1038 | 1038 |
| 1039 if (resource->type == GLTexture && !resource->gl_id) { | 1039 if (resource->type == GLTexture && !resource->gl_id) { |
| 1040 DCHECK(resource->origin != Resource::Internal); | 1040 DCHECK(resource->origin != Resource::Internal); |
| 1041 DCHECK(resource->mailbox.IsTexture()); | 1041 DCHECK(resource->mailbox.IsTexture()); |
| 1042 |
| 1043 // Mailbox sync_points must be processed by a call to |
| 1044 // WaitSyncPointIfNeeded() prior to calling LockForRead(). |
| 1045 DCHECK(!resource->mailbox.sync_point()); |
| 1046 |
| 1042 GLES2Interface* gl = ContextGL(); | 1047 GLES2Interface* gl = ContextGL(); |
| 1043 DCHECK(gl); | 1048 DCHECK(gl); |
| 1044 if (resource->mailbox.sync_point()) { | |
| 1045 GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); | |
| 1046 resource->mailbox.set_sync_point(0); | |
| 1047 } | |
| 1048 resource->gl_id = texture_id_allocator_->NextId(); | 1049 resource->gl_id = texture_id_allocator_->NextId(); |
| 1049 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); | 1050 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); |
| 1050 GLC(gl, | 1051 GLC(gl, |
| 1051 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), | 1052 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), |
| 1052 resource->mailbox.name())); | 1053 resource->mailbox.name())); |
| 1053 } | 1054 } |
| 1054 | 1055 |
| 1055 if (!resource->pixels && resource->has_shared_bitmap_id && | 1056 if (!resource->pixels && resource->has_shared_bitmap_id && |
| 1056 shared_bitmap_manager_) { | 1057 shared_bitmap_manager_) { |
| 1057 scoped_ptr<SharedBitmap> bitmap = | 1058 scoped_ptr<SharedBitmap> bitmap = |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 } else { | 2236 } else { |
| 2236 DCHECK_EQ(Bitmap, source_resource->type); | 2237 DCHECK_EQ(Bitmap, source_resource->type); |
| 2237 DCHECK_EQ(RGBA_8888, source_resource->format); | 2238 DCHECK_EQ(RGBA_8888, source_resource->format); |
| 2238 LazyAllocate(dest_resource); | 2239 LazyAllocate(dest_resource); |
| 2239 | 2240 |
| 2240 size_t bytes = SharedBitmap::CheckedSizeInBytes(source_resource->size); | 2241 size_t bytes = SharedBitmap::CheckedSizeInBytes(source_resource->size); |
| 2241 memcpy(dest_resource->pixels, source_resource->pixels, bytes); | 2242 memcpy(dest_resource->pixels, source_resource->pixels, bytes); |
| 2242 } | 2243 } |
| 2243 } | 2244 } |
| 2244 | 2245 |
| 2246 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { |
| 2247 Resource* resource = GetResource(id); |
| 2248 DCHECK_EQ(resource->exported_count, 0); |
| 2249 DCHECK(resource->allocated); |
| 2250 if (resource->type != GLTexture || resource->gl_id) |
| 2251 return; |
| 2252 if (!resource->mailbox.sync_point()) |
| 2253 return; |
| 2254 DCHECK(resource->mailbox.IsValid()); |
| 2255 GLES2Interface* gl = ContextGL(); |
| 2256 DCHECK(gl); |
| 2257 GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); |
| 2258 resource->mailbox.set_sync_point(0); |
| 2259 } |
| 2260 |
| 2245 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 2261 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
| 2246 GLint active_unit = 0; | 2262 GLint active_unit = 0; |
| 2247 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 2263 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
| 2248 return active_unit; | 2264 return active_unit; |
| 2249 } | 2265 } |
| 2250 | 2266 |
| 2251 GLES2Interface* ResourceProvider::ContextGL() const { | 2267 GLES2Interface* ResourceProvider::ContextGL() const { |
| 2252 ContextProvider* context_provider = output_surface_->context_provider(); | 2268 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2253 return context_provider ? context_provider->ContextGL() : NULL; | 2269 return context_provider ? context_provider->ContextGL() : NULL; |
| 2254 } | 2270 } |
| 2255 | 2271 |
| 2256 class GrContext* ResourceProvider::GrContext() const { | 2272 class GrContext* ResourceProvider::GrContext() const { |
| 2257 ContextProvider* context_provider = output_surface_->context_provider(); | 2273 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2258 return context_provider ? context_provider->GrContext() : NULL; | 2274 return context_provider ? context_provider->GrContext() : NULL; |
| 2259 } | 2275 } |
| 2260 | 2276 |
| 2261 } // namespace cc | 2277 } // namespace cc |
| OLD | NEW |