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

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: Formatting 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/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 "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
11 #include "third_party/khronos/GLES2/gl2.h" 11 #include "third_party/khronos/GLES2/gl2.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client) 15 scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client)
16 { 16 {
17 return scoped_refptr<TextureLayer>(new TextureLayer(client)); 17 return scoped_refptr<TextureLayer>(new TextureLayer(client, false));
18 } 18 }
19 19
20 TextureLayer::TextureLayer(TextureLayerClient* client) 20 scoped_refptr<TextureLayer> TextureLayer::createMailboxLayer()
21 {
22 return scoped_refptr<TextureLayer>(new TextureLayer(0, true));
23 }
24
25 TextureLayer::TextureLayer(TextureLayerClient* client, bool mailboxLayer)
21 : Layer() 26 : Layer()
22 , m_client(client) 27 , m_client(client)
28 , m_mailboxLayer(mailboxLayer)
23 , m_flipped(true) 29 , m_flipped(true)
24 , m_uvRect(0, 0, 1, 1) 30 , m_uvRect(0, 0, 1, 1)
25 , m_premultipliedAlpha(true) 31 , m_premultipliedAlpha(true)
26 , m_rateLimitContext(false) 32 , m_rateLimitContext(false)
27 , m_contextLost(false) 33 , m_contextLost(false)
28 , m_textureId(0) 34 , m_textureId(0)
29 , m_contentCommitted(false) 35 , m_contentCommitted(false)
30 { 36 {
31 m_vertexOpacity[0] = 1.0f; 37 m_vertexOpacity[0] = 1.0f;
32 m_vertexOpacity[1] = 1.0f; 38 m_vertexOpacity[1] = 1.0f;
33 m_vertexOpacity[2] = 1.0f; 39 m_vertexOpacity[2] = 1.0f;
34 m_vertexOpacity[3] = 1.0f; 40 m_vertexOpacity[3] = 1.0f;
35 } 41 }
36 42
37 TextureLayer::~TextureLayer() 43 TextureLayer::~TextureLayer()
38 { 44 {
39 if (layerTreeHost()) { 45 if (layerTreeHost()) {
40 if (m_textureId) 46 if (m_textureId)
41 layerTreeHost()->acquireLayerTextures(); 47 layerTreeHost()->acquireLayerTextures();
42 if (m_rateLimitContext && m_client) 48 if (m_rateLimitContext && m_client)
43 layerTreeHost()->stopRateLimiter(m_client->context()); 49 layerTreeHost()->stopRateLimiter(m_client->context());
44 } 50 }
51 if (!m_contentCommitted && m_mailboxName.size())
52 m_mailboxReleaseCallback.Run(0);
45 } 53 }
46 54
47 scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl) 55 scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl)
48 { 56 {
49 return TextureLayerImpl::create(treeImpl, m_layerId).PassAs<LayerImpl>(); 57 return TextureLayerImpl::create(treeImpl, m_layerId, m_mailboxLayer).PassAs< LayerImpl>();
50 } 58 }
51 59
52 void TextureLayer::setFlipped(bool flipped) 60 void TextureLayer::setFlipped(bool flipped)
53 { 61 {
54 m_flipped = flipped; 62 m_flipped = flipped;
55 setNeedsCommit(); 63 setNeedsCommit();
56 } 64 }
57 65
58 void TextureLayer::setUVRect(const gfx::RectF& rect) 66 void TextureLayer::setUVRect(const gfx::RectF& rect)
59 { 67 {
(...skipping 25 matching lines...) Expand all
85 void TextureLayer::setRateLimitContext(bool rateLimit) 93 void TextureLayer::setRateLimitContext(bool rateLimit)
86 { 94 {
87 if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost()) 95 if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost())
88 layerTreeHost()->stopRateLimiter(m_client->context()); 96 layerTreeHost()->stopRateLimiter(m_client->context());
89 97
90 m_rateLimitContext = rateLimit; 98 m_rateLimitContext = rateLimit;
91 } 99 }
92 100
93 void TextureLayer::setTextureId(unsigned id) 101 void TextureLayer::setTextureId(unsigned id)
94 { 102 {
103 DCHECK(!m_mailboxLayer);
95 if (m_textureId == id) 104 if (m_textureId == id)
96 return; 105 return;
97 if (m_textureId && layerTreeHost()) 106 if (m_textureId && layerTreeHost())
98 layerTreeHost()->acquireLayerTextures(); 107 layerTreeHost()->acquireLayerTextures();
99 m_textureId = id; 108 m_textureId = id;
100 setNeedsCommit(); 109 setNeedsCommit();
101 } 110 }
102 111
112 void TextureLayer::setTextureMailbox(const std::string& mailboxName, const base: :Callback<void(unsigned)>& callback)
113 {
114 DCHECK(m_mailboxLayer);
danakj 2013/01/02 16:17:22 Can we DCHECK that mailboxName.isempty == callback
115 if (m_mailboxName.compare(mailboxName) == 0)
116 return;
117 // If we never commited the mailbox, we need to release it here
118 if (!m_contentCommitted && m_mailboxName.size())
119 m_mailboxReleaseCallback.Run(0);
120 m_mailboxReleaseCallback = callback;
121 m_mailboxName = mailboxName;
122 setNeedsCommit();
123 }
124
103 void TextureLayer::willModifyTexture() 125 void TextureLayer::willModifyTexture()
104 { 126 {
105 if (layerTreeHost() && (drawsContent() || m_contentCommitted)) { 127 if (layerTreeHost() && (drawsContent() || m_contentCommitted)) {
106 layerTreeHost()->acquireLayerTextures(); 128 layerTreeHost()->acquireLayerTextures();
107 m_contentCommitted = false; 129 m_contentCommitted = false;
108 } 130 }
109 } 131 }
110 132
111 void TextureLayer::setNeedsDisplayRect(const gfx::RectF& dirtyRect) 133 void TextureLayer::setNeedsDisplayRect(const gfx::RectF& dirtyRect)
112 { 134 {
113 Layer::setNeedsDisplayRect(dirtyRect); 135 Layer::setNeedsDisplayRect(dirtyRect);
114 136
115 if (m_rateLimitContext && m_client && layerTreeHost() && drawsContent()) 137 if (m_rateLimitContext && m_client && layerTreeHost() && drawsContent())
116 layerTreeHost()->startRateLimiter(m_client->context()); 138 layerTreeHost()->startRateLimiter(m_client->context());
117 } 139 }
118 140
119 void TextureLayer::setLayerTreeHost(LayerTreeHost* host) 141 void TextureLayer::setLayerTreeHost(LayerTreeHost* host)
120 { 142 {
121 if (m_textureId && layerTreeHost() && host != layerTreeHost()) 143 if (m_textureId && layerTreeHost() && host != layerTreeHost())
122 layerTreeHost()->acquireLayerTextures(); 144 layerTreeHost()->acquireLayerTextures();
123 Layer::setLayerTreeHost(host); 145 Layer::setLayerTreeHost(host);
124 } 146 }
125 147
126 bool TextureLayer::drawsContent() const 148 bool TextureLayer::drawsContent() const
127 { 149 {
128 return (m_client || m_textureId) && !m_contextLost && Layer::drawsContent(); 150 return (m_client || m_textureId || m_mailboxName.size()) && !m_contextLost & & Layer::drawsContent();
129 } 151 }
130 152
131 void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, R enderingStats&) 153 void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, R enderingStats&)
132 { 154 {
133 if (m_client) { 155 if (m_client) {
134 m_textureId = m_client->prepareTexture(queue); 156 m_textureId = m_client->prepareTexture(queue);
135 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GL_N O_ERROR; 157 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GL_N O_ERROR;
136 } 158 }
137 159
138 m_needsDisplay = false; 160 m_needsDisplay = false;
139 } 161 }
140 162
141 void TextureLayer::pushPropertiesTo(LayerImpl* layer) 163 void TextureLayer::pushPropertiesTo(LayerImpl* layer)
142 { 164 {
143 Layer::pushPropertiesTo(layer); 165 Layer::pushPropertiesTo(layer);
144 166
145 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer); 167 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer);
146 textureLayer->setFlipped(m_flipped); 168 textureLayer->setFlipped(m_flipped);
147 textureLayer->setUVRect(m_uvRect); 169 textureLayer->setUVRect(m_uvRect);
148 textureLayer->setVertexOpacity(m_vertexOpacity); 170 textureLayer->setVertexOpacity(m_vertexOpacity);
149 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); 171 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
150 textureLayer->setTextureId(m_textureId); 172 if (m_mailboxLayer)
173 textureLayer->setTextureMailbox(m_mailboxName, m_mailboxReleaseCallback) ;
174 else
175 textureLayer->setTextureId(m_textureId);
151 m_contentCommitted = drawsContent(); 176 m_contentCommitted = drawsContent();
152 } 177 }
153 178
154 bool TextureLayer::blocksPendingCommit() const 179 bool TextureLayer::blocksPendingCommit() const
155 { 180 {
156 // Double-buffered texture layers need to be blocked until they can be made 181 // Double-buffered texture layers need to be blocked until they can be made
157 // triple-buffered. Single-buffered layers already prevent draws, so 182 // triple-buffered. Single-buffered layers already prevent draws, so
158 // can block too for simplicity. 183 // can block too for simplicity.
159 return true; 184 return true;
160 } 185 }
161 186
162 } // namespace cc 187 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698