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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2233 } else { | 2234 } else { |
2234 DCHECK_EQ(Bitmap, source_resource->type); | 2235 DCHECK_EQ(Bitmap, source_resource->type); |
2235 DCHECK_EQ(RGBA_8888, source_resource->format); | 2236 DCHECK_EQ(RGBA_8888, source_resource->format); |
2236 LazyAllocate(dest_resource); | 2237 LazyAllocate(dest_resource); |
2237 | 2238 |
2238 size_t bytes = SharedBitmap::CheckedSizeInBytes(source_resource->size); | 2239 size_t bytes = SharedBitmap::CheckedSizeInBytes(source_resource->size); |
2239 memcpy(dest_resource->pixels, source_resource->pixels, bytes); | 2240 memcpy(dest_resource->pixels, source_resource->pixels, bytes); |
2240 } | 2241 } |
2241 } | 2242 } |
2242 | 2243 |
2244 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { | |
2245 Resource* resource = GetResource(id); | |
2246 DCHECK_EQ(resource->exported_count, 0); | |
2247 DCHECK(resource->allocated); | |
2248 if (resource->type != GLTexture || resource->gl_id) | |
2249 return; | |
2250 if (!resource->mailbox.sync_point()) | |
2251 return; | |
2252 DCHECK(resource->mailbox.IsValid()); | |
2253 | |
2254 // Insert WaitSyncPointCHROMIUM on gl context, and clear sync_point from | |
danakj
2014/08/13 23:05:19
this comment says "what", not "why". i think it ca
vmiura
2014/08/15 21:20:39
Done.
| |
2255 // mailbox. | |
2256 GLES2Interface* gl = ContextGL(); | |
2257 DCHECK(gl); | |
2258 GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); | |
2259 resource->mailbox.set_sync_point(0); | |
2260 } | |
2261 | |
2243 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 2262 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
2244 GLint active_unit = 0; | 2263 GLint active_unit = 0; |
2245 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 2264 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
2246 return active_unit; | 2265 return active_unit; |
2247 } | 2266 } |
2248 | 2267 |
2249 GLES2Interface* ResourceProvider::ContextGL() const { | 2268 GLES2Interface* ResourceProvider::ContextGL() const { |
2250 ContextProvider* context_provider = output_surface_->context_provider(); | 2269 ContextProvider* context_provider = output_surface_->context_provider(); |
2251 return context_provider ? context_provider->ContextGL() : NULL; | 2270 return context_provider ? context_provider->ContextGL() : NULL; |
2252 } | 2271 } |
2253 | 2272 |
2254 class GrContext* ResourceProvider::GrContext() const { | 2273 class GrContext* ResourceProvider::GrContext() const { |
2255 ContextProvider* context_provider = output_surface_->context_provider(); | 2274 ContextProvider* context_provider = output_surface_->context_provider(); |
2256 return context_provider ? context_provider->GrContext() : NULL; | 2275 return context_provider ? context_provider->GrContext() : NULL; |
2257 } | 2276 } |
2258 | 2277 |
2259 } // namespace cc | 2278 } // namespace cc |
OLD | NEW |