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 #include <utility> |
9 | 10 |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "base/test/simple_test_tick_clock.h" | 17 #include "base/test/simple_test_tick_clock.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "cc/output/begin_frame_args.h" | 19 #include "cc/output/begin_frame_args.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { | 260 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { |
260 public: | 261 public: |
261 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget, | 262 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget, |
262 bool is_guest_view_hack) | 263 bool is_guest_view_hack) |
263 : RenderWidgetHostViewAura(widget, is_guest_view_hack), | 264 : RenderWidgetHostViewAura(widget, is_guest_view_hack), |
264 has_resize_lock_(false) {} | 265 has_resize_lock_(false) {} |
265 | 266 |
266 void UseFakeDispatcher() { | 267 void UseFakeDispatcher() { |
267 dispatcher_ = new FakeWindowEventDispatcher(window()->GetHost()); | 268 dispatcher_ = new FakeWindowEventDispatcher(window()->GetHost()); |
268 scoped_ptr<aura::WindowEventDispatcher> dispatcher(dispatcher_); | 269 scoped_ptr<aura::WindowEventDispatcher> dispatcher(dispatcher_); |
269 aura::test::SetHostDispatcher(window()->GetHost(), dispatcher.Pass()); | 270 aura::test::SetHostDispatcher(window()->GetHost(), std::move(dispatcher)); |
270 } | 271 } |
271 | 272 |
272 ~FakeRenderWidgetHostViewAura() override {} | 273 ~FakeRenderWidgetHostViewAura() override {} |
273 | 274 |
274 scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( | 275 scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( |
275 bool defer_compositor_lock) override { | 276 bool defer_compositor_lock) override { |
276 gfx::Size desired_size = window()->bounds().size(); | 277 gfx::Size desired_size = window()->bounds().size(); |
277 return scoped_ptr<ResizeLock>( | 278 return scoped_ptr<ResizeLock>( |
278 new FakeResizeLock(desired_size, defer_compositor_lock)); | 279 new FakeResizeLock(desired_size, defer_compositor_lock)); |
279 } | 280 } |
280 | 281 |
281 bool DelegatedFrameCanCreateResizeLock() const override { return true; } | 282 bool DelegatedFrameCanCreateResizeLock() const override { return true; } |
282 | 283 |
283 void RunOnCompositingDidCommit() { | 284 void RunOnCompositingDidCommit() { |
284 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( | 285 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( |
285 window()->GetHost()->compositor()); | 286 window()->GetHost()->compositor()); |
286 } | 287 } |
287 | 288 |
288 void InterceptCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { | 289 void InterceptCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { |
289 last_copy_request_ = request.Pass(); | 290 last_copy_request_ = std::move(request); |
290 if (last_copy_request_->has_texture_mailbox()) { | 291 if (last_copy_request_->has_texture_mailbox()) { |
291 // Give the resulting texture a size. | 292 // Give the resulting texture a size. |
292 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 293 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
293 GLuint texture = gl_helper->ConsumeMailboxToTexture( | 294 GLuint texture = gl_helper->ConsumeMailboxToTexture( |
294 last_copy_request_->texture_mailbox().mailbox(), | 295 last_copy_request_->texture_mailbox().mailbox(), |
295 last_copy_request_->texture_mailbox().sync_token()); | 296 last_copy_request_->texture_mailbox().sync_token()); |
296 gl_helper->ResizeTexture(texture, window()->bounds().size()); | 297 gl_helper->ResizeTexture(texture, window()->bounds().size()); |
297 gl_helper->DeleteTexture(texture); | 298 gl_helper->DeleteTexture(texture); |
298 } | 299 } |
299 } | 300 } |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 scoped_ptr<cc::CompositorFrame> MakeDelegatedFrame(float scale_factor, | 1524 scoped_ptr<cc::CompositorFrame> MakeDelegatedFrame(float scale_factor, |
1524 gfx::Size size, | 1525 gfx::Size size, |
1525 gfx::Rect damage) { | 1526 gfx::Rect damage) { |
1526 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | 1527 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); |
1527 frame->metadata.device_scale_factor = scale_factor; | 1528 frame->metadata.device_scale_factor = scale_factor; |
1528 frame->delegated_frame_data.reset(new cc::DelegatedFrameData); | 1529 frame->delegated_frame_data.reset(new cc::DelegatedFrameData); |
1529 | 1530 |
1530 scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); | 1531 scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); |
1531 pass->SetNew( | 1532 pass->SetNew( |
1532 cc::RenderPassId(1, 1), gfx::Rect(size), damage, gfx::Transform()); | 1533 cc::RenderPassId(1, 1), gfx::Rect(size), damage, gfx::Transform()); |
1533 frame->delegated_frame_data->render_pass_list.push_back(pass.Pass()); | 1534 frame->delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
1534 return frame.Pass(); | 1535 return frame; |
1535 } | 1536 } |
1536 | 1537 |
1537 // Resizing in fullscreen mode should send the up-to-date screen info. | 1538 // Resizing in fullscreen mode should send the up-to-date screen info. |
1538 // http://crbug.com/324350 | 1539 // http://crbug.com/324350 |
1539 TEST_F(RenderWidgetHostViewAuraTest, DISABLED_FullscreenResize) { | 1540 TEST_F(RenderWidgetHostViewAuraTest, DISABLED_FullscreenResize) { |
1540 aura::Window* root_window = aura_test_helper_->root_window(); | 1541 aura::Window* root_window = aura_test_helper_->root_window(); |
1541 root_window->SetLayoutManager(new FullscreenLayoutManager(root_window)); | 1542 root_window->SetLayoutManager(new FullscreenLayoutManager(root_window)); |
1542 view_->InitAsFullscreen(parent_view_); | 1543 view_->InitAsFullscreen(parent_view_); |
1543 view_->Show(); | 1544 view_->Show(); |
1544 widget_host_->ResetSizeAndRepaintPendingFlags(); | 1545 widget_host_->ResetSizeAndRepaintPendingFlags(); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2288 1, MakeDelegatedFrame(1.f, view_rect_.size(), view_rect_)); | 2289 1, MakeDelegatedFrame(1.f, view_rect_.size(), view_rect_)); |
2289 cc::SurfaceId surface_id = | 2290 cc::SurfaceId surface_id = |
2290 view_->GetDelegatedFrameHost()->SurfaceIdForTesting(); | 2291 view_->GetDelegatedFrameHost()->SurfaceIdForTesting(); |
2291 if (!surface_id.is_null()) | 2292 if (!surface_id.is_null()) |
2292 view_->GetDelegatedFrameHost()->WillDrawSurface(surface_id, view_rect_); | 2293 view_->GetDelegatedFrameHost()->WillDrawSurface(surface_id, view_rect_); |
2293 ASSERT_TRUE(view_->last_copy_request_); | 2294 ASSERT_TRUE(view_->last_copy_request_); |
2294 } | 2295 } |
2295 | 2296 |
2296 void ReleaseSwappedFrame() { | 2297 void ReleaseSwappedFrame() { |
2297 scoped_ptr<cc::CopyOutputRequest> request = | 2298 scoped_ptr<cc::CopyOutputRequest> request = |
2298 view_->last_copy_request_.Pass(); | 2299 std::move(view_->last_copy_request_); |
2299 request->SendTextureResult(view_rect_.size(), request->texture_mailbox(), | 2300 request->SendTextureResult(view_rect_.size(), request->texture_mailbox(), |
2300 scoped_ptr<cc::SingleReleaseCallback>()); | 2301 scoped_ptr<cc::SingleReleaseCallback>()); |
2301 RunLoopUntilCallback(); | 2302 RunLoopUntilCallback(); |
2302 } | 2303 } |
2303 | 2304 |
2304 void OnSwapCompositorFrameAndRelease() { | 2305 void OnSwapCompositorFrameAndRelease() { |
2305 OnSwapCompositorFrame(); | 2306 OnSwapCompositorFrame(); |
2306 ReleaseSwappedFrame(); | 2307 ReleaseSwappedFrame(); |
2307 } | 2308 } |
2308 | 2309 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 // Send back the mailbox included in the request. There's no release callback | 2401 // Send back the mailbox included in the request. There's no release callback |
2401 // since the mailbox came from the RWHVA originally. | 2402 // since the mailbox came from the RWHVA originally. |
2402 RunOnCompositingDidCommitAndReleaseFrame(); | 2403 RunOnCompositingDidCommitAndReleaseFrame(); |
2403 | 2404 |
2404 // The callback should succeed. | 2405 // The callback should succeed. |
2405 EXPECT_EQ(1, callback_count_); | 2406 EXPECT_EQ(1, callback_count_); |
2406 EXPECT_TRUE(result_); | 2407 EXPECT_TRUE(result_); |
2407 | 2408 |
2408 OnSwapCompositorFrame(); | 2409 OnSwapCompositorFrame(); |
2409 EXPECT_EQ(1, callback_count_); | 2410 EXPECT_EQ(1, callback_count_); |
2410 scoped_ptr<cc::CopyOutputRequest> request = view_->last_copy_request_.Pass(); | 2411 scoped_ptr<cc::CopyOutputRequest> request = |
| 2412 std::move(view_->last_copy_request_); |
2411 | 2413 |
2412 // Destroy the RenderWidgetHostViewAura and ImageTransportFactory. | 2414 // Destroy the RenderWidgetHostViewAura and ImageTransportFactory. |
2413 TearDownEnvironment(); | 2415 TearDownEnvironment(); |
2414 | 2416 |
2415 // Send the result after-the-fact. It goes nowhere since DelegatedFrameHost | 2417 // Send the result after-the-fact. It goes nowhere since DelegatedFrameHost |
2416 // has been destroyed. | 2418 // has been destroyed. |
2417 request->SendTextureResult(view_rect_.size(), request->texture_mailbox(), | 2419 request->SendTextureResult(view_rect_.size(), request->texture_mailbox(), |
2418 scoped_ptr<cc::SingleReleaseCallback>()); | 2420 scoped_ptr<cc::SingleReleaseCallback>()); |
2419 | 2421 |
2420 // Because the copy request callback may be holding state within it, that | 2422 // Because the copy request callback may be holding state within it, that |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3636 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); | 3638 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); |
3637 view_->InitAsChild(NULL); | 3639 view_->InitAsChild(NULL); |
3638 view_->Show(); | 3640 view_->Show(); |
3639 view_->SetSize(size); | 3641 view_->SetSize(size); |
3640 view_->OnSwapCompositorFrame(0, | 3642 view_->OnSwapCompositorFrame(0, |
3641 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); | 3643 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); |
3642 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); | 3644 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); |
3643 } | 3645 } |
3644 | 3646 |
3645 } // namespace content | 3647 } // namespace content |
OLD | NEW |