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

Side by Side Diff: content/common/gpu/texture_image_transport_surface.cc

Issue 10974008: Aura: Keep scheduling in line with other platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/gpu/texture_image_transport_surface.h" 5 #include "content/common/gpu/texture_image_transport_surface.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 24 matching lines...) Expand all
35 GpuCommandBufferStub* stub, 35 GpuCommandBufferStub* stub,
36 const gfx::GLSurfaceHandle& handle) 36 const gfx::GLSurfaceHandle& handle)
37 : fbo_id_(0), 37 : fbo_id_(0),
38 front_(0), 38 front_(0),
39 stub_destroyed_(false), 39 stub_destroyed_(false),
40 backbuffer_suggested_allocation_(true), 40 backbuffer_suggested_allocation_(true),
41 frontbuffer_suggested_allocation_(true), 41 frontbuffer_suggested_allocation_(true),
42 frontbuffer_is_protected_(true), 42 frontbuffer_is_protected_(true),
43 protection_state_id_(0), 43 protection_state_id_(0),
44 handle_(handle), 44 handle_(handle),
45 parent_stub_(NULL) { 45 parent_stub_(NULL),
46 is_swap_buffers_pending_(false),
47 did_unschedule_(false) {
46 helper_.reset(new ImageTransportHelper(this, 48 helper_.reset(new ImageTransportHelper(this,
47 manager, 49 manager,
48 stub, 50 stub,
49 gfx::kNullPluginWindow)); 51 gfx::kNullPluginWindow));
50 } 52 }
51 53
52 TextureImageTransportSurface::~TextureImageTransportSurface() { 54 TextureImageTransportSurface::~TextureImageTransportSurface() {
53 DCHECK(stub_destroyed_); 55 DCHECK(stub_destroyed_);
54 Destroy(); 56 Destroy();
55 } 57 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 111 }
110 112
111 if (surface_.get()) { 113 if (surface_.get()) {
112 surface_->Destroy(); 114 surface_->Destroy();
113 surface_ = NULL; 115 surface_ = NULL;
114 } 116 }
115 117
116 helper_->Destroy(); 118 helper_->Destroy();
117 } 119 }
118 120
121 bool TextureImageTransportSurface::DeferDraws() {
122 // The command buffer hit a draw/clear command that could clobber the
123 // texture in use by the UI compositor. If a Swap is pending, abort
124 // processing of the command by returning true and unschedule until the Swap
125 // Ack arrives.
126 if (did_unschedule_)
piman 2012/09/24 16:29:48 nit: How can this be called at all if we're unsche
jonathan.backer 2012/09/24 21:08:18 Done.
127 return true; // Still unscheduled, so just return true.
128 if (is_swap_buffers_pending_) {
129 did_unschedule_ = true;
130 helper_->SetScheduled(false);
131 return true;
132 }
133 return false;
134 }
135
119 bool TextureImageTransportSurface::Resize(const gfx::Size&) { 136 bool TextureImageTransportSurface::Resize(const gfx::Size&) {
120 return true; 137 return true;
121 } 138 }
122 139
123 bool TextureImageTransportSurface::IsOffscreen() { 140 bool TextureImageTransportSurface::IsOffscreen() {
124 return true; 141 return true;
125 } 142 }
126 143
127 bool TextureImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { 144 bool TextureImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
128 if (stub_destroyed_) { 145 if (stub_destroyed_) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 front_ = back(); 264 front_ = back();
248 previous_damage_rect_ = gfx::Rect(textures_[front()].size); 265 previous_damage_rect_ = gfx::Rect(textures_[front()].size);
249 266
250 DCHECK(textures_[front()].client_id != 0); 267 DCHECK(textures_[front()].client_id != 0);
251 268
252 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 269 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
253 params.surface_handle = textures_[front()].client_id; 270 params.surface_handle = textures_[front()].client_id;
254 params.protection_state_id = protection_state_id_; 271 params.protection_state_id = protection_state_id_;
255 params.skip_ack = false; 272 params.skip_ack = false;
256 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 273 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
257 helper_->SetScheduled(false); 274
275 DCHECK(!is_swap_buffers_pending_);
276 is_swap_buffers_pending_ = true;
258 return true; 277 return true;
259 } 278 }
260 279
261 bool TextureImageTransportSurface::PostSubBuffer( 280 bool TextureImageTransportSurface::PostSubBuffer(
262 int x, int y, int width, int height) { 281 int x, int y, int width, int height) {
263 DCHECK(backbuffer_suggested_allocation_); 282 DCHECK(backbuffer_suggested_allocation_);
264 DCHECK(textures_[back()].info->service_id()); 283 DCHECK(textures_[back()].info->service_id());
265 if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_) 284 if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_)
266 return true; 285 return true;
267 // If we are recreating the frontbuffer with this swap, make sure we are 286 // If we are recreating the frontbuffer with this swap, make sure we are
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 DCHECK(textures_[front()].client_id); 335 DCHECK(textures_[front()].client_id);
317 336
318 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; 337 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params;
319 params.surface_handle = textures_[front()].client_id; 338 params.surface_handle = textures_[front()].client_id;
320 params.x = x; 339 params.x = x;
321 params.y = y; 340 params.y = y;
322 params.width = width; 341 params.width = width;
323 params.height = height; 342 params.height = height;
324 params.protection_state_id = protection_state_id_; 343 params.protection_state_id = protection_state_id_;
325 helper_->SendAcceleratedSurfacePostSubBuffer(params); 344 helper_->SendAcceleratedSurfacePostSubBuffer(params);
326 helper_->SetScheduled(false); 345
346 DCHECK(!is_swap_buffers_pending_);
347 is_swap_buffers_pending_ = true;
327 return true; 348 return true;
328 } 349 }
329 350
330 std::string TextureImageTransportSurface::GetExtensions() { 351 std::string TextureImageTransportSurface::GetExtensions() {
331 std::string extensions = gfx::GLSurface::GetExtensions(); 352 std::string extensions = gfx::GLSurface::GetExtensions();
332 extensions += extensions.empty() ? "" : " "; 353 extensions += extensions.empty() ? "" : " ";
333 extensions += "GL_CHROMIUM_front_buffer_cached "; 354 extensions += "GL_CHROMIUM_front_buffer_cached ";
334 extensions += "GL_CHROMIUM_post_sub_buffer"; 355 extensions += "GL_CHROMIUM_post_sub_buffer";
335 return extensions; 356 return extensions;
336 } 357 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 BufferPresentedImpl(); 397 BufferPresentedImpl();
377 } else { 398 } else {
378 helper_->manager()->sync_point_manager()->AddSyncPointCallback( 399 helper_->manager()->sync_point_manager()->AddSyncPointCallback(
379 sync_point, 400 sync_point,
380 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, 401 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl,
381 this->AsWeakPtr())); 402 this->AsWeakPtr()));
382 } 403 }
383 } 404 }
384 405
385 void TextureImageTransportSurface::BufferPresentedImpl() { 406 void TextureImageTransportSurface::BufferPresentedImpl() {
407 DCHECK(is_swap_buffers_pending_);
408 is_swap_buffers_pending_ = false;
409
386 // We're relying on the fact that the parent context is 410 // We're relying on the fact that the parent context is
387 // finished with it's context when it inserts the sync point that 411 // finished with it's context when it inserts the sync point that
388 // triggers this callback. 412 // triggers this callback.
389 if (helper_->MakeCurrent()) { 413 if (helper_->MakeCurrent()) {
390 if (textures_[front()].size != textures_[back()].size || 414 if (textures_[front()].size != textures_[back()].size ||
391 !textures_[back()].info->service_id() || 415 !textures_[back()].info->service_id() ||
392 !textures_[back()].sent_to_client) { 416 !textures_[back()].sent_to_client) {
393 // We may get an ACK from a stale swap just to reschedule. In that case, 417 // We may get an ACK from a stale swap just to reschedule. In that case,
394 // we may not have a backbuffer suggestion and should not recreate one. 418 // we may not have a backbuffer suggestion and should not recreate one.
395 if (backbuffer_suggested_allocation_) 419 if (backbuffer_suggested_allocation_)
396 CreateBackTexture(textures_[front()].size); 420 CreateBackTexture(textures_[front()].size);
397 } else { 421 } else {
398 AttachBackTextureToFBO(); 422 AttachBackTextureToFBO();
399 } 423 }
400 } 424 }
401 425
402 // Even if MakeCurrent fails, schedule anyway, to trigger the lost context 426 // Even if MakeCurrent fails, schedule anyway, to trigger the lost context
403 // logic. 427 // logic.
404 helper_->SetScheduled(true); 428 if (did_unschedule_) {
429 did_unschedule_ = false;
430 helper_->SetScheduled(true);
431 }
405 } 432 }
406 433
407 void TextureImageTransportSurface::OnResizeViewACK() { 434 void TextureImageTransportSurface::OnResizeViewACK() {
408 NOTREACHED(); 435 NOTREACHED();
409 } 436 }
410 437
411 void TextureImageTransportSurface::ReleaseTexture(int id) { 438 void TextureImageTransportSurface::ReleaseTexture(int id) {
412 if (!parent_stub_) 439 if (!parent_stub_)
413 return; 440 return;
414 Texture& texture = textures_[id]; 441 Texture& texture = textures_[id];
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 Texture& texture = textures_[i]; 542 Texture& texture = textures_[i];
516 texture.info = NULL; 543 texture.info = NULL;
517 if (!texture.sent_to_client) 544 if (!texture.sent_to_client)
518 continue; 545 continue;
519 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 546 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
520 params.identifier = texture.client_id; 547 params.identifier = texture.client_id;
521 helper_->SendAcceleratedSurfaceRelease(params); 548 helper_->SendAcceleratedSurfaceRelease(params);
522 } 549 }
523 parent_stub_ = NULL; 550 parent_stub_ = NULL;
524 } 551 }
OLDNEW
« no previous file with comments | « content/common/gpu/texture_image_transport_surface.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698