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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 9838045: aura: fast resizes for accelerated pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « no previous file | ui/aura/root_window.h » ('j') | ui/aura/root_window.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "content/browser/renderer_host/backing_store_skia.h" 10 #include "content/browser/renderer_host/backing_store_skia.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 RenderWidgetHostViewAura* view_; 120 RenderWidgetHostViewAura* view_;
121 121
122 DISALLOW_COPY_AND_ASSIGN(WindowObserver); 122 DISALLOW_COPY_AND_ASSIGN(WindowObserver);
123 }; 123 };
124 124
125 class RenderWidgetHostViewAura::ResizeLock : 125 class RenderWidgetHostViewAura::ResizeLock :
126 public base::SupportsWeakPtr<RenderWidgetHostViewAura::ResizeLock> { 126 public base::SupportsWeakPtr<RenderWidgetHostViewAura::ResizeLock> {
127 public: 127 public:
128 ResizeLock(aura::RootWindow* root_window, const gfx::Size new_size) 128 ResizeLock(aura::RootWindow* root_window, const gfx::Size new_size)
129 : root_window_(root_window), 129 : root_window_(root_window),
130 new_size_(new_size) { 130 new_size_(new_size),
131 compositor_lock_(root_window_->GetCompositorLock()) {
131 root_window_->HoldMouseMoves(); 132 root_window_->HoldMouseMoves();
132 133
133 BrowserThread::PostDelayedTask( 134 BrowserThread::PostDelayedTask(
134 BrowserThread::UI, FROM_HERE, 135 BrowserThread::UI, FROM_HERE,
135 base::Bind(&RenderWidgetHostViewAura::ResizeLock::CancelLock, 136 base::Bind(&RenderWidgetHostViewAura::ResizeLock::CancelLock,
136 AsWeakPtr()), 137 AsWeakPtr()),
137 kResizeLockTimeoutMs); 138 kResizeLockTimeoutMs);
138 } 139 }
139 140
140 ~ResizeLock() { 141 ~ResizeLock() {
141 CancelLock(); 142 CancelLock();
142 } 143 }
143 144
145 void UnlockCompositor() {
146 compositor_lock_ = NULL;
147 }
148
144 void CancelLock() { 149 void CancelLock() {
145 if (root_window_) 150 if (!root_window_)
146 root_window_->ReleaseMouseMoves(); 151 return;
152 UnlockCompositor();
153 root_window_->ReleaseMouseMoves();
147 root_window_ = NULL; 154 root_window_ = NULL;
148 } 155 }
149 156
150 const gfx::Size& expected_size() const { 157 const gfx::Size& expected_size() const {
151 return new_size_; 158 return new_size_;
152 } 159 }
153 160
154 private: 161 private:
155 aura::RootWindow* root_window_; 162 aura::RootWindow* root_window_;
156 gfx::Size new_size_; 163 gfx::Size new_size_;
164 scoped_refptr<aura::CompositorLock> compositor_lock_;
157 165
158 DISALLOW_COPY_AND_ASSIGN(ResizeLock); 166 DISALLOW_COPY_AND_ASSIGN(ResizeLock);
159 }; 167 };
160 168
161 //////////////////////////////////////////////////////////////////////////////// 169 ////////////////////////////////////////////////////////////////////////////////
162 // RenderWidgetHostViewAura, public: 170 // RenderWidgetHostViewAura, public:
163 171
164 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) 172 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host)
165 : host_(RenderWidgetHostImpl::From(host)), 173 : host_(RenderWidgetHostImpl::From(host)),
166 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 174 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 420
413 ImageTransportClient* container = 421 ImageTransportClient* container =
414 image_transport_clients_[current_surface_]; 422 image_transport_clients_[current_surface_];
415 if (container) 423 if (container)
416 container->Update(); 424 container->Update();
417 window_->SetExternalTexture(container); 425 window_->SetExternalTexture(container);
418 426
419 if (!container) { 427 if (!container) {
420 resize_locks_.clear(); 428 resize_locks_.clear();
421 } else { 429 } else {
422 std::vector<linked_ptr<ResizeLock> >::iterator it = resize_locks_.begin(); 430 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList;
431 ResizeLockList::iterator it = resize_locks_.begin();
423 while (it != resize_locks_.end()) { 432 while (it != resize_locks_.end()) {
424 if ((*it)->expected_size() == container->size()) 433 if ((*it)->expected_size() == container->size())
425 break; 434 break;
426 ++it; 435 ++it;
427 } 436 }
428 if (it != resize_locks_.end()) { 437 if (it != resize_locks_.end()) {
429 ++it; 438 ++it;
430 ui::Compositor* compositor = GetCompositor(); 439 ui::Compositor* compositor = GetCompositor();
431 if (compositor) { 440 if (compositor) {
432 // Delay the release of the lock until we've kicked a frame with the 441 // Delay the release of the lock until we've kicked a frame with the
433 // new texture, to avoid resizing the UI before we have a chance to 442 // new texture, to avoid resizing the UI before we have a chance to
434 // draw a "good" frame. 443 // draw a "good" frame.
435 locks_pending_draw_.insert( 444 locks_pending_draw_.insert(
436 locks_pending_draw_.begin(), resize_locks_.begin(), it); 445 locks_pending_draw_.begin(), resize_locks_.begin(), it);
446 // However since we got the size we were looking for, unlock the
447 // compositor.
448 for (ResizeLockList::iterator it2 = resize_locks_.begin();
449 it2 !=it; ++it2) {
450 it2->get()->UnlockCompositor();
451 }
437 if (!compositor->HasObserver(this)) 452 if (!compositor->HasObserver(this))
438 compositor->AddObserver(this); 453 compositor->AddObserver(this);
439 } 454 }
440 resize_locks_.erase(resize_locks_.begin(), it); 455 resize_locks_.erase(resize_locks_.begin(), it);
441 } 456 }
442 } 457 }
443 } else { 458 } else {
444 window_->SetExternalTexture(NULL); 459 window_->SetExternalTexture(NULL);
445 resize_locks_.clear(); 460 resize_locks_.clear();
446 } 461 }
447 } 462 }
448 463
449 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 464 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
450 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 465 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
451 int gpu_host_id) { 466 int gpu_host_id) {
452 current_surface_ = params.surface_handle; 467 current_surface_ = params.surface_handle;
453 UpdateExternalTexture(); 468 UpdateExternalTexture();
454 469
455 ui::Compositor* compositor = GetCompositor(); 470 ui::Compositor* compositor = GetCompositor();
456 if (!compositor) { 471 if (!compositor) {
457 // We have no compositor, so we have no way to display the surface. 472 // We have no compositor, so we have no way to display the surface.
458 // Must still send the ACK. 473 // Must still send the ACK.
459 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); 474 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params.route_id, gpu_host_id);
460 } else { 475 } else {
461 gfx::Size surface_size = 476 gfx::Size surface_size =
462 image_transport_clients_[params.surface_handle]->size(); 477 image_transport_clients_[params.surface_handle]->size();
463 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 478 window_->SchedulePaintInRect(gfx::Rect(surface_size));
464 479
465 // Add sending an ACK to the list of things to do OnCompositingEnded 480 if (!resize_locks_.empty() && !compositor->DrawPending()) {
jonathan.backer 2012/03/23 15:48:00 I'm not sure that !compositor->DrawPending() is st
piman 2012/03/23 17:41:09 So, we don't pipeline draws on the client side (br
466 on_compositing_ended_callbacks_.push_back( 481 // If we are waiting for the resize, fast-track the ACK.
467 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers, 482 // However only do so if we're not between the Draw() and the
468 params.route_id, gpu_host_id)); 483 // OnCompositingEnded(), because out-of-order execution in the GPU process
469 if (!compositor->HasObserver(this)) 484 // might corrupt the "front buffer" for the currently issued frame.
470 compositor->AddObserver(this); 485 RenderWidgetHostImpl::AcknowledgePostSubBuffer(
486 params.route_id, gpu_host_id);
487 } else {
488 // Add sending an ACK to the list of things to do OnCompositingEnded
489 on_compositing_ended_callbacks_.push_back(
490 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers,
491 params.route_id, gpu_host_id));
492 if (!compositor->HasObserver(this))
493 compositor->AddObserver(this);
494 }
471 } 495 }
472 } 496 }
473 497
474 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 498 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
475 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 499 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
476 int gpu_host_id) { 500 int gpu_host_id) {
477 current_surface_ = params.surface_handle; 501 current_surface_ = params.surface_handle;
478 UpdateExternalTexture(); 502 UpdateExternalTexture();
479 503
480 ui::Compositor* compositor = GetCompositor(); 504 ui::Compositor* compositor = GetCompositor();
481 if (!compositor) { 505 if (!compositor) {
482 // We have no compositor, so we have no way to display the surface 506 // We have no compositor, so we have no way to display the surface
483 // Must still send the ACK 507 // Must still send the ACK
484 RenderWidgetHostImpl::AcknowledgePostSubBuffer( 508 RenderWidgetHostImpl::AcknowledgePostSubBuffer(
485 params.route_id, gpu_host_id); 509 params.route_id, gpu_host_id);
486 } else { 510 } else {
487 gfx::Size surface_size = 511 gfx::Size surface_size =
488 image_transport_clients_[params.surface_handle]->size(); 512 image_transport_clients_[params.surface_handle]->size();
489 513
490 // Co-ordinates come in OpenGL co-ordinate space. 514 // Co-ordinates come in OpenGL co-ordinate space.
491 // We need to convert to layer space. 515 // We need to convert to layer space.
492 window_->SchedulePaintInRect(gfx::Rect( 516 window_->SchedulePaintInRect(gfx::Rect(
493 params.x, 517 params.x,
494 surface_size.height() - params.y - params.height, 518 surface_size.height() - params.y - params.height,
495 params.width, 519 params.width,
496 params.height)); 520 params.height));
497 521
498 // Add sending an ACK to the list of things to do OnCompositingEnded 522 if (!resize_locks_.empty() && !compositor->DrawPending()) {
499 on_compositing_ended_callbacks_.push_back( 523 // If we are waiting for the resize, fast-track the ACK.
500 base::Bind(&RenderWidgetHostImpl::AcknowledgePostSubBuffer, 524 // However only do so if we're not between the Draw() and the
501 params.route_id, gpu_host_id)); 525 // OnCompositingEnded(), because out-of-order execution in the GPU process
502 if (!compositor->HasObserver(this)) 526 // might corrupt the "front buffer" for the currently issued frame.
503 compositor->AddObserver(this); 527 RenderWidgetHostImpl::AcknowledgePostSubBuffer(
528 params.route_id, gpu_host_id);
529 } else {
530 // Add sending an ACK to the list of things to do OnCompositingEnded
531 on_compositing_ended_callbacks_.push_back(
532 base::Bind(&RenderWidgetHostImpl::AcknowledgePostSubBuffer,
533 params.route_id, gpu_host_id));
534 if (!compositor->HasObserver(this))
535 compositor->AddObserver(this);
536 }
504 } 537 }
505 } 538 }
506 539
507 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { 540 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() {
508 } 541 }
509 542
510 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( 543 void RenderWidgetHostViewAura::AcceleratedSurfaceNew(
511 int32 width, 544 int32 width,
512 int32 height, 545 int32 height,
513 uint64* surface_handle, 546 uint64* surface_handle,
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 WebKit::WebScreenInfo* results) { 1247 WebKit::WebScreenInfo* results) {
1215 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); 1248 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize();
1216 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); 1249 results->rect = WebKit::WebRect(0, 0, size.width(), size.height());
1217 results->availableRect = results->rect; 1250 results->availableRect = results->rect;
1218 // TODO(derat): Don't hardcode this? 1251 // TODO(derat): Don't hardcode this?
1219 results->depth = 24; 1252 results->depth = 24;
1220 results->depthPerComponent = 8; 1253 results->depthPerComponent = 8;
1221 results->verticalDPI = 96; 1254 results->verticalDPI = 96;
1222 results->horizontalDPI = 96; 1255 results->horizontalDPI = 96;
1223 } 1256 }
OLDNEW
« no previous file with comments | « no previous file | ui/aura/root_window.h » ('j') | ui/aura/root_window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698