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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 } | 542 } |
| 543 private: | 543 private: |
| 544 RenderWidgetHostViewAura* view_; | 544 RenderWidgetHostViewAura* view_; |
| 545 aura::Window* top_level_; | 545 aura::Window* top_level_; |
| 546 | 546 |
| 547 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver); | 547 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver); |
| 548 }; | 548 }; |
| 549 | 549 |
| 550 #endif | 550 #endif |
| 551 | 551 |
| 552 RenderWidgetHostViewAura::DelegatedFrameEvictionObserver:: | |
| 553 DelegatedFrameEvictionObserver(RenderWidgetHostViewAura* view) | |
| 554 : view_(view), has_frame_(false) {} | |
| 555 | |
| 556 RenderWidgetHostViewAura::DelegatedFrameEvictionObserver:: | |
| 557 ~DelegatedFrameEvictionObserver() { | |
| 558 DiscardedFrame(); | |
| 559 } | |
| 560 | |
| 561 void RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::SwappedFrame( | |
| 562 bool visible) { | |
| 563 has_frame_ = true; | |
| 564 RendererFrameManager::GetInstance()->AddFrame(this, visible); | |
| 565 } | |
| 566 | |
| 567 void | |
| 568 RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::DiscardedFrame() { | |
| 569 RendererFrameManager::GetInstance()->RemoveFrame(this); | |
| 570 has_frame_ = false; | |
| 571 } | |
| 572 | |
| 573 void RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::SetVisible( | |
| 574 bool visible) { | |
| 575 if (has_frame_) | |
| 576 RendererFrameManager::GetInstance()->SetFrameVisibility(this, visible); | |
| 577 } | |
| 578 | |
| 579 void | |
| 580 RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::EvictCurrentFrame() { | |
| 581 view_->EvictDelegatedFrame(); | |
| 582 } | |
| 583 | |
| 552 //////////////////////////////////////////////////////////////////////////////// | 584 //////////////////////////////////////////////////////////////////////////////// |
| 553 // RenderWidgetHostViewAura, public: | 585 // RenderWidgetHostViewAura, public: |
| 554 | 586 |
| 555 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 587 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
| 556 : host_(RenderWidgetHostImpl::From(host)), | 588 : host_(RenderWidgetHostImpl::From(host)), |
| 557 window_(new aura::Window(this)), | 589 window_(new aura::Window(this)), |
| 558 in_shutdown_(false), | 590 in_shutdown_(false), |
| 559 is_fullscreen_(false), | 591 is_fullscreen_(false), |
| 560 popup_parent_host_view_(NULL), | 592 popup_parent_host_view_(NULL), |
| 561 popup_child_host_view_(NULL), | 593 popup_child_host_view_(NULL), |
| 562 is_loading_(false), | 594 is_loading_(false), |
| 563 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 595 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 564 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 596 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 565 can_compose_inline_(true), | 597 can_compose_inline_(true), |
| 566 has_composition_text_(false), | 598 has_composition_text_(false), |
| 567 last_output_surface_id_(0), | 599 last_output_surface_id_(0), |
| 568 pending_delegated_ack_count_(0), | 600 pending_delegated_ack_count_(0), |
| 569 skipped_frames_(false), | 601 skipped_frames_(false), |
| 570 last_swapped_surface_scale_factor_(1.f), | 602 last_swapped_surface_scale_factor_(1.f), |
| 571 paint_canvas_(NULL), | 603 paint_canvas_(NULL), |
| 572 synthetic_move_sent_(false), | 604 synthetic_move_sent_(false), |
| 573 accelerated_compositing_state_changed_(false), | 605 accelerated_compositing_state_changed_(false), |
| 574 can_lock_compositor_(YES), | 606 can_lock_compositor_(YES), |
| 575 cursor_visibility_state_in_renderer_(UNKNOWN), | 607 cursor_visibility_state_in_renderer_(UNKNOWN), |
| 576 paint_observer_(NULL), | 608 paint_observer_(NULL), |
| 577 touch_editing_client_(NULL), | 609 touch_editing_client_(NULL), |
| 610 delegated_frame_eviction_observer_(this), | |
| 578 weak_ptr_factory_(this) { | 611 weak_ptr_factory_(this) { |
| 579 host_->SetView(this); | 612 host_->SetView(this); |
| 580 window_observer_.reset(new WindowObserver(this)); | 613 window_observer_.reset(new WindowObserver(this)); |
| 581 aura::client::SetTooltipText(window_, &tooltip_); | 614 aura::client::SetTooltipText(window_, &tooltip_); |
| 582 aura::client::SetActivationDelegate(window_, this); | 615 aura::client::SetActivationDelegate(window_, this); |
| 583 aura::client::SetActivationChangeObserver(window_, this); | 616 aura::client::SetActivationChangeObserver(window_, this); |
| 584 aura::client::SetFocusChangeObserver(window_, this); | 617 aura::client::SetFocusChangeObserver(window_, this); |
| 585 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 618 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
| 586 #if defined(OS_WIN) | 619 #if defined(OS_WIN) |
| 587 transient_observer_.reset(new TransientWindowObserver(this)); | 620 transient_observer_.reset(new TransientWindowObserver(this)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 699 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
| 667 return host_; | 700 return host_; |
| 668 } | 701 } |
| 669 | 702 |
| 670 void RenderWidgetHostViewAura::WasShown() { | 703 void RenderWidgetHostViewAura::WasShown() { |
| 671 DCHECK(host_); | 704 DCHECK(host_); |
| 672 if (!host_->is_hidden()) | 705 if (!host_->is_hidden()) |
| 673 return; | 706 return; |
| 674 host_->WasShown(); | 707 host_->WasShown(); |
| 675 software_frame_manager_->SetVisibility(true); | 708 software_frame_manager_->SetVisibility(true); |
| 709 delegated_frame_eviction_observer_.SetVisible(true); | |
| 676 | 710 |
| 677 aura::Window* root = window_->GetRootWindow(); | 711 aura::Window* root = window_->GetRootWindow(); |
| 678 if (root) { | 712 if (root) { |
| 679 aura::client::CursorClient* cursor_client = | 713 aura::client::CursorClient* cursor_client = |
| 680 aura::client::GetCursorClient(root); | 714 aura::client::GetCursorClient(root); |
| 681 if (cursor_client) | 715 if (cursor_client) |
| 682 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 716 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
| 683 } | 717 } |
| 684 | 718 |
| 685 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && | 719 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && |
| 686 !released_front_lock_.get()) { | 720 !released_front_lock_.get()) { |
| 687 ui::Compositor* compositor = GetCompositor(); | 721 ui::Compositor* compositor = GetCompositor(); |
| 688 if (compositor) | 722 if (compositor) |
| 689 released_front_lock_ = compositor->GetCompositorLock(); | 723 released_front_lock_ = compositor->GetCompositorLock(); |
| 690 } | 724 } |
| 691 | 725 |
| 692 #if defined(OS_WIN) | 726 #if defined(OS_WIN) |
| 693 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 727 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 694 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); | 728 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
| 695 transient_observer_->SendPluginCutoutRects(); | 729 transient_observer_->SendPluginCutoutRects(); |
| 696 #endif | 730 #endif |
| 697 } | 731 } |
| 698 | 732 |
| 699 void RenderWidgetHostViewAura::WasHidden() { | 733 void RenderWidgetHostViewAura::WasHidden() { |
| 700 if (!host_ || host_->is_hidden()) | 734 if (!host_ || host_->is_hidden()) |
| 701 return; | 735 return; |
| 702 host_->WasHidden(); | 736 host_->WasHidden(); |
| 703 software_frame_manager_->SetVisibility(false); | 737 software_frame_manager_->SetVisibility(false); |
| 738 delegated_frame_eviction_observer_.SetVisible(false); | |
| 704 released_front_lock_ = NULL; | 739 released_front_lock_ = NULL; |
| 705 | 740 |
| 706 #if defined(OS_WIN) | 741 #if defined(OS_WIN) |
| 707 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 742 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
| 708 if (dispatcher) { | 743 if (dispatcher) { |
| 709 HWND parent = dispatcher->GetAcceleratedWidget(); | 744 HWND parent = dispatcher->GetAcceleratedWidget(); |
| 710 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 745 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 711 | 746 |
| 712 EnumChildWindows(parent, HideWindowsCallback, lparam); | 747 EnumChildWindows(parent, HideWindowsCallback, lparam); |
| 713 } | 748 } |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 if (output_surface_id != last_output_surface_id_) { | 1471 if (output_surface_id != last_output_surface_id_) { |
| 1437 // Resource ids are scoped by the output surface. | 1472 // Resource ids are scoped by the output surface. |
| 1438 // If the originating output surface doesn't match the last one, it | 1473 // If the originating output surface doesn't match the last one, it |
| 1439 // indicates the renderer's output surface may have been recreated, in which | 1474 // indicates the renderer's output surface may have been recreated, in which |
| 1440 // case we should recreate the DelegatedRendererLayer, to avoid matching | 1475 // case we should recreate the DelegatedRendererLayer, to avoid matching |
| 1441 // resources from the old one with resources from the new one which would | 1476 // resources from the old one with resources from the new one which would |
| 1442 // have the same id. Changing the layer to showing painted content destroys | 1477 // have the same id. Changing the layer to showing painted content destroys |
| 1443 // the DelegatedRendererLayer. | 1478 // the DelegatedRendererLayer. |
| 1444 window_->layer()->SetShowPaintedContent(); | 1479 window_->layer()->SetShowPaintedContent(); |
| 1445 frame_provider_ = NULL; | 1480 frame_provider_ = NULL; |
| 1481 delegated_frame_eviction_observer_.DiscardedFrame(); | |
| 1446 | 1482 |
| 1447 // Drop the cc::DelegatedFrameResourceCollection so that we will not return | 1483 // Drop the cc::DelegatedFrameResourceCollection so that we will not return |
| 1448 // any resources from the old output surface with the new output surface id. | 1484 // any resources from the old output surface with the new output surface id. |
| 1449 if (resource_collection_.get()) { | 1485 if (resource_collection_.get()) { |
| 1450 resource_collection_->SetClient(NULL); | 1486 resource_collection_->SetClient(NULL); |
| 1451 | 1487 |
| 1452 if (resource_collection_->LoseAllResources()) | 1488 if (resource_collection_->LoseAllResources()) |
| 1453 SendReturnedDelegatedResources(last_output_surface_id_); | 1489 SendReturnedDelegatedResources(last_output_surface_id_); |
| 1454 | 1490 |
| 1455 resource_collection_ = NULL; | 1491 resource_collection_ = NULL; |
| 1456 } | 1492 } |
| 1457 last_output_surface_id_ = output_surface_id; | 1493 last_output_surface_id_ = output_surface_id; |
| 1458 } | 1494 } |
| 1459 if (frame_size.IsEmpty()) { | 1495 if (frame_size.IsEmpty()) { |
| 1460 DCHECK_EQ(0u, frame_data->resource_list.size()); | 1496 DCHECK_EQ(0u, frame_data->resource_list.size()); |
| 1461 window_->layer()->SetShowPaintedContent(); | 1497 window_->layer()->SetShowPaintedContent(); |
|
danakj
2013/10/28 21:39:21
Should this just call EvictDelegatedFrame() rather
piman
2013/10/28 22:08:38
Done, and above as well.
| |
| 1462 frame_provider_ = NULL; | 1498 frame_provider_ = NULL; |
| 1499 delegated_frame_eviction_observer_.DiscardedFrame(); | |
| 1463 } else { | 1500 } else { |
| 1464 if (!resource_collection_) { | 1501 if (!resource_collection_) { |
| 1465 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 1502 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
| 1466 resource_collection_->SetClient(this); | 1503 resource_collection_->SetClient(this); |
| 1467 } | 1504 } |
| 1468 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size()) { | 1505 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size()) { |
| 1469 frame_provider_ = new cc::DelegatedFrameProvider( | 1506 frame_provider_ = new cc::DelegatedFrameProvider( |
| 1470 resource_collection_.get(), frame_data.Pass()); | 1507 resource_collection_.get(), frame_data.Pass()); |
| 1471 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), | 1508 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), |
| 1472 frame_size_in_dip); | 1509 frame_size_in_dip); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1488 if (!compositor) { | 1525 if (!compositor) { |
| 1489 SendDelegatedFrameAck(output_surface_id); | 1526 SendDelegatedFrameAck(output_surface_id); |
| 1490 } else { | 1527 } else { |
| 1491 compositor->SetLatencyInfo(latency_info); | 1528 compositor->SetLatencyInfo(latency_info); |
| 1492 AddOnCommitCallbackAndDisableLocks( | 1529 AddOnCommitCallbackAndDisableLocks( |
| 1493 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, | 1530 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, |
| 1494 AsWeakPtr(), | 1531 AsWeakPtr(), |
| 1495 output_surface_id)); | 1532 output_surface_id)); |
| 1496 } | 1533 } |
| 1497 DidReceiveFrameFromRenderer(); | 1534 DidReceiveFrameFromRenderer(); |
| 1535 if (frame_provider_.get()) | |
| 1536 delegated_frame_eviction_observer_.SwappedFrame(!host_->is_hidden()); | |
| 1537 // Note: the frame may have been evicted immediately. | |
| 1498 } | 1538 } |
| 1499 | 1539 |
| 1500 void RenderWidgetHostViewAura::SendDelegatedFrameAck(uint32 output_surface_id) { | 1540 void RenderWidgetHostViewAura::SendDelegatedFrameAck(uint32 output_surface_id) { |
| 1501 cc::CompositorFrameAck ack; | 1541 cc::CompositorFrameAck ack; |
| 1502 if (resource_collection_) | 1542 if (resource_collection_) |
| 1503 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); | 1543 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); |
| 1504 RenderWidgetHostImpl::SendSwapCompositorFrameAck(host_->GetRoutingID(), | 1544 RenderWidgetHostImpl::SendSwapCompositorFrameAck(host_->GetRoutingID(), |
| 1505 output_surface_id, | 1545 output_surface_id, |
| 1506 host_->GetProcess()->GetID(), | 1546 host_->GetProcess()->GetID(), |
| 1507 ack); | 1547 ack); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1522 if (resource_collection_) | 1562 if (resource_collection_) |
| 1523 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); | 1563 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); |
| 1524 DCHECK(!ack.resources.empty()); | 1564 DCHECK(!ack.resources.empty()); |
| 1525 RenderWidgetHostImpl::SendReclaimCompositorResources( | 1565 RenderWidgetHostImpl::SendReclaimCompositorResources( |
| 1526 host_->GetRoutingID(), | 1566 host_->GetRoutingID(), |
| 1527 output_surface_id, | 1567 output_surface_id, |
| 1528 host_->GetProcess()->GetID(), | 1568 host_->GetProcess()->GetID(), |
| 1529 ack); | 1569 ack); |
| 1530 } | 1570 } |
| 1531 | 1571 |
| 1572 void RenderWidgetHostViewAura::EvictDelegatedFrame() { | |
| 1573 DCHECK(frame_provider_.get()); | |
| 1574 window_->layer()->SetShowPaintedContent(); | |
| 1575 frame_provider_ = NULL; | |
| 1576 delegated_frame_eviction_observer_.DiscardedFrame(); | |
| 1577 } | |
| 1578 | |
| 1532 void RenderWidgetHostViewAura::SwapSoftwareFrame( | 1579 void RenderWidgetHostViewAura::SwapSoftwareFrame( |
| 1533 uint32 output_surface_id, | 1580 uint32 output_surface_id, |
| 1534 scoped_ptr<cc::SoftwareFrameData> frame_data, | 1581 scoped_ptr<cc::SoftwareFrameData> frame_data, |
| 1535 float frame_device_scale_factor, | 1582 float frame_device_scale_factor, |
| 1536 const ui::LatencyInfo& latency_info) { | 1583 const ui::LatencyInfo& latency_info) { |
| 1537 const gfx::Size& frame_size = frame_data->size; | 1584 const gfx::Size& frame_size = frame_data->size; |
| 1538 const gfx::Rect& damage_rect = frame_data->damage_rect; | 1585 const gfx::Rect& damage_rect = frame_data->damage_rect; |
| 1539 gfx::Size frame_size_in_dip = | 1586 gfx::Size frame_size_in_dip = |
| 1540 ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1587 ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 1541 if (ShouldSkipFrame(frame_size_in_dip)) { | 1588 if (ShouldSkipFrame(frame_size_in_dip)) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1780 } | 1827 } |
| 1781 | 1828 |
| 1782 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1829 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
| 1783 // This really tells us to release the frontbuffer. | 1830 // This really tells us to release the frontbuffer. |
| 1784 if (current_surface_.get()) { | 1831 if (current_surface_.get()) { |
| 1785 ui::Compositor* compositor = GetCompositor(); | 1832 ui::Compositor* compositor = GetCompositor(); |
| 1786 if (compositor) { | 1833 if (compositor) { |
| 1787 // We need to wait for a commit to clear to guarantee that all we | 1834 // We need to wait for a commit to clear to guarantee that all we |
| 1788 // will not issue any more GL referencing the previous surface. | 1835 // will not issue any more GL referencing the previous surface. |
| 1789 AddOnCommitCallbackAndDisableLocks( | 1836 AddOnCommitCallbackAndDisableLocks( |
| 1790 base::Bind(&RenderWidgetHostViewAura:: | 1837 base::Bind(&RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor, |
| 1791 SetSurfaceNotInUseByCompositor, | |
| 1792 AsWeakPtr(), | 1838 AsWeakPtr(), |
| 1793 current_surface_)); // Hold a ref so the texture will not | 1839 current_surface_)); // Hold a ref so the texture will not |
| 1794 // get deleted until after commit. | 1840 // get deleted until after commit. |
| 1795 } | 1841 } |
| 1796 current_surface_ = NULL; | 1842 current_surface_ = NULL; |
| 1797 UpdateExternalTexture(); | 1843 UpdateExternalTexture(); |
| 1798 } | 1844 } |
| 1799 } | 1845 } |
| 1800 | 1846 |
| 1801 bool RenderWidgetHostViewAura::HasAcceleratedSurface( | 1847 bool RenderWidgetHostViewAura::HasAcceleratedSurface( |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3404 RenderWidgetHost* widget) { | 3450 RenderWidgetHost* widget) { |
| 3405 return new RenderWidgetHostViewAura(widget); | 3451 return new RenderWidgetHostViewAura(widget); |
| 3406 } | 3452 } |
| 3407 | 3453 |
| 3408 // static | 3454 // static |
| 3409 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3455 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3410 GetScreenInfoForWindow(results, NULL); | 3456 GetScreenInfoForWindow(results, NULL); |
| 3411 } | 3457 } |
| 3412 | 3458 |
| 3413 } // namespace content | 3459 } // namespace content |
| OLD | NEW |