Index: cc/resources/resource_provider.cc |
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc |
index ff0652465d9047447fb376bd097988db9828acdb..e08c19b8a519edebc9ff39817133eb68f36a88d8 100644 |
--- a/cc/resources/resource_provider.cc |
+++ b/cc/resources/resource_provider.cc |
@@ -1039,12 +1039,13 @@ const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { |
if (resource->type == GLTexture && !resource->gl_id) { |
DCHECK(resource->origin != Resource::Internal); |
DCHECK(resource->mailbox.IsTexture()); |
+ |
+ // Mailbox sync_points must be processed by a call to |
+ // WaitSyncPointIfNeeded() prior to calling LockForRead(). |
+ DCHECK(!resource->mailbox.sync_point()); |
+ |
GLES2Interface* gl = ContextGL(); |
DCHECK(gl); |
- if (resource->mailbox.sync_point()) { |
- GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); |
- resource->mailbox.set_sync_point(0); |
- } |
resource->gl_id = texture_id_allocator_->NextId(); |
GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); |
GLC(gl, |
@@ -2242,6 +2243,21 @@ void ResourceProvider::CopyResource(ResourceId source_id, ResourceId dest_id) { |
} |
} |
+void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { |
+ Resource* resource = GetResource(id); |
+ DCHECK_EQ(resource->exported_count, 0); |
+ DCHECK(resource->allocated); |
+ if (resource->type != GLTexture || resource->gl_id) |
+ return; |
+ if (!resource->mailbox.sync_point()) |
+ return; |
+ DCHECK(resource->mailbox.IsValid()); |
+ GLES2Interface* gl = ContextGL(); |
+ DCHECK(gl); |
+ GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); |
+ resource->mailbox.set_sync_point(0); |
+} |
+ |
GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
GLint active_unit = 0; |
gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |