Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/texture_layer_impl.h" | 5 #include "cc/texture_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "cc/layer_tree_impl.h" | |
| 9 #include "cc/mailbox_release_client.h" | |
| 8 #include "cc/quad_sink.h" | 10 #include "cc/quad_sink.h" |
| 9 #include "cc/renderer.h" | 11 #include "cc/renderer.h" |
| 10 #include "cc/texture_draw_quad.h" | 12 #include "cc/texture_draw_quad.h" |
| 11 | 13 |
| 14 #include <public/WebGraphicsContext3D.h> | |
|
danakj
2012/12/20 02:16:19
use "third_party/WebKit/..."
alexst (slow to review)
2012/12/21 14:15:21
Goes away with base::bind
On 2012/12/20 02:16:19,
| |
| 15 | |
| 12 namespace cc { | 16 namespace cc { |
| 13 | 17 |
| 14 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* treeImpl, int id) | 18 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* treeImpl, int id, MailboxRelea seClient* client) |
| 15 : LayerImpl(treeImpl, id) | 19 : LayerImpl(treeImpl, id) |
| 16 , m_textureId(0) | 20 , m_textureId(0) |
| 17 , m_externalTextureResource(0) | 21 , m_externalTextureResource(0) |
| 18 , m_premultipliedAlpha(true) | 22 , m_premultipliedAlpha(true) |
| 19 , m_flipped(true) | 23 , m_flipped(true) |
| 20 , m_uvRect(0, 0, 1, 1) | 24 , m_uvRect(0, 0, 1, 1) |
| 25 , m_newMailboxPending(false) | |
| 26 , m_mailboxClient(client) | |
| 21 { | 27 { |
| 22 m_vertexOpacity[0] = 1.0f; | 28 m_vertexOpacity[0] = 1.0f; |
| 23 m_vertexOpacity[1] = 1.0f; | 29 m_vertexOpacity[1] = 1.0f; |
| 24 m_vertexOpacity[2] = 1.0f; | 30 m_vertexOpacity[2] = 1.0f; |
| 25 m_vertexOpacity[3] = 1.0f; | 31 m_vertexOpacity[3] = 1.0f; |
| 26 } | 32 } |
| 27 | 33 |
| 28 TextureLayerImpl::~TextureLayerImpl() | 34 TextureLayerImpl::~TextureLayerImpl() |
| 29 { | 35 { |
|
piman
2012/12/20 02:14:21
You probably need to do more here, for the case wh
alexst (slow to review)
2012/12/21 14:15:21
Done.
| |
| 30 } | 36 } |
| 31 | 37 |
| 38 void TextureLayerImpl::setTextureMailbox(const std::string& mailboxName) | |
| 39 { | |
| 40 // Same mailbox name was commited, nothing to do | |
| 41 if (m_lastMailbox.compare(mailboxName) == 0) | |
| 42 return; | |
| 43 m_newMailbox = mailboxName; | |
| 44 m_newMailboxPending = true; | |
| 45 } | |
| 46 | |
| 32 void TextureLayerImpl::willDraw(ResourceProvider* resourceProvider) | 47 void TextureLayerImpl::willDraw(ResourceProvider* resourceProvider) |
| 33 { | 48 { |
| 49 if (m_mailboxClient) { | |
| 50 handleMailboxResources(resourceProvider); | |
| 51 return; | |
| 52 } | |
| 34 if (!m_textureId) | 53 if (!m_textureId) |
| 35 return; | 54 return; |
| 36 DCHECK(!m_externalTextureResource); | 55 DCHECK(!m_externalTextureResource); |
| 37 m_externalTextureResource = resourceProvider->createResourceFromExternalText ure(m_textureId); | 56 m_externalTextureResource = resourceProvider->createResourceFromExternalText ure(m_textureId); |
| 38 } | 57 } |
| 39 | 58 |
| 40 void TextureLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQu adsData) | 59 void TextureLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQu adsData) |
| 41 { | 60 { |
| 42 if (!m_externalTextureResource) | 61 if (!m_externalTextureResource) |
| 43 return; | 62 return; |
| 44 | 63 |
| 45 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState()); | 64 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState()); |
| 46 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 65 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
| 47 | 66 |
| 48 gfx::Rect quadRect(gfx::Point(), contentBounds()); | 67 gfx::Rect quadRect(gfx::Point(), contentBounds()); |
| 49 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); | 68 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); |
| 50 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 69 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
| 51 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_externalTextureResourc e, m_premultipliedAlpha, m_uvRect, m_vertexOpacity, m_flipped); | 70 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_externalTextureResourc e, m_premultipliedAlpha, m_uvRect, m_vertexOpacity, m_flipped); |
| 52 | 71 |
| 53 // Perform explicit clipping on a quad to avoid setting a scissor later. | 72 // Perform explicit clipping on a quad to avoid setting a scissor later. |
| 54 if (sharedQuadState->is_clipped && quad->PerformClipping()) | 73 if (sharedQuadState->is_clipped && quad->PerformClipping()) |
| 55 sharedQuadState->is_clipped = false; | 74 sharedQuadState->is_clipped = false; |
| 56 if (!quad->rect.IsEmpty()) | 75 if (!quad->rect.IsEmpty()) |
| 57 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 76 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 58 } | 77 } |
| 59 | 78 |
| 60 void TextureLayerImpl::didDraw(ResourceProvider* resourceProvider) | 79 void TextureLayerImpl::didDraw(ResourceProvider* resourceProvider) |
| 61 { | 80 { |
| 81 if (m_mailboxClient) | |
| 82 return; | |
| 62 if (!m_externalTextureResource) | 83 if (!m_externalTextureResource) |
| 63 return; | 84 return; |
| 64 // FIXME: the following assert will not be true when sending resources to a | 85 // FIXME: the following assert will not be true when sending resources to a |
| 65 // parent compositor. A synchronization scheme (double-buffering or | 86 // parent compositor. A synchronization scheme (double-buffering or |
| 66 // pipelining of updates) for the client will need to exist to solve this. | 87 // pipelining of updates) for the client will need to exist to solve this. |
| 67 DCHECK(!resourceProvider->inUseByConsumer(m_externalTextureResource)); | 88 DCHECK(!resourceProvider->inUseByConsumer(m_externalTextureResource)); |
| 68 resourceProvider->deleteResource(m_externalTextureResource); | 89 resourceProvider->deleteResource(m_externalTextureResource); |
| 69 m_externalTextureResource = 0; | 90 m_externalTextureResource = 0; |
| 70 } | 91 } |
| 71 | 92 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 87 { | 108 { |
| 88 m_textureId = 0; | 109 m_textureId = 0; |
| 89 m_externalTextureResource = 0; | 110 m_externalTextureResource = 0; |
| 90 } | 111 } |
| 91 | 112 |
| 92 const char* TextureLayerImpl::layerTypeAsString() const | 113 const char* TextureLayerImpl::layerTypeAsString() const |
| 93 { | 114 { |
| 94 return "TextureLayer"; | 115 return "TextureLayer"; |
| 95 } | 116 } |
| 96 | 117 |
| 118 void TextureLayerImpl::handleMailboxResources(ResourceProvider* resourceProvider ) | |
| 119 { | |
| 120 if (!m_newMailboxPending) | |
| 121 return; | |
| 122 | |
| 123 if (m_externalTextureResource) { | |
| 124 DCHECK(!resourceProvider->inUseByConsumer(m_externalTextureResource)); | |
| 125 resourceProvider->deleteResource(m_externalTextureResource); | |
| 126 m_externalTextureResource = 0; | |
| 127 WebKit::WebGraphicsContext3D* context = | |
| 128 layerTreeImpl()->resource_provider()->graphicsContext3D(); | |
| 129 | |
| 130 m_mailboxClient->mailboxReleased(m_lastMailbox, context->insertSyncPoint ()); | |
|
piman
2012/12/20 02:14:21
We need to be clear about which thread the client
alexst (slow to review)
2012/12/21 14:15:21
That's one of the things I wanted to discuss.
Lik
| |
| 131 } | |
| 132 if (m_newMailbox.size()) { | |
| 133 m_externalTextureResource = resourceProvider->createResourceFromTextureM ailbox(m_newMailbox); | |
| 134 m_newMailboxPending = false; | |
| 135 } | |
| 136 m_lastMailbox = m_newMailbox; | |
| 137 m_newMailbox.clear(); | |
| 138 } | |
| 139 | |
| 97 } // namespace cc | 140 } // namespace cc |
| OLD | NEW |