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

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

Issue 10453117: Tighter sync and faster ACK on SwapBuffers/PostSubBuffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 6 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/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/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 569
570 if (!resize_locks_.empty() && !compositor->DrawPending()) { 570 if (!resize_locks_.empty() && !compositor->DrawPending()) {
571 // If we are waiting for the resize, fast-track the ACK. 571 // If we are waiting for the resize, fast-track the ACK.
572 // However only do so if we're not between the Draw() and the 572 // However only do so if we're not between the Draw() and the
573 // OnCompositingEnded(), because out-of-order execution in the GPU process 573 // OnCompositingEnded(), because out-of-order execution in the GPU process
574 // might corrupt the "front buffer" for the currently issued frame. 574 // might corrupt the "front buffer" for the currently issued frame.
575 RenderWidgetHostImpl::AcknowledgeSwapBuffers( 575 RenderWidgetHostImpl::AcknowledgeSwapBuffers(
576 params_in_pixel.route_id, gpu_host_id); 576 params_in_pixel.route_id, gpu_host_id);
577 } else { 577 } else {
578 // Add sending an ACK to the list of things to do OnCompositingEnded 578 // Add sending an ACK to the list of things to do OnCompositingEnded
579 on_compositing_ended_callbacks_.push_back( 579 on_compositing_will_end_callbacks_.push_back(CallbackAndCompositeNumber(
piman 2012/06/04 18:20:39 A possible gotcha for the future, is that this rel
jonathan.backer 2012/06/05 13:35:58 Just to reiterate what I think you are saying: Cur
580 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers, 580 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers,
581 params_in_pixel.route_id, gpu_host_id)); 581 params_in_pixel.route_id, gpu_host_id),
582 compositor->last_started_id() + 1));
582 if (!compositor->HasObserver(this)) 583 if (!compositor->HasObserver(this))
583 compositor->AddObserver(this); 584 compositor->AddObserver(this);
584 } 585 }
585 } 586 }
586 } 587 }
587 588
588 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 589 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
589 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 590 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
590 int gpu_host_id) { 591 int gpu_host_id) {
591 current_surface_ = params_in_pixel.surface_handle; 592 current_surface_ = params_in_pixel.surface_handle;
(...skipping 21 matching lines...) Expand all
613 614
614 if (!resize_locks_.empty() && !compositor->DrawPending()) { 615 if (!resize_locks_.empty() && !compositor->DrawPending()) {
615 // If we are waiting for the resize, fast-track the ACK. 616 // If we are waiting for the resize, fast-track the ACK.
616 // However only do so if we're not between the Draw() and the 617 // However only do so if we're not between the Draw() and the
617 // OnCompositingEnded(), because out-of-order execution in the GPU process 618 // OnCompositingEnded(), because out-of-order execution in the GPU process
618 // might corrupt the "front buffer" for the currently issued frame. 619 // might corrupt the "front buffer" for the currently issued frame.
619 RenderWidgetHostImpl::AcknowledgePostSubBuffer( 620 RenderWidgetHostImpl::AcknowledgePostSubBuffer(
620 params_in_pixel.route_id, gpu_host_id); 621 params_in_pixel.route_id, gpu_host_id);
621 } else { 622 } else {
622 // Add sending an ACK to the list of things to do OnCompositingEnded 623 // Add sending an ACK to the list of things to do OnCompositingEnded
623 on_compositing_ended_callbacks_.push_back( 624 on_compositing_will_end_callbacks_.push_back(CallbackAndCompositeNumber(
624 base::Bind(&RenderWidgetHostImpl::AcknowledgePostSubBuffer, 625 base::Bind(&RenderWidgetHostImpl::AcknowledgePostSubBuffer,
625 params_in_pixel.route_id, gpu_host_id)); 626 params_in_pixel.route_id, gpu_host_id),
627 compositor->last_started_id() + 1));
626 if (!compositor->HasObserver(this)) 628 if (!compositor->HasObserver(this))
627 compositor->AddObserver(this); 629 compositor->AddObserver(this);
628 } 630 }
629 } 631 }
630 } 632 }
631 633
632 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { 634 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() {
633 } 635 }
634 636
635 bool RenderWidgetHostViewAura::HasAcceleratedSurface( 637 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 } 1181 }
1180 1182
1181 //////////////////////////////////////////////////////////////////////////////// 1183 ////////////////////////////////////////////////////////////////////////////////
1182 // RenderWidgetHostViewAura, ui::CompositorDelegate implementation: 1184 // RenderWidgetHostViewAura, ui::CompositorDelegate implementation:
1183 1185
1184 void RenderWidgetHostViewAura::OnCompositingStarted( 1186 void RenderWidgetHostViewAura::OnCompositingStarted(
1185 ui::Compositor* compositor) { 1187 ui::Compositor* compositor) {
1186 locks_pending_draw_.clear(); 1188 locks_pending_draw_.clear();
1187 } 1189 }
1188 1190
1189 void RenderWidgetHostViewAura::OnCompositingEnded(ui::Compositor* compositor) { 1191 void RenderWidgetHostViewAura::OnCompositingWillEnd(
1190 RunCompositingCallbacks(); 1192 ui::Compositor* compositor) {
1191 compositor->RemoveObserver(this); 1193 RunCompositingCallbacks(compositor);
1194 if (on_compositing_will_end_callbacks_.empty())
1195 compositor->RemoveObserver(this);
1196 }
1197
1198 void RenderWidgetHostViewAura::OnCompositingEnded(
1199 ui::Compositor* compositor) {
1192 } 1200 }
1193 1201
1194 //////////////////////////////////////////////////////////////////////////////// 1202 ////////////////////////////////////////////////////////////////////////////////
1195 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 1203 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
1196 1204
1197 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { 1205 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) {
1198 image_transport_clients_.clear(); 1206 image_transport_clients_.clear();
1199 current_surface_ = 0; 1207 current_surface_ = 0;
1200 UpdateExternalTexture(); 1208 UpdateExternalTexture();
1201 locks_pending_draw_.clear(); 1209 locks_pending_draw_.clear();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 gfx::Rect rect = window_->bounds(); 1302 gfx::Rect rect = window_->bounds();
1295 int border_x = rect.width() * kMouseLockBorderPercentage / 100; 1303 int border_x = rect.width() * kMouseLockBorderPercentage / 100;
1296 int border_y = rect.height() * kMouseLockBorderPercentage / 100; 1304 int border_y = rect.height() * kMouseLockBorderPercentage / 100;
1297 1305
1298 return global_mouse_position_.x() < rect.x() + border_x || 1306 return global_mouse_position_.x() < rect.x() + border_x ||
1299 global_mouse_position_.x() > rect.right() - border_x || 1307 global_mouse_position_.x() > rect.right() - border_x ||
1300 global_mouse_position_.y() < rect.y() + border_y || 1308 global_mouse_position_.y() < rect.y() + border_y ||
1301 global_mouse_position_.y() > rect.bottom() - border_y; 1309 global_mouse_position_.y() > rect.bottom() - border_y;
1302 } 1310 }
1303 1311
1304 void RenderWidgetHostViewAura::RunCompositingCallbacks() { 1312 void RenderWidgetHostViewAura::RunCompositingCallbacks(
1305 for (std::vector< base::Callback<void(void)> >::const_iterator 1313 ui::Compositor* compositor) {
1306 it = on_compositing_ended_callbacks_.begin(); 1314 std::vector<CallbackAndCompositeNumber>::iterator it =
1307 it != on_compositing_ended_callbacks_.end(); ++it) { 1315 on_compositing_will_end_callbacks_.begin();
1308 it->Run(); 1316 while (it != on_compositing_will_end_callbacks_.end()) {
1317 if (compositor == NULL ||
1318 it->second <= compositor->last_will_end_id()) {
1319 it->first.Run();
1320 it = on_compositing_will_end_callbacks_.erase(it);
1321 } else {
1322 it++;
1323 }
1309 } 1324 }
1310 on_compositing_ended_callbacks_.clear();
1311 } 1325 }
1312 1326
1313 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 1327 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
1314 // We are about to disconnect ourselves from the compositor, we need to issue 1328 // We are about to disconnect ourselves from the compositor, we need to issue
1315 // the callbacks now, because we won't get notified when the frame is done. 1329 // the callbacks now, because we won't get notified when the frame is done.
1316 // TODO(piman): this might in theory cause a race where the GPU process starts 1330 // TODO(piman): this might in theory cause a race where the GPU process starts
1317 // drawing to the buffer we haven't yet displayed. This will only show for 1 1331 // drawing to the buffer we haven't yet displayed. This will only show for 1
1318 // frame though, because we will reissue a new frame right away without that 1332 // frame though, because we will reissue a new frame right away without that
1319 // composited data. 1333 // composited data.
1320 RunCompositingCallbacks(); 1334 RunCompositingCallbacks(NULL);
1321 locks_pending_draw_.clear(); 1335 locks_pending_draw_.clear();
1322 ui::Compositor* compositor = GetCompositor(); 1336 ui::Compositor* compositor = GetCompositor();
1323 if (compositor && compositor->HasObserver(this)) 1337 if (compositor && compositor->HasObserver(this))
1324 compositor->RemoveObserver(this); 1338 compositor->RemoveObserver(this);
1325 } 1339 }
1326 1340
1327 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { 1341 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() {
1328 aura::RootWindow* root_window = window_->GetRootWindow(); 1342 aura::RootWindow* root_window = window_->GetRootWindow();
1329 return root_window ? root_window->compositor() : NULL; 1343 return root_window ? root_window->compositor() : NULL;
1330 } 1344 }
1331 1345
1332 //////////////////////////////////////////////////////////////////////////////// 1346 ////////////////////////////////////////////////////////////////////////////////
1333 // RenderWidgetHostView, public: 1347 // RenderWidgetHostView, public:
1334 1348
1335 // static 1349 // static
1336 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 1350 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
1337 RenderWidgetHost* widget) { 1351 RenderWidgetHost* widget) {
1338 return new RenderWidgetHostViewAura(widget); 1352 return new RenderWidgetHostViewAura(widget);
1339 } 1353 }
1340 1354
1341 // static 1355 // static
1342 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1356 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1343 WebKit::WebScreenInfo* results) { 1357 WebKit::WebScreenInfo* results) {
1344 GetScreenInfoForWindow(results, NULL); 1358 GetScreenInfoForWindow(results, NULL);
1345 } 1359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698