Commit ccfc7a81 authored by reveman@chromium.org's avatar reveman@chromium.org

cc: Add zero-copy texture update support to delegating renderer.

This adds necessary BindTexImage/ReleaseTexImage calls to
ResourceProvider::TransferResource.

BUG=334747

Review URL: https://codereview.chromium.org/132873006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245460 0039d316-1c4b-4281-b951-d872f2087c98
parent f5d6d24a
...@@ -1194,6 +1194,11 @@ void ResourceProvider::ReceiveReturnsFromParent( ...@@ -1194,6 +1194,11 @@ void ResourceProvider::ReceiveReturnsFromParent(
if (resource->exported_count) if (resource->exported_count)
continue; continue;
// Need to wait for the current read lock fence to pass before we can
// recycle this resource.
if (resource->enable_read_lock_fences)
resource->read_lock_fence = current_read_lock_fence_;
if (resource->gl_id) { if (resource->gl_id) {
if (returned.sync_point) if (returned.sync_point)
GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point)); GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point));
...@@ -1255,16 +1260,26 @@ void ResourceProvider::TransferResource(GLES2Interface* gl, ...@@ -1255,16 +1260,26 @@ void ResourceProvider::TransferResource(GLES2Interface* gl,
resource->mailbox = source->shared_bitmap->id(); resource->mailbox = source->shared_bitmap->id();
resource->is_software = true; resource->is_software = true;
} else if (!source->mailbox.IsValid()) { } else if (!source->mailbox.IsValid()) {
// This is a resource allocated by the compositor, we need to produce it. LazyCreate(source);
// Don't set a sync point, the caller will do it.
DCHECK(source->gl_id); DCHECK(source->gl_id);
GLC(gl, gl->BindTexture(resource->target, source->gl_id)); GLC(gl, gl->BindTexture(resource->target, source->gl_id));
if (source->image_id) {
DCHECK(source->dirty_image);
BindImageForSampling(source);
}
// This is a resource allocated by the compositor, we need to produce it.
// Don't set a sync point, the caller will do it.
GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name)); GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name));
GLC(gl, GLC(gl,
gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name)); gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name));
source->mailbox.SetName(resource->mailbox); source->mailbox.SetName(resource->mailbox);
} else { } else {
DCHECK(source->mailbox.IsTexture()); DCHECK(source->mailbox.IsTexture());
if (source->image_id && source->dirty_image) {
DCHECK(source->gl_id);
GLC(gl, gl->BindTexture(resource->target, source->gl_id));
BindImageForSampling(source);
}
// This is either an external resource, or a compositor resource that we // This is either an external resource, or a compositor resource that we
// already exported. Make sure to forward the sync point that we were given. // already exported. Make sure to forward the sync point that we were given.
resource->mailbox = source->mailbox.name(); resource->mailbox = source->mailbox.name();
...@@ -1497,14 +1512,8 @@ GLenum ResourceProvider::BindForSampling( ...@@ -1497,14 +1512,8 @@ GLenum ResourceProvider::BindForSampling(
resource->filter = filter; resource->filter = filter;
} }
if (resource->image_id && resource->dirty_image) { if (resource->image_id && resource->dirty_image)
// Release image currently bound to texture. BindImageForSampling(resource);
if (resource->bound_image_id)
gl->ReleaseTexImage2DCHROMIUM(target, resource->bound_image_id);
gl->BindTexImage2DCHROMIUM(target, resource->image_id);
resource->bound_image_id = resource->image_id;
resource->dirty_image = false;
}
return target; return target;
} }
...@@ -1628,6 +1637,8 @@ void ResourceProvider::LazyCreate(Resource* resource) { ...@@ -1628,6 +1637,8 @@ void ResourceProvider::LazyCreate(Resource* resource) {
if (resource->texture_pool == 0) if (resource->texture_pool == 0)
return; return;
DCHECK(!resource->external);
DCHECK(!resource->mailbox.IsValid());
resource->gl_id = texture_id_allocator_->NextId(); resource->gl_id = texture_id_allocator_->NextId();
GLES2Interface* gl = ContextGL(); GLES2Interface* gl = ContextGL();
...@@ -1696,6 +1707,19 @@ void ResourceProvider::LazyAllocate(Resource* resource) { ...@@ -1696,6 +1707,19 @@ void ResourceProvider::LazyAllocate(Resource* resource) {
} }
} }
void ResourceProvider::BindImageForSampling(Resource* resource) {
GLES2Interface* gl = ContextGL();
DCHECK(resource->gl_id);
DCHECK(resource->image_id);
// Release image currently bound to texture.
if (resource->bound_image_id)
gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id);
gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id);
resource->bound_image_id = resource->image_id;
resource->dirty_image = false;
}
void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
bool enable) { bool enable) {
Resource* resource = GetResource(id); Resource* resource = GetResource(id);
......
...@@ -469,6 +469,7 @@ class CC_EXPORT ResourceProvider { ...@@ -469,6 +469,7 @@ class CC_EXPORT ResourceProvider {
void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style);
void LazyCreate(Resource* resource); void LazyCreate(Resource* resource);
void LazyAllocate(Resource* resource); void LazyAllocate(Resource* resource);
void BindImageForSampling(Resource* resource);
// Binds the given GL resource to a texture target for sampling using the // Binds the given GL resource to a texture target for sampling using the
// specified filter for both minification and magnification. Returns the // specified filter for both minification and magnification. Returns the
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment