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