Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1114)

Side by Side Diff: cc/texture_layer.cc

Issue 11638028: Mailbox support for texture layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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.h" 5 #include "cc/texture_layer.h"
6 6
7 #include "cc/layer_tree_host.h" 7 #include "cc/layer_tree_host.h"
8 #include "cc/mailbox_release_client.h"
8 #include "cc/texture_layer_client.h" 9 #include "cc/texture_layer_client.h"
9 #include "cc/texture_layer_impl.h" 10 #include "cc/texture_layer_impl.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
11 #include "third_party/khronos/GLES2/gl2.h" 12 #include "third_party/khronos/GLES2/gl2.h"
12 13
13 namespace cc { 14 namespace cc {
14 15
15 scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client) 16 scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client)
16 { 17 {
17 return scoped_refptr<TextureLayer>(new TextureLayer(client)); 18 return scoped_refptr<TextureLayer>(new TextureLayer(client, 0));
18 } 19 }
19 20
20 TextureLayer::TextureLayer(TextureLayerClient* client) 21 scoped_refptr<TextureLayer> TextureLayer::createWithMailboxClient(MailboxRelease Client* client)
22 {
23 return scoped_refptr<TextureLayer>(new TextureLayer(0, client));
24 }
25
26 TextureLayer::TextureLayer(TextureLayerClient* client, MailboxReleaseClient* mai lboxClient)
21 : Layer() 27 : Layer()
22 , m_client(client) 28 , m_client(client)
29 , m_mailboxClient(mailboxClient)
23 , m_flipped(true) 30 , m_flipped(true)
24 , m_uvRect(0, 0, 1, 1) 31 , m_uvRect(0, 0, 1, 1)
25 , m_premultipliedAlpha(true) 32 , m_premultipliedAlpha(true)
26 , m_rateLimitContext(false) 33 , m_rateLimitContext(false)
27 , m_contextLost(false) 34 , m_contextLost(false)
28 , m_textureId(0) 35 , m_textureId(0)
29 , m_contentCommitted(false) 36 , m_contentCommitted(false)
30 { 37 {
31 m_vertexOpacity[0] = 1.0f; 38 m_vertexOpacity[0] = 1.0f;
32 m_vertexOpacity[1] = 1.0f; 39 m_vertexOpacity[1] = 1.0f;
33 m_vertexOpacity[2] = 1.0f; 40 m_vertexOpacity[2] = 1.0f;
34 m_vertexOpacity[3] = 1.0f; 41 m_vertexOpacity[3] = 1.0f;
35 } 42 }
36 43
37 TextureLayer::~TextureLayer() 44 TextureLayer::~TextureLayer()
38 { 45 {
39 if (layerTreeHost()) { 46 if (layerTreeHost()) {
40 if (m_textureId) 47 if (m_textureId)
41 layerTreeHost()->acquireLayerTextures(); 48 layerTreeHost()->acquireLayerTextures();
42 if (m_rateLimitContext && m_client) 49 if (m_rateLimitContext && m_client)
43 layerTreeHost()->stopRateLimiter(m_client->context()); 50 layerTreeHost()->stopRateLimiter(m_client->context());
44 } 51 }
45 } 52 }
46 53
47 scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl) 54 scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl)
48 { 55 {
49 return TextureLayerImpl::create(treeImpl, m_layerId).PassAs<LayerImpl>(); 56 return TextureLayerImpl::create(treeImpl, m_layerId, m_mailboxClient).PassAs <LayerImpl>();
50 } 57 }
51 58
52 void TextureLayer::setFlipped(bool flipped) 59 void TextureLayer::setFlipped(bool flipped)
53 { 60 {
54 m_flipped = flipped; 61 m_flipped = flipped;
55 setNeedsCommit(); 62 setNeedsCommit();
56 } 63 }
57 64
58 void TextureLayer::setUVRect(const gfx::RectF& rect) 65 void TextureLayer::setUVRect(const gfx::RectF& rect)
59 { 66 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void TextureLayer::setTextureId(unsigned id) 100 void TextureLayer::setTextureId(unsigned id)
94 { 101 {
95 if (m_textureId == id) 102 if (m_textureId == id)
96 return; 103 return;
97 if (m_textureId && layerTreeHost()) 104 if (m_textureId && layerTreeHost())
98 layerTreeHost()->acquireLayerTextures(); 105 layerTreeHost()->acquireLayerTextures();
99 m_textureId = id; 106 m_textureId = id;
100 setNeedsCommit(); 107 setNeedsCommit();
101 } 108 }
102 109
110 void TextureLayer::setTextureMailbox(const std::string& mailboxName)
111 {
112 if (m_mailboxName.compare(mailboxName) == 0)
113 return;
114 // If we never commited the mailbox, we need to release it here
115 if (!m_contentCommitted && m_mailboxName.size())
116 m_mailboxClient->mailboxReleased(m_mailboxName, 0);
117 m_mailboxName = mailboxName;
118 setNeedsCommit();
119 }
120
103 void TextureLayer::willModifyTexture() 121 void TextureLayer::willModifyTexture()
104 { 122 {
105 if (layerTreeHost() && (drawsContent() || m_contentCommitted)) { 123 if (layerTreeHost() && (drawsContent() || m_contentCommitted)) {
106 layerTreeHost()->acquireLayerTextures(); 124 layerTreeHost()->acquireLayerTextures();
107 m_contentCommitted = false; 125 m_contentCommitted = false;
108 } 126 }
109 } 127 }
110 128
111 void TextureLayer::setNeedsDisplayRect(const gfx::RectF& dirtyRect) 129 void TextureLayer::setNeedsDisplayRect(const gfx::RectF& dirtyRect)
112 { 130 {
113 Layer::setNeedsDisplayRect(dirtyRect); 131 Layer::setNeedsDisplayRect(dirtyRect);
114 132
115 if (m_rateLimitContext && m_client && layerTreeHost() && drawsContent()) 133 if (m_rateLimitContext && m_client && layerTreeHost() && drawsContent())
116 layerTreeHost()->startRateLimiter(m_client->context()); 134 layerTreeHost()->startRateLimiter(m_client->context());
117 } 135 }
118 136
119 void TextureLayer::setLayerTreeHost(LayerTreeHost* host) 137 void TextureLayer::setLayerTreeHost(LayerTreeHost* host)
120 { 138 {
121 if (m_textureId && layerTreeHost() && host != layerTreeHost()) 139 if (m_textureId && layerTreeHost() && host != layerTreeHost())
122 layerTreeHost()->acquireLayerTextures(); 140 layerTreeHost()->acquireLayerTextures();
123 Layer::setLayerTreeHost(host); 141 Layer::setLayerTreeHost(host);
124 } 142 }
125 143
126 bool TextureLayer::drawsContent() const 144 bool TextureLayer::drawsContent() const
127 { 145 {
128 return (m_client || m_textureId) && !m_contextLost && Layer::drawsContent(); 146 return (m_client || m_textureId || m_mailboxName.size()) && !m_contextLost & & Layer::drawsContent();
129 } 147 }
130 148
131 void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, R enderingStats&) 149 void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, R enderingStats&)
132 { 150 {
133 if (m_client) { 151 if (m_client) {
134 m_textureId = m_client->prepareTexture(queue); 152 m_textureId = m_client->prepareTexture(queue);
135 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GL_N O_ERROR; 153 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GL_N O_ERROR;
136 } 154 }
137 155
138 m_needsDisplay = false; 156 m_needsDisplay = false;
139 } 157 }
140 158
141 void TextureLayer::pushPropertiesTo(LayerImpl* layer) 159 void TextureLayer::pushPropertiesTo(LayerImpl* layer)
142 { 160 {
143 Layer::pushPropertiesTo(layer); 161 Layer::pushPropertiesTo(layer);
144 162
145 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer); 163 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer);
146 textureLayer->setFlipped(m_flipped); 164 textureLayer->setFlipped(m_flipped);
147 textureLayer->setUVRect(m_uvRect); 165 textureLayer->setUVRect(m_uvRect);
148 textureLayer->setVertexOpacity(m_vertexOpacity); 166 textureLayer->setVertexOpacity(m_vertexOpacity);
149 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); 167 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
150 textureLayer->setTextureId(m_textureId); 168 if (m_mailboxClient)
169 textureLayer->setTextureMailbox(m_mailboxName);
170 else
171 textureLayer->setTextureId(m_textureId);
151 m_contentCommitted = drawsContent(); 172 m_contentCommitted = drawsContent();
152 } 173 }
153 174
154 bool TextureLayer::blocksPendingCommit() const 175 bool TextureLayer::blocksPendingCommit() const
155 { 176 {
156 // Double-buffered texture layers need to be blocked until they can be made 177 // Double-buffered texture layers need to be blocked until they can be made
157 // triple-buffered. Single-buffered layers already prevent draws, so 178 // triple-buffered. Single-buffered layers already prevent draws, so
158 // can block too for simplicity. 179 // can block too for simplicity.
159 return true; 180 return true;
160 } 181 }
161 182
162 } // namespace cc 183 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698