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

Side by Side Diff: cc/layers/texture_layer.cc

Issue 23530003: cc: Block commit on activate by setting a flag on LayerTreeHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blockcommit: fix flake Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/texture_layer.h ('k') | cc/layers/texture_layer_unittest.cc » ('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/layers/texture_layer.h" 5 #include "cc/layers/texture_layer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/layers/texture_layer_client.h" 10 #include "cc/layers/texture_layer_client.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 void TextureLayer::SetTextureId(unsigned id) { 120 void TextureLayer::SetTextureId(unsigned id) {
121 DCHECK(!uses_mailbox_); 121 DCHECK(!uses_mailbox_);
122 if (texture_id_ == id) 122 if (texture_id_ == id)
123 return; 123 return;
124 if (texture_id_ && layer_tree_host()) 124 if (texture_id_ && layer_tree_host())
125 layer_tree_host()->AcquireLayerTextures(); 125 layer_tree_host()->AcquireLayerTextures();
126 texture_id_ = id; 126 texture_id_ = id;
127 SetNeedsCommit(); 127 SetNeedsCommit();
128 // The texture id needs to be removed from the active tree before the
129 // commit is called complete.
130 SetNextCommitWaitsForActivation();
128 } 131 }
129 132
130 void TextureLayer::SetTextureMailbox(const TextureMailbox& mailbox) { 133 void TextureLayer::SetTextureMailbox(const TextureMailbox& mailbox) {
131 DCHECK(uses_mailbox_); 134 DCHECK(uses_mailbox_);
132 DCHECK(!mailbox.IsValid() || !holder_ref_ || 135 DCHECK(!mailbox.IsValid() || !holder_ref_ ||
133 !mailbox.Equals(holder_ref_->holder()->mailbox())); 136 !mailbox.Equals(holder_ref_->holder()->mailbox()));
134 // If we never commited the mailbox, we need to release it here. 137 // If we never commited the mailbox, we need to release it here.
135 if (mailbox.IsValid()) 138 if (mailbox.IsValid())
136 holder_ref_ = MailboxHolder::Create(mailbox); 139 holder_ref_ = MailboxHolder::Create(mailbox);
137 else 140 else
138 holder_ref_.reset(); 141 holder_ref_.reset();
139 needs_set_mailbox_ = true; 142 needs_set_mailbox_ = true;
140 SetNeedsCommit(); 143 SetNeedsCommit();
144 // The active frame needs to be replaced and the mailbox returned before the
145 // commit is called complete.
146 SetNextCommitWaitsForActivation();
141 } 147 }
142 148
143 void TextureLayer::WillModifyTexture() { 149 void TextureLayer::WillModifyTexture() {
144 if (layer_tree_host() && (DrawsContent() || content_committed_)) { 150 if (layer_tree_host() && (DrawsContent() || content_committed_)) {
145 layer_tree_host()->AcquireLayerTextures(); 151 layer_tree_host()->AcquireLayerTextures();
146 content_committed_ = false; 152 content_committed_ = false;
147 } 153 }
148 } 154 }
149 155
150 void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { 156 void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) {
151 Layer::SetNeedsDisplayRect(dirty_rect); 157 Layer::SetNeedsDisplayRect(dirty_rect);
152 158
153 if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent()) 159 if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent())
154 layer_tree_host()->StartRateLimiter(client_->Context3d()); 160 layer_tree_host()->StartRateLimiter(client_->Context3d());
155 } 161 }
156 162
157 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) { 163 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
158 if (layer_tree_host() == host) { 164 if (layer_tree_host() == host) {
159 Layer::SetLayerTreeHost(host); 165 Layer::SetLayerTreeHost(host);
160 return; 166 return;
161 } 167 }
162 168
163 if (layer_tree_host()) { 169 if (layer_tree_host()) {
164 if (texture_id_) 170 if (texture_id_) {
165 layer_tree_host()->AcquireLayerTextures(); 171 layer_tree_host()->AcquireLayerTextures();
172 // The texture id needs to be removed from the active tree before the
173 // commit is called complete.
174 SetNextCommitWaitsForActivation();
175 }
166 if (rate_limit_context_ && client_) 176 if (rate_limit_context_ && client_)
167 layer_tree_host()->StopRateLimiter(client_->Context3d()); 177 layer_tree_host()->StopRateLimiter(client_->Context3d());
168 } 178 }
169 // If we're removed from the tree, the TextureLayerImpl will be destroyed, and 179 // If we're removed from the tree, the TextureLayerImpl will be destroyed, and
170 // we will need to set the mailbox again on a new TextureLayerImpl the next 180 // we will need to set the mailbox again on a new TextureLayerImpl the next
171 // time we push. 181 // time we push.
172 if (!host && uses_mailbox_ && holder_ref_) 182 if (!host && uses_mailbox_ && holder_ref_) {
173 needs_set_mailbox_ = true; 183 needs_set_mailbox_ = true;
184 // The active frame needs to be replaced and the mailbox returned before the
185 // commit is called complete.
186 SetNextCommitWaitsForActivation();
187 }
174 Layer::SetLayerTreeHost(host); 188 Layer::SetLayerTreeHost(host);
175 } 189 }
176 190
177 bool TextureLayer::DrawsContent() const { 191 bool TextureLayer::DrawsContent() const {
178 return (client_ || texture_id_ || holder_ref_) && Layer::DrawsContent(); 192 return (client_ || texture_id_ || holder_ref_) && Layer::DrawsContent();
179 } 193 }
180 194
181 bool TextureLayer::Update(ResourceUpdateQueue* queue, 195 bool TextureLayer::Update(ResourceUpdateQueue* queue,
182 const OcclusionTracker* occlusion) { 196 const OcclusionTracker* occlusion) {
183 bool updated = Layer::Update(queue, occlusion); 197 bool updated = Layer::Update(queue, occlusion);
184 if (client_) { 198 if (client_) {
185 if (uses_mailbox_) { 199 if (uses_mailbox_) {
186 TextureMailbox mailbox; 200 TextureMailbox mailbox;
187 if (client_->PrepareTextureMailbox( 201 if (client_->PrepareTextureMailbox(
188 &mailbox, layer_tree_host()->UsingSharedMemoryResources())) { 202 &mailbox, layer_tree_host()->UsingSharedMemoryResources())) {
189 SetTextureMailbox(mailbox); 203 SetTextureMailbox(mailbox);
190 updated = true; 204 updated = true;
191 } 205 }
192 } else { 206 } else {
193 texture_id_ = client_->PrepareTexture(); 207 texture_id_ = client_->PrepareTexture();
194 DCHECK_EQ(!!texture_id_, !!client_->Context3d()); 208 DCHECK_EQ(!!texture_id_, !!client_->Context3d());
195 if (client_->Context3d() && 209 if (client_->Context3d() &&
196 client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR) 210 client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR)
197 texture_id_ = 0; 211 texture_id_ = 0;
198 updated = true; 212 updated = true;
213 // The texture id needs to be removed from the active tree before the
214 // commit is called complete.
215 SetNextCommitWaitsForActivation();
199 } 216 }
200 } 217 }
201 218
202 // SetTextureMailbox could be called externally and the same mailbox used for 219 // SetTextureMailbox could be called externally and the same mailbox used for
203 // different textures. Such callers notify this layer that the texture has 220 // different textures. Such callers notify this layer that the texture has
204 // changed by calling SetNeedsDisplay, so check for that here. 221 // changed by calling SetNeedsDisplay, so check for that here.
205 return updated || !update_rect_.IsEmpty(); 222 return updated || !update_rect_.IsEmpty();
206 } 223 }
207 224
208 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { 225 void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
(...skipping 25 matching lines...) Expand all
234 Region TextureLayer::VisibleContentOpaqueRegion() const { 251 Region TextureLayer::VisibleContentOpaqueRegion() const {
235 if (contents_opaque()) 252 if (contents_opaque())
236 return visible_content_rect(); 253 return visible_content_rect();
237 254
238 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) 255 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF))
239 return visible_content_rect(); 256 return visible_content_rect();
240 257
241 return Region(); 258 return Region();
242 } 259 }
243 260
244 bool TextureLayer::BlocksPendingCommit() const {
245 // Double-buffered texture layers need to be blocked until they can be made
246 // triple-buffered. Single-buffered layers already prevent draws, so
247 // can block too for simplicity.
248 return DrawsContent();
249 }
250
251 bool TextureLayer::CanClipSelf() const { 261 bool TextureLayer::CanClipSelf() const {
252 return true; 262 return true;
253 } 263 }
254 264
255 TextureLayer::MailboxHolder::MainThreadReference::MainThreadReference( 265 TextureLayer::MailboxHolder::MainThreadReference::MainThreadReference(
256 MailboxHolder* holder) 266 MailboxHolder* holder)
257 : holder_(holder) { 267 : holder_(holder) {
258 holder_->InternalAddRef(); 268 holder_->InternalAddRef();
259 } 269 }
260 270
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 318 }
309 319
310 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread( 320 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread(
311 unsigned sync_point, bool is_lost) { 321 unsigned sync_point, bool is_lost) {
312 Return(sync_point, is_lost); 322 Return(sync_point, is_lost);
313 message_loop_->PostTask(FROM_HERE, 323 message_loop_->PostTask(FROM_HERE,
314 base::Bind(&MailboxHolder::InternalRelease, this)); 324 base::Bind(&MailboxHolder::InternalRelease, this));
315 } 325 }
316 326
317 } // namespace cc 327 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer.h ('k') | cc/layers/texture_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698