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

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: Storing the list of thumbnail callbacks, so that we can issue them upon RWHVA destruction. Created 8 years, 5 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_aura.h" 14 #include "content/browser/renderer_host/backing_store_aura.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/render_view_host_delegate.h" 16 #include "content/browser/renderer_host/render_view_host_delegate.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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 results->horizontalDPI = default_dpi; 125 results->horizontalDPI = default_dpi;
127 } 126 }
128 127
129 bool ShouldSendPinchGesture() { 128 bool ShouldSendPinchGesture() {
130 static bool pinch_allowed = 129 static bool pinch_allowed =
131 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) || 130 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) ||
132 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); 131 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch);
133 return pinch_allowed; 132 return pinch_allowed;
134 } 133 }
135 134
135 bool ShouldReleaseFrontSurface() {
136 static bool release_front_surface_allowed =
137 CommandLine::ForCurrentProcess()->HasSwitch(
138 switches::kEnableUIReleaseFrontSurface);
139 return release_front_surface_allowed;
140 }
141
136 } // namespace 142 } // namespace
137 143
138 // We have to implement the WindowObserver interface on a separate object 144 // We have to implement the WindowObserver interface on a separate object
139 // because clang doesn't like implementing multiple interfaces that have 145 // because clang doesn't like implementing multiple interfaces that have
140 // methods with the same name. This object is owned by the 146 // methods with the same name. This object is owned by the
141 // RenderWidgetHostViewAura. 147 // RenderWidgetHostViewAura.
142 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { 148 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
143 public: 149 public:
144 explicit WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} 150 explicit WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {}
145 virtual ~WindowObserver() {} 151 virtual ~WindowObserver() {}
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 213 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
208 in_shutdown_(false), 214 in_shutdown_(false),
209 is_fullscreen_(false), 215 is_fullscreen_(false),
210 popup_parent_host_view_(NULL), 216 popup_parent_host_view_(NULL),
211 popup_child_host_view_(NULL), 217 popup_child_host_view_(NULL),
212 is_loading_(false), 218 is_loading_(false),
213 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 219 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
214 can_compose_inline_(true), 220 can_compose_inline_(true),
215 has_composition_text_(false), 221 has_composition_text_(false),
216 current_surface_(0), 222 current_surface_(0),
223 current_surface_is_protected_(true),
224 current_surface_in_use_by_compositor_(true),
225 protection_state_id_(0),
226 surface_route_id_(0),
217 paint_canvas_(NULL), 227 paint_canvas_(NULL),
218 synthetic_move_sent_(false), 228 synthetic_move_sent_(false),
219 accelerated_compositing_state_changed_(false) { 229 accelerated_compositing_state_changed_(false) {
220 host_->SetView(this); 230 host_->SetView(this);
221 window_observer_.reset(new WindowObserver(this)); 231 window_observer_.reset(new WindowObserver(this));
222 window_->AddObserver(window_observer_.get()); 232 window_->AddObserver(window_observer_.get());
223 aura::client::SetTooltipText(window_, &tooltip_); 233 aura::client::SetTooltipText(window_, &tooltip_);
224 aura::client::SetActivationDelegate(window_, this); 234 aura::client::SetActivationDelegate(window_, this);
225 } 235 }
226 236
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 window_->SetParent(NULL); 268 window_->SetParent(NULL);
259 Show(); 269 Show();
260 Focus(); 270 Focus();
261 } 271 }
262 272
263 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 273 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
264 return host_; 274 return host_;
265 } 275 }
266 276
267 void RenderWidgetHostViewAura::WasRestored() { 277 void RenderWidgetHostViewAura::WasRestored() {
278 if (!host_->IsHidden())
279 return;
268 host_->WasRestored(); 280 host_->WasRestored();
281
269 if (!current_surface_ && host_->is_accelerated_compositing_active() && 282 if (!current_surface_ && host_->is_accelerated_compositing_active() &&
270 !released_front_lock_.get()) 283 !released_front_lock_.get()) {
271 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock(); 284 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock();
285 }
286
287 AdjustSurfaceProtection();
272 } 288 }
273 289
274 void RenderWidgetHostViewAura::WasHidden() { 290 void RenderWidgetHostViewAura::WasHidden() {
291 if (host_->IsHidden())
292 return;
275 host_->WasHidden(); 293 host_->WasHidden();
294
276 released_front_lock_ = NULL; 295 released_front_lock_ = NULL;
296
297 if (ShouldReleaseFrontSurface() &&
298 host_->is_accelerated_compositing_active()) {
299 current_surface_ = 0;
300 UpdateExternalTexture();
301 }
302
303 AdjustSurfaceProtection();
277 } 304 }
278 305
279 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 306 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
280 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 307 SetBounds(gfx::Rect(window_->bounds().origin(), size));
281 } 308 }
282 309
283 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 310 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
284 if (window_->bounds().size() != rect.size() && 311 if (window_->bounds().size() != rect.size() &&
285 host_->is_accelerated_compositing_active()) { 312 host_->is_accelerated_compositing_active()) {
286 resize_locks_.push_back(make_linked_ptr( 313 resize_locks_.push_back(make_linked_ptr(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 return; 496 return;
470 497
471 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 498 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
472 GLHelper* gl_helper = factory->GetGLHelper(compositor); 499 GLHelper* gl_helper = factory->GetGLHelper(compositor);
473 if (!gl_helper) 500 if (!gl_helper)
474 return; 501 return;
475 502
476 unsigned char* addr = static_cast<unsigned char*>( 503 unsigned char* addr = static_cast<unsigned char*>(
477 output->getTopDevice()->accessBitmap(true).getPixels()); 504 output->getTopDevice()->accessBitmap(true).getPixels());
478 scoped_callback_runner.Release(); 505 scoped_callback_runner.Release();
506 // Wrap the callback with an internal handler so that we can inject our
507 // own completion handlers (where we can call AdjustSurfaceProtection).
508 base::Callback<void(bool)> wrapper_callback = base::Bind(
509 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished,
510 AsWeakPtr(),
511 callback);
512 pending_thumbnail_tasks_.push_back(callback);
479 gfx::Rect src_subrect_in_pixel = ConvertRectToPixel(this, src_subrect); 513 gfx::Rect src_subrect_in_pixel = ConvertRectToPixel(this, src_subrect);
480 gl_helper->CopyTextureTo(container->texture_id(), 514 gl_helper->CopyTextureTo(container->texture_id(),
481 container->size(), 515 container->size(),
482 src_subrect_in_pixel, 516 src_subrect_in_pixel,
483 dst_size_in_pixel, 517 dst_size_in_pixel,
484 addr, 518 addr,
485 callback); 519 wrapper_callback);
486 } 520 }
487 521
488 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { 522 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
489 // Delay processing the state change until we either get a software frame if 523 // Delay processing the state change until we either get a software frame if
490 // switching to software mode or receive a buffers swapped notification 524 // switching to software mode or receive a buffers swapped notification
491 // if switching to accelerated mode. 525 // if switching to accelerated mode.
492 // Sometimes (e.g. on a page load) the renderer will spuriously disable then 526 // Sometimes (e.g. on a page load) the renderer will spuriously disable then
493 // re-enable accelerated compositing, causing us to flash. 527 // re-enable accelerated compositing, causing us to flash.
494 // TODO(piman): factor the enable/disable accelerated compositing message into 528 // TODO(piman): factor the enable/disable accelerated compositing message into
495 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have 529 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
(...skipping 10 matching lines...) Expand all
506 // care of it. 540 // care of it.
507 window_->layer()->set_scale_content( 541 window_->layer()->set_scale_content(
508 !host_->is_accelerated_compositing_active()); 542 !host_->is_accelerated_compositing_active());
509 543
510 accelerated_compositing_state_changed_ = false; 544 accelerated_compositing_state_changed_ = false;
511 } 545 }
512 546
513 if (current_surface_ != 0 && host_->is_accelerated_compositing_active()) { 547 if (current_surface_ != 0 && host_->is_accelerated_compositing_active()) {
514 ui::Texture* container = image_transport_clients_[current_surface_]; 548 ui::Texture* container = image_transport_clients_[current_surface_];
515 window_->SetExternalTexture(container); 549 window_->SetExternalTexture(container);
516 550 current_surface_in_use_by_compositor_ = true;
517 released_front_lock_ = NULL;
518 551
519 if (!container) { 552 if (!container) {
520 resize_locks_.clear(); 553 resize_locks_.clear();
521 } else { 554 } else {
522 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; 555 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList;
523 ResizeLockList::iterator it = resize_locks_.begin(); 556 ResizeLockList::iterator it = resize_locks_.begin();
524 while (it != resize_locks_.end()) { 557 while (it != resize_locks_.end()) {
525 gfx::Size container_size = ConvertSizeToDIP(this, 558 gfx::Size container_size = ConvertSizeToDIP(this,
526 container->size()); 559 container->size());
527 if ((*it)->expected_size() == container_size) 560 if ((*it)->expected_size() == container_size)
(...skipping 16 matching lines...) Expand all
544 it2->get()->UnlockCompositor(); 577 it2->get()->UnlockCompositor();
545 } 578 }
546 if (!compositor->HasObserver(this)) 579 if (!compositor->HasObserver(this))
547 compositor->AddObserver(this); 580 compositor->AddObserver(this);
548 } 581 }
549 resize_locks_.erase(resize_locks_.begin(), it); 582 resize_locks_.erase(resize_locks_.begin(), it);
550 } 583 }
551 } 584 }
552 } else { 585 } else {
553 window_->SetExternalTexture(NULL); 586 window_->SetExternalTexture(NULL);
587 if (ShouldReleaseFrontSurface() &&
588 host_->is_accelerated_compositing_active()) {
589 // The current surface may have pipelined gl commands, so always wait for
590 // the next composite to start. If the current surface is still null,
591 // then we really know its no longer in use.
592 ui::Compositor* compositor = GetCompositor();
593 if (compositor) {
594 on_compositing_will_start_callbacks_.push_back(
595 base::Bind(&RenderWidgetHostViewAura::
596 SetSurfaceNotInUseByCompositor,
597 AsWeakPtr()));
598 if (!compositor->HasObserver(this))
599 compositor->AddObserver(this);
600 }
601 }
554 resize_locks_.clear(); 602 resize_locks_.clear();
555 } 603 }
556 } 604 }
557 605
558 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 606 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
559 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 607 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
560 int gpu_host_id) { 608 int gpu_host_id) {
609 surface_route_id_ = params_in_pixel.route_id;
610 // If protection state changed, then this swap is stale. We must still ACK but
611 // do not update current_surface_ since it may have been discarded.
612 if (host_->IsHidden() ||
613 (params_in_pixel.protection_state_id &&
614 params_in_pixel.protection_state_id != protection_state_id_)) {
615 DCHECK(!current_surface_);
616 if (!params_in_pixel.skip_ack)
617 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL);
618 return;
619 }
561 current_surface_ = params_in_pixel.surface_handle; 620 current_surface_ = params_in_pixel.surface_handle;
621 // If we don't require an ACK that means the content is not a fresh updated
622 // new frame, rather we are just resetting our handle to some old content that
623 // we still hadn't discarded. Although we could display immediately, by not
624 // resetting the compositor lock here, we give us some time to get a fresh
625 // frame which means fewer content flashes.
626 if (!params_in_pixel.skip_ack)
627 released_front_lock_ = NULL;
628
562 UpdateExternalTexture(); 629 UpdateExternalTexture();
563 630
564 ui::Compositor* compositor = GetCompositor(); 631 ui::Compositor* compositor = GetCompositor();
565 if (!compositor) { 632 if (!compositor) {
566 // We have no compositor, so we have no way to display the surface. 633 // We have no compositor, so we have no way to display the surface.
567 // Must still send the ACK. 634 // Must still send the ACK.
568 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); 635 if (!params_in_pixel.skip_ack)
636 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL);
569 } else { 637 } else {
638 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
639 image_transport_clients_.end());
570 gfx::Size surface_size_in_pixel = 640 gfx::Size surface_size_in_pixel =
571 image_transport_clients_[params_in_pixel.surface_handle]->size(); 641 image_transport_clients_[params_in_pixel.surface_handle]->size();
572 gfx::Size surface_size = ConvertSizeToDIP(this, 642 gfx::Size surface_size = ConvertSizeToDIP(this,
573 surface_size_in_pixel); 643 surface_size_in_pixel);
574 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 644 window_->SchedulePaintInRect(gfx::Rect(surface_size));
575 645
576 if (!resize_locks_.empty()) { 646 if (!params_in_pixel.skip_ack) {
577 // If we are waiting for the resize, fast-track the ACK. 647 if (!resize_locks_.empty()) {
578 if (compositor->IsThreaded()) { 648 // If we are waiting for the resize, fast-track the ACK.
579 // We need the compositor thread to pick up the active buffer before 649 if (compositor->IsThreaded()) {
580 // ACKing. 650 // We need the compositor thread to pick up the active buffer before
581 on_compositing_did_commit_callbacks_.push_back( 651 // ACKing.
652 on_compositing_did_commit_callbacks_.push_back(
653 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK,
654 params_in_pixel.route_id,
655 gpu_host_id));
656 if (!compositor->HasObserver(this))
657 compositor->AddObserver(this);
658 } else {
659 // The compositor will pickup the active buffer during a draw, so we
660 // can ACK immediately.
661 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id,
662 compositor);
663 }
664 } else {
665 // Add sending an ACK to the list of things to do OnCompositingWillStart
666 on_compositing_will_start_callbacks_.push_back(
582 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, 667 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK,
583 params_in_pixel.route_id, 668 params_in_pixel.route_id,
584 gpu_host_id)); 669 gpu_host_id));
585 if (!compositor->HasObserver(this)) 670 if (!compositor->HasObserver(this))
586 compositor->AddObserver(this); 671 compositor->AddObserver(this);
587 } else {
588 // The compositor will pickup the active buffer during a draw, so we
589 // can ACK immediately.
590 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id,
591 compositor);
592 } 672 }
593 } else {
594 // Add sending an ACK to the list of things to do OnCompositingWillStart
595 on_compositing_will_start_callbacks_.push_back(
596 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK,
597 params_in_pixel.route_id,
598 gpu_host_id));
599 if (!compositor->HasObserver(this))
600 compositor->AddObserver(this);
601 } 673 }
602 } 674 }
603 } 675 }
604 676
605 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 677 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
606 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 678 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
607 int gpu_host_id) { 679 int gpu_host_id) {
680 surface_route_id_ = params_in_pixel.route_id;
681 // If visible state changed, then this PSB is stale. We must still ACK but
682 // do not update current_surface_.
683 if (host_->IsHidden() ||
684 (params_in_pixel.protection_state_id &&
685 params_in_pixel.protection_state_id != protection_state_id_)) {
686 DCHECK(!current_surface_);
687 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL);
688 return;
689 }
608 current_surface_ = params_in_pixel.surface_handle; 690 current_surface_ = params_in_pixel.surface_handle;
691 released_front_lock_ = NULL;
692 DCHECK(current_surface_);
609 UpdateExternalTexture(); 693 UpdateExternalTexture();
610 694
611 ui::Compositor* compositor = GetCompositor(); 695 ui::Compositor* compositor = GetCompositor();
612 if (!compositor) { 696 if (!compositor) {
613 // We have no compositor, so we have no way to display the surface 697 // We have no compositor, so we have no way to display the surface
614 // Must still send the ACK 698 // Must still send the ACK
615 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); 699 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL);
616 } else { 700 } else {
701 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
702 image_transport_clients_.end());
617 gfx::Size surface_size_in_pixel = 703 gfx::Size surface_size_in_pixel =
618 image_transport_clients_[params_in_pixel.surface_handle]->size(); 704 image_transport_clients_[params_in_pixel.surface_handle]->size();
619 705
620 // Co-ordinates come in OpenGL co-ordinate space. 706 // Co-ordinates come in OpenGL co-ordinate space.
621 // We need to convert to layer space. 707 // We need to convert to layer space.
622 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( 708 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect(
623 params_in_pixel.x, 709 params_in_pixel.x,
624 surface_size_in_pixel.height() - params_in_pixel.y - 710 surface_size_in_pixel.height() - params_in_pixel.y -
625 params_in_pixel.height, 711 params_in_pixel.height,
626 params_in_pixel.width, 712 params_in_pixel.width,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 if (!surface) { 766 if (!surface) {
681 LOG(ERROR) << "Failed to create ImageTransport texture"; 767 LOG(ERROR) << "Failed to create ImageTransport texture";
682 return; 768 return;
683 } 769 }
684 770
685 image_transport_clients_[surface_handle] = surface; 771 image_transport_clients_[surface_handle] = surface;
686 } 772 }
687 773
688 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( 774 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(
689 uint64 surface_handle) { 775 uint64 surface_handle) {
776 DCHECK(image_transport_clients_.find(surface_handle) !=
777 image_transport_clients_.end());
690 if (current_surface_ == surface_handle) { 778 if (current_surface_ == surface_handle) {
691 current_surface_ = 0; 779 current_surface_ = 0;
692 UpdateExternalTexture(); 780 UpdateExternalTexture();
693 } 781 }
694 image_transport_clients_.erase(surface_handle); 782 image_transport_clients_.erase(surface_handle);
695 } 783 }
696 784
785 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(ui::Compositor*) {
786 if (current_surface_ || !host_->IsHidden())
787 return;
788 current_surface_in_use_by_compositor_ = false;
789 AdjustSurfaceProtection();
790 }
791
792 void RenderWidgetHostViewAura::AdjustSurfaceProtection() {
793 // If the current surface is non null, it is protected.
794 // If we are visible, it is protected.
795 // Otherwise, change to not proctected once done thumbnailing and compositing.
796 bool surface_is_protected =
797 current_surface_ ||
798 !host_->IsHidden() ||
799 (current_surface_is_protected_ &&
800 (!pending_thumbnail_tasks_.empty() ||
801 current_surface_in_use_by_compositor_));
802 if (current_surface_is_protected_ == surface_is_protected)
803 return;
804 current_surface_is_protected_ = surface_is_protected;
805 ++protection_state_id_;
806
807 if (!surface_route_id_ || !shared_surface_handle_.parent_gpu_process_id)
808 return;
809
810 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(
811 surface_is_protected,
812 protection_state_id_,
813 surface_route_id_,
814 shared_surface_handle_.parent_gpu_process_id);
815 }
816
817 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished(
818 base::Callback<void(bool)> callback, bool result) {
819 for (size_t i = 0; i != pending_thumbnail_tasks_.size(); ++i) {
820 if (pending_thumbnail_tasks_[i].Equals(callback)) {
821 pending_thumbnail_tasks_.erase(pending_thumbnail_tasks_.begin()+i);
822 break;
823 }
824 }
825 AdjustSurfaceProtection();
826 callback.Run(result);
827 }
828
697 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { 829 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) {
698 RenderWidgetHostViewBase::SetBackground(background); 830 RenderWidgetHostViewBase::SetBackground(background);
699 host_->SetBackground(background); 831 host_->SetBackground(background);
700 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); 832 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
701 } 833 }
702 834
703 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { 835 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) {
704 GetScreenInfoForWindow(results, window_); 836 GetScreenInfoForWindow(results, window_);
705 } 837 }
706 838
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 void RenderWidgetHostViewAura::OnCompositingAborted( 1432 void RenderWidgetHostViewAura::OnCompositingAborted(
1301 ui::Compositor* compositor) { 1433 ui::Compositor* compositor) {
1302 } 1434 }
1303 1435
1304 //////////////////////////////////////////////////////////////////////////////// 1436 ////////////////////////////////////////////////////////////////////////////////
1305 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 1437 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
1306 1438
1307 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { 1439 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) {
1308 image_transport_clients_.clear(); 1440 image_transport_clients_.clear();
1309 current_surface_ = 0; 1441 current_surface_ = 0;
1442 protection_state_id_ = 0;
1443 current_surface_is_protected_ = true;
1444 current_surface_in_use_by_compositor_ = true;
1445 surface_route_id_ = 0;
1310 UpdateExternalTexture(); 1446 UpdateExternalTexture();
1311 locks_pending_draw_.clear(); 1447 locks_pending_draw_.clear();
1312 1448
1313 DCHECK(!shared_surface_handle_.is_null()); 1449 DCHECK(!shared_surface_handle_.is_null());
1314 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1450 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1315 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 1451 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
1316 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); 1452 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor);
1317 host_->CompositingSurfaceUpdated(); 1453 host_->CompositingSurfaceUpdated();
1318 host_->ScheduleComposite(); 1454 host_->ScheduleComposite();
1319 } 1455 }
1320 1456
1321 //////////////////////////////////////////////////////////////////////////////// 1457 ////////////////////////////////////////////////////////////////////////////////
1322 // RenderWidgetHostViewAura, private: 1458 // RenderWidgetHostViewAura, private:
1323 1459
1324 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 1460 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
1325 if (!shared_surface_handle_.is_null()) { 1461 if (!shared_surface_handle_.is_null()) {
1326 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1462 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1327 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 1463 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
1328 factory->RemoveObserver(this); 1464 factory->RemoveObserver(this);
1329 } 1465 }
1330 window_->RemoveObserver(window_observer_.get()); 1466 window_->RemoveObserver(window_observer_.get());
1331 UnlockMouse(); 1467 UnlockMouse();
1332 if (popup_type_ != WebKit::WebPopupTypeNone) { 1468 if (popup_type_ != WebKit::WebPopupTypeNone) {
1333 DCHECK(popup_parent_host_view_); 1469 DCHECK(popup_parent_host_view_);
1334 popup_parent_host_view_->popup_child_host_view_ = NULL; 1470 popup_parent_host_view_->popup_child_host_view_ = NULL;
1335 } 1471 }
1336 aura::client::SetTooltipText(window_, NULL); 1472 aura::client::SetTooltipText(window_, NULL);
1337 1473
1474 for (size_t i = 0; i != pending_thumbnail_tasks_.size(); ++i)
1475 pending_thumbnail_tasks_[i].Run(false);
1476
1338 // This call is usually no-op since |this| object is already removed from the 1477 // This call is usually no-op since |this| object is already removed from the
1339 // Aura root window and we don't have a way to get an input method object 1478 // Aura root window and we don't have a way to get an input method object
1340 // associated with the window, but just in case. 1479 // associated with the window, but just in case.
1341 DetachFromInputMethod(); 1480 DetachFromInputMethod();
1342 } 1481 }
1343 1482
1344 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 1483 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
1345 const gfx::Point screen_point = gfx::Screen::GetCursorScreenPoint(); 1484 const gfx::Point screen_point = gfx::Screen::GetCursorScreenPoint();
1346 aura::RootWindow* root_window = window_->GetRootWindow(); 1485 aura::RootWindow* root_window = window_->GetRootWindow();
1347 if (!root_window) 1486 if (!root_window)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 RenderWidgetHost* widget) { 1642 RenderWidgetHost* widget) {
1504 return new RenderWidgetHostViewAura(widget); 1643 return new RenderWidgetHostViewAura(widget);
1505 } 1644 }
1506 1645
1507 // static 1646 // static
1508 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 1647 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
1509 GetScreenInfoForWindow(results, NULL); 1648 GetScreenInfoForWindow(results, NULL);
1510 } 1649 }
1511 1650
1512 } // namespace content 1651 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/common/gpu/gpu_memory_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698