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

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: fix ALL the issues. 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 visibility_state_id_(0),
228 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 window_->layer()->set_scale_content(false); 290 window_->layer()->set_scale_content(false);
280 Show(); 291 Show();
281 Focus(); 292 Focus();
282 } 293 }
283 294
284 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 295 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
285 return host_; 296 return host_;
286 } 297 }
287 298
288 void RenderWidgetHostViewAura::DidBecomeSelected() { 299 void RenderWidgetHostViewAura::DidBecomeSelected() {
300 if (host_->IsVisible())
301 return;
302
289 host_->WasRestored(); 303 host_->WasRestored();
304
305 ++visibility_state_id_;
piman 2012/06/12 20:59:48 Why not do this in AdjustSurfaceProtection() befor
mmocny 2012/06/12 21:25:51 I need to increase state id before the Adjust func
306
307 if (!current_surface_ && host_->is_accelerated_compositing_active() &&
308 !released_front_lock_.get())
309 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock();
310
311 AdjustSurfaceProtection();
290 } 312 }
291 313
292 void RenderWidgetHostViewAura::WasHidden() { 314 void RenderWidgetHostViewAura::WasHidden() {
315 if (!host_->IsVisible())
316 return;
317
293 host_->WasHidden(); 318 host_->WasHidden();
319
320 ++visibility_state_id_;
321 released_front_lock_ = NULL;
322
323 if (ShouldReleaseFrontSurface()) {
324 current_surface_ = 0;
325 UpdateExternalTexture();
326 }
327
328 AdjustSurfaceProtection();
294 } 329 }
295 330
296 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 331 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
297 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 332 SetBounds(gfx::Rect(window_->bounds().origin(), size));
298 } 333 }
299 334
300 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 335 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
301 if (window_->bounds().size() != rect.size() && 336 if (window_->bounds().size() != rect.size() &&
302 host_->is_accelerated_compositing_active()) { 337 host_->is_accelerated_compositing_active()) {
303 resize_locks_.push_back(make_linked_ptr( 338 resize_locks_.push_back(make_linked_ptr(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( 481 BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
447 const gfx::Size& size) { 482 const gfx::Size& size) {
448 return new BackingStoreSkia(host_, size); 483 return new BackingStoreSkia(host_, size);
449 } 484 }
450 485
451 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 486 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
452 const gfx::Size& size, 487 const gfx::Size& size,
453 skia::PlatformCanvas* output, 488 skia::PlatformCanvas* output,
454 base::Callback<void(bool)> callback) { 489 base::Callback<void(bool)> callback) {
455 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); 490 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false));
491
456 ui::Compositor* compositor = GetCompositor(); 492 ui::Compositor* compositor = GetCompositor();
457 if (!compositor) 493 if (!compositor)
458 return; 494 return;
459 495
460 std::map<uint64, scoped_refptr<ImageTransportClient> >::iterator it = 496 std::map<uint64, scoped_refptr<ImageTransportClient> >::iterator it =
461 image_transport_clients_.find(current_surface_); 497 image_transport_clients_.find(current_surface_);
462 if (it == image_transport_clients_.end()) 498 if (it == image_transport_clients_.end())
463 return; 499 return;
464 500
465 ImageTransportClient* container = it->second; 501 ImageTransportClient* container = it->second;
466 DCHECK(container); 502 DCHECK(container);
467 503
468 gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size); 504 gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size);
469 if (!output->initialize( 505 if (!output->initialize(
470 size_in_pixel.width(), size_in_pixel.height(), true)) 506 size_in_pixel.width(), size_in_pixel.height(), true))
471 return; 507 return;
472 508
473 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 509 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
474 content::GLHelper* gl_helper = factory->GetGLHelper(compositor); 510 content::GLHelper* gl_helper = factory->GetGLHelper(compositor);
475 if (!gl_helper) 511 if (!gl_helper)
476 return; 512 return;
477 513
478 unsigned char* addr = static_cast<unsigned char*>( 514 unsigned char* addr = static_cast<unsigned char*>(
479 output->getTopDevice()->accessBitmap(true).getPixels()); 515 output->getTopDevice()->accessBitmap(true).getPixels());
480 scoped_callback_runner.Release(); 516 scoped_callback_runner.Release();
517 // Wrap the callback with an internal handler so that we can inject our
518 // own completion handlers (where we can call AdjustSurfaceProtection).
519 base::Callback<void(bool)> wrapper_callback = base::Bind(
520 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished,
521 AsWeakPtr(),
522 callback);
481 gl_helper->CopyTextureTo(container->texture_id(), 523 gl_helper->CopyTextureTo(container->texture_id(),
482 container->size(), 524 container->size(),
483 size_in_pixel, 525 size_in_pixel,
484 addr, 526 addr,
485 callback); 527 wrapper_callback);
528 ++pending_thumbnail_tasks_;
piman 2012/06/12 20:59:48 do this before kicking the copy, in case the callb
529 }
530
531 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished(
532 base::Callback<void(bool)> callback, bool result) {
533 --pending_thumbnail_tasks_;
534 AdjustSurfaceProtection();
535 callback.Run(result);
486 } 536 }
487 537
488 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { 538 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
489 // Delay UpdateExternalTexture until we actually got a software frame. 539 // Delay UpdateExternalTexture until we actually got a software frame.
490 // Sometimes (e.g. on a page load) the renderer will spuriously disable then 540 // Sometimes (e.g. on a page load) the renderer will spuriously disable then
491 // re-enable accelerated compositing, causing us to flash. 541 // re-enable accelerated compositing, causing us to flash.
492 // TODO(piman): factor the enable/disable accelerated compositing message into 542 // TODO(piman): factor the enable/disable accelerated compositing message into
493 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have 543 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
494 // fewer inconsistent temporary states. 544 // fewer inconsistent temporary states.
495 needs_update_texture_ = true; 545 needs_update_texture_ = true;
496 } 546 }
497 547
498 void RenderWidgetHostViewAura::UpdateExternalTexture() { 548 void RenderWidgetHostViewAura::UpdateExternalTexture() {
499 needs_update_texture_ = false; 549 needs_update_texture_ = false;
500 if (current_surface_ != 0 && 550 if (current_surface_ != 0 &&
501 host_->is_accelerated_compositing_active()) { 551 host_->is_accelerated_compositing_active()) {
502 552 DCHECK(image_transport_clients_.find(current_surface_) !=
553 image_transport_clients_.end());
503 ImageTransportClient* container = 554 ImageTransportClient* container =
504 image_transport_clients_[current_surface_]; 555 image_transport_clients_[current_surface_];
505 if (container) 556 if (container)
506 container->Update(); 557 container->Update();
507 window_->SetExternalTexture(container); 558 window_->SetExternalTexture(container);
559 current_surface_in_use_by_compositor_ = true;
508 560
509 if (!container) { 561 if (!container) {
510 resize_locks_.clear(); 562 resize_locks_.clear();
511 } else { 563 } else {
512 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; 564 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList;
513 ResizeLockList::iterator it = resize_locks_.begin(); 565 ResizeLockList::iterator it = resize_locks_.begin();
514 while (it != resize_locks_.end()) { 566 while (it != resize_locks_.end()) {
515 gfx::Size container_size = content::ConvertSizeToDIP(this, 567 gfx::Size container_size = content::ConvertSizeToDIP(this,
516 container->size()); 568 container->size());
517 if ((*it)->expected_size() == container_size) 569 if ((*it)->expected_size() == container_size)
(...skipping 16 matching lines...) Expand all
534 it2->get()->UnlockCompositor(); 586 it2->get()->UnlockCompositor();
535 } 587 }
536 if (!compositor->HasObserver(this)) 588 if (!compositor->HasObserver(this))
537 compositor->AddObserver(this); 589 compositor->AddObserver(this);
538 } 590 }
539 resize_locks_.erase(resize_locks_.begin(), it); 591 resize_locks_.erase(resize_locks_.begin(), it);
540 } 592 }
541 } 593 }
542 } else { 594 } else {
543 window_->SetExternalTexture(NULL); 595 window_->SetExternalTexture(NULL);
596 ui::Compositor* compositor = GetCompositor();
597 if (!compositor->DrawPending()) {
598 current_surface_in_use_by_compositor_ = false;
599 AdjustSurfaceProtection();
600 } else {
601 on_compositing_ended_callbacks_.push_back(
602 base::Bind(&RenderWidgetHostViewAura::
603 SetSurfaceNotInUseByCompositor,
604 AsWeakPtr(),
605 visibility_state_id_));
606 if (!compositor->HasObserver(this))
607 compositor->AddObserver(this);
608 }
544 resize_locks_.clear(); 609 resize_locks_.clear();
545 } 610 }
546 } 611 }
547 612
548 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 613 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
549 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 614 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
550 int gpu_host_id) { 615 int gpu_host_id) {
616 // If visibility state changed, then this swap is stale. We must still ACK but
617 // do not update current_surface_ since it may have been discarded.
618 if (params_in_pixel.visibility_state_id &&
619 params_in_pixel.visibility_state_id != visibility_state_id_) {
620 DCHECK(!current_surface_);
621 if (params_in_pixel.require_ack)
piman 2012/06/12 20:59:48 nit: per sytle, needs braces if the body is >1 lin
622 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id,
623 gpu_host_id);
624 return;
625 }
551 current_surface_ = params_in_pixel.surface_handle; 626 current_surface_ = params_in_pixel.surface_handle;
627 // If we don't require an ACK that means the content is not a fresh updated
628 // new frame, rather we are just resetting our handle to some old content that
629 // we still hadn't discarded. Although we could display imedietally, by not
630 // resetting the compositor lock here, we give us some time to get a fresh
631 // frame which means fewer content flashes.
632 if (params_in_pixel.require_ack)
633 released_front_lock_ = NULL;
634
635 DCHECK(current_surface_);
552 UpdateExternalTexture(); 636 UpdateExternalTexture();
553 637
554 ui::Compositor* compositor = GetCompositor(); 638 ui::Compositor* compositor = GetCompositor();
555 if (!compositor) { 639 if (!compositor) {
556 // We have no compositor, so we have no way to display the surface. 640 // We have no compositor, so we have no way to display the surface.
557 // Must still send the ACK. 641 // Must still send the ACK.
558 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id, 642 if (params_in_pixel.require_ack)
559 gpu_host_id); 643 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id,
644 gpu_host_id);
560 } else { 645 } else {
646 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
647 image_transport_clients_.end());
561 gfx::Size surface_size_in_pixel = 648 gfx::Size surface_size_in_pixel =
562 image_transport_clients_[params_in_pixel.surface_handle]->size(); 649 image_transport_clients_[params_in_pixel.surface_handle]->size();
563 gfx::Size surface_size = content::ConvertSizeToDIP(this, 650 gfx::Size surface_size = content::ConvertSizeToDIP(this,
564 surface_size_in_pixel); 651 surface_size_in_pixel);
565 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 652 window_->SchedulePaintInRect(gfx::Rect(surface_size));
566 653
567 if (!resize_locks_.empty() && !compositor->DrawPending()) { 654 if (params_in_pixel.require_ack) {
568 // If we are waiting for the resize, fast-track the ACK. 655 if (!resize_locks_.empty() && !compositor->DrawPending()) {
569 // However only do so if we're not between the Draw() and the 656 // If we are waiting for the resize, fast-track the ACK.
570 // OnCompositingEnded(), because out-of-order execution in the GPU process 657 // However only do so if we're not between the Draw() and the
571 // might corrupt the "front buffer" for the currently issued frame. 658 // OnCompositingEnded(), because out-of-order execution in the GPU
572 RenderWidgetHostImpl::AcknowledgeSwapBuffers( 659 // process might corrupt the "front buffer" for the currently issued
573 params_in_pixel.route_id, gpu_host_id); 660 // frame.
574 } else { 661 RenderWidgetHostImpl::AcknowledgeSwapBuffers(
575 // Add sending an ACK to the list of things to do OnCompositingEnded 662 params_in_pixel.route_id, gpu_host_id);
576 on_compositing_ended_callbacks_.push_back( 663 } else {
577 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers, 664 // Add sending an ACK to the list of things to do OnCompositingEnded
578 params_in_pixel.route_id, gpu_host_id)); 665 on_compositing_ended_callbacks_.push_back(
579 if (!compositor->HasObserver(this)) 666 base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers,
580 compositor->AddObserver(this); 667 params_in_pixel.route_id, gpu_host_id));
668 if (!compositor->HasObserver(this))
669 compositor->AddObserver(this);
670 }
581 } 671 }
582 } 672 }
583 } 673 }
584 674
585 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 675 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
586 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 676 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
587 int gpu_host_id) { 677 int gpu_host_id) {
678 // If visible state changed, then this PSB is stale. We must still ACK but
679 // do not update current_surface_.
680 if (params_in_pixel.visibility_state_id &&
681 params_in_pixel.visibility_state_id != visibility_state_id_) {
682 DCHECK(!current_surface_);
683 RenderWidgetHostImpl::AcknowledgePostSubBuffer(params_in_pixel.route_id,
684 gpu_host_id);
685 return;
686 }
588 current_surface_ = params_in_pixel.surface_handle; 687 current_surface_ = params_in_pixel.surface_handle;
688 released_front_lock_ = NULL;
689 DCHECK(current_surface_);
589 UpdateExternalTexture(); 690 UpdateExternalTexture();
590 691
591 ui::Compositor* compositor = GetCompositor(); 692 ui::Compositor* compositor = GetCompositor();
592 if (!compositor) { 693 if (!compositor) {
593 // We have no compositor, so we have no way to display the surface 694 // We have no compositor, so we have no way to display the surface
594 // Must still send the ACK 695 // Must still send the ACK
595 RenderWidgetHostImpl::AcknowledgePostSubBuffer( 696 RenderWidgetHostImpl::AcknowledgePostSubBuffer(
596 params_in_pixel.route_id, gpu_host_id); 697 params_in_pixel.route_id, gpu_host_id);
597 } else { 698 } else {
699 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) !=
700 image_transport_clients_.end());
598 gfx::Size surface_size_in_pixel = 701 gfx::Size surface_size_in_pixel =
599 image_transport_clients_[params_in_pixel.surface_handle]->size(); 702 image_transport_clients_[params_in_pixel.surface_handle]->size();
600 703
601 // Co-ordinates come in OpenGL co-ordinate space. 704 // Co-ordinates come in OpenGL co-ordinate space.
602 // We need to convert to layer space. 705 // We need to convert to layer space.
603 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect( 706 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect(
604 params_in_pixel.x, 707 params_in_pixel.x,
605 surface_size_in_pixel.height() - params_in_pixel.y - 708 surface_size_in_pixel.height() - params_in_pixel.y -
606 params_in_pixel.height, 709 params_in_pixel.height,
607 params_in_pixel.width, 710 params_in_pixel.width,
(...skipping 26 matching lines...) Expand all
634 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 737 // 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 738 // 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. 739 // method. TODO(jbates) implement this if other Aura code needs it.
637 return false; 740 return false;
638 } 741 }
639 742
640 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( 743 void RenderWidgetHostViewAura::AcceleratedSurfaceNew(
641 int32 width_in_pixel, 744 int32 width_in_pixel,
642 int32 height_in_pixel, 745 int32 height_in_pixel,
643 uint64* surface_handle, 746 uint64* surface_handle,
644 TransportDIB::Handle* shm_handle) { 747 TransportDIB::Handle* shm_handle,
748 int32 route_id) {
645 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 749 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
646 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient( 750 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient(
647 gfx::Size(width_in_pixel, height_in_pixel), surface_handle)); 751 gfx::Size(width_in_pixel, height_in_pixel), surface_handle));
648 if (!surface) { 752 if (!surface) {
649 LOG(ERROR) << "Failed to create ImageTransportClient"; 753 LOG(ERROR) << "Failed to create ImageTransportClient";
650 return; 754 return;
651 } 755 }
652 *shm_handle = surface->Handle(); 756 *shm_handle = surface->Handle();
653 757
654 image_transport_clients_[*surface_handle] = surface; 758 image_transport_clients_[*surface_handle] = surface;
759
760 route_id_ = route_id;
655 } 761 }
656 762
657 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( 763 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(
658 uint64 surface_handle) { 764 uint64 surface_handle) {
765 DCHECK(image_transport_clients_.find(surface_handle) !=
766 image_transport_clients_.end());
659 if (current_surface_ == surface_handle) { 767 if (current_surface_ == surface_handle) {
660 current_surface_ = 0; 768 current_surface_ = 0;
661 UpdateExternalTexture(); 769 UpdateExternalTexture();
662 } 770 }
663 image_transport_clients_.erase(surface_handle); 771 image_transport_clients_.erase(surface_handle);
664 } 772 }
665 773
774 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(
775 uint32 expected_visibility_state_id) {
776 if (visibility_state_id_ != expected_visibility_state_id)
777 return;
778 current_surface_in_use_by_compositor_ = false;
779 AdjustSurfaceProtection();
780 }
781
782 void RenderWidgetHostViewAura::AdjustSurfaceProtection() {
783 // If the current surface is non null, it is protected.
784 // If we are visible, it is protected.
785 // If we are not visible and current surface is null, still stay protected
786 // until we finish thumbnailing and compositing.
787 bool surface_is_protected =
788 current_surface_ ||
789 host_->IsVisible() ||
790 (current_surface_is_protected_ &&
791 (pending_thumbnail_tasks_ || GetCompositor()->DrawPending()));
792 if (current_surface_is_protected_ == surface_is_protected)
793 return;
794 current_surface_is_protected_ = surface_is_protected;
795
796 if (!route_id_ || !shared_surface_handle_.parent_gpu_process_id)
797 return;
798
799 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(
800 surface_is_protected,
801 visibility_state_id_,
802 route_id_,
803 shared_surface_handle_.parent_gpu_process_id);
804 }
805
666 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { 806 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) {
667 content::RenderWidgetHostViewBase::SetBackground(background); 807 content::RenderWidgetHostViewBase::SetBackground(background);
668 host_->SetBackground(background); 808 host_->SetBackground(background);
669 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); 809 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
670 } 810 }
671 811
672 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { 812 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) {
673 GetScreenInfoForWindow(results, window_); 813 GetScreenInfoForWindow(results, window_);
674 } 814 }
675 815
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 void RenderWidgetHostViewAura::OnCompositingAborted( 1336 void RenderWidgetHostViewAura::OnCompositingAborted(
1197 ui::Compositor* compositor) { 1337 ui::Compositor* compositor) {
1198 } 1338 }
1199 1339
1200 //////////////////////////////////////////////////////////////////////////////// 1340 ////////////////////////////////////////////////////////////////////////////////
1201 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 1341 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
1202 1342
1203 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { 1343 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) {
1204 image_transport_clients_.clear(); 1344 image_transport_clients_.clear();
1205 current_surface_ = 0; 1345 current_surface_ = 0;
1346 visibility_state_id_ = 0;
1347 current_surface_is_protected_ = true;
1348 current_surface_in_use_by_compositor_ = true;
1349 route_id_ = 0;
1206 UpdateExternalTexture(); 1350 UpdateExternalTexture();
1207 locks_pending_draw_.clear(); 1351 locks_pending_draw_.clear();
1208 1352
1209 DCHECK(!shared_surface_handle_.is_null()); 1353 DCHECK(!shared_surface_handle_.is_null());
1210 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1354 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1211 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 1355 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
1212 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); 1356 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor);
1213 host_->CompositingSurfaceUpdated(); 1357 host_->CompositingSurfaceUpdated();
1214 host_->ScheduleComposite(); 1358 host_->ScheduleComposite();
1215 } 1359 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 1486 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
1343 RenderWidgetHost* widget) { 1487 RenderWidgetHost* widget) {
1344 return new RenderWidgetHostViewAura(widget); 1488 return new RenderWidgetHostViewAura(widget);
1345 } 1489 }
1346 1490
1347 // static 1491 // static
1348 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1492 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1349 WebKit::WebScreenInfo* results) { 1493 WebKit::WebScreenInfo* results) {
1350 GetScreenInfoForWindow(results, NULL); 1494 GetScreenInfoForWindow(results, NULL);
1351 } 1495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698