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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 void RunOnCompositingDidCommit() { | 450 void RunOnCompositingDidCommit() { |
451 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( | 451 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( |
452 window()->GetHost()->compositor()); | 452 window()->GetHost()->compositor()); |
453 } | 453 } |
454 | 454 |
455 void InterceptCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request) { | 455 void InterceptCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request) { |
456 last_copy_request_ = std::move(request); | 456 last_copy_request_ = std::move(request); |
457 if (last_copy_request_->has_texture_mailbox()) { | 457 if (last_copy_request_->has_texture_mailbox()) { |
458 // Give the resulting texture a size. | 458 // Give the resulting texture a size. |
459 display_compositor::GLHelper* gl_helper = | 459 viz::GLHelper* gl_helper = |
460 ImageTransportFactory::GetInstance()->GetGLHelper(); | 460 ImageTransportFactory::GetInstance()->GetGLHelper(); |
461 GLuint texture = gl_helper->ConsumeMailboxToTexture( | 461 GLuint texture = gl_helper->ConsumeMailboxToTexture( |
462 last_copy_request_->texture_mailbox().mailbox(), | 462 last_copy_request_->texture_mailbox().mailbox(), |
463 last_copy_request_->texture_mailbox().sync_token()); | 463 last_copy_request_->texture_mailbox().sync_token()); |
464 gl_helper->ResizeTexture(texture, window()->bounds().size()); | 464 gl_helper->ResizeTexture(texture, window()->bounds().size()); |
465 gl_helper->DeleteTexture(texture); | 465 gl_helper->DeleteTexture(texture); |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 cc::SurfaceId surface_id() const { | 469 cc::SurfaceId surface_id() const { |
(...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 | 2722 |
2723 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { | 2723 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { |
2724 view_->InitAsChild(nullptr); | 2724 view_->InitAsChild(nullptr); |
2725 | 2725 |
2726 size_t max_renderer_frames = | 2726 size_t max_renderer_frames = |
2727 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2727 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
2728 ASSERT_LE(2u, max_renderer_frames); | 2728 ASSERT_LE(2u, max_renderer_frames); |
2729 size_t renderer_count = max_renderer_frames + 1; | 2729 size_t renderer_count = max_renderer_frames + 1; |
2730 gfx::Rect view_rect(100, 100); | 2730 gfx::Rect view_rect(100, 100); |
2731 gfx::Size frame_size = view_rect.size(); | 2731 gfx::Size frame_size = view_rect.size(); |
2732 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() | 2732 DCHECK_EQ(0u, |
2733 ->AllocatedBitmapCount()); | 2733 viz::HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
2734 | 2734 |
2735 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2735 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2736 new RenderWidgetHostImpl*[renderer_count]); | 2736 new RenderWidgetHostImpl*[renderer_count]); |
2737 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2737 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2738 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2738 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2739 | 2739 |
2740 // Create a bunch of renderers. | 2740 // Create a bunch of renderers. |
2741 for (size_t i = 0; i < renderer_count; ++i) { | 2741 for (size_t i = 0; i < renderer_count; ++i) { |
2742 int32_t routing_id = process_host_->GetNextRoutingID(); | 2742 int32_t routing_id = process_host_->GetNextRoutingID(); |
2743 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2743 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2862 EXPECT_FALSE(views[1]->released_front_lock_active()); | 2862 EXPECT_FALSE(views[1]->released_front_lock_active()); |
2863 | 2863 |
2864 for (size_t i = 0; i < renderer_count - 1; ++i) | 2864 for (size_t i = 0; i < renderer_count - 1; ++i) |
2865 views[i]->Hide(); | 2865 views[i]->Hide(); |
2866 | 2866 |
2867 // Allocate enough bitmaps so that two frames (proportionally) would be | 2867 // Allocate enough bitmaps so that two frames (proportionally) would be |
2868 // enough hit the handle limit. | 2868 // enough hit the handle limit. |
2869 int handles_per_frame = 5; | 2869 int handles_per_frame = 5; |
2870 FrameEvictionManager::GetInstance()->set_max_handles(handles_per_frame * 2); | 2870 FrameEvictionManager::GetInstance()->set_max_handles(handles_per_frame * 2); |
2871 | 2871 |
2872 display_compositor::HostSharedBitmapManagerClient bitmap_client( | 2872 viz::HostSharedBitmapManagerClient bitmap_client( |
2873 display_compositor::HostSharedBitmapManager::current()); | 2873 viz::HostSharedBitmapManager::current()); |
2874 | 2874 |
2875 for (size_t i = 0; i < (renderer_count - 1) * handles_per_frame; i++) { | 2875 for (size_t i = 0; i < (renderer_count - 1) * handles_per_frame; i++) { |
2876 bitmap_client.ChildAllocatedSharedBitmap(1, base::SharedMemoryHandle(), | 2876 bitmap_client.ChildAllocatedSharedBitmap(1, base::SharedMemoryHandle(), |
2877 cc::SharedBitmap::GenerateId()); | 2877 cc::SharedBitmap::GenerateId()); |
2878 } | 2878 } |
2879 | 2879 |
2880 // Hiding this last bitmap should evict all but two frames. | 2880 // Hiding this last bitmap should evict all but two frames. |
2881 views[renderer_count - 1]->Hide(); | 2881 views[renderer_count - 1]->Hide(); |
2882 for (size_t i = 0; i < renderer_count; ++i) { | 2882 for (size_t i = 0; i < renderer_count; ++i) { |
2883 if (i + 2 < renderer_count) | 2883 if (i + 2 < renderer_count) |
(...skipping 12 matching lines...) Expand all Loading... |
2896 | 2896 |
2897 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { | 2897 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { |
2898 view_->InitAsChild(nullptr); | 2898 view_->InitAsChild(nullptr); |
2899 | 2899 |
2900 size_t max_renderer_frames = | 2900 size_t max_renderer_frames = |
2901 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2901 FrameEvictionManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
2902 ASSERT_LE(2u, max_renderer_frames); | 2902 ASSERT_LE(2u, max_renderer_frames); |
2903 size_t renderer_count = max_renderer_frames + 1; | 2903 size_t renderer_count = max_renderer_frames + 1; |
2904 gfx::Rect view_rect(100, 100); | 2904 gfx::Rect view_rect(100, 100); |
2905 gfx::Size frame_size = view_rect.size(); | 2905 gfx::Size frame_size = view_rect.size(); |
2906 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() | 2906 DCHECK_EQ(0u, |
2907 ->AllocatedBitmapCount()); | 2907 viz::HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
2908 | 2908 |
2909 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2909 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2910 new RenderWidgetHostImpl*[renderer_count]); | 2910 new RenderWidgetHostImpl*[renderer_count]); |
2911 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2911 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2912 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2912 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2913 | 2913 |
2914 // Create a bunch of renderers. | 2914 // Create a bunch of renderers. |
2915 for (size_t i = 0; i < renderer_count; ++i) { | 2915 for (size_t i = 0; i < renderer_count; ++i) { |
2916 int32_t routing_id = process_host_->GetNextRoutingID(); | 2916 int32_t routing_id = process_host_->GetNextRoutingID(); |
2917 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2917 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2969 // The test logic below relies on having max_renderer_frames > 2. By default, | 2969 // The test logic below relies on having max_renderer_frames > 2. By default, |
2970 // this value is calculated from total physical memory and causes the test to | 2970 // this value is calculated from total physical memory and causes the test to |
2971 // fail when run on hardware with < 256MB of RAM. | 2971 // fail when run on hardware with < 256MB of RAM. |
2972 const size_t kMaxRendererFrames = 5; | 2972 const size_t kMaxRendererFrames = 5; |
2973 FrameEvictionManager::GetInstance()->set_max_number_of_saved_frames( | 2973 FrameEvictionManager::GetInstance()->set_max_number_of_saved_frames( |
2974 kMaxRendererFrames); | 2974 kMaxRendererFrames); |
2975 | 2975 |
2976 size_t renderer_count = kMaxRendererFrames; | 2976 size_t renderer_count = kMaxRendererFrames; |
2977 gfx::Rect view_rect(100, 100); | 2977 gfx::Rect view_rect(100, 100); |
2978 gfx::Size frame_size = view_rect.size(); | 2978 gfx::Size frame_size = view_rect.size(); |
2979 DCHECK_EQ(0u, display_compositor::HostSharedBitmapManager::current() | 2979 DCHECK_EQ(0u, |
2980 ->AllocatedBitmapCount()); | 2980 viz::HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
2981 | 2981 |
2982 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2982 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
2983 new RenderWidgetHostImpl*[renderer_count]); | 2983 new RenderWidgetHostImpl*[renderer_count]); |
2984 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2984 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
2985 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2985 new FakeRenderWidgetHostViewAura*[renderer_count]); |
2986 | 2986 |
2987 // Create a bunch of renderers. | 2987 // Create a bunch of renderers. |
2988 for (size_t i = 0; i < renderer_count; ++i) { | 2988 for (size_t i = 0; i < renderer_count; ++i) { |
2989 int32_t routing_id = process_host_->GetNextRoutingID(); | 2989 int32_t routing_id = process_host_->GetNextRoutingID(); |
2990 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2990 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
(...skipping 2556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5547 // There is no composition in the beginning. | 5547 // There is no composition in the beginning. |
5548 EXPECT_FALSE(has_composition_text()); | 5548 EXPECT_FALSE(has_composition_text()); |
5549 SetHasCompositionTextToTrue(); | 5549 SetHasCompositionTextToTrue(); |
5550 view->ImeCancelComposition(); | 5550 view->ImeCancelComposition(); |
5551 // The composition must have been canceled. | 5551 // The composition must have been canceled. |
5552 EXPECT_FALSE(has_composition_text()); | 5552 EXPECT_FALSE(has_composition_text()); |
5553 } | 5553 } |
5554 } | 5554 } |
5555 | 5555 |
5556 } // namespace content | 5556 } // namespace content |
OLD | NEW |