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

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: fixing nits 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 results->horizontalDPI = default_dpi; 126 results->horizontalDPI = default_dpi;
128 } 127 }
129 128
130 bool ShouldSendPinchGesture() { 129 bool ShouldSendPinchGesture() {
131 static bool pinch_allowed = 130 static bool pinch_allowed =
132 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) || 131 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) ||
133 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); 132 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch);
134 return pinch_allowed; 133 return pinch_allowed;
135 } 134 }
136 135
136 bool ShouldReleaseFrontSurface() {
137 static bool release_front_surface_allowed =
138 CommandLine::ForCurrentProcess()->HasSwitch(
139 switches::kEnableUIReleaseFrontSurface);
140 return release_front_surface_allowed;
141 }
142
137 } // namespace 143 } // namespace
138 144
139 // We have to implement the WindowObserver interface on a separate object 145 // We have to implement the WindowObserver interface on a separate object
140 // because clang doesn't like implementing multiple interfaces that have 146 // because clang doesn't like implementing multiple interfaces that have
141 // methods with the same name. This object is owned by the 147 // methods with the same name. This object is owned by the
142 // RenderWidgetHostViewAura. 148 // RenderWidgetHostViewAura.
143 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { 149 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
144 public: 150 public:
145 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} 151 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {}
146 virtual ~WindowObserver() {} 152 virtual ~WindowObserver() {}
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 214 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
209 in_shutdown_(false), 215 in_shutdown_(false),
210 is_fullscreen_(false), 216 is_fullscreen_(false),
211 popup_parent_host_view_(NULL), 217 popup_parent_host_view_(NULL),
212 popup_child_host_view_(NULL), 218 popup_child_host_view_(NULL),
213 is_loading_(false), 219 is_loading_(false),
214 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 220 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
215 can_compose_inline_(true), 221 can_compose_inline_(true),
216 has_composition_text_(false), 222 has_composition_text_(false),
217 current_surface_(0), 223 current_surface_(0),
224 current_surface_is_protected_(true),
225 current_surface_in_use_by_compositor_(true),
226 pending_thumbnail_tasks_(0),
227 protection_state_id_(0),
228 surface_route_id_(0),
218 paint_canvas_(NULL), 229 paint_canvas_(NULL),
219 synthetic_move_sent_(false), 230 synthetic_move_sent_(false),
220 needs_update_texture_(false) { 231 needs_update_texture_(false) {
221 host_->SetView(this); 232 host_->SetView(this);
222 window_observer_.reset(new WindowObserver(this)); 233 window_observer_.reset(new WindowObserver(this));
223 window_->AddObserver(window_observer_.get()); 234 window_->AddObserver(window_observer_.get());
224 aura::client::SetTooltipText(window_, &tooltip_); 235 aura::client::SetTooltipText(window_, &tooltip_);
225 aura::client::SetActivationDelegate(window_, this); 236 aura::client::SetActivationDelegate(window_, this);
226 } 237 }
227 238
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 window_->layer()->set_scale_content(false); 295 window_->layer()->set_scale_content(false);
285 Show(); 296 Show();
286 Focus(); 297 Focus();
287 } 298 }
288 299
289 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 300 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
290 return host_; 301 return host_;
291 } 302 }
292 303
293 void RenderWidgetHostViewAura::DidBecomeSelected() { 304 void RenderWidgetHostViewAura::DidBecomeSelected() {
305 if (host_->IsVisible())
306 return;
307
294 host_->WasRestored(); 308 host_->WasRestored();
309
295 if (!current_surface_ && host_->is_accelerated_compositing_active() && 310 if (!current_surface_ && host_->is_accelerated_compositing_active() &&
296 !released_front_lock_.get()) 311 !released_front_lock_.get())
297 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock(); 312 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock();
313
314 AdjustSurfaceProtection();
298 } 315 }
299 316
300 void RenderWidgetHostViewAura::WasHidden() { 317 void RenderWidgetHostViewAura::WasHidden() {
318 if (!host_->IsVisible())
319 return;
320
301 host_->WasHidden(); 321 host_->WasHidden();
322
302 released_front_lock_ = NULL; 323 released_front_lock_ = NULL;
324
325 if (ShouldReleaseFrontSurface()) {
326 current_surface_ = 0;
327 UpdateExternalTexture();
328 }
329
330 AdjustSurfaceProtection();
303 } 331 }
304 332
305 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 333 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
306 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 334 SetBounds(gfx::Rect(window_->bounds().origin(), size));
307 } 335 }
308 336
309 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 337 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
310 if (window_->bounds().size() != rect.size() && 338 if (window_->bounds().size() != rect.size() &&
311 host_->is_accelerated_compositing_active()) { 339 host_->is_accelerated_compositing_active()) {
312 resize_locks_.push_back(make_linked_ptr( 340 resize_locks_.push_back(make_linked_ptr(
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 return; 514 return;
487 515
488 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 516 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
489 content::GLHelper* gl_helper = factory->GetGLHelper(compositor); 517 content::GLHelper* gl_helper = factory->GetGLHelper(compositor);
490 if (!gl_helper) 518 if (!gl_helper)
491 return; 519 return;
492 520
493 unsigned char* addr = static_cast<unsigned char*>( 521 unsigned char* addr = static_cast<unsigned char*>(
494 output->getTopDevice()->accessBitmap(true).getPixels()); 522 output->getTopDevice()->accessBitmap(true).getPixels());
495 scoped_callback_runner.Release(); 523 scoped_callback_runner.Release();
524 // Wrap the callback with an internal handler so that we can inject our
525 // own completion handlers (where we can call AdjustSurfaceProtection).
526 base::Callback<void(bool)> wrapper_callback = base::Bind(
527 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished,
528 AsWeakPtr(),
529 callback);
530 ++pending_thumbnail_tasks_;
sky 2012/06/13 16:21:23 Why does this need to be delayed, and why do you n
mmocny 2012/06/13 18:40:05 The browser thumbnailer will call this multiple ti
496 gl_helper->CopyTextureTo(container->texture_id(), 531 gl_helper->CopyTextureTo(container->texture_id(),
497 container->size(), 532 container->size(),
498 size_in_pixel, 533 size_in_pixel,
499 addr, 534 addr,
500 callback); 535 wrapper_callback);
536 }
537
538 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished(
sky 2012/06/13 16:21:23 Position should match that of header.
mmocny 2012/06/13 18:40:05 Done.
539 base::Callback<void(bool)> callback, bool result) {
540 --pending_thumbnail_tasks_;
541 AdjustSurfaceProtection();
542 callback.Run(result);
501 } 543 }
502 544
503 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { 545 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
504 // Delay UpdateExternalTexture until we actually got a software frame. 546 // Delay UpdateExternalTexture until we actually got a software frame.
505 // Sometimes (e.g. on a page load) the renderer will spuriously disable then 547 // Sometimes (e.g. on a page load) the renderer will spuriously disable then
506 // re-enable accelerated compositing, causing us to flash. 548 // re-enable accelerated compositing, causing us to flash.
507 // TODO(piman): factor the enable/disable accelerated compositing message into 549 // TODO(piman): factor the enable/disable accelerated compositing message into
508 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have 550 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
509 // fewer inconsistent temporary states. 551 // fewer inconsistent temporary states.
510 needs_update_texture_ = true; 552 needs_update_texture_ = true;
511 } 553 }
512 554
513 void RenderWidgetHostViewAura::UpdateExternalTexture() { 555 void RenderWidgetHostViewAura::UpdateExternalTexture() {
514 needs_update_texture_ = false; 556 needs_update_texture_ = false;
515 if (current_surface_ != 0 && 557 if (current_surface_ != 0 &&
516 host_->is_accelerated_compositing_active()) { 558 host_->is_accelerated_compositing_active()) {
517 559 DCHECK(image_transport_clients_.find(current_surface_) !=
sky 2012/06/13 16:21:23 DCHECK_NE
mmocny 2012/06/13 18:40:05 DCHECK_NE seems to cause compile failure when valu
560 image_transport_clients_.end());
518 ImageTransportClient* container = 561 ImageTransportClient* container =
519 image_transport_clients_[current_surface_]; 562 image_transport_clients_[current_surface_];
520 if (container) 563 if (container)
521 container->Update(); 564 container->Update();
522 window_->SetExternalTexture(container); 565 window_->SetExternalTexture(container);
523 566 current_surface_in_use_by_compositor_ = true;
524 released_front_lock_ = NULL;
525 567
526 if (!container) { 568 if (!container) {
527 resize_locks_.clear(); 569 resize_locks_.clear();
528 } else { 570 } else {
529 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; 571 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList;
530 ResizeLockList::iterator it = resize_locks_.begin(); 572 ResizeLockList::iterator it = resize_locks_.begin();
531 while (it != resize_locks_.end()) { 573 while (it != resize_locks_.end()) {
532 gfx::Size container_size = content::ConvertSizeToDIP(this, 574 gfx::Size container_size = content::ConvertSizeToDIP(this,
533 container->size()); 575 container->size());
534 if ((*it)->expected_size() == container_size) 576 if ((*it)->expected_size() == container_size)
(...skipping 16 matching lines...) Expand all
551 it2->get()->UnlockCompositor(); 593 it2->get()->UnlockCompositor();
552 } 594 }
553 if (!compositor->HasObserver(this)) 595 if (!compositor->HasObserver(this))
554 compositor->AddObserver(this); 596 compositor->AddObserver(this);
555 } 597 }
556 resize_locks_.erase(resize_locks_.begin(), it); 598 resize_locks_.erase(resize_locks_.begin(), it);
557 } 599 }
558 } 600 }
559 } else { 601 } else {
560 window_->SetExternalTexture(NULL); 602 window_->SetExternalTexture(NULL);
603 ui::Compositor* compositor = GetCompositor();
604 if (!compositor->DrawPending()) {
605 current_surface_in_use_by_compositor_ = false;
606 AdjustSurfaceProtection();
607 } else {
608 on_compositing_ended_callbacks_.push_back(
609 base::Bind(&RenderWidgetHostViewAura::
610 SetSurfaceNotInUseByCompositor,
611 AsWeakPtr()));
612 if (!compositor->HasObserver(this))
613 compositor->AddObserver(this);
614 }
561 resize_locks_.clear(); 615 resize_locks_.clear();
562 } 616 }
563 } 617 }
564 618
565 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 619 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
566 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 620 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
567 int gpu_host_id) { 621 int gpu_host_id) {
622 // If protection state changed, then this swap is stale. We must still ACK but
623 // do not update current_surface_ since it may have been discarded.
624 if (params_in_pixel.protection_state_id &&
625 params_in_pixel.protection_state_id != protection_state_id_) {
626 DCHECK(!current_surface_);
627 if (params_in_pixel.require_ack) {
628 RenderWidgetHostImpl::AcknowledgeSwapBuffers(
629 params_in_pixel.route_id, gpu_host_id);
630 }
631 return;
632 }
568 current_surface_ = params_in_pixel.surface_handle; 633 current_surface_ = params_in_pixel.surface_handle;
634 // If we don't require an ACK that means the content is not a fresh updated
635 // new frame, rather we are just resetting our handle to some old content that
636 // we still hadn't discarded. Although we could display immediately, by not
637 // resetting the compositor lock here, we give us some time to get a fresh
638 // frame which means fewer content flashes.
639 if (params_in_pixel.require_ack)
640 released_front_lock_ = NULL;
641
642 DCHECK(current_surface_);
569 UpdateExternalTexture(); 643 UpdateExternalTexture();
570 644
571 ui::Compositor* compositor = GetCompositor(); 645 ui::Compositor* compositor = GetCompositor();
572 if (!compositor) { 646 if (!compositor) {
573 // We have no compositor, so we have no way to display the surface. 647 // We have no compositor, so we have no way to display the surface.
574 // Must still send the ACK. 648 // Must still send the ACK.
575 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id, 649 if (params_in_pixel.require_ack) {
576 gpu_host_id); 650 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id,
651 gpu_host_id);
652 }
577 } else { 653 } else {
654 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
655 image_transport_clients_.end());
578 gfx::Size surface_size_in_pixel = 656 gfx::Size surface_size_in_pixel =
579 image_transport_clients_[params_in_pixel.surface_handle]->size(); 657 image_transport_clients_[params_in_pixel.surface_handle]->size();
580 gfx::Size surface_size = content::ConvertSizeToDIP(this, 658 gfx::Size surface_size = content::ConvertSizeToDIP(this,
581 surface_size_in_pixel); 659 surface_size_in_pixel);
582 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 660 window_->SchedulePaintInRect(gfx::Rect(surface_size));
583 661
584 if (!resize_locks_.empty() && !compositor->DrawPending()) { 662 if (params_in_pixel.require_ack) {
585 // If we are waiting for the resize, fast-track the ACK. 663 if (!resize_locks_.empty() && !compositor->DrawPending()) {
586 // However only do so if we're not between the Draw() and the 664 // If we are waiting for the resize, fast-track the ACK.
587 // OnCompositingEnded(), because out-of-order execution in the GPU process 665 // However only do so if we're not between the Draw() and the
588 // might corrupt the "front buffer" for the currently issued frame. 666 // OnCompositingEnded(), because out-of-order execution in the GPU
589 RenderWidgetHostImpl::AcknowledgeSwapBuffers( 667 // process might corrupt the "front buffer" for the currently issued
590 params_in_pixel.route_id, gpu_host_id); 668 // frame.
591 } else { 669 RenderWidgetHostImpl::AcknowledgeSwapBuffers(
592 // Add sending an ACK to the list of things to do OnCompositingEnded 670 params_in_pixel.route_id, gpu_host_id);
593 on_compositing_ended_callbacks_.push_back( 671 } else {
594 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers, 672 // Add sending an ACK to the list of things to do OnCompositingEnded
595 params_in_pixel.route_id, gpu_host_id)); 673 on_compositing_ended_callbacks_.push_back(
596 if (!compositor->HasObserver(this)) 674 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers,
597 compositor->AddObserver(this); 675 params_in_pixel.route_id, gpu_host_id));
676 if (!compositor->HasObserver(this))
677 compositor->AddObserver(this);
678 }
598 } 679 }
599 } 680 }
600 } 681 }
601 682
602 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 683 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
603 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 684 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
604 int gpu_host_id) { 685 int gpu_host_id) {
686 // If visible state changed, then this PSB is stale. We must still ACK but
687 // do not update current_surface_.
688 if (params_in_pixel.protection_state_id &&
689 params_in_pixel.protection_state_id != protection_state_id_) {
690 DCHECK(!current_surface_);
691 RenderWidgetHostImpl::AcknowledgePostSubBuffer(params_in_pixel.route_id,
692 gpu_host_id);
693 return;
694 }
605 current_surface_ = params_in_pixel.surface_handle; 695 current_surface_ = params_in_pixel.surface_handle;
696 released_front_lock_ = NULL;
697 DCHECK(current_surface_);
606 UpdateExternalTexture(); 698 UpdateExternalTexture();
607 699
608 ui::Compositor* compositor = GetCompositor(); 700 ui::Compositor* compositor = GetCompositor();
609 if (!compositor) { 701 if (!compositor) {
610 // We have no compositor, so we have no way to display the surface 702 // We have no compositor, so we have no way to display the surface
611 // Must still send the ACK 703 // Must still send the ACK
612 RenderWidgetHostImpl::AcknowledgePostSubBuffer( 704 RenderWidgetHostImpl::AcknowledgePostSubBuffer(
613 params_in_pixel.route_id, gpu_host_id); 705 params_in_pixel.route_id, gpu_host_id);
614 } else { 706 } else {
707 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
708 image_transport_clients_.end());
615 gfx::Size surface_size_in_pixel = 709 gfx::Size surface_size_in_pixel =
616 image_transport_clients_[params_in_pixel.surface_handle]->size(); 710 image_transport_clients_[params_in_pixel.surface_handle]->size();
617 711
618 // Co-ordinates come in OpenGL co-ordinate space. 712 // Co-ordinates come in OpenGL co-ordinate space.
619 // We need to convert to layer space. 713 // We need to convert to layer space.
620 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect( 714 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect(
621 params_in_pixel.x, 715 params_in_pixel.x,
622 surface_size_in_pixel.height() - params_in_pixel.y - 716 surface_size_in_pixel.height() - params_in_pixel.y -
623 params_in_pixel.height, 717 params_in_pixel.height,
624 params_in_pixel.width, 718 params_in_pixel.width,
(...skipping 26 matching lines...) Expand all
651 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 745 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't
652 // matter what is returned here as GetBackingStore is the only caller of this 746 // matter what is returned here as GetBackingStore is the only caller of this
653 // method. TODO(jbates) implement this if other Aura code needs it. 747 // method. TODO(jbates) implement this if other Aura code needs it.
654 return false; 748 return false;
655 } 749 }
656 750
657 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( 751 void RenderWidgetHostViewAura::AcceleratedSurfaceNew(
658 int32 width_in_pixel, 752 int32 width_in_pixel,
659 int32 height_in_pixel, 753 int32 height_in_pixel,
660 uint64* surface_handle, 754 uint64* surface_handle,
661 TransportDIB::Handle* shm_handle) { 755 TransportDIB::Handle* shm_handle,
756 int32 route_id) {
662 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 757 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
663 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient( 758 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient(
664 gfx::Size(width_in_pixel, height_in_pixel), surface_handle)); 759 gfx::Size(width_in_pixel, height_in_pixel), surface_handle));
665 if (!surface) { 760 if (!surface) {
666 LOG(ERROR) << "Failed to create ImageTransportClient"; 761 LOG(ERROR) << "Failed to create ImageTransportClient";
667 return; 762 return;
668 } 763 }
669 *shm_handle = surface->Handle(); 764 *shm_handle = surface->Handle();
670 765
671 image_transport_clients_[*surface_handle] = surface; 766 image_transport_clients_[*surface_handle] = surface;
767
768 surface_route_id_ = route_id;
672 } 769 }
673 770
674 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( 771 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(
675 uint64 surface_handle) { 772 uint64 surface_handle) {
773 DCHECK(image_transport_clients_.find(surface_handle) !=
774 image_transport_clients_.end());
676 if (current_surface_ == surface_handle) { 775 if (current_surface_ == surface_handle) {
677 current_surface_ = 0; 776 current_surface_ = 0;
678 UpdateExternalTexture(); 777 UpdateExternalTexture();
679 } 778 }
680 image_transport_clients_.erase(surface_handle); 779 image_transport_clients_.erase(surface_handle);
681 } 780 }
682 781
782 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor() {
783 if (current_surface_ || host_->IsVisible())
784 return;
785 current_surface_in_use_by_compositor_ = false;
786 AdjustSurfaceProtection();
787 }
788
789 void RenderWidgetHostViewAura::AdjustSurfaceProtection() {
790 // If the current surface is non null, it is protected.
791 // If we are visible, it is protected.
792 // If we are not visible and current surface is null, still stay protected
793 // until we finish thumbnailing and compositing.
794 bool surface_is_protected =
795 current_surface_ ||
796 host_->IsVisible() ||
797 (current_surface_is_protected_ &&
798 (pending_thumbnail_tasks_ || current_surface_in_use_by_compositor_));
799 if (current_surface_is_protected_ == surface_is_protected)
800 return;
801 current_surface_is_protected_ = surface_is_protected;
802 ++protection_state_id_;
803
804 if (!surface_route_id_ || !shared_surface_handle_.parent_gpu_process_id)
805 return;
806
807 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(
808 surface_is_protected,
809 protection_state_id_,
810 surface_route_id_,
811 shared_surface_handle_.parent_gpu_process_id);
812 }
813
683 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { 814 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) {
684 content::RenderWidgetHostViewBase::SetBackground(background); 815 content::RenderWidgetHostViewBase::SetBackground(background);
685 host_->SetBackground(background); 816 host_->SetBackground(background);
686 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); 817 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
687 } 818 }
688 819
689 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { 820 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) {
690 GetScreenInfoForWindow(results, window_); 821 GetScreenInfoForWindow(results, window_);
691 } 822 }
692 823
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 void RenderWidgetHostViewAura::OnCompositingAborted( 1342 void RenderWidgetHostViewAura::OnCompositingAborted(
1212 ui::Compositor* compositor) { 1343 ui::Compositor* compositor) {
1213 } 1344 }
1214 1345
1215 //////////////////////////////////////////////////////////////////////////////// 1346 ////////////////////////////////////////////////////////////////////////////////
1216 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 1347 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
1217 1348
1218 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { 1349 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) {
1219 image_transport_clients_.clear(); 1350 image_transport_clients_.clear();
1220 current_surface_ = 0; 1351 current_surface_ = 0;
1352 protection_state_id_ = 0;
1353 current_surface_is_protected_ = true;
1354 current_surface_in_use_by_compositor_ = true;
1355 surface_route_id_ = 0;
1221 UpdateExternalTexture(); 1356 UpdateExternalTexture();
1222 locks_pending_draw_.clear(); 1357 locks_pending_draw_.clear();
1223 1358
1224 DCHECK(!shared_surface_handle_.is_null()); 1359 DCHECK(!shared_surface_handle_.is_null());
1225 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1360 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1226 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 1361 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
1227 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); 1362 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor);
1228 host_->CompositingSurfaceUpdated(); 1363 host_->CompositingSurfaceUpdated();
1229 host_->ScheduleComposite(); 1364 host_->ScheduleComposite();
1230 } 1365 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 1501 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
1367 RenderWidgetHost* widget) { 1502 RenderWidgetHost* widget) {
1368 return new RenderWidgetHostViewAura(widget); 1503 return new RenderWidgetHostViewAura(widget);
1369 } 1504 }
1370 1505
1371 // static 1506 // static
1372 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1507 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1373 WebKit::WebScreenInfo* results) { 1508 WebKit::WebScreenInfo* results) {
1374 GetScreenInfoForWindow(results, NULL); 1509 GetScreenInfoForWindow(results, NULL);
1375 } 1510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698