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

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

Powered by Google App Engine
This is Rietveld 408576698