| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 const cc::LocalSurfaceId& GetLocalSurfaceId() const { | 421 const cc::LocalSurfaceId& GetLocalSurfaceId() const { |
| 422 return GetDelegatedFrameHost()->LocalSurfaceIdForTesting(); | 422 return GetDelegatedFrameHost()->LocalSurfaceIdForTesting(); |
| 423 } | 423 } |
| 424 | 424 |
| 425 bool HasFrameData() const { return GetLocalSurfaceId().is_valid(); } | 425 bool HasFrameData() const { return GetLocalSurfaceId().is_valid(); } |
| 426 | 426 |
| 427 bool released_front_lock_active() const { | 427 bool released_front_lock_active() const { |
| 428 return GetDelegatedFrameHost()->ReleasedFrontLockActiveForTesting(); | 428 return GetDelegatedFrameHost()->ReleasedFrontLockActiveForTesting(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void ReturnResources(const cc::ReturnedResourceArray& resources) { | 431 void ReclaimResources(const cc::ReturnedResourceArray& resources) { |
| 432 GetDelegatedFrameHost()->ReturnResources(resources); | 432 GetDelegatedFrameHost()->ReclaimResources(resources); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void ResetCompositor() { GetDelegatedFrameHost()->ResetCompositor(); } | 435 void ResetCompositor() { GetDelegatedFrameHost()->ResetCompositor(); } |
| 436 | 436 |
| 437 const ui::MotionEventAura& pointer_state_for_test() { | 437 const ui::MotionEventAura& pointer_state_for_test() { |
| 438 return event_handler()->pointer_state(); | 438 return event_handler()->pointer_state(); |
| 439 } | 439 } |
| 440 | 440 |
| 441 // In this unit test, |window_| is directly added to the root and is | 441 // In this unit test, |window_| is directly added to the root and is |
| 442 // toplevel. | 442 // toplevel. |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 gfx::Rect view_rect(view_size); | 1760 gfx::Rect view_rect(view_size); |
| 1761 | 1761 |
| 1762 view_->InitAsChild(nullptr); | 1762 view_->InitAsChild(nullptr); |
| 1763 aura::client::ParentWindowWithContext( | 1763 aura::client::ParentWindowWithContext( |
| 1764 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), | 1764 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 1765 gfx::Rect()); | 1765 gfx::Rect()); |
| 1766 view_->SetSize(view_size); | 1766 view_->SetSize(view_size); |
| 1767 view_->Show(); | 1767 view_->Show(); |
| 1768 sink_->ClearMessages(); | 1768 sink_->ClearMessages(); |
| 1769 | 1769 |
| 1770 // Accumulate some returned resources. This should not trigger an IPC. | 1770 // Accumulate some returned resources. This should trigger an IPC. |
| 1771 cc::ReturnedResourceArray resources; | 1771 cc::ReturnedResourceArray resources; |
| 1772 cc::ReturnedResource resource; | 1772 cc::ReturnedResource resource; |
| 1773 resource.id = 1; | 1773 resource.id = 1; |
| 1774 resources.push_back(resource); | 1774 resources.push_back(resource); |
| 1775 view_->ReturnResources(resources); | 1775 view_->ReclaimResources(resources); |
| 1776 EXPECT_EQ(1u, sink_->message_count()); | 1776 EXPECT_EQ(1u, sink_->message_count()); |
| 1777 { | 1777 { |
| 1778 const IPC::Message* msg = sink_->GetMessageAt(0); | 1778 const IPC::Message* msg = sink_->GetMessageAt(0); |
| 1779 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); | 1779 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); |
| 1780 ViewMsg_ReclaimCompositorResources::Param params; | 1780 ViewMsg_ReclaimCompositorResources::Param params; |
| 1781 ViewMsg_ReclaimCompositorResources::Read(msg, ¶ms); | 1781 ViewMsg_ReclaimCompositorResources::Read(msg, ¶ms); |
| 1782 EXPECT_EQ(0u, std::get<0>(params)); // compositor_frame_sink_id | 1782 EXPECT_EQ(0u, std::get<0>(params)); // compositor_frame_sink_id |
| 1783 EXPECT_FALSE(std::get<1>(params)); // is_swap_ack | 1783 EXPECT_FALSE(std::get<1>(params)); // is_swap_ack |
| 1784 } | 1784 } |
| 1785 } | 1785 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1797 gfx::Rect view_rect(view_size); | 1797 gfx::Rect view_rect(view_size); |
| 1798 | 1798 |
| 1799 view_->InitAsChild(nullptr); | 1799 view_->InitAsChild(nullptr); |
| 1800 aura::client::ParentWindowWithContext( | 1800 aura::client::ParentWindowWithContext( |
| 1801 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), | 1801 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 1802 gfx::Rect()); | 1802 gfx::Rect()); |
| 1803 view_->SetSize(view_size); | 1803 view_->SetSize(view_size); |
| 1804 view_->Show(); | 1804 view_->Show(); |
| 1805 sink_->ClearMessages(); | 1805 sink_->ClearMessages(); |
| 1806 | 1806 |
| 1807 view_->OnSwapCompositorFrame(0, | 1807 // Submit a frame with resources. |
| 1808 MakeDelegatedFrame(1.f, view_size, view_rect)); | 1808 cc::CompositorFrame frame = MakeDelegatedFrame(1.f, view_size, view_rect); |
| 1809 | 1809 cc::TransferableResource resource; |
| 1810 // Accumulate some returned resources. This should not trigger an IPC. | |
| 1811 cc::ReturnedResourceArray resources; | |
| 1812 cc::ReturnedResource resource; | |
| 1813 resource.id = 1; | 1810 resource.id = 1; |
| 1814 resources.push_back(resource); | 1811 frame.resource_list.push_back(resource); |
| 1815 view_->ReturnResources(resources); | 1812 view_->OnSwapCompositorFrame(0, std::move(frame)); |
| 1816 EXPECT_EQ(0u, sink_->message_count()); | 1813 EXPECT_EQ(0u, sink_->message_count()); |
| 1817 | 1814 |
| 1818 // Swap another CompositorFrame but this time from another | 1815 // Swap another CompositorFrame but this time from another |
| 1819 // compositor_frame_sink_id. The resources held by DelegatedFrameHost are old | 1816 // compositor_frame_sink_id. The resources for the previous frame are old and |
| 1820 // and should not be returned. | 1817 // should not be returned. |
| 1821 view_->OnSwapCompositorFrame(1, | 1818 view_->OnSwapCompositorFrame(1, |
| 1822 MakeDelegatedFrame(1.f, view_size, view_rect)); | 1819 MakeDelegatedFrame(1.f, view_size, view_rect)); |
| 1823 EXPECT_EQ(0u, sink_->message_count()); | 1820 EXPECT_EQ(0u, sink_->message_count()); |
| 1824 | 1821 |
| 1825 // Report that the surface is drawn to trigger an ACK. | 1822 // Report that the surface is drawn to trigger an ACK. |
| 1826 cc::Surface* surface = manager->GetSurfaceForId(view_->surface_id()); | 1823 cc::Surface* surface = manager->GetSurfaceForId(view_->surface_id()); |
| 1827 EXPECT_TRUE(surface); | 1824 EXPECT_TRUE(surface); |
| 1828 surface->RunDrawCallbacks(); | 1825 surface->RunDrawCallbacks(); |
| 1829 EXPECT_EQ(1u, sink_->message_count()); | 1826 EXPECT_EQ(1u, sink_->message_count()); |
| 1830 { | 1827 { |
| (...skipping 2888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4719 // There is no composition in the beginning. | 4716 // There is no composition in the beginning. |
| 4720 EXPECT_FALSE(has_composition_text()); | 4717 EXPECT_FALSE(has_composition_text()); |
| 4721 SetHasCompositionTextToTrue(); | 4718 SetHasCompositionTextToTrue(); |
| 4722 view->ImeCancelComposition(); | 4719 view->ImeCancelComposition(); |
| 4723 // The composition must have been canceled. | 4720 // The composition must have been canceled. |
| 4724 EXPECT_FALSE(has_composition_text()); | 4721 EXPECT_FALSE(has_composition_text()); |
| 4725 } | 4722 } |
| 4726 } | 4723 } |
| 4727 | 4724 |
| 4728 } // namespace content | 4725 } // namespace content |
| OLD | NEW |