Chromium Code Reviews| Index: cc/texture_layer.cc |
| diff --git a/cc/texture_layer.cc b/cc/texture_layer.cc |
| index 36c4220371d6f5653a7dedae16ed17b414504f96..3592ef85a91009d782615a2c9eef48c5a01463ba 100644 |
| --- a/cc/texture_layer.cc |
| +++ b/cc/texture_layer.cc |
| @@ -14,12 +14,18 @@ namespace cc { |
| scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client) |
| { |
| - return scoped_refptr<TextureLayer>(new TextureLayer(client)); |
| + return scoped_refptr<TextureLayer>(new TextureLayer(client, false)); |
| } |
| -TextureLayer::TextureLayer(TextureLayerClient* client) |
| +scoped_refptr<TextureLayer> TextureLayer::createMailboxLayer() |
| +{ |
| + return scoped_refptr<TextureLayer>(new TextureLayer(0, true)); |
| +} |
| + |
| +TextureLayer::TextureLayer(TextureLayerClient* client, bool mailboxLayer) |
| : Layer() |
| , m_client(client) |
| + , m_mailboxLayer(mailboxLayer) |
| , m_flipped(true) |
| , m_uvRect(0, 0, 1, 1) |
| , m_premultipliedAlpha(true) |
| @@ -42,11 +48,13 @@ TextureLayer::~TextureLayer() |
| if (m_rateLimitContext && m_client) |
| layerTreeHost()->stopRateLimiter(m_client->context()); |
| } |
| + if (!m_contentCommitted && m_mailboxName.size()) |
| + m_mailboxReleaseCallback.Run(0); |
| } |
| scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl) |
| { |
| - return TextureLayerImpl::create(treeImpl, m_layerId).PassAs<LayerImpl>(); |
| + return TextureLayerImpl::create(treeImpl, m_layerId, m_mailboxLayer).PassAs<LayerImpl>(); |
| } |
| void TextureLayer::setFlipped(bool flipped) |
| @@ -92,6 +100,7 @@ void TextureLayer::setRateLimitContext(bool rateLimit) |
| void TextureLayer::setTextureId(unsigned id) |
| { |
| + DCHECK(!m_mailboxLayer); |
| if (m_textureId == id) |
| return; |
| if (m_textureId && layerTreeHost()) |
| @@ -100,6 +109,19 @@ void TextureLayer::setTextureId(unsigned id) |
| setNeedsCommit(); |
| } |
| +void TextureLayer::setTextureMailbox(const std::string& mailboxName, const base::Callback<void(unsigned)>& callback) |
| +{ |
| + DCHECK(m_mailboxLayer); |
|
danakj
2013/01/02 16:17:22
Can we DCHECK that mailboxName.isempty == callback
|
| + if (m_mailboxName.compare(mailboxName) == 0) |
| + return; |
| + // If we never commited the mailbox, we need to release it here |
| + if (!m_contentCommitted && m_mailboxName.size()) |
| + m_mailboxReleaseCallback.Run(0); |
| + m_mailboxReleaseCallback = callback; |
| + m_mailboxName = mailboxName; |
| + setNeedsCommit(); |
| +} |
| + |
| void TextureLayer::willModifyTexture() |
| { |
| if (layerTreeHost() && (drawsContent() || m_contentCommitted)) { |
| @@ -125,7 +147,7 @@ void TextureLayer::setLayerTreeHost(LayerTreeHost* host) |
| bool TextureLayer::drawsContent() const |
| { |
| - return (m_client || m_textureId) && !m_contextLost && Layer::drawsContent(); |
| + return (m_client || m_textureId || m_mailboxName.size()) && !m_contextLost && Layer::drawsContent(); |
| } |
| void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats&) |
| @@ -147,7 +169,10 @@ void TextureLayer::pushPropertiesTo(LayerImpl* layer) |
| textureLayer->setUVRect(m_uvRect); |
| textureLayer->setVertexOpacity(m_vertexOpacity); |
| textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); |
| - textureLayer->setTextureId(m_textureId); |
| + if (m_mailboxLayer) |
| + textureLayer->setTextureMailbox(m_mailboxName, m_mailboxReleaseCallback); |
| + else |
| + textureLayer->setTextureId(m_textureId); |
| m_contentCommitted = drawsContent(); |
| } |