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

Side by Side Diff: cc/texture_layer.cc

Issue 11888010: Cosmetic cleanup to texture_layer mailboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 11 months 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
« no previous file with comments | « cc/texture_layer.h ('k') | cc/texture_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/texture_layer_client.h" 8 #include "cc/texture_layer_client.h"
9 #include "cc/texture_layer_impl.h" 9 #include "cc/texture_layer_impl.h"
10 #include "cc/thread.h" 10 #include "cc/thread.h"
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 static void runCallbackOnMainThread(const TextureLayer::MailboxCallback& callbac k, unsigned syncPoint) 15 static void runCallbackOnMainThread(const TextureMailbox::ReleaseCallback& callb ack, unsigned syncPoint)
16 { 16 {
17 callback.Run(syncPoint); 17 callback.Run(syncPoint);
18 } 18 }
19 19
20 static void postCallbackToMainThread(Thread *mainThread, const TextureLayer::Mai lboxCallback& callback, unsigned syncPoint) 20 static void postCallbackToMainThread(Thread *mainThread, const TextureMailbox::R eleaseCallback& callback, unsigned syncPoint)
21 { 21 {
22 mainThread->postTask(base::Bind(&runCallbackOnMainThread, callback, syncPoin t)); 22 mainThread->postTask(base::Bind(&runCallbackOnMainThread, callback, syncPoin t));
23 } 23 }
24 24
25 scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client) 25 scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client)
26 { 26 {
27 return scoped_refptr<TextureLayer>(new TextureLayer(client, false)); 27 return scoped_refptr<TextureLayer>(new TextureLayer(client, false));
28 } 28 }
29 29
30 scoped_refptr<TextureLayer> TextureLayer::createForMailbox() 30 scoped_refptr<TextureLayer> TextureLayer::createForMailbox()
(...skipping 21 matching lines...) Expand all
52 } 52 }
53 53
54 TextureLayer::~TextureLayer() 54 TextureLayer::~TextureLayer()
55 { 55 {
56 if (layerTreeHost()) { 56 if (layerTreeHost()) {
57 if (m_textureId) 57 if (m_textureId)
58 layerTreeHost()->acquireLayerTextures(); 58 layerTreeHost()->acquireLayerTextures();
59 if (m_rateLimitContext && m_client) 59 if (m_rateLimitContext && m_client)
60 layerTreeHost()->stopRateLimiter(m_client->context()); 60 layerTreeHost()->stopRateLimiter(m_client->context());
61 } 61 }
62 if (!m_contentCommitted && !m_mailboxName.empty()) 62 if (!m_contentCommitted)
63 m_mailboxReleaseCallback.Run(0); 63 m_textureMailbox.RunReleaseCallback(0);
64 } 64 }
65 65
66 scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl) 66 scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl)
67 { 67 {
68 return TextureLayerImpl::create(treeImpl, m_layerId, m_usesMailbox).PassAs<L ayerImpl>(); 68 return TextureLayerImpl::create(treeImpl, m_layerId, m_usesMailbox).PassAs<L ayerImpl>();
69 } 69 }
70 70
71 void TextureLayer::setFlipped(bool flipped) 71 void TextureLayer::setFlipped(bool flipped)
72 { 72 {
73 m_flipped = flipped; 73 m_flipped = flipped;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { 114 {
115 DCHECK(!m_usesMailbox); 115 DCHECK(!m_usesMailbox);
116 if (m_textureId == id) 116 if (m_textureId == id)
117 return; 117 return;
118 if (m_textureId && layerTreeHost()) 118 if (m_textureId && layerTreeHost())
119 layerTreeHost()->acquireLayerTextures(); 119 layerTreeHost()->acquireLayerTextures();
120 m_textureId = id; 120 m_textureId = id;
121 setNeedsCommit(); 121 setNeedsCommit();
122 } 122 }
123 123
124 void TextureLayer::setTextureMailbox(const std::string& mailboxName, const Mailb oxCallback& callback) 124 void TextureLayer::setTextureMailbox(const TextureMailbox& mailbox)
125 { 125 {
126 DCHECK(m_usesMailbox); 126 DCHECK(m_usesMailbox);
127 DCHECK(mailboxName.empty() == callback.is_null()); 127 if (m_textureMailbox.Equals(mailbox))
128 if (m_mailboxName.compare(mailboxName) == 0)
129 return; 128 return;
130 // If we never commited the mailbox, we need to release it here 129 // If we never commited the mailbox, we need to release it here
131 if (!m_contentCommitted && !m_mailboxName.empty()) 130 if (!m_contentCommitted)
132 m_mailboxReleaseCallback.Run(0); 131 m_textureMailbox.RunReleaseCallback(0);
133 m_mailboxReleaseCallback = callback; 132 m_textureMailbox = mailbox;
134 m_mailboxName = mailboxName;
135 133
136 setNeedsCommit(); 134 setNeedsCommit();
137 } 135 }
138 136
139 void TextureLayer::willModifyTexture() 137 void TextureLayer::willModifyTexture()
140 { 138 {
141 if (layerTreeHost() && (drawsContent() || m_contentCommitted)) { 139 if (layerTreeHost() && (drawsContent() || m_contentCommitted)) {
142 layerTreeHost()->acquireLayerTextures(); 140 layerTreeHost()->acquireLayerTextures();
143 m_contentCommitted = false; 141 m_contentCommitted = false;
144 } 142 }
145 } 143 }
146 144
147 void TextureLayer::setNeedsDisplayRect(const gfx::RectF& dirtyRect) 145 void TextureLayer::setNeedsDisplayRect(const gfx::RectF& dirtyRect)
148 { 146 {
149 Layer::setNeedsDisplayRect(dirtyRect); 147 Layer::setNeedsDisplayRect(dirtyRect);
150 148
151 if (m_rateLimitContext && m_client && layerTreeHost() && drawsContent()) 149 if (m_rateLimitContext && m_client && layerTreeHost() && drawsContent())
152 layerTreeHost()->startRateLimiter(m_client->context()); 150 layerTreeHost()->startRateLimiter(m_client->context());
153 } 151 }
154 152
155 void TextureLayer::setLayerTreeHost(LayerTreeHost* host) 153 void TextureLayer::setLayerTreeHost(LayerTreeHost* host)
156 { 154 {
157 if (m_textureId && layerTreeHost() && host != layerTreeHost()) 155 if (m_textureId && layerTreeHost() && host != layerTreeHost())
158 layerTreeHost()->acquireLayerTextures(); 156 layerTreeHost()->acquireLayerTextures();
159 Layer::setLayerTreeHost(host); 157 Layer::setLayerTreeHost(host);
160 } 158 }
161 159
162 bool TextureLayer::drawsContent() const 160 bool TextureLayer::drawsContent() const
163 { 161 {
164 return (m_client || m_textureId || !m_mailboxName.empty()) && !m_contextLost && Layer::drawsContent(); 162 return (m_client || m_textureId || !m_textureMailbox.IsEmpty()) && !m_contex tLost && Layer::drawsContent();
165 } 163 }
166 164
167 void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, R enderingStats&) 165 void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, R enderingStats&)
168 { 166 {
169 if (m_client) { 167 if (m_client) {
170 m_textureId = m_client->prepareTexture(queue); 168 m_textureId = m_client->prepareTexture(queue);
171 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GL_N O_ERROR; 169 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GL_N O_ERROR;
172 } 170 }
173 171
174 m_needsDisplay = false; 172 m_needsDisplay = false;
175 } 173 }
176 174
177 void TextureLayer::pushPropertiesTo(LayerImpl* layer) 175 void TextureLayer::pushPropertiesTo(LayerImpl* layer)
178 { 176 {
179 Layer::pushPropertiesTo(layer); 177 Layer::pushPropertiesTo(layer);
180 178
181 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer); 179 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer);
182 textureLayer->setFlipped(m_flipped); 180 textureLayer->setFlipped(m_flipped);
183 textureLayer->setUVTopLeft(m_uvTopLeft); 181 textureLayer->setUVTopLeft(m_uvTopLeft);
184 textureLayer->setUVBottomRight(m_uvBottomRight); 182 textureLayer->setUVBottomRight(m_uvBottomRight);
185 textureLayer->setVertexOpacity(m_vertexOpacity); 183 textureLayer->setVertexOpacity(m_vertexOpacity);
186 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); 184 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
187 if (m_usesMailbox) { 185 if (m_usesMailbox) {
188 Thread* mainThread = layerTreeHost()->proxy()->mainThread(); 186 Thread* mainThread = layerTreeHost()->proxy()->mainThread();
189 textureLayer->setTextureMailbox(m_mailboxName, base::Bind(&postCallbackT oMainThread, mainThread, m_mailboxReleaseCallback)); 187 TextureMailbox::ReleaseCallback callback;
188 if (!m_textureMailbox.IsEmpty())
189 callback = base::Bind(&postCallbackToMainThread, mainThread, m_texture Mailbox.callback());
190 textureLayer->setTextureMailbox(TextureMailbox(m_textureMailbox.name(), callback));
190 } else { 191 } else {
191 textureLayer->setTextureId(m_textureId); 192 textureLayer->setTextureId(m_textureId);
192 } 193 }
193 m_contentCommitted = drawsContent(); 194 m_contentCommitted = drawsContent();
194 } 195 }
195 196
196 bool TextureLayer::blocksPendingCommit() const 197 bool TextureLayer::blocksPendingCommit() const
197 { 198 {
198 // Double-buffered texture layers need to be blocked until they can be made 199 // Double-buffered texture layers need to be blocked until they can be made
199 // triple-buffered. Single-buffered layers already prevent draws, so 200 // triple-buffered. Single-buffered layers already prevent draws, so
200 // can block too for simplicity. 201 // can block too for simplicity.
201 return drawsContent(); 202 return drawsContent();
202 } 203 }
203 204
204 bool TextureLayer::canClipSelf() const 205 bool TextureLayer::canClipSelf() const
205 { 206 {
206 return true; 207 return true;
207 } 208 }
208 209
209 } // namespace cc 210 } // namespace cc
OLDNEW
« no previous file with comments | « cc/texture_layer.h ('k') | cc/texture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698