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

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

Issue 10052018: Drop frontbuffers with ui-use-gpu-process, synchronized with browser, decoupled from backbuffer dro… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Major simplification! 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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h" 12 #include "base/message_loop.h"
14 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
15 #include "content/browser/renderer_host/backing_store_skia.h" 14 #include "content/browser/renderer_host/backing_store_skia.h"
16 #include "content/browser/renderer_host/dip_util.h" 15 #include "content/browser/renderer_host/dip_util.h"
17 #include "content/browser/renderer_host/image_transport_client.h" 16 #include "content/browser/renderer_host/image_transport_client.h"
18 #include "content/browser/renderer_host/render_widget_host_impl.h" 17 #include "content/browser/renderer_host/render_widget_host_impl.h"
19 #include "content/browser/renderer_host/web_input_event_aura.h" 18 #include "content/browser/renderer_host/web_input_event_aura.h"
20 #include "content/common/gpu/client/gl_helper.h" 19 #include "content/common/gpu/client/gl_helper.h"
21 #include "content/common/gpu/gpu_messages.h" 20 #include "content/common/gpu/gpu_messages.h"
22 #include "content/port/browser/render_widget_host_view_port.h" 21 #include "content/port/browser/render_widget_host_view_port.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 207 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
209 in_shutdown_(false), 208 in_shutdown_(false),
210 is_fullscreen_(false), 209 is_fullscreen_(false),
211 popup_parent_host_view_(NULL), 210 popup_parent_host_view_(NULL),
212 popup_child_host_view_(NULL), 211 popup_child_host_view_(NULL),
213 is_loading_(false), 212 is_loading_(false),
214 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 213 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
215 can_compose_inline_(true), 214 can_compose_inline_(true),
216 has_composition_text_(false), 215 has_composition_text_(false),
217 current_surface_(0), 216 current_surface_(0),
217 route_id_(0),
218 gpu_host_id_(0),
219 weak_factory_(this),
piman 2012/06/11 21:32:24 ALLOW_THIS_IN_INITIALIZER_LIST
mmocny 2012/06/12 18:26:18 Not needed once using SupportsWeakPtr. On 2012/06
220 is_thumbnailing_(false),
218 paint_canvas_(NULL), 221 paint_canvas_(NULL),
219 synthetic_move_sent_(false), 222 synthetic_move_sent_(false),
220 needs_update_texture_(false) { 223 needs_update_texture_(false) {
221 host_->SetView(this); 224 host_->SetView(this);
222 window_observer_.reset(new WindowObserver(this)); 225 window_observer_.reset(new WindowObserver(this));
223 window_->AddObserver(window_observer_.get()); 226 window_->AddObserver(window_observer_.get());
224 aura::client::SetTooltipText(window_, &tooltip_); 227 aura::client::SetTooltipText(window_, &tooltip_);
225 aura::client::SetActivationDelegate(window_, this); 228 aura::client::SetActivationDelegate(window_, this);
226 } 229 }
227 230
228 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 231 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
229 if (!shared_surface_handle_.is_null()) { 232 if (!shared_surface_handle_.is_null()) {
230 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 233 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
231 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 234 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
232 factory->RemoveObserver(this); 235 factory->RemoveObserver(this);
233 } 236 }
234 window_->RemoveObserver(window_observer_.get()); 237 window_->RemoveObserver(window_observer_.get());
235 UnlockMouse(); 238 UnlockMouse();
236 if (popup_type_ != WebKit::WebPopupTypeNone) { 239 if (popup_type_ != WebKit::WebPopupTypeNone) {
237 DCHECK(popup_parent_host_view_); 240 DCHECK(popup_parent_host_view_);
238 popup_parent_host_view_->popup_child_host_view_ = NULL; 241 popup_parent_host_view_->popup_child_host_view_ = NULL;
239 } 242 }
240 aura::client::SetTooltipText(window_, NULL); 243 aura::client::SetTooltipText(window_, NULL);
244 weak_factory_.InvalidateWeakPtrs();
piman 2012/06/11 21:32:24 Do you need this? weak_factory_ will invalidate th
mmocny 2012/06/12 18:26:18 Done.
241 } 245 }
242 246
243 //////////////////////////////////////////////////////////////////////////////// 247 ////////////////////////////////////////////////////////////////////////////////
244 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 248 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
245 249
246 void RenderWidgetHostViewAura::InitAsChild( 250 void RenderWidgetHostViewAura::InitAsChild(
247 gfx::NativeView parent_view) { 251 gfx::NativeView parent_view) {
248 window_->Init(ui::LAYER_TEXTURED); 252 window_->Init(ui::LAYER_TEXTURED);
249 window_->SetName("RenderWidgetHostViewAura"); 253 window_->SetName("RenderWidgetHostViewAura");
250 window_->layer()->set_scale_content(false); 254 window_->layer()->set_scale_content(false);
(...skipping 29 matching lines...) Expand all
280 Show(); 284 Show();
281 Focus(); 285 Focus();
282 } 286 }
283 287
284 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 288 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
285 return host_; 289 return host_;
286 } 290 }
287 291
288 void RenderWidgetHostViewAura::DidBecomeSelected() { 292 void RenderWidgetHostViewAura::DidBecomeSelected() {
289 host_->WasRestored(); 293 host_->WasRestored();
294
295 if (!current_surface_ && host_->is_accelerated_compositing_active() &&
296 !released_front_lock_.get())
297 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock();
298
299 if (CommandLine::ForCurrentProcess()->HasSwitch(
300 switches::kEnableUIReleaseFrontSurface)) {
piman 2012/06/11 21:32:24 Rather than parsing the command line every time th
mmocny 2012/06/12 18:26:18 Done, using static bool inside anon namespace help
301 SendSurfaceIsProtectedBasedOnVisibilityWhenReady();
302 // Reset this here in case there is an outstanding callback to remove
303 // frontbuffer protection. This protects against ABA issues.
304 on_thumbnailing_ended_callback_.Reset();
305 }
290 } 306 }
291 307
292 void RenderWidgetHostViewAura::WasHidden() { 308 void RenderWidgetHostViewAura::WasHidden() {
293 host_->WasHidden(); 309 host_->WasHidden();
310
311 released_front_lock_ = NULL;
312
313 if (CommandLine::ForCurrentProcess()->HasSwitch(
314 switches::kEnableUIReleaseFrontSurface)) {
315 current_surface_ = 0;
316 UpdateExternalTexture();
317 SendSurfaceIsProtectedBasedOnVisibilityWhenReady();
318 }
294 } 319 }
295 320
296 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 321 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
297 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 322 SetBounds(gfx::Rect(window_->bounds().origin(), size));
298 } 323 }
299 324
300 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 325 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
301 if (window_->bounds().size() != rect.size() && 326 if (window_->bounds().size() != rect.size() &&
302 host_->is_accelerated_compositing_active()) { 327 host_->is_accelerated_compositing_active()) {
303 resize_locks_.push_back(make_linked_ptr( 328 resize_locks_.push_back(make_linked_ptr(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( 471 BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
447 const gfx::Size& size) { 472 const gfx::Size& size) {
448 return new BackingStoreSkia(host_, size); 473 return new BackingStoreSkia(host_, size);
449 } 474 }
450 475
451 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 476 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
452 const gfx::Size& size, 477 const gfx::Size& size,
453 skia::PlatformCanvas* output, 478 skia::PlatformCanvas* output,
454 base::Callback<void(bool)> callback) { 479 base::Callback<void(bool)> callback) {
455 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); 480 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false));
481
456 ui::Compositor* compositor = GetCompositor(); 482 ui::Compositor* compositor = GetCompositor();
457 if (!compositor) 483 if (!compositor)
458 return; 484 return;
459 485
460 std::map<uint64, scoped_refptr<ImageTransportClient> >::iterator it = 486 std::map<uint64, scoped_refptr<ImageTransportClient> >::iterator it =
461 image_transport_clients_.find(current_surface_); 487 image_transport_clients_.find(current_surface_);
462 if (it == image_transport_clients_.end()) 488 if (it == image_transport_clients_.end())
463 return; 489 return;
464 490
465 ImageTransportClient* container = it->second; 491 ImageTransportClient* container = it->second;
466 DCHECK(container); 492 DCHECK(container);
467 493
468 gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size); 494 gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size);
469 if (!output->initialize( 495 if (!output->initialize(
470 size_in_pixel.width(), size_in_pixel.height(), true)) 496 size_in_pixel.width(), size_in_pixel.height(), true))
471 return; 497 return;
472 498
473 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 499 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
474 content::GLHelper* gl_helper = factory->GetGLHelper(compositor); 500 content::GLHelper* gl_helper = factory->GetGLHelper(compositor);
475 if (!gl_helper) 501 if (!gl_helper)
476 return; 502 return;
477 503
478 unsigned char* addr = static_cast<unsigned char*>( 504 unsigned char* addr = static_cast<unsigned char*>(
479 output->getTopDevice()->accessBitmap(true).getPixels()); 505 output->getTopDevice()->accessBitmap(true).getPixels());
480 scoped_callback_runner.Release(); 506 scoped_callback_runner.Release();
507 // on_thumbnailing_ended_callback_ is not set up to handle multiple concurrent
508 // thumbnail requests, nor would doing that be a good idea. Could early exit
509 // instead of DCHECK if this is not already handled by thumbnailer generater.
510 DCHECK(!is_thumbnailing_);
piman 2012/06/11 21:32:24 Please check with mazda that this is ensured. That
mmocny 2012/06/12 18:26:18 Had a talk with @mazda. It is not correct to igno
511 is_thumbnailing_ = true;
512 // Wrap the callback with an internal handler so that we can inject our
513 // own completion handlers. Used to delay informing gpu process that it can
514 // discard frontbuffer until after we finish thumbnailing.
515 base::Callback<void(bool)> wrapper_callback = base::Bind(
516 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished,
517 weak_factory_.GetWeakPtr(),
518 callback);
481 gl_helper->CopyTextureTo(container->texture_id(), 519 gl_helper->CopyTextureTo(container->texture_id(),
482 container->size(), 520 container->size(),
483 size_in_pixel, 521 size_in_pixel,
484 addr, 522 addr,
485 callback); 523 wrapper_callback);
524 }
525
526 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished(
527 base::Callback<void(bool)> callback, bool result) {
528 is_thumbnailing_ = false;
529 if(!on_thumbnailing_ended_callback_.is_null())
530 on_thumbnailing_ended_callback_.Run();
531 callback.Run(result);
486 } 532 }
487 533
488 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { 534 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
489 // Delay UpdateExternalTexture until we actually got a software frame. 535 // Delay UpdateExternalTexture until we actually got a software frame.
490 // Sometimes (e.g. on a page load) the renderer will spuriously disable then 536 // Sometimes (e.g. on a page load) the renderer will spuriously disable then
491 // re-enable accelerated compositing, causing us to flash. 537 // re-enable accelerated compositing, causing us to flash.
492 // TODO(piman): factor the enable/disable accelerated compositing message into 538 // TODO(piman): factor the enable/disable accelerated compositing message into
493 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have 539 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
494 // fewer inconsistent temporary states. 540 // fewer inconsistent temporary states.
495 needs_update_texture_ = true; 541 needs_update_texture_ = true;
496 } 542 }
497 543
498 void RenderWidgetHostViewAura::UpdateExternalTexture() { 544 void RenderWidgetHostViewAura::UpdateExternalTexture() {
499 needs_update_texture_ = false; 545 needs_update_texture_ = false;
500 if (current_surface_ != 0 && 546 if (current_surface_ != 0 &&
501 host_->is_accelerated_compositing_active()) { 547 host_->is_accelerated_compositing_active()) {
502 548 DCHECK(image_transport_clients_.find(current_surface_) !=
549 image_transport_clients_.end());
503 ImageTransportClient* container = 550 ImageTransportClient* container =
504 image_transport_clients_[current_surface_]; 551 image_transport_clients_[current_surface_];
505 if (container) 552 if (container)
506 container->Update(); 553 container->Update();
507 window_->SetExternalTexture(container); 554 window_->SetExternalTexture(container);
508 555
556 released_front_lock_ = NULL;
557
509 if (!container) { 558 if (!container) {
510 resize_locks_.clear(); 559 resize_locks_.clear();
511 } else { 560 } else {
512 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; 561 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList;
513 ResizeLockList::iterator it = resize_locks_.begin(); 562 ResizeLockList::iterator it = resize_locks_.begin();
514 while (it != resize_locks_.end()) { 563 while (it != resize_locks_.end()) {
515 gfx::Size container_size = content::ConvertSizeToDIP(this, 564 gfx::Size container_size = content::ConvertSizeToDIP(this,
516 container->size()); 565 container->size());
517 if ((*it)->expected_size() == container_size) 566 if ((*it)->expected_size() == container_size)
518 break; 567 break;
(...skipping 22 matching lines...) Expand all
541 } 590 }
542 } else { 591 } else {
543 window_->SetExternalTexture(NULL); 592 window_->SetExternalTexture(NULL);
544 resize_locks_.clear(); 593 resize_locks_.clear();
545 } 594 }
546 } 595 }
547 596
548 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 597 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
549 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 598 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
550 int gpu_host_id) { 599 int gpu_host_id) {
600 // If we are not visible then this swap is stale. We must still ACK but do not
piman 2012/06/11 21:32:24 I think there's still ABA issues. Say at some poin
mmocny 2012/06/11 21:45:09 Keen observation! I will add this. On 2012/06/11
mmocny 2012/06/12 18:26:18 Done.
601 // reset current_surface_ so that we do not try to display this surface later.
602 if (!host_->IsVisible()) {
603 DCHECK(!current_surface_);
604 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id,
605 gpu_host_id);
606 return;
607 }
551 current_surface_ = params_in_pixel.surface_handle; 608 current_surface_ = params_in_pixel.surface_handle;
609 DCHECK(current_surface_);
552 UpdateExternalTexture(); 610 UpdateExternalTexture();
553 611
554 ui::Compositor* compositor = GetCompositor(); 612 ui::Compositor* compositor = GetCompositor();
555 if (!compositor) { 613 if (!compositor) {
556 // We have no compositor, so we have no way to display the surface. 614 // We have no compositor, so we have no way to display the surface.
557 // Must still send the ACK. 615 // Must still send the ACK.
558 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id, 616 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id,
559 gpu_host_id); 617 gpu_host_id);
560 } else { 618 } else {
619 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
620 image_transport_clients_.end());
561 gfx::Size surface_size_in_pixel = 621 gfx::Size surface_size_in_pixel =
562 image_transport_clients_[params_in_pixel.surface_handle]->size(); 622 image_transport_clients_[params_in_pixel.surface_handle]->size();
563 gfx::Size surface_size = content::ConvertSizeToDIP(this, 623 gfx::Size surface_size = content::ConvertSizeToDIP(this,
564 surface_size_in_pixel); 624 surface_size_in_pixel);
565 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 625 window_->SchedulePaintInRect(gfx::Rect(surface_size));
566 626
567 if (!resize_locks_.empty() && !compositor->DrawPending()) { 627 if (!resize_locks_.empty() && !compositor->DrawPending()) {
568 // If we are waiting for the resize, fast-track the ACK. 628 // If we are waiting for the resize, fast-track the ACK.
569 // However only do so if we're not between the Draw() and the 629 // However only do so if we're not between the Draw() and the
570 // OnCompositingEnded(), because out-of-order execution in the GPU process 630 // OnCompositingEnded(), because out-of-order execution in the GPU process
571 // might corrupt the "front buffer" for the currently issued frame. 631 // might corrupt the "front buffer" for the currently issued frame.
572 RenderWidgetHostImpl::AcknowledgeSwapBuffers( 632 RenderWidgetHostImpl::AcknowledgeSwapBuffers(
573 params_in_pixel.route_id, gpu_host_id); 633 params_in_pixel.route_id, gpu_host_id);
574 } else { 634 } else {
575 // Add sending an ACK to the list of things to do OnCompositingEnded 635 // Add sending an ACK to the list of things to do OnCompositingEnded
576 on_compositing_ended_callbacks_.push_back( 636 on_compositing_ended_callbacks_.push_back(
577 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers, 637 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers,
578 params_in_pixel.route_id, gpu_host_id)); 638 params_in_pixel.route_id, gpu_host_id));
579 if (!compositor->HasObserver(this)) 639 if (!compositor->HasObserver(this))
580 compositor->AddObserver(this); 640 compositor->AddObserver(this);
581 } 641 }
582 } 642 }
583 } 643 }
584 644
585 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 645 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
586 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 646 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
587 int gpu_host_id) { 647 int gpu_host_id) {
648 // If we are not visible then this PSB is stale. We must still ACK but do not
649 // reset current_surface_ so that we do not try to display this surface later.
650 if (!host_->IsVisible()) {
651 DCHECK(!current_surface_);
652 RenderWidgetHostImpl::AcknowledgePostSubBuffer(params_in_pixel.route_id,
653 gpu_host_id);
654 return;
655 }
588 current_surface_ = params_in_pixel.surface_handle; 656 current_surface_ = params_in_pixel.surface_handle;
657 DCHECK(current_surface_);
589 UpdateExternalTexture(); 658 UpdateExternalTexture();
590 659
591 ui::Compositor* compositor = GetCompositor(); 660 ui::Compositor* compositor = GetCompositor();
592 if (!compositor) { 661 if (!compositor) {
593 // We have no compositor, so we have no way to display the surface 662 // We have no compositor, so we have no way to display the surface
594 // Must still send the ACK 663 // Must still send the ACK
595 RenderWidgetHostImpl::AcknowledgePostSubBuffer( 664 RenderWidgetHostImpl::AcknowledgePostSubBuffer(
596 params_in_pixel.route_id, gpu_host_id); 665 params_in_pixel.route_id, gpu_host_id);
597 } else { 666 } else {
667 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
668 image_transport_clients_.end());
598 gfx::Size surface_size_in_pixel = 669 gfx::Size surface_size_in_pixel =
599 image_transport_clients_[params_in_pixel.surface_handle]->size(); 670 image_transport_clients_[params_in_pixel.surface_handle]->size();
600 671
601 // Co-ordinates come in OpenGL co-ordinate space. 672 // Co-ordinates come in OpenGL co-ordinate space.
602 // We need to convert to layer space. 673 // We need to convert to layer space.
603 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect( 674 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect(
604 params_in_pixel.x, 675 params_in_pixel.x,
605 surface_size_in_pixel.height() - params_in_pixel.y - 676 surface_size_in_pixel.height() - params_in_pixel.y -
606 params_in_pixel.height, 677 params_in_pixel.height,
607 params_in_pixel.width, 678 params_in_pixel.width,
(...skipping 26 matching lines...) Expand all
634 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 705 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't
635 // matter what is returned here as GetBackingStore is the only caller of this 706 // matter what is returned here as GetBackingStore is the only caller of this
636 // method. TODO(jbates) implement this if other Aura code needs it. 707 // method. TODO(jbates) implement this if other Aura code needs it.
637 return false; 708 return false;
638 } 709 }
639 710
640 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( 711 void RenderWidgetHostViewAura::AcceleratedSurfaceNew(
641 int32 width_in_pixel, 712 int32 width_in_pixel,
642 int32 height_in_pixel, 713 int32 height_in_pixel,
643 uint64* surface_handle, 714 uint64* surface_handle,
644 TransportDIB::Handle* shm_handle) { 715 TransportDIB::Handle* shm_handle,
716 int32 route_id,
717 int gpu_host_id) {
645 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 718 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
646 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient( 719 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient(
647 gfx::Size(width_in_pixel, height_in_pixel), surface_handle)); 720 gfx::Size(width_in_pixel, height_in_pixel), surface_handle));
648 if (!surface) { 721 if (!surface) {
649 LOG(ERROR) << "Failed to create ImageTransportClient"; 722 LOG(ERROR) << "Failed to create ImageTransportClient";
650 return; 723 return;
651 } 724 }
652 *shm_handle = surface->Handle(); 725 *shm_handle = surface->Handle();
653 726
654 image_transport_clients_[*surface_handle] = surface; 727 image_transport_clients_[*surface_handle] = surface;
728
729 route_id_ = route_id;
730 gpu_host_id_ = gpu_host_id;
655 } 731 }
656 732
657 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( 733 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(
658 uint64 surface_handle) { 734 uint64 surface_handle) {
735 DCHECK(image_transport_clients_.find(surface_handle) !=
736 image_transport_clients_.end());
659 if (current_surface_ == surface_handle) { 737 if (current_surface_ == surface_handle) {
660 current_surface_ = 0; 738 current_surface_ = 0;
661 UpdateExternalTexture(); 739 UpdateExternalTexture();
662 } 740 }
663 image_transport_clients_.erase(surface_handle); 741 image_transport_clients_.erase(surface_handle);
664 } 742 }
665 743
744 void RenderWidgetHostViewAura::
745 SendSurfaceIsProtectedBasedOnVisibilityWhenReady() {
746 if (!route_id_ || !gpu_host_id_)
747 return;
748 if (host_->IsVisible()) {
749 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(true,
750 route_id_,
751 gpu_host_id_);
752 return;
753 }
754 DCHECK(!current_surface_);
755
756 ui::Compositor* compositor = GetCompositor();
757 // If we are currently compositing, schedule this function to be called again
758 // after we finish. This function must handle changes to state due to this
759 // delay.
760 // Note: There is no ABA issue because if visibility changes to true and back,
761 // we know we didn't schedule a composite during that time.
762 if (compositor->DrawPending()) {
763 on_compositing_ended_callbacks_.push_back(
764 base::Bind(&RenderWidgetHostViewAura::
765 SendSurfaceIsProtectedFalseAfterThumbnailerFinished,
766 weak_factory_.GetWeakPtr()));
767 if (!compositor->HasObserver(this))
768 compositor->AddObserver(this);
769 return;
770 }
771
772 SendSurfaceIsProtectedFalseAfterThumbnailerFinished();
773 }
774
775 void RenderWidgetHostViewAura::
776 SendSurfaceIsProtectedFalseAfterThumbnailerFinished() {
777 if (!route_id_ || !gpu_host_id_)
778 return;
779 if (host_->IsVisible())
780 return;
781 DCHECK(!current_surface_);
782 // If we are currently thumbnailing, schedule this function to be called again
783 // after we finish. This function must handle changes to state due to this
784 // delay.
785 // Note: We guard against ABA issue with visibility changes by resetting the
786 // on_thumbnailing_ended_callback_ in DidBecomeSelected.
787 if (is_thumbnailing_) {
788 on_thumbnailing_ended_callback_ =
piman 2012/06/11 21:32:24 Do you need to make this a callback? You could jus
mmocny 2012/06/11 21:45:09 Sounds great, will do. On 2012/06/11 21:32:24, pi
mmocny 2012/06/12 18:26:18 Done.
789 base::Bind(&RenderWidgetHostViewAura::
790 SendSurfaceIsProtectedFalseAfterThumbnailerFinished,
791 weak_factory_.GetWeakPtr());
792 return;
793 }
794
795 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(false,
796 route_id_,
797 gpu_host_id_);
798 }
799
666 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { 800 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) {
667 content::RenderWidgetHostViewBase::SetBackground(background); 801 content::RenderWidgetHostViewBase::SetBackground(background);
668 host_->SetBackground(background); 802 host_->SetBackground(background);
669 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); 803 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
670 } 804 }
671 805
672 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { 806 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) {
673 GetScreenInfoForWindow(results, window_); 807 GetScreenInfoForWindow(results, window_);
674 } 808 }
675 809
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 void RenderWidgetHostViewAura::OnCompositingAborted( 1330 void RenderWidgetHostViewAura::OnCompositingAborted(
1197 ui::Compositor* compositor) { 1331 ui::Compositor* compositor) {
1198 } 1332 }
1199 1333
1200 //////////////////////////////////////////////////////////////////////////////// 1334 ////////////////////////////////////////////////////////////////////////////////
1201 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 1335 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
1202 1336
1203 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { 1337 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) {
1204 image_transport_clients_.clear(); 1338 image_transport_clients_.clear();
1205 current_surface_ = 0; 1339 current_surface_ = 0;
1340 route_id_ = 0;
1341 gpu_host_id_ = 0;
1342 is_thumbnailing_ = 0;
piman 2012/06/11 21:32:24 The thumbnailing callback should be called either
mmocny 2012/06/12 18:26:18 Done.
1206 UpdateExternalTexture(); 1343 UpdateExternalTexture();
1207 locks_pending_draw_.clear(); 1344 locks_pending_draw_.clear();
1208 1345
1209 DCHECK(!shared_surface_handle_.is_null()); 1346 DCHECK(!shared_surface_handle_.is_null());
1210 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1347 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1211 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 1348 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
1212 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); 1349 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor);
1213 host_->CompositingSurfaceUpdated(); 1350 host_->CompositingSurfaceUpdated();
1214 host_->ScheduleComposite(); 1351 host_->ScheduleComposite();
1215 } 1352 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 1479 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
1343 RenderWidgetHost* widget) { 1480 RenderWidgetHost* widget) {
1344 return new RenderWidgetHostViewAura(widget); 1481 return new RenderWidgetHostViewAura(widget);
1345 } 1482 }
1346 1483
1347 // static 1484 // static
1348 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1485 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1349 WebKit::WebScreenInfo* results) { 1486 WebKit::WebScreenInfo* results) {
1350 GetScreenInfoForWindow(results, NULL); 1487 GetScreenInfoForWindow(results, NULL);
1351 } 1488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698