Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: cc/resources/resource_provider.cc

Issue 69343011: cc: Rationalize sync points and lost status for returned resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 58603548d6f34bde24d24ea5168913100bba72ca..40744177e36a1aa5d2c7229a575e727f3c9d9e50 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -180,6 +180,7 @@ ResourceProvider::Resource::Resource()
set_pixels_completion_forced(false),
allocated(false),
enable_read_lock_fences(false),
+ sync_point_is_from_client(false),
read_lock_fence(NULL),
size(),
target(0),
@@ -222,6 +223,7 @@ ResourceProvider::Resource::Resource(unsigned texture_id,
set_pixels_completion_forced(false),
allocated(false),
enable_read_lock_fences(false),
+ sync_point_is_from_client(false),
read_lock_fence(NULL),
size(size),
target(target),
@@ -261,6 +263,7 @@ ResourceProvider::Resource::Resource(uint8_t* pixels,
set_pixels_completion_forced(false),
allocated(false),
enable_read_lock_fences(false),
+ sync_point_is_from_client(false),
read_lock_fence(NULL),
size(size),
target(0),
@@ -481,6 +484,7 @@ ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
resource.external = true;
resource.allocated = true;
resource.mailbox = mailbox;
+ resource.sync_point_is_from_client = true;
resource.release_callback =
base::Bind(&SingleReleaseCallback::Run,
base::Owned(release_callback.release()));
@@ -538,14 +542,18 @@ void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it,
}
if (resource->mailbox.IsValid() && resource->external) {
unsigned sync_point = resource->mailbox.sync_point();
+ if (resource->sync_point_is_from_client)
+ sync_point = 0;
if (resource->mailbox.IsTexture()) {
lost_resource |= lost_output_surface_;
WebGraphicsContext3D* context3d = Context3d();
DCHECK(context3d);
if (resource->gl_id)
GLC(context3d, context3d->deleteTexture(resource->gl_id));
- if (!lost_resource && resource->gl_id)
+ if (!lost_resource && resource->gl_id) {
+ DCHECK(!sync_point);
sync_point = context3d->insertSyncPoint();
+ }
} else {
DCHECK(resource->mailbox.IsSharedMemory());
base::SharedMemory* shared_memory = resource->mailbox.shared_memory();
@@ -709,23 +717,21 @@ const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
// Uninitialized! Call SetPixels or LockForWrite first.
DCHECK(resource->allocated);
- LazyCreate(resource);
-
- if (resource->external) {
- if (!resource->gl_id && resource->mailbox.IsTexture()) {
- WebGraphicsContext3D* context3d = Context3d();
- DCHECK(context3d);
- if (resource->mailbox.sync_point()) {
- GLC(context3d,
- context3d->waitSyncPoint(resource->mailbox.sync_point()));
- resource->mailbox.ResetSyncPoint();
- }
- resource->gl_id = texture_id_allocator_->NextId();
- GLC(context3d, context3d->bindTexture(resource->target, resource->gl_id));
- GLC(context3d,
- context3d->consumeTextureCHROMIUM(resource->target,
- resource->mailbox.data()));
+ if (!resource->gl_id && resource->mailbox.IsTexture()) {
+ WebGraphicsContext3D* context3d = Context3d();
+ DCHECK(context3d);
+ resource->sync_point_is_from_client = false;
+ if (resource->mailbox.sync_point()) {
+ GLC(context3d, context3d->waitSyncPoint(resource->mailbox.sync_point()));
+ resource->mailbox.ResetSyncPoint();
}
+ resource->gl_id = texture_id_allocator_->NextId();
+ GLC(context3d, context3d->bindTexture(resource->target, resource->gl_id));
+ GLC(context3d,
+ context3d->consumeTextureCHROMIUM(resource->target,
+ resource->mailbox.data()));
+ } else {
+ LazyCreate(resource);
}
resource->lock_for_read_count++;
@@ -753,6 +759,7 @@ const ResourceProvider::Resource* ResourceProvider::LockForWrite(
DCHECK(ReadLockFenceHasPassed(resource));
LazyAllocate(resource);
+ resource->mailbox.ResetSyncPoint();
resource->locked_for_write = true;
return resource;
}
@@ -1071,20 +1078,7 @@ void ResourceProvider::ReceiveFromChild(
resource = Resource(
pixels, bitmap.release(), it->size, GL_LINEAR, GL_CLAMP_TO_EDGE);
} else {
- unsigned texture_id;
- // NOTE: If the parent is a browser and the child a renderer, the parent
- // is not supposed to have its context wait, because that could induce
- // deadlocks and/or security issues. The caller is responsible for
- // waiting asynchronously, and resetting sync_point before calling this.
- // However if the parent is a renderer (e.g. browser tag), it may be ok
- // (and is simpler) to wait.
- if (it->sync_point)
- GLC(context3d, context3d->waitSyncPoint(it->sync_point));
- texture_id = texture_id_allocator_->NextId();
- GLC(context3d, context3d->bindTexture(it->target, texture_id));
- GLC(context3d,
- context3d->consumeTextureCHROMIUM(it->target, it->mailbox.name));
- resource = Resource(texture_id,
+ resource = Resource(0,
it->size,
it->target,
it->filter,
@@ -1092,7 +1086,8 @@ void ResourceProvider::ReceiveFromChild(
GL_CLAMP_TO_EDGE,
TextureUsageAny,
it->format);
- resource.mailbox.SetName(it->mailbox);
+ resource.mailbox = TextureMailbox(it->mailbox, it->sync_point);
+ resource.sync_point_is_from_client = true;
}
resource.child_id = child;
// Don't allocate a texture for a child.
@@ -1191,12 +1186,16 @@ void ResourceProvider::ReceiveReturnsFromParent(
if (resource->exported_count)
continue;
- if (resource->gl_id) {
- if (returned.sync_point)
+ if (returned.sync_point) {
+ DCHECK(!resource->shared_bitmap);
+ resource->sync_point_is_from_client = false;
+ if (resource->gl_id) {
GLC(context3d, context3d->waitSyncPoint(returned.sync_point));
- } else if (!resource->shared_bitmap) {
- resource->mailbox =
- TextureMailbox(resource->mailbox.name(), returned.sync_point);
+ resource->mailbox.ResetSyncPoint();
+ } else {
+ resource->mailbox =
+ TextureMailbox(resource->mailbox.name(), returned.sync_point);
+ }
}
if (!resource->marked_for_deletion)
@@ -1266,7 +1265,6 @@ void ResourceProvider::TransferResource(WebGraphicsContext3D* context,
// already exported. Make sure to forward the sync point that we were given.
resource->mailbox = source->mailbox.name();
resource->sync_point = source->mailbox.sync_point();
- source->mailbox.ResetSyncPoint();
}
}
@@ -1333,9 +1331,11 @@ void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
ReturnedResource returned;
returned.id = child_id;
- returned.sync_point = resource.mailbox.sync_point();
- if (!returned.sync_point && !resource.shared_bitmap)
- need_sync_point = true;
+ if (!resource.sync_point_is_from_client) {
+ returned.sync_point = resource.mailbox.sync_point();
+ if (!returned.sync_point && !resource.shared_bitmap)
+ need_sync_point = true;
+ }
returned.count = resource.imported_count;
returned.lost = is_lost;
to_return.push_back(returned);
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698