Chromium Code Reviews| Index: cc/resource_provider.cc |
| diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc |
| index c2b44d28e8e0885674e6233fe0024ab0227616bd..d14b3426e9a035d30df101336e825a84fcf6581a 100644 |
| --- a/cc/resource_provider.cc |
| +++ b/cc/resource_provider.cc |
| @@ -235,6 +235,28 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture |
| return id; |
| } |
| +ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox(const std::string& mailbox, const base::Callback<void(unsigned)>& releaseCallback) |
| +{ |
| + DCHECK(m_threadChecker.CalledOnValidThread()); |
| + |
| + const int8* name = reinterpret_cast<const int8*>(mailbox.data()); |
| + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
| + DCHECK(context3d); |
| + unsigned textureId; |
| + GLC(context3d, textureId = context3d->createTexture()); |
| + GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
| + GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name)); |
| + GLC(context3d, context3d->flush()); |
| + |
| + ResourceId id = m_nextId++; |
| + Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); |
| + resource.external = true; |
| + resource.mailbox.setName(name); |
| + resource.mailbox.releaseCallback = releaseCallback; |
| + m_resources[id] = resource; |
| + return id; |
| +} |
| + |
| void ResourceProvider::deleteResource(ResourceId id) |
| { |
| DCHECK(m_threadChecker.CalledOnValidThread()); |
| @@ -270,6 +292,18 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it) |
| DCHECK(context3d); |
| GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); |
| } |
| + if (!resource->mailbox.isZero() && resource->external) { |
|
danakj
2013/01/02 16:17:22
Should this be just if (!mailbox.IsZero) {}
and t
alexst (slow to review)
2013/01/02 19:31:35
I was addressing an earlier comment below so we on
|
| + 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->mailbox.releaseCallback.is_null()) { |
| + unsigned syncPoint = 0; |
| + GLC(context3d, syncPoint = context3d->insertSyncPoint()); |
| + resource->mailbox.releaseCallback.Run(syncPoint); |
| + } |
| + } |
| if (resource->pixels) |
| delete[] resource->pixels; |
| if (resource->pixelBuffer) |