Index: cc/resource_provider.cc |
diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc |
index c2b44d28e8e0885674e6233fe0024ab0227616bd..bde81604a06d5c52d650128a6fb481dc6140beaa 100644 |
--- a/cc/resource_provider.cc |
+++ b/cc/resource_provider.cc |
@@ -235,6 +235,31 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture |
return id; |
} |
+ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox(const std::string& mailbox) |
+{ |
+ DCHECK(m_threadChecker.CalledOnValidThread()); |
+ |
+ const int8* name = reinterpret_cast<const int8*>(mailbox.c_str()); |
piman
2012/12/20 02:14:21
nit: .data() instead of c_str() to avoid forcing a
danakj
2012/12/20 02:16:19
how come you need reinterpret_cast to do this? wha
alexst (slow to review)
2012/12/21 14:15:21
Done.
alexst (slow to review)
2012/12/21 14:15:21
consumeTextureCHROMIUM expects signed data both, c
|
+ 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->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
+ GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
+ GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
+ GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
piman
2012/12/20 02:14:21
nit: we shouldn't have to set the tex parameters,
alexst (slow to review)
2012/12/21 14:15:21
Done.
|
+ GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name)); |
+ GLC(context3d, context3d->flush()); |
danakj
2012/12/20 02:16:19
how come the flush is needed?
alexst (slow to review)
2012/12/21 14:15:21
Backing texture for the mailbox is in a different
|
+ |
+ ResourceId id = m_nextId++; |
+ Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); |
piman
2012/12/20 02:14:21
We probably want to pass all the info so that thes
alexst (slow to review)
2012/12/21 14:15:21
I only know the size but not the format from swapB
|
+ resource.external = true; |
+ resource.mailbox.setName(name); |
+ m_resources[id] = resource; |
+ return id; |
+} |
+ |
void ResourceProvider::deleteResource(ResourceId id) |
{ |
DCHECK(m_threadChecker.CalledOnValidThread()); |
@@ -270,6 +295,13 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it) |
DCHECK(context3d); |
GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); |
} |
+ if (!resource->mailbox.isZero()) { |
piman
2012/12/20 02:14:21
This is not quite right, since we will have a mail
alexst (slow to review)
2012/12/21 14:15:21
Done.
|
+ 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->pixels) |
delete[] resource->pixels; |
if (resource->pixelBuffer) |