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 14 matching lines...) Expand all Loading... |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "cc/output/begin_frame_args.h" | 26 #include "cc/output/begin_frame_args.h" |
27 #include "cc/output/compositor_frame.h" | 27 #include "cc/output/compositor_frame.h" |
28 #include "cc/output/compositor_frame_metadata.h" | 28 #include "cc/output/compositor_frame_metadata.h" |
29 #include "cc/output/copy_output_request.h" | 29 #include "cc/output/copy_output_request.h" |
30 #include "cc/surfaces/surface.h" | 30 #include "cc/surfaces/surface.h" |
31 #include "cc/surfaces/surface_manager.h" | 31 #include "cc/surfaces/surface_manager.h" |
32 #include "cc/test/begin_frame_args_test.h" | 32 #include "cc/test/begin_frame_args_test.h" |
33 #include "cc/test/fake_external_begin_frame_source.h" | 33 #include "cc/test/fake_external_begin_frame_source.h" |
34 #include "components/display_compositor/gl_helper.h" | 34 #include "components/display_compositor/gl_helper.h" |
| 35 #include "components/display_compositor/host_shared_bitmap_manager.h" |
35 #include "content/browser/browser_thread_impl.h" | 36 #include "content/browser/browser_thread_impl.h" |
36 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 37 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
37 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 38 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
38 #include "content/browser/gpu/compositor_util.h" | 39 #include "content/browser/gpu/compositor_util.h" |
39 #include "content/browser/renderer_host/delegated_frame_host.h" | 40 #include "content/browser/renderer_host/delegated_frame_host.h" |
40 #include "content/browser/renderer_host/delegated_frame_host_client_aura.h" | 41 #include "content/browser/renderer_host/delegated_frame_host_client_aura.h" |
41 #include "content/browser/renderer_host/input/input_router.h" | 42 #include "content/browser/renderer_host/input/input_router.h" |
42 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" | 43 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" |
43 #include "content/browser/renderer_host/overscroll_controller.h" | 44 #include "content/browser/renderer_host/overscroll_controller.h" |
44 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 45 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
45 #include "content/browser/renderer_host/render_view_host_factory.h" | 46 #include "content/browser/renderer_host/render_view_host_factory.h" |
46 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 47 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
47 #include "content/browser/renderer_host/render_widget_host_impl.h" | 48 #include "content/browser/renderer_host/render_widget_host_impl.h" |
48 #include "content/browser/renderer_host/render_widget_host_view_event_handler.h" | 49 #include "content/browser/renderer_host/render_widget_host_view_event_handler.h" |
49 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber
.h" | 50 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber
.h" |
50 #include "content/browser/renderer_host/text_input_manager.h" | 51 #include "content/browser/renderer_host/text_input_manager.h" |
51 #include "content/browser/web_contents/web_contents_view_aura.h" | 52 #include "content/browser/web_contents/web_contents_view_aura.h" |
52 #include "content/common/host_shared_bitmap_manager.h" | |
53 #include "content/common/input/synthetic_web_input_event_builders.h" | 53 #include "content/common/input/synthetic_web_input_event_builders.h" |
54 #include "content/common/input_messages.h" | 54 #include "content/common/input_messages.h" |
55 #include "content/common/text_input_state.h" | 55 #include "content/common/text_input_state.h" |
56 #include "content/common/view_messages.h" | 56 #include "content/common/view_messages.h" |
57 #include "content/public/browser/keyboard_event_processing_result.h" | 57 #include "content/public/browser/keyboard_event_processing_result.h" |
58 #include "content/public/browser/render_widget_host_view.h" | 58 #include "content/public/browser/render_widget_host_view.h" |
59 #include "content/public/browser/web_contents_view_delegate.h" | 59 #include "content/public/browser/web_contents_view_delegate.h" |
60 #include "content/public/common/content_features.h" | 60 #include "content/public/common/content_features.h" |
61 #include "content/public/common/context_menu_params.h" | 61 #include "content/public/common/context_menu_params.h" |
62 #include "content/public/test/mock_render_process_host.h" | 62 #include "content/public/test/mock_render_process_host.h" |
(...skipping 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2664 | 2664 |
2665 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { | 2665 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { |
2666 view_->InitAsChild(nullptr); | 2666 view_->InitAsChild(nullptr); |
2667 | 2667 |
2668 size_t max_renderer_frames = | 2668 size_t max_renderer_frames = |
2669 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2669 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
2670 ASSERT_LE(2u, max_renderer_frames); | 2670 ASSERT_LE(2u, max_renderer_frames); |
2671 size_t renderer_count = max_renderer_frames + 1; | 2671 size_t renderer_count = max_renderer_frames + 1; |
2672 gfx::Rect view_rect(100, 100); | 2672 gfx::Rect view_rect(100, 100); |
2673 gfx::Size frame_size = view_rect.size(); | 2673 gfx::Size frame_size = view_rect.size(); |
2674 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); | 2674 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() |
| 2675 ->AllocatedBitmapCount()); |
2675 | 2676 |
2676 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2677 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2677 new RenderWidgetHostImpl*[renderer_count]); | 2678 new RenderWidgetHostImpl*[renderer_count]); |
2678 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2679 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2679 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2680 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2680 | 2681 |
2681 // Create a bunch of renderers. | 2682 // Create a bunch of renderers. |
2682 for (size_t i = 0; i < renderer_count; ++i) { | 2683 for (size_t i = 0; i < renderer_count; ++i) { |
2683 int32_t routing_id = process_host_->GetNextRoutingID(); | 2684 int32_t routing_id = process_host_->GetNextRoutingID(); |
2684 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2685 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2803 EXPECT_FALSE(views[1]->released_front_lock_active()); | 2804 EXPECT_FALSE(views[1]->released_front_lock_active()); |
2804 | 2805 |
2805 for (size_t i = 0; i < renderer_count - 1; ++i) | 2806 for (size_t i = 0; i < renderer_count - 1; ++i) |
2806 views[i]->Hide(); | 2807 views[i]->Hide(); |
2807 | 2808 |
2808 // Allocate enough bitmaps so that two frames (proportionally) would be | 2809 // Allocate enough bitmaps so that two frames (proportionally) would be |
2809 // enough hit the handle limit. | 2810 // enough hit the handle limit. |
2810 int handles_per_frame = 5; | 2811 int handles_per_frame = 5; |
2811 RendererFrameManager::GetInstance()->set_max_handles(handles_per_frame * 2); | 2812 RendererFrameManager::GetInstance()->set_max_handles(handles_per_frame * 2); |
2812 | 2813 |
2813 HostSharedBitmapManagerClient bitmap_client( | 2814 display_compositor::HostSharedBitmapManagerClient bitmap_client( |
2814 HostSharedBitmapManager::current()); | 2815 display_compositor::HostSharedBitmapManager::current()); |
2815 | 2816 |
2816 for (size_t i = 0; i < (renderer_count - 1) * handles_per_frame; i++) { | 2817 for (size_t i = 0; i < (renderer_count - 1) * handles_per_frame; i++) { |
2817 bitmap_client.ChildAllocatedSharedBitmap( | 2818 bitmap_client.ChildAllocatedSharedBitmap( |
2818 1, base::SharedMemory::NULLHandle(), cc::SharedBitmap::GenerateId()); | 2819 1, base::SharedMemory::NULLHandle(), cc::SharedBitmap::GenerateId()); |
2819 } | 2820 } |
2820 | 2821 |
2821 // Hiding this last bitmap should evict all but two frames. | 2822 // Hiding this last bitmap should evict all but two frames. |
2822 views[renderer_count - 1]->Hide(); | 2823 views[renderer_count - 1]->Hide(); |
2823 for (size_t i = 0; i < renderer_count; ++i) { | 2824 for (size_t i = 0; i < renderer_count; ++i) { |
2824 if (i + 2 < renderer_count) | 2825 if (i + 2 < renderer_count) |
(...skipping 12 matching lines...) Expand all Loading... |
2837 | 2838 |
2838 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { | 2839 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { |
2839 view_->InitAsChild(nullptr); | 2840 view_->InitAsChild(nullptr); |
2840 | 2841 |
2841 size_t max_renderer_frames = | 2842 size_t max_renderer_frames = |
2842 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2843 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
2843 ASSERT_LE(2u, max_renderer_frames); | 2844 ASSERT_LE(2u, max_renderer_frames); |
2844 size_t renderer_count = max_renderer_frames + 1; | 2845 size_t renderer_count = max_renderer_frames + 1; |
2845 gfx::Rect view_rect(100, 100); | 2846 gfx::Rect view_rect(100, 100); |
2846 gfx::Size frame_size = view_rect.size(); | 2847 gfx::Size frame_size = view_rect.size(); |
2847 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); | 2848 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() |
| 2849 ->AllocatedBitmapCount()); |
2848 | 2850 |
2849 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2851 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2850 new RenderWidgetHostImpl*[renderer_count]); | 2852 new RenderWidgetHostImpl*[renderer_count]); |
2851 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2853 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2852 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2854 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2853 | 2855 |
2854 // Create a bunch of renderers. | 2856 // Create a bunch of renderers. |
2855 for (size_t i = 0; i < renderer_count; ++i) { | 2857 for (size_t i = 0; i < renderer_count; ++i) { |
2856 int32_t routing_id = process_host_->GetNextRoutingID(); | 2858 int32_t routing_id = process_host_->GetNextRoutingID(); |
2857 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2859 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2909 // The test logic below relies on having max_renderer_frames > 2. By default, | 2911 // The test logic below relies on having max_renderer_frames > 2. By default, |
2910 // this value is calculated from total physical memory and causes the test to | 2912 // this value is calculated from total physical memory and causes the test to |
2911 // fail when run on hardware with < 256MB of RAM. | 2913 // fail when run on hardware with < 256MB of RAM. |
2912 const size_t kMaxRendererFrames = 5; | 2914 const size_t kMaxRendererFrames = 5; |
2913 RendererFrameManager::GetInstance()->set_max_number_of_saved_frames( | 2915 RendererFrameManager::GetInstance()->set_max_number_of_saved_frames( |
2914 kMaxRendererFrames); | 2916 kMaxRendererFrames); |
2915 | 2917 |
2916 size_t renderer_count = kMaxRendererFrames; | 2918 size_t renderer_count = kMaxRendererFrames; |
2917 gfx::Rect view_rect(100, 100); | 2919 gfx::Rect view_rect(100, 100); |
2918 gfx::Size frame_size = view_rect.size(); | 2920 gfx::Size frame_size = view_rect.size(); |
2919 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); | 2921 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() |
| 2922 ->AllocatedBitmapCount()); |
2920 | 2923 |
2921 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2924 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2922 new RenderWidgetHostImpl*[renderer_count]); | 2925 new RenderWidgetHostImpl*[renderer_count]); |
2923 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2926 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2924 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2927 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2925 | 2928 |
2926 // Create a bunch of renderers. | 2929 // Create a bunch of renderers. |
2927 for (size_t i = 0; i < renderer_count; ++i) { | 2930 for (size_t i = 0; i < renderer_count; ++i) { |
2928 int32_t routing_id = process_host_->GetNextRoutingID(); | 2931 int32_t routing_id = process_host_->GetNextRoutingID(); |
2929 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2932 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 2506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5436 // There is no composition in the beginning. | 5439 // There is no composition in the beginning. |
5437 EXPECT_FALSE(has_composition_text()); | 5440 EXPECT_FALSE(has_composition_text()); |
5438 SetHasCompositionTextToTrue(); | 5441 SetHasCompositionTextToTrue(); |
5439 view->ImeCancelComposition(); | 5442 view->ImeCancelComposition(); |
5440 // The composition must have been canceled. | 5443 // The composition must have been canceled. |
5441 EXPECT_FALSE(has_composition_text()); | 5444 EXPECT_FALSE(has_composition_text()); |
5442 } | 5445 } |
5443 } | 5446 } |
5444 | 5447 |
5445 } // namespace content | 5448 } // namespace content |
OLD | NEW |