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 13 matching lines...) Expand all Loading... |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
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/viz/display_compositor/gl_helper.h" |
35 #include "components/display_compositor/host_shared_bitmap_manager.h" | 35 #include "components/viz/display_compositor/host_shared_bitmap_manager.h" |
36 #include "content/browser/browser_thread_impl.h" | 36 #include "content/browser/browser_thread_impl.h" |
37 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 37 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
38 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 38 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
39 #include "content/browser/gpu/compositor_util.h" | 39 #include "content/browser/gpu/compositor_util.h" |
40 #include "content/browser/renderer_host/delegated_frame_host.h" | 40 #include "content/browser/renderer_host/delegated_frame_host.h" |
41 #include "content/browser/renderer_host/delegated_frame_host_client_aura.h" | 41 #include "content/browser/renderer_host/delegated_frame_host_client_aura.h" |
42 #include "content/browser/renderer_host/input/input_router.h" | 42 #include "content/browser/renderer_host/input/input_router.h" |
43 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" | 43 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" |
44 #include "content/browser/renderer_host/overscroll_controller.h" | 44 #include "content/browser/renderer_host/overscroll_controller.h" |
45 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 45 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 444 |
445 void RunOnCompositingDidCommit() { | 445 void RunOnCompositingDidCommit() { |
446 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( | 446 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( |
447 window()->GetHost()->compositor()); | 447 window()->GetHost()->compositor()); |
448 } | 448 } |
449 | 449 |
450 void InterceptCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request) { | 450 void InterceptCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request) { |
451 last_copy_request_ = std::move(request); | 451 last_copy_request_ = std::move(request); |
452 if (last_copy_request_->has_texture_mailbox()) { | 452 if (last_copy_request_->has_texture_mailbox()) { |
453 // Give the resulting texture a size. | 453 // Give the resulting texture a size. |
454 display_compositor::GLHelper* gl_helper = | 454 viz::GLHelper* gl_helper = |
455 ImageTransportFactory::GetInstance()->GetGLHelper(); | 455 ImageTransportFactory::GetInstance()->GetGLHelper(); |
456 GLuint texture = gl_helper->ConsumeMailboxToTexture( | 456 GLuint texture = gl_helper->ConsumeMailboxToTexture( |
457 last_copy_request_->texture_mailbox().mailbox(), | 457 last_copy_request_->texture_mailbox().mailbox(), |
458 last_copy_request_->texture_mailbox().sync_token()); | 458 last_copy_request_->texture_mailbox().sync_token()); |
459 gl_helper->ResizeTexture(texture, window()->bounds().size()); | 459 gl_helper->ResizeTexture(texture, window()->bounds().size()); |
460 gl_helper->DeleteTexture(texture); | 460 gl_helper->DeleteTexture(texture); |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 cc::SurfaceId surface_id() const { | 464 cc::SurfaceId surface_id() const { |
(...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2717 | 2717 |
2718 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { | 2718 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { |
2719 view_->InitAsChild(nullptr); | 2719 view_->InitAsChild(nullptr); |
2720 | 2720 |
2721 size_t max_renderer_frames = | 2721 size_t max_renderer_frames = |
2722 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2722 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
2723 ASSERT_LE(2u, max_renderer_frames); | 2723 ASSERT_LE(2u, max_renderer_frames); |
2724 size_t renderer_count = max_renderer_frames + 1; | 2724 size_t renderer_count = max_renderer_frames + 1; |
2725 gfx::Rect view_rect(100, 100); | 2725 gfx::Rect view_rect(100, 100); |
2726 gfx::Size frame_size = view_rect.size(); | 2726 gfx::Size frame_size = view_rect.size(); |
2727 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() | 2727 DCHECK_EQ(0u, |
2728 ->AllocatedBitmapCount()); | 2728 viz::HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
2729 | 2729 |
2730 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2730 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2731 new RenderWidgetHostImpl*[renderer_count]); | 2731 new RenderWidgetHostImpl*[renderer_count]); |
2732 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2732 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2733 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2733 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2734 | 2734 |
2735 // Create a bunch of renderers. | 2735 // Create a bunch of renderers. |
2736 for (size_t i = 0; i < renderer_count; ++i) { | 2736 for (size_t i = 0; i < renderer_count; ++i) { |
2737 int32_t routing_id = process_host_->GetNextRoutingID(); | 2737 int32_t routing_id = process_host_->GetNextRoutingID(); |
2738 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2738 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2857 EXPECT_FALSE(views[1]->released_front_lock_active()); | 2857 EXPECT_FALSE(views[1]->released_front_lock_active()); |
2858 | 2858 |
2859 for (size_t i = 0; i < renderer_count - 1; ++i) | 2859 for (size_t i = 0; i < renderer_count - 1; ++i) |
2860 views[i]->Hide(); | 2860 views[i]->Hide(); |
2861 | 2861 |
2862 // Allocate enough bitmaps so that two frames (proportionally) would be | 2862 // Allocate enough bitmaps so that two frames (proportionally) would be |
2863 // enough hit the handle limit. | 2863 // enough hit the handle limit. |
2864 int handles_per_frame = 5; | 2864 int handles_per_frame = 5; |
2865 FrameEvictionManager::GetInstance()->set_max_handles(handles_per_frame * 2); | 2865 FrameEvictionManager::GetInstance()->set_max_handles(handles_per_frame * 2); |
2866 | 2866 |
2867 display_compositor::HostSharedBitmapManagerClient bitmap_client( | 2867 viz::HostSharedBitmapManagerClient bitmap_client( |
2868 display_compositor::HostSharedBitmapManager::current()); | 2868 viz::HostSharedBitmapManager::current()); |
2869 | 2869 |
2870 for (size_t i = 0; i < (renderer_count - 1) * handles_per_frame; i++) { | 2870 for (size_t i = 0; i < (renderer_count - 1) * handles_per_frame; i++) { |
2871 bitmap_client.ChildAllocatedSharedBitmap(1, base::SharedMemoryHandle(), | 2871 bitmap_client.ChildAllocatedSharedBitmap(1, base::SharedMemoryHandle(), |
2872 cc::SharedBitmap::GenerateId()); | 2872 cc::SharedBitmap::GenerateId()); |
2873 } | 2873 } |
2874 | 2874 |
2875 // Hiding this last bitmap should evict all but two frames. | 2875 // Hiding this last bitmap should evict all but two frames. |
2876 views[renderer_count - 1]->Hide(); | 2876 views[renderer_count - 1]->Hide(); |
2877 for (size_t i = 0; i < renderer_count; ++i) { | 2877 for (size_t i = 0; i < renderer_count; ++i) { |
2878 if (i + 2 < renderer_count) | 2878 if (i + 2 < renderer_count) |
(...skipping 12 matching lines...) Expand all Loading... |
2891 | 2891 |
2892 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { | 2892 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { |
2893 view_->InitAsChild(nullptr); | 2893 view_->InitAsChild(nullptr); |
2894 | 2894 |
2895 size_t max_renderer_frames = | 2895 size_t max_renderer_frames = |
2896 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2896 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
2897 ASSERT_LE(2u, max_renderer_frames); | 2897 ASSERT_LE(2u, max_renderer_frames); |
2898 size_t renderer_count = max_renderer_frames + 1; | 2898 size_t renderer_count = max_renderer_frames + 1; |
2899 gfx::Rect view_rect(100, 100); | 2899 gfx::Rect view_rect(100, 100); |
2900 gfx::Size frame_size = view_rect.size(); | 2900 gfx::Size frame_size = view_rect.size(); |
2901 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() | 2901 DCHECK_EQ(0u, |
2902 ->AllocatedBitmapCount()); | 2902 viz::HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
2903 | 2903 |
2904 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2904 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2905 new RenderWidgetHostImpl*[renderer_count]); | 2905 new RenderWidgetHostImpl*[renderer_count]); |
2906 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2906 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2907 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2907 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2908 | 2908 |
2909 // Create a bunch of renderers. | 2909 // Create a bunch of renderers. |
2910 for (size_t i = 0; i < renderer_count; ++i) { | 2910 for (size_t i = 0; i < renderer_count; ++i) { |
2911 int32_t routing_id = process_host_->GetNextRoutingID(); | 2911 int32_t routing_id = process_host_->GetNextRoutingID(); |
2912 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2912 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2964 // The test logic below relies on having max_renderer_frames > 2. By default, | 2964 // The test logic below relies on having max_renderer_frames > 2. By default, |
2965 // this value is calculated from total physical memory and causes the test to | 2965 // this value is calculated from total physical memory and causes the test to |
2966 // fail when run on hardware with < 256MB of RAM. | 2966 // fail when run on hardware with < 256MB of RAM. |
2967 const size_t kMaxRendererFrames = 5; | 2967 const size_t kMaxRendererFrames = 5; |
2968 FrameEvictionManager::GetInstance()->set_max_number_of_saved_frames( | 2968 FrameEvictionManager::GetInstance()->set_max_number_of_saved_frames( |
2969 kMaxRendererFrames); | 2969 kMaxRendererFrames); |
2970 | 2970 |
2971 size_t renderer_count = kMaxRendererFrames; | 2971 size_t renderer_count = kMaxRendererFrames; |
2972 gfx::Rect view_rect(100, 100); | 2972 gfx::Rect view_rect(100, 100); |
2973 gfx::Size frame_size = view_rect.size(); | 2973 gfx::Size frame_size = view_rect.size(); |
2974 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() | 2974 DCHECK_EQ(0u, |
2975 ->AllocatedBitmapCount()); | 2975 viz::HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
2976 | 2976 |
2977 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2977 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2978 new RenderWidgetHostImpl*[renderer_count]); | 2978 new RenderWidgetHostImpl*[renderer_count]); |
2979 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2979 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2980 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2980 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2981 | 2981 |
2982 // Create a bunch of renderers. | 2982 // Create a bunch of renderers. |
2983 for (size_t i = 0; i < renderer_count; ++i) { | 2983 for (size_t i = 0; i < renderer_count; ++i) { |
2984 int32_t routing_id = process_host_->GetNextRoutingID(); | 2984 int32_t routing_id = process_host_->GetNextRoutingID(); |
2985 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2985 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 2506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5492 // There is no composition in the beginning. | 5492 // There is no composition in the beginning. |
5493 EXPECT_FALSE(has_composition_text()); | 5493 EXPECT_FALSE(has_composition_text()); |
5494 SetHasCompositionTextToTrue(); | 5494 SetHasCompositionTextToTrue(); |
5495 view->ImeCancelComposition(); | 5495 view->ImeCancelComposition(); |
5496 // The composition must have been canceled. | 5496 // The composition must have been canceled. |
5497 EXPECT_FALSE(has_composition_text()); | 5497 EXPECT_FALSE(has_composition_text()); |
5498 } | 5498 } |
5499 } | 5499 } |
5500 | 5500 |
5501 } // namespace content | 5501 } // namespace content |
OLD | NEW |