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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return scoped_ptr<ResizeLock>( | 162 return scoped_ptr<ResizeLock>( |
163 new FakeResizeLock(desired_size, defer_compositor_lock)); | 163 new FakeResizeLock(desired_size, defer_compositor_lock)); |
164 } | 164 } |
165 | 165 |
166 void RunOnCompositingDidCommit() { | 166 void RunOnCompositingDidCommit() { |
167 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( | 167 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( |
168 window()->GetHost()->compositor()); | 168 window()->GetHost()->compositor()); |
169 } | 169 } |
170 | 170 |
171 virtual bool ShouldCreateResizeLock() OVERRIDE { | 171 virtual bool ShouldCreateResizeLock() OVERRIDE { |
172 gfx::Size desired_size = window()->bounds().size(); | 172 return GetDelegatedFrameHost()->ShouldCreateResizeLockForTesting(); |
173 return desired_size != | |
174 GetDelegatedFrameHost()->CurrentFrameSizeInDIPForTesting(); | |
175 } | 173 } |
176 | 174 |
177 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) | 175 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) |
178 OVERRIDE { | 176 OVERRIDE { |
179 last_copy_request_ = request.Pass(); | 177 last_copy_request_ = request.Pass(); |
180 if (last_copy_request_->has_texture_mailbox()) { | 178 if (last_copy_request_->has_texture_mailbox()) { |
181 // Give the resulting texture a size. | 179 // Give the resulting texture a size. |
182 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 180 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
183 GLuint texture = gl_helper->ConsumeMailboxToTexture( | 181 GLuint texture = gl_helper->ConsumeMailboxToTexture( |
184 last_copy_request_->texture_mailbox().mailbox(), | 182 last_copy_request_->texture_mailbox().mailbox(), |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 EXPECT_CALL(observer, | 979 EXPECT_CALL(observer, |
982 OnWindowPaintScheduled(view_->window_, partial_view_rect)); | 980 OnWindowPaintScheduled(view_->window_, partial_view_rect)); |
983 view_->OnSwapCompositorFrame( | 981 view_->OnSwapCompositorFrame( |
984 0, MakeDelegatedFrame(1.f, frame_size, partial_view_rect)); | 982 0, MakeDelegatedFrame(1.f, frame_size, partial_view_rect)); |
985 testing::Mock::VerifyAndClearExpectations(&observer); | 983 testing::Mock::VerifyAndClearExpectations(&observer); |
986 view_->RunOnCompositingDidCommit(); | 984 view_->RunOnCompositingDidCommit(); |
987 | 985 |
988 // Lock the compositor. Now we should drop frames. | 986 // Lock the compositor. Now we should drop frames. |
989 view_rect = gfx::Rect(150, 150); | 987 view_rect = gfx::Rect(150, 150); |
990 view_->SetSize(view_rect.size()); | 988 view_->SetSize(view_rect.size()); |
991 view_->GetDelegatedFrameHost()->MaybeCreateResizeLock(); | |
992 | 989 |
993 // This frame is dropped. | 990 // This frame is dropped. |
994 gfx::Rect dropped_damage_rect_1(10, 20, 30, 40); | 991 gfx::Rect dropped_damage_rect_1(10, 20, 30, 40); |
995 EXPECT_CALL(observer, OnWindowPaintScheduled(_, _)).Times(0); | 992 EXPECT_CALL(observer, OnWindowPaintScheduled(_, _)).Times(0); |
996 view_->OnSwapCompositorFrame( | 993 view_->OnSwapCompositorFrame( |
997 0, MakeDelegatedFrame(1.f, frame_size, dropped_damage_rect_1)); | 994 0, MakeDelegatedFrame(1.f, frame_size, dropped_damage_rect_1)); |
998 testing::Mock::VerifyAndClearExpectations(&observer); | 995 testing::Mock::VerifyAndClearExpectations(&observer); |
999 view_->RunOnCompositingDidCommit(); | 996 view_->RunOnCompositingDidCommit(); |
1000 | 997 |
1001 gfx::Rect dropped_damage_rect_2(40, 50, 10, 20); | 998 gfx::Rect dropped_damage_rect_2(40, 50, 10, 20); |
(...skipping 16 matching lines...) Expand all Loading... |
1018 | 1015 |
1019 // A partial damage frame, this should not be dropped. | 1016 // A partial damage frame, this should not be dropped. |
1020 EXPECT_CALL(observer, | 1017 EXPECT_CALL(observer, |
1021 OnWindowPaintScheduled(view_->window_, partial_view_rect)); | 1018 OnWindowPaintScheduled(view_->window_, partial_view_rect)); |
1022 view_->OnSwapCompositorFrame( | 1019 view_->OnSwapCompositorFrame( |
1023 0, MakeDelegatedFrame(1.f, frame_size, partial_view_rect)); | 1020 0, MakeDelegatedFrame(1.f, frame_size, partial_view_rect)); |
1024 testing::Mock::VerifyAndClearExpectations(&observer); | 1021 testing::Mock::VerifyAndClearExpectations(&observer); |
1025 view_->RunOnCompositingDidCommit(); | 1022 view_->RunOnCompositingDidCommit(); |
1026 | 1023 |
1027 | 1024 |
| 1025 // Resize to something empty. |
| 1026 view_rect = gfx::Rect(100, 0); |
| 1027 view_->SetSize(view_rect.size()); |
| 1028 |
| 1029 // We're never expecting empty frames, resize to something non-empty. |
| 1030 view_rect = gfx::Rect(100, 100); |
| 1031 view_->SetSize(view_rect.size()); |
| 1032 |
| 1033 // This frame should not be dropped. |
| 1034 EXPECT_CALL(observer, OnWindowPaintScheduled(view_->window_, view_rect)); |
| 1035 view_->OnSwapCompositorFrame( |
| 1036 0, MakeDelegatedFrame(1.f, view_rect.size(), view_rect)); |
| 1037 testing::Mock::VerifyAndClearExpectations(&observer); |
| 1038 view_->RunOnCompositingDidCommit(); |
| 1039 |
1028 view_->window_->RemoveObserver(&observer); | 1040 view_->window_->RemoveObserver(&observer); |
1029 } | 1041 } |
1030 | 1042 |
1031 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) { | 1043 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) { |
1032 gfx::Rect view_rect(100, 100); | 1044 gfx::Rect view_rect(100, 100); |
1033 gfx::Size frame_size = view_rect.size(); | 1045 gfx::Size frame_size = view_rect.size(); |
1034 | 1046 |
1035 view_->InitAsChild(NULL); | 1047 view_->InitAsChild(NULL); |
1036 aura::client::ParentWindowWithContext( | 1048 aura::client::ParentWindowWithContext( |
1037 view_->GetNativeView(), | 1049 view_->GetNativeView(), |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 const IPC::Message *message = sink_->GetFirstMessageMatching( | 1426 const IPC::Message *message = sink_->GetFirstMessageMatching( |
1415 ViewMsg_Resize::ID); | 1427 ViewMsg_Resize::ID); |
1416 ASSERT_TRUE(message != NULL); | 1428 ASSERT_TRUE(message != NULL); |
1417 | 1429 |
1418 ViewMsg_Resize::Param params; | 1430 ViewMsg_Resize::Param params; |
1419 ViewMsg_Resize::Read(message, ¶ms); | 1431 ViewMsg_Resize::Read(message, ¶ms); |
1420 EXPECT_EQ(60, params.a.visible_viewport_size.height()); | 1432 EXPECT_EQ(60, params.a.visible_viewport_size.height()); |
1421 } | 1433 } |
1422 | 1434 |
1423 } // namespace content | 1435 } // namespace content |
OLD | NEW |