Chromium Code Reviews| Index: cc/resource_provider.cc |
| diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc |
| index 2cbafaeec119556cfaf526801b5852be4bd0e4e4..c691673582f868abe4c81fc8eab429daf200d853 100644 |
| --- a/cc/resource_provider.cc |
| +++ b/cc/resource_provider.cc |
| @@ -234,6 +234,27 @@ 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 = context3d->createTexture(); |
| + GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
| + GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name)); |
| + context3d->flush(); |
|
jamesr
2013/01/04 21:38:31
I'd still like to understand what the meaning of t
|
| + |
| + 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()); |
| @@ -269,6 +290,17 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it) |
| DCHECK(context3d); |
| GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); |
| } |
| + 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->mailbox.releaseCallback.is_null()) { |
| + unsigned syncPoint = context3d->insertSyncPoint(); |
| + resource->mailbox.releaseCallback.Run(syncPoint); |
| + } |
| + } |
| if (resource->pixels) |
| delete[] resource->pixels; |
| if (resource->pixelBuffer) |