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

Unified Diff: cc/resources/resource_provider.cc

Issue 105743004: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: c301e01d Rebase. Created 6 years, 12 months 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
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 3973fb8868c24a9a8d86b4eeea72e5f525dcec60..1b48709ec79d223df86611a59f8eb45b7174d1c1 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -544,7 +544,7 @@ void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it,
GLC(gl, gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id));
}
if (resource->mailbox.IsValid() && resource->external) {
- GLuint sync_point = resource->mailbox.sync_point();
+ uint32 sync_point = resource->mailbox.sync_point();
if (resource->mailbox.IsTexture()) {
lost_resource |= lost_output_surface_;
GLES2Interface* gl = ContextGL();
@@ -739,13 +739,13 @@ const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
DCHECK(gl);
if (resource->mailbox.sync_point()) {
GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()));
- resource->mailbox.ResetSyncPoint();
+ resource->mailbox.set_sync_point(0);
}
resource->gl_id = texture_id_allocator_->NextId();
GLC(gl, gl->BindTexture(resource->target, resource->gl_id));
GLC(gl,
gl->ConsumeTextureCHROMIUM(resource->target,
- resource->mailbox.data()));
+ resource->mailbox.mailbox().name));
danakj 2014/01/06 20:13:42 Law of Demeter is sad about this. Can we have a na
sheu 2014/01/06 22:44:44 We need to have the mailbox() accessible for other
danakj 2014/01/06 23:28:33 As it's just an accessor, I'd prefer a 2nd path he
sheu 2014/01/07 01:41:00 Done.
}
}
@@ -1021,7 +1021,7 @@ void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources,
++it) {
TransferableResource resource;
TransferResource(gl, *it, &resource);
- if (!resource.sync_point && !resource.is_software)
+ if (!resource.mailbox_holder.sync_point && !resource.is_software)
need_sync_point = true;
++resources_.find(*it)->second.exported_count;
list->push_back(resource);
@@ -1031,8 +1031,8 @@ void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources,
for (TransferableResourceArray::iterator it = list->begin();
it != list->end();
++it) {
- if (!it->sync_point)
- it->sync_point = sync_point;
+ if (!it->mailbox_holder.sync_point)
+ it->mailbox_holder.sync_point = sync_point;
}
}
}
@@ -1056,9 +1056,10 @@ void ResourceProvider::ReceiveFromChild(
scoped_ptr<SharedBitmap> bitmap;
uint8_t* pixels = NULL;
if (it->is_software) {
- if (shared_bitmap_manager_)
- bitmap = shared_bitmap_manager_->GetSharedBitmapFromId(it->size,
- it->mailbox);
+ if (shared_bitmap_manager_) {
+ bitmap = shared_bitmap_manager_->GetSharedBitmapFromId(
+ it->size, it->mailbox_holder.mailbox);
+ }
if (bitmap)
pixels = bitmap->pixels();
}
@@ -1084,20 +1085,23 @@ void ResourceProvider::ReceiveFromChild(
// 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(gl, gl->WaitSyncPointCHROMIUM(it->sync_point));
+ if (it->mailbox_holder.sync_point)
+ GLC(gl, gl->WaitSyncPointCHROMIUM(it->mailbox_holder.sync_point));
texture_id = texture_id_allocator_->NextId();
- GLC(gl, gl->BindTexture(it->target, texture_id));
- GLC(gl, gl->ConsumeTextureCHROMIUM(it->target, it->mailbox.name));
+ GLC(gl, gl->BindTexture(it->mailbox_holder.texture_target, texture_id));
+ GLC(gl,
+ gl->ConsumeTextureCHROMIUM(it->mailbox_holder.texture_target,
+ it->mailbox_holder.mailbox.name));
resource = Resource(texture_id,
it->size,
- it->target,
+ it->mailbox_holder.texture_target,
it->filter,
0,
GL_CLAMP_TO_EDGE,
TextureUsageAny,
it->format);
- resource.mailbox.SetName(it->mailbox);
+ resource.mailbox = TextureMailbox(
+ it->mailbox_holder.mailbox, it->mailbox_holder.texture_target, 0);
}
resource.child_id = child;
// Don't allocate a texture for a child.
@@ -1198,8 +1202,7 @@ void ResourceProvider::ReceiveReturnsFromParent(
if (returned.sync_point)
GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point));
} else if (!resource->shared_bitmap) {
- resource->mailbox =
- TextureMailbox(resource->mailbox.name(), returned.sync_point);
+ resource->mailbox.set_sync_point(returned.sync_point);
}
if (!resource->marked_for_deletion)
@@ -1247,29 +1250,33 @@ void ResourceProvider::TransferResource(GLES2Interface* gl,
DCHECK_EQ(source->wrap_mode, GL_CLAMP_TO_EDGE);
resource->id = id;
resource->format = source->format;
- resource->target = source->target;
+ resource->mailbox_holder.texture_target = source->target;
resource->filter = source->filter;
resource->size = source->size;
if (source->shared_bitmap) {
- resource->mailbox = source->shared_bitmap->id();
+ resource->mailbox_holder.mailbox = source->shared_bitmap->id();
resource->is_software = true;
} else if (!source->mailbox.IsValid()) {
// This is a resource allocated by the compositor, we need to produce it.
// Don't set a sync point, the caller will do it.
DCHECK(source->gl_id);
- GLC(gl, gl->BindTexture(resource->target, source->gl_id));
- GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name));
GLC(gl,
- gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name));
- source->mailbox.SetName(resource->mailbox);
+ gl->BindTexture(resource->mailbox_holder.texture_target,
+ source->gl_id));
+ GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name));
+ GLC(gl,
+ gl->ProduceTextureCHROMIUM(resource->mailbox_holder.texture_target,
+ resource->mailbox_holder.mailbox.name));
+ source->mailbox = TextureMailbox(resource->mailbox_holder);
} else {
DCHECK(source->mailbox.IsTexture());
// 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.
- resource->mailbox = source->mailbox.name();
- resource->sync_point = source->mailbox.sync_point();
- source->mailbox.ResetSyncPoint();
+ resource->mailbox_holder.mailbox = source->mailbox.mailbox();
+ resource->mailbox_holder.texture_target = source->mailbox.target();
+ resource->mailbox_holder.sync_point = source->mailbox.sync_point();
+ source->mailbox.set_sync_point(0);
}
}

Powered by Google App Engine
This is Rietveld 408576698