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

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

Issue 189333003: cc: Allow pepper to avoid DCHECK but reuse gpu::Mailbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: baddcheck: compile Created 6 years, 9 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/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 texture_id_ = id; 128 texture_id_ = id;
129 SetNeedsCommit(); 129 SetNeedsCommit();
130 // The texture id needs to be removed from the active tree before the 130 // The texture id needs to be removed from the active tree before the
131 // commit is called complete. 131 // commit is called complete.
132 SetNextCommitWaitsForActivation(); 132 SetNextCommitWaitsForActivation();
133 } 133 }
134 134
135 void TextureLayer::SetTextureMailboxInternal( 135 void TextureLayer::SetTextureMailboxInternal(
136 const TextureMailbox& mailbox, 136 const TextureMailbox& mailbox,
137 scoped_ptr<SingleReleaseCallback> release_callback, 137 scoped_ptr<SingleReleaseCallback> release_callback,
138 bool requires_commit) { 138 bool requires_commit,
139 bool allow_mailbox_reuse) {
139 DCHECK(uses_mailbox_); 140 DCHECK(uses_mailbox_);
140 DCHECK(!mailbox.IsValid() || !holder_ref_ || 141 DCHECK(!mailbox.IsValid() || !holder_ref_ ||
141 !mailbox.Equals(holder_ref_->holder()->mailbox())); 142 !mailbox.Equals(holder_ref_->holder()->mailbox()) ||
143 allow_mailbox_reuse);
142 DCHECK_EQ(mailbox.IsValid(), !!release_callback); 144 DCHECK_EQ(mailbox.IsValid(), !!release_callback);
143 145
144 // If we never commited the mailbox, we need to release it here. 146 // If we never commited the mailbox, we need to release it here.
145 if (mailbox.IsValid()) { 147 if (mailbox.IsValid()) {
146 holder_ref_ = 148 holder_ref_ =
147 TextureMailboxHolder::Create(mailbox, release_callback.Pass()); 149 TextureMailboxHolder::Create(mailbox, release_callback.Pass());
148 } else { 150 } else {
149 holder_ref_.reset(); 151 holder_ref_.reset();
150 } 152 }
151 needs_set_mailbox_ = true; 153 needs_set_mailbox_ = true;
152 // If we are within a commit, no need to do it again immediately after. 154 // If we are within a commit, no need to do it again immediately after.
153 if (requires_commit) 155 if (requires_commit)
154 SetNeedsCommit(); 156 SetNeedsCommit();
155 else 157 else
156 SetNeedsPushProperties(); 158 SetNeedsPushProperties();
157 159
158 // The active frame needs to be replaced and the mailbox returned before the 160 // The active frame needs to be replaced and the mailbox returned before the
159 // commit is called complete. 161 // commit is called complete.
160 SetNextCommitWaitsForActivation(); 162 SetNextCommitWaitsForActivation();
161 } 163 }
162 164
163 void TextureLayer::SetTextureMailbox( 165 void TextureLayer::SetTextureMailbox(
164 const TextureMailbox& mailbox, 166 const TextureMailbox& mailbox,
165 scoped_ptr<SingleReleaseCallback> release_callback) { 167 scoped_ptr<SingleReleaseCallback> release_callback) {
168 bool requires_commit = true;
169 bool allow_mailbox_reuse = false;
166 SetTextureMailboxInternal( 170 SetTextureMailboxInternal(
167 mailbox, 171 mailbox, release_callback.Pass(), requires_commit, allow_mailbox_reuse);
168 release_callback.Pass(), 172 }
169 true /* requires_commit */); 173
174 static void IgnoreReleaseCallback(uint32 sync_point, bool lost) {}
175
176 void TextureLayer::SetTextureMailboxWithoutReleaseCallback(
177 const TextureMailbox& mailbox) {
178 // We allow reuse of the mailbox if there is a new sync point signalling new
179 // content, and the release callback goes nowhere since we'll be calling it
180 // multiple times for the same mailbox.
181 DCHECK(!mailbox.IsValid() || !holder_ref_ ||
182 !mailbox.Equals(holder_ref_->holder()->mailbox()) ||
183 mailbox.sync_point() != holder_ref_->holder()->mailbox().sync_point());
184 scoped_ptr<SingleReleaseCallback> release;
185 bool requires_commit = true;
186 bool allow_mailbox_reuse = true;
187 if (mailbox.IsValid())
188 release = SingleReleaseCallback::Create(base::Bind(&IgnoreReleaseCallback));
189 SetTextureMailboxInternal(
190 mailbox, release.Pass(), requires_commit, allow_mailbox_reuse);
170 } 191 }
171 192
172 void TextureLayer::WillModifyTexture() { 193 void TextureLayer::WillModifyTexture() {
173 if (!uses_mailbox_ && layer_tree_host() && (DrawsContent() || 194 if (!uses_mailbox_ && layer_tree_host() && (DrawsContent() ||
174 content_committed_)) { 195 content_committed_)) {
175 layer_tree_host()->AcquireLayerTextures(); 196 layer_tree_host()->AcquireLayerTextures();
176 content_committed_ = false; 197 content_committed_ = false;
177 } 198 }
178 } 199 }
179 200
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 bool updated = Layer::Update(queue, occlusion); 242 bool updated = Layer::Update(queue, occlusion);
222 if (client_) { 243 if (client_) {
223 if (uses_mailbox_) { 244 if (uses_mailbox_) {
224 TextureMailbox mailbox; 245 TextureMailbox mailbox;
225 scoped_ptr<SingleReleaseCallback> release_callback; 246 scoped_ptr<SingleReleaseCallback> release_callback;
226 if (client_->PrepareTextureMailbox( 247 if (client_->PrepareTextureMailbox(
227 &mailbox, 248 &mailbox,
228 &release_callback, 249 &release_callback,
229 layer_tree_host()->UsingSharedMemoryResources())) { 250 layer_tree_host()->UsingSharedMemoryResources())) {
230 // Already within a commit, no need to do another one immediately. 251 // Already within a commit, no need to do another one immediately.
231 SetTextureMailboxInternal( 252 bool requires_commit = false;
232 mailbox, 253 bool allow_mailbox_reuse = false;
233 release_callback.Pass(), 254 SetTextureMailboxInternal(mailbox,
234 false /* requires_commit */); 255 release_callback.Pass(),
256 requires_commit,
257 allow_mailbox_reuse);
235 updated = true; 258 updated = true;
236 } 259 }
237 } else { 260 } else {
238 texture_id_ = client_->PrepareTexture(); 261 texture_id_ = client_->PrepareTexture();
239 updated = true; 262 updated = true;
240 SetNeedsPushProperties(); 263 SetNeedsPushProperties();
241 // The texture id needs to be removed from the active tree before the 264 // The texture id needs to be removed from the active tree before the
242 // commit is called complete. 265 // commit is called complete.
243 SetNextCommitWaitsForActivation(); 266 SetNextCommitWaitsForActivation();
244 } 267 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 374
352 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( 375 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread(
353 uint32 sync_point, 376 uint32 sync_point,
354 bool is_lost) { 377 bool is_lost) {
355 Return(sync_point, is_lost); 378 Return(sync_point, is_lost);
356 message_loop_->PostTask( 379 message_loop_->PostTask(
357 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); 380 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this));
358 } 381 }
359 382
360 } // namespace cc 383 } // 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