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

Unified Diff: cc/resource_provider.cc

Issue 11820056: Delay consuming the mailbox in the resource provider until lockForRead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase, fix typo Created 7 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resource_provider.cc
diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc
index c31002e640ebd959783849f459d4b4d4b1e47d4d..fcaa5cf701a8f11ddc668f55c6fc5434b9ca5e24 100644
--- a/cc/resource_provider.cc
+++ b/cc/resource_provider.cc
@@ -244,21 +244,13 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture
ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox(const std::string& mailbox, const base::Callback<void(unsigned)>& releaseCallback)
{
DCHECK(m_threadChecker.CalledOnValidThread());
-
- // FIXME: As an optimization, delay consuming the mailbox
- // and creating the texture ID until lockForRead.
- const int8* name = reinterpret_cast<const int8*>(mailbox.data());
- WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
- DCHECK(context3d);
- unsigned textureId = context3d->createTexture();
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
- GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name));
-
+ // Just store the information. Mailbox will be consumed in lockForRead().
ResourceId id = m_nextId++;
+ unsigned textureId = 0;
Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
resource.external = true;
resource.allocated = true;
- resource.mailbox.setName(name);
+ resource.mailbox.setName(reinterpret_cast<const int8*>(mailbox.data()));
resource.mailboxReleaseCallback = releaseCallback;
m_resources[id] = resource;
return id;
@@ -302,13 +294,15 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
if (!resource->mailbox.isZero() && resource->external) {
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
- GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
- GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.name));
- GLC(context3d, context3d->deleteTexture(resource->glId));
- if (!resource->mailboxReleaseCallback.is_null()) {
- unsigned syncPoint = context3d->insertSyncPoint();
- resource->mailboxReleaseCallback.Run(syncPoint);
+ unsigned syncPoint = 0;
+ if (resource->glId) {
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
+ GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.name));
+ GLC(context3d, context3d->deleteTexture(resource->glId));
+ syncPoint = context3d->insertSyncPoint();
}
+ if (!resource->mailboxReleaseCallback.is_null())
+ resource->mailboxReleaseCallback.Run(syncPoint);
}
if (resource->pixels)
delete[] resource->pixels;
@@ -430,6 +424,14 @@ const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
DCHECK(!resource->exported);
DCHECK(resource->allocated); // Uninitialized! Call setPixels or lockForWrite first.
+ if (!resource->glId && resource->external && !resource->mailbox.isZero()) {
+ WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
+ DCHECK(context3d);
+ resource->glId = context3d->createTexture();
+ GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
+ GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.name));
+ }
+
resource->lockForReadCount++;
return resource;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698