| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/barrier_closure.h" | 8 #include "base/barrier_closure.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 GetRenderWidgetHost()); | 104 GetRenderWidgetHost()); |
| 105 CHECK(rwh); | 105 CHECK(rwh); |
| 106 return rwh; | 106 return rwh; |
| 107 } | 107 } |
| 108 | 108 |
| 109 RenderWidgetHostViewBase* GetRenderWidgetHostView() const { | 109 RenderWidgetHostViewBase* GetRenderWidgetHostView() const { |
| 110 return static_cast<RenderWidgetHostViewBase*>( | 110 return static_cast<RenderWidgetHostViewBase*>( |
| 111 GetRenderViewHost()->GetWidget()->GetView()); | 111 GetRenderViewHost()->GetWidget()->GetView()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Callback when using CopyFromBackingStore() API. | 114 // Callback when using CopyFromSurface() API. |
| 115 void FinishCopyFromBackingStore(const base::Closure& quit_closure, | 115 void FinishCopyFromSurface(const base::Closure& quit_closure, |
| 116 const SkBitmap& bitmap, | 116 const SkBitmap& bitmap, |
| 117 ReadbackResponse response) { | 117 ReadbackResponse response) { |
| 118 ++callback_invoke_count_; | 118 ++callback_invoke_count_; |
| 119 if (response == READBACK_SUCCESS) { | 119 if (response == READBACK_SUCCESS) { |
| 120 ++frames_captured_; | 120 ++frames_captured_; |
| 121 EXPECT_FALSE(bitmap.empty()); | 121 EXPECT_FALSE(bitmap.empty()); |
| 122 } | 122 } |
| 123 if (!quit_closure.is_null()) | 123 if (!quit_closure.is_null()) |
| 124 quit_closure.Run(); | 124 quit_closure.Run(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Callback when using CopyFromCompositingSurfaceToVideoFrame() API. | 127 // Callback when using CopyFromSurfaceToVideoFrame() API. |
| 128 void FinishCopyFromCompositingSurface(const base::Closure& quit_closure, | 128 void FinishCopyFromSurfaceToVideoFrame(const base::Closure& quit_closure, |
| 129 const gfx::Rect& region_in_frame, | 129 const gfx::Rect& region_in_frame, |
| 130 bool frame_captured) { | 130 bool frame_captured) { |
| 131 ++callback_invoke_count_; | 131 ++callback_invoke_count_; |
| 132 if (frame_captured) | 132 if (frame_captured) |
| 133 ++frames_captured_; | 133 ++frames_captured_; |
| 134 if (!quit_closure.is_null()) | 134 if (!quit_closure.is_null()) |
| 135 quit_closure.Run(); | 135 quit_closure.Run(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Callback when using frame subscriber API. | 138 // Callback when using frame subscriber API. |
| 139 void FrameDelivered( | 139 void FrameDelivered( |
| 140 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 140 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 141 base::Closure quit_closure, | 141 base::Closure quit_closure, |
| 142 base::TimeTicks timestamp, | 142 base::TimeTicks timestamp, |
| 143 const gfx::Rect& region_in_frame, | 143 const gfx::Rect& region_in_frame, |
| 144 bool frame_captured) { | 144 bool frame_captured) { |
| 145 ++callback_invoke_count_; | 145 ++callback_invoke_count_; |
| 146 if (frame_captured) | 146 if (frame_captured) |
| 147 ++frames_captured_; | 147 ++frames_captured_; |
| 148 if (!quit_closure.is_null()) | 148 if (!quit_closure.is_null()) |
| 149 task_runner->PostTask(FROM_HERE, quit_closure); | 149 task_runner->PostTask(FROM_HERE, quit_closure); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Copy one frame using the CopyFromBackingStore API. | 152 // Copy one frame using the CopyFromSurface API. |
| 153 void RunBasicCopyFromBackingStoreTest() { | 153 void RunBasicCopyFromSurfaceTest() { |
| 154 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 154 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
| 155 | 155 |
| 156 // Repeatedly call CopyFromBackingStore() since, on some platforms (e.g., | 156 // Repeatedly call CopyFromBackingStore() since, on some platforms (e.g., |
| 157 // Windows), the operation will fail until the first "present" has been | 157 // Windows), the operation will fail until the first "present" has been |
| 158 // made. | 158 // made. |
| 159 int count_attempts = 0; | 159 int count_attempts = 0; |
| 160 while (true) { | 160 while (true) { |
| 161 ++count_attempts; | 161 ++count_attempts; |
| 162 base::RunLoop run_loop; | 162 base::RunLoop run_loop; |
| 163 GetRenderViewHost()->GetWidget()->CopyFromBackingStore( | 163 GetRenderWidgetHostView()->CopyFromSurface( |
| 164 gfx::Rect(), frame_size(), | 164 gfx::Rect(), frame_size(), |
| 165 base::Bind( | 165 base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromSurface, |
| 166 &RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, | 166 base::Unretained(this), run_loop.QuitClosure()), |
| 167 base::Unretained(this), run_loop.QuitClosure()), | |
| 168 kN32_SkColorType); | 167 kN32_SkColorType); |
| 169 run_loop.Run(); | 168 run_loop.Run(); |
| 170 | 169 |
| 171 if (frames_captured()) | 170 if (frames_captured()) |
| 172 break; | 171 break; |
| 173 else | 172 else |
| 174 GiveItSomeTime(); | 173 GiveItSomeTime(); |
| 175 } | 174 } |
| 176 | 175 |
| 177 EXPECT_EQ(count_attempts, callback_invoke_count()); | 176 EXPECT_EQ(count_attempts, callback_invoke_count()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 } | 275 } |
| 277 | 276 |
| 278 private: | 277 private: |
| 279 DeliverFrameCallback callback_; | 278 DeliverFrameCallback callback_; |
| 280 base::UnguessableToken source_id_for_copy_request_; | 279 base::UnguessableToken source_id_for_copy_request_; |
| 281 }; | 280 }; |
| 282 | 281 |
| 283 // Disable tests for Android as it has an incomplete implementation. | 282 // Disable tests for Android as it has an incomplete implementation. |
| 284 #if !defined(OS_ANDROID) | 283 #if !defined(OS_ANDROID) |
| 285 | 284 |
| 286 // The CopyFromBackingStore() API should work on all platforms when compositing | 285 // The CopyFromSurface() API should work on all platforms when compositing is |
| 287 // is enabled. | 286 // enabled. |
| 288 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, | 287 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
| 289 CopyFromBackingStore) { | 288 CopyFromSurface) { |
| 290 RunBasicCopyFromBackingStoreTest(); | 289 RunBasicCopyFromSurfaceTest(); |
| 291 } | 290 } |
| 292 | 291 |
| 293 // Tests that the callback passed to CopyFromBackingStore is always called, | 292 // Tests that the callback passed to CopyFromSurface is always called, even |
| 294 // even when the RenderWidgetHost is deleting in the middle of an async copy. | 293 // when the RenderWidgetHostView is deleting in the middle of an async copy. |
| 295 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, | 294 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
| 296 CopyFromBackingStore_CallbackDespiteDelete) { | 295 CopyFromSurface_CallbackDespiteDelete) { |
| 297 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 296 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
| 298 | 297 |
| 299 base::RunLoop run_loop; | 298 base::RunLoop run_loop; |
| 300 GetRenderViewHost()->GetWidget()->CopyFromBackingStore( | 299 GetRenderWidgetHostView()->CopyFromSurface( |
| 301 gfx::Rect(), frame_size(), | 300 gfx::Rect(), frame_size(), |
| 302 base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, | 301 base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromSurface, |
| 303 base::Unretained(this), run_loop.QuitClosure()), | 302 base::Unretained(this), run_loop.QuitClosure()), |
| 304 kN32_SkColorType); | 303 kN32_SkColorType); |
| 305 run_loop.Run(); | 304 run_loop.Run(); |
| 306 | 305 |
| 307 EXPECT_EQ(1, callback_invoke_count()); | 306 EXPECT_EQ(1, callback_invoke_count()); |
| 308 } | 307 } |
| 309 | 308 |
| 310 // Tests that the callback passed to CopyFromCompositingSurfaceToVideoFrame is | 309 // Tests that the callback passed to CopyFromSurfaceToVideoFrame is always |
| 311 // always called, even when the RenderWidgetHost is deleting in the middle of | 310 // called, even when the RenderWidgetHostView is deleting in the middle of an |
| 312 // an async copy. | 311 // async copy. |
| 313 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, | 312 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
| 314 CopyFromCompositingSurface_CallbackDespiteDelete) { | 313 CopyFromSurfaceToVideoFrame_CallbackDespiteDelete) { |
| 315 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 314 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
| 316 RenderWidgetHostViewBase* const view = GetRenderWidgetHostView(); | |
| 317 if (!view->CanCopyToVideoFrame()) { | |
| 318 LOG(WARNING) << | |
| 319 ("Blindly passing this test: CopyFromCompositingSurfaceToVideoFrame() " | |
| 320 "not supported on this platform."); | |
| 321 return; | |
| 322 } | |
| 323 | 315 |
| 324 base::RunLoop run_loop; | 316 base::RunLoop run_loop; |
| 325 scoped_refptr<media::VideoFrame> dest = | 317 scoped_refptr<media::VideoFrame> dest = |
| 326 media::VideoFrame::CreateBlackFrame(frame_size()); | 318 media::VideoFrame::CreateBlackFrame(frame_size()); |
| 327 view->CopyFromCompositingSurfaceToVideoFrame( | 319 GetRenderWidgetHostView()->CopyFromSurfaceToVideoFrame( |
| 328 gfx::Rect(view->GetViewBounds().size()), dest, base::Bind( | 320 gfx::Rect(), dest, |
| 329 &RenderWidgetHostViewBrowserTest::FinishCopyFromCompositingSurface, | 321 base::Bind( |
| 322 &RenderWidgetHostViewBrowserTest::FinishCopyFromSurfaceToVideoFrame, |
| 330 base::Unretained(this), run_loop.QuitClosure())); | 323 base::Unretained(this), run_loop.QuitClosure())); |
| 331 run_loop.Run(); | 324 run_loop.Run(); |
| 332 | 325 |
| 333 EXPECT_EQ(1, callback_invoke_count()); | 326 EXPECT_EQ(1, callback_invoke_count()); |
| 334 } | 327 } |
| 335 | 328 |
| 336 // Test basic frame subscription functionality. We subscribe, and then run | 329 // Test basic frame subscription functionality. We subscribe, and then run |
| 337 // until at least one DeliverFrameCallback has been invoked. | 330 // until at least one DeliverFrameCallback has been invoked. |
| 338 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, | 331 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
| 339 FrameSubscriberTest) { | 332 FrameSubscriberTest) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 350 run_loop.Run(); | 343 run_loop.Run(); |
| 351 view->EndFrameSubscription(); | 344 view->EndFrameSubscription(); |
| 352 | 345 |
| 353 EXPECT_LE(1, callback_invoke_count()); | 346 EXPECT_LE(1, callback_invoke_count()); |
| 354 EXPECT_LE(1, frames_captured()); | 347 EXPECT_LE(1, frames_captured()); |
| 355 } | 348 } |
| 356 | 349 |
| 357 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) { | 350 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) { |
| 358 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 351 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
| 359 RenderWidgetHostViewBase* const view = GetRenderWidgetHostView(); | 352 RenderWidgetHostViewBase* const view = GetRenderWidgetHostView(); |
| 360 if (!view->CanCopyToVideoFrame()) { | |
| 361 LOG(WARNING) << ("Blindly passing this test: " | |
| 362 "CopyFromCompositingSurfaceToVideoFrame() not supported " | |
| 363 "on this platform."); | |
| 364 return; | |
| 365 } | |
| 366 | 353 |
| 367 base::RunLoop run_loop; | 354 base::RunLoop run_loop; |
| 368 scoped_refptr<media::VideoFrame> first_output = | 355 scoped_refptr<media::VideoFrame> first_output = |
| 369 media::VideoFrame::CreateBlackFrame(frame_size()); | 356 media::VideoFrame::CreateBlackFrame(frame_size()); |
| 370 ASSERT_TRUE(first_output.get()); | 357 ASSERT_TRUE(first_output.get()); |
| 371 scoped_refptr<media::VideoFrame> second_output = | 358 scoped_refptr<media::VideoFrame> second_output = |
| 372 media::VideoFrame::CreateBlackFrame(frame_size()); | 359 media::VideoFrame::CreateBlackFrame(frame_size()); |
| 373 ASSERT_TRUE(second_output.get()); | 360 ASSERT_TRUE(second_output.get()); |
| 374 base::Closure closure = base::BarrierClosure(2, run_loop.QuitClosure()); | 361 base::Closure closure = base::BarrierClosure(2, run_loop.QuitClosure()); |
| 375 view->CopyFromCompositingSurfaceToVideoFrame( | 362 view->CopyFromSurfaceToVideoFrame( |
| 376 gfx::Rect(view->GetViewBounds().size()), first_output, | 363 gfx::Rect(), first_output, |
| 377 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, | 364 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, |
| 378 base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), | 365 base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), |
| 379 closure, base::TimeTicks::Now())); | 366 closure, base::TimeTicks::Now())); |
| 380 view->CopyFromCompositingSurfaceToVideoFrame( | 367 view->CopyFromSurfaceToVideoFrame( |
| 381 gfx::Rect(view->GetViewBounds().size()), second_output, | 368 gfx::Rect(), second_output, |
| 382 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, | 369 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, |
| 383 base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), | 370 base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), |
| 384 closure, base::TimeTicks::Now())); | 371 closure, base::TimeTicks::Now())); |
| 385 run_loop.Run(); | 372 run_loop.Run(); |
| 386 | 373 |
| 387 EXPECT_EQ(2, callback_invoke_count()); | 374 EXPECT_EQ(2, callback_invoke_count()); |
| 388 EXPECT_EQ(2, frames_captured()); | 375 EXPECT_EQ(2, frames_captured()); |
| 389 } | 376 } |
| 390 | 377 |
| 391 class CompositingRenderWidgetHostViewBrowserTestTabCapture | 378 class CompositingRenderWidgetHostViewBrowserTestTabCapture |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 box_size.height(), | 550 box_size.height(), |
| 564 box_size.width(), | 551 box_size.width(), |
| 565 box_size.width(), | 552 box_size.width(), |
| 566 box_size.height())); | 553 box_size.height())); |
| 567 | 554 |
| 568 SET_UP_SURFACE_OR_PASS_TEST("\"DONE\""); | 555 SET_UP_SURFACE_OR_PASS_TEST("\"DONE\""); |
| 569 if (!ShouldContinueAfterTestURLLoad()) | 556 if (!ShouldContinueAfterTestURLLoad()) |
| 570 return; | 557 return; |
| 571 | 558 |
| 572 RenderWidgetHostViewBase* rwhv = GetRenderWidgetHostView(); | 559 RenderWidgetHostViewBase* rwhv = GetRenderWidgetHostView(); |
| 573 ASSERT_TRUE(!video_frame || rwhv->CanCopyToVideoFrame()); | |
| 574 | 560 |
| 575 SetupLeftRightBitmap(output_size, | 561 SetupLeftRightBitmap(output_size, |
| 576 &expected_copy_from_compositing_surface_bitmap_); | 562 &expected_copy_from_compositing_surface_bitmap_); |
| 577 | 563 |
| 578 // The page is loaded in the renderer. Request frames from the renderer | 564 // The page is loaded in the renderer. Request frames from the renderer |
| 579 // until readback succeeds. When readback succeeds, the resulting | 565 // until readback succeeds. When readback succeeds, the resulting |
| 580 // SkBitmap/VideoFrame is examined to ensure it matches the expected result. | 566 // SkBitmap/VideoFrame is examined to ensure it matches the expected result. |
| 581 // This loop is needed because: | 567 // This loop is needed because: |
| 582 // 1. Painting/Compositing is not synchronous with the Javascript engine, | 568 // 1. Painting/Compositing is not synchronous with the Javascript engine, |
| 583 // and so the "DONE" signal above could be received before the renderer | 569 // and so the "DONE" signal above could be received before the renderer |
| (...skipping 26 matching lines...) Expand all Loading... |
| 610 scoped_refptr<media::VideoFrame> video_frame = | 596 scoped_refptr<media::VideoFrame> video_frame = |
| 611 media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_YV12, | 597 media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_YV12, |
| 612 output_size, gfx::Rect(output_size), | 598 output_size, gfx::Rect(output_size), |
| 613 output_size, base::TimeDelta()); | 599 output_size, base::TimeDelta()); |
| 614 | 600 |
| 615 base::Callback<void(const gfx::Rect& rect, bool success)> callback = | 601 base::Callback<void(const gfx::Rect& rect, bool success)> callback = |
| 616 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: | 602 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: |
| 617 ReadbackRequestCallbackForVideo, | 603 ReadbackRequestCallbackForVideo, |
| 618 base::Unretained(this), video_frame, | 604 base::Unretained(this), video_frame, |
| 619 run_loop.QuitClosure()); | 605 run_loop.QuitClosure()); |
| 620 rwhv->CopyFromCompositingSurfaceToVideoFrame( | 606 rwhv->CopyFromSurfaceToVideoFrame(copy_rect, video_frame, callback); |
| 621 copy_rect, video_frame, callback); | |
| 622 } else { | 607 } else { |
| 623 if (!content::GpuDataManager::GetInstance() | 608 if (!content::GpuDataManager::GetInstance() |
| 624 ->CanUseGpuBrowserCompositor()) { | 609 ->CanUseGpuBrowserCompositor()) { |
| 625 // Skia rendering can cause color differences, particularly in the | 610 // Skia rendering can cause color differences, particularly in the |
| 626 // middle two columns. | 611 // middle two columns. |
| 627 SetAllowableError(2); | 612 SetAllowableError(2); |
| 628 SetExcludeRect(gfx::Rect(output_size.width() / 2 - 1, 0, 2, | 613 SetExcludeRect(gfx::Rect(output_size.width() / 2 - 1, 0, 2, |
| 629 output_size.height())); | 614 output_size.height())); |
| 630 } | 615 } |
| 631 | 616 |
| 632 const ReadbackRequestCallback callback = | 617 const ReadbackRequestCallback callback = |
| 633 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: | 618 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: |
| 634 ReadbackRequestCallbackTest, | 619 ReadbackRequestCallbackTest, |
| 635 base::Unretained(this), | 620 base::Unretained(this), |
| 636 run_loop.QuitClosure()); | 621 run_loop.QuitClosure()); |
| 637 rwhv->CopyFromCompositingSurface( | 622 rwhv->CopyFromSurface(copy_rect, output_size, callback, |
| 638 copy_rect, output_size, callback, kN32_SkColorType); | 623 kN32_SkColorType); |
| 639 } | 624 } |
| 640 run_loop.Run(); | 625 run_loop.Run(); |
| 641 | 626 |
| 642 // If the readback operation did not provide a frame, log the reason | 627 // If the readback operation did not provide a frame, log the reason |
| 643 // to aid in future debugging. This information will also help determine | 628 // to aid in future debugging. This information will also help determine |
| 644 // whether the implementation is broken, or a test bot is in a bad state. | 629 // whether the implementation is broken, or a test bot is in a bad state. |
| 645 #define CASE_LOG_READBACK_WARNING(enum_value) \ | 630 #define CASE_LOG_READBACK_WARNING(enum_value) \ |
| 646 case enum_value: \ | 631 case enum_value: \ |
| 647 LOG(WARNING) << "Readback attempt failed (render frame #" \ | 632 LOG(WARNING) << "Readback attempt failed (render frame #" \ |
| 648 << last_frame_number << "). Reason: " #enum_value; \ | 633 << last_frame_number << "). Reason: " #enum_value; \ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 // |readback_response_| is always a content::ReadbackResponse or | 683 // |readback_response_| is always a content::ReadbackResponse or |
| 699 // ExtraReadbackResponsesForTest enum value. | 684 // ExtraReadbackResponsesForTest enum value. |
| 700 int readback_response_; | 685 int readback_response_; |
| 701 SkBitmap expected_copy_from_compositing_surface_bitmap_; | 686 SkBitmap expected_copy_from_compositing_surface_bitmap_; |
| 702 int allowable_error_; | 687 int allowable_error_; |
| 703 gfx::Rect exclude_rect_; | 688 gfx::Rect exclude_rect_; |
| 704 std::string test_url_; | 689 std::string test_url_; |
| 705 }; | 690 }; |
| 706 | 691 |
| 707 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 692 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 708 CopyFromCompositingSurface_Origin_Unscaled) { | 693 CopyFromSurface_Origin_Unscaled) { |
| 709 gfx::Rect copy_rect(400, 300); | 694 gfx::Rect copy_rect(400, 300); |
| 710 gfx::Size output_size = copy_rect.size(); | 695 gfx::Size output_size = copy_rect.size(); |
| 711 gfx::Size html_rect_size(400, 300); | 696 gfx::Size html_rect_size(400, 300); |
| 712 bool video_frame = false; | 697 bool video_frame = false; |
| 713 PerformTestWithLeftRightRects(html_rect_size, | 698 PerformTestWithLeftRightRects(html_rect_size, |
| 714 copy_rect, | 699 copy_rect, |
| 715 output_size, | 700 output_size, |
| 716 video_frame); | 701 video_frame); |
| 717 } | 702 } |
| 718 | 703 |
| 719 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 704 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 720 CopyFromCompositingSurface_Origin_Scaled) { | 705 CopyFromSurface_Origin_Scaled) { |
| 721 gfx::Rect copy_rect(400, 300); | 706 gfx::Rect copy_rect(400, 300); |
| 722 gfx::Size output_size(200, 100); | 707 gfx::Size output_size(200, 100); |
| 723 gfx::Size html_rect_size(400, 300); | 708 gfx::Size html_rect_size(400, 300); |
| 724 bool video_frame = false; | 709 bool video_frame = false; |
| 725 PerformTestWithLeftRightRects(html_rect_size, | 710 PerformTestWithLeftRightRects(html_rect_size, |
| 726 copy_rect, | 711 copy_rect, |
| 727 output_size, | 712 output_size, |
| 728 video_frame); | 713 video_frame); |
| 729 } | 714 } |
| 730 | 715 |
| 731 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 716 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 732 CopyFromCompositingSurface_Cropped_Unscaled) { | 717 CopyFromSurface_Cropped_Unscaled) { |
| 733 // Grab 60x60 pixels from the center of the tab contents. | 718 // Grab 60x60 pixels from the center of the tab contents. |
| 734 gfx::Rect copy_rect(400, 300); | 719 gfx::Rect copy_rect(400, 300); |
| 735 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), | 720 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), |
| 736 gfx::Size(60, 60)); | 721 gfx::Size(60, 60)); |
| 737 gfx::Size output_size = copy_rect.size(); | 722 gfx::Size output_size = copy_rect.size(); |
| 738 gfx::Size html_rect_size(400, 300); | 723 gfx::Size html_rect_size(400, 300); |
| 739 bool video_frame = false; | 724 bool video_frame = false; |
| 740 PerformTestWithLeftRightRects(html_rect_size, | 725 PerformTestWithLeftRightRects(html_rect_size, |
| 741 copy_rect, | 726 copy_rect, |
| 742 output_size, | 727 output_size, |
| 743 video_frame); | 728 video_frame); |
| 744 } | 729 } |
| 745 | 730 |
| 746 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 731 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 747 CopyFromCompositingSurface_Cropped_Scaled) { | 732 CopyFromSurface_Cropped_Scaled) { |
| 748 // Grab 60x60 pixels from the center of the tab contents. | 733 // Grab 60x60 pixels from the center of the tab contents. |
| 749 gfx::Rect copy_rect(400, 300); | 734 gfx::Rect copy_rect(400, 300); |
| 750 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), | 735 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), |
| 751 gfx::Size(60, 60)); | 736 gfx::Size(60, 60)); |
| 752 gfx::Size output_size(20, 10); | 737 gfx::Size output_size(20, 10); |
| 753 gfx::Size html_rect_size(400, 300); | 738 gfx::Size html_rect_size(400, 300); |
| 754 bool video_frame = false; | 739 bool video_frame = false; |
| 755 PerformTestWithLeftRightRects(html_rect_size, | 740 PerformTestWithLeftRightRects(html_rect_size, |
| 756 copy_rect, | 741 copy_rect, |
| 757 output_size, | 742 output_size, |
| 758 video_frame); | 743 video_frame); |
| 759 } | 744 } |
| 760 | 745 |
| 761 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 746 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 762 CopyFromCompositingSurface_ForVideoFrame) { | 747 CopyFromSurface_ForVideoFrame) { |
| 763 // Grab 90x60 pixels from the center of the tab contents. | 748 // Grab 90x60 pixels from the center of the tab contents. |
| 764 gfx::Rect copy_rect(400, 300); | 749 gfx::Rect copy_rect(400, 300); |
| 765 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), | 750 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), |
| 766 gfx::Size(90, 60)); | 751 gfx::Size(90, 60)); |
| 767 gfx::Size output_size = copy_rect.size(); | 752 gfx::Size output_size = copy_rect.size(); |
| 768 gfx::Size html_rect_size(400, 300); | 753 gfx::Size html_rect_size(400, 300); |
| 769 bool video_frame = true; | 754 bool video_frame = true; |
| 770 PerformTestWithLeftRightRects(html_rect_size, | 755 PerformTestWithLeftRightRects(html_rect_size, |
| 771 copy_rect, | 756 copy_rect, |
| 772 output_size, | 757 output_size, |
| 773 video_frame); | 758 video_frame); |
| 774 } | 759 } |
| 775 | 760 |
| 776 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 761 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 777 CopyFromCompositingSurface_ForVideoFrame_Scaled) { | 762 CopyFromSurface_ForVideoFrame_Scaled) { |
| 778 // Grab 90x60 pixels from the center of the tab contents. | 763 // Grab 90x60 pixels from the center of the tab contents. |
| 779 gfx::Rect copy_rect(400, 300); | 764 gfx::Rect copy_rect(400, 300); |
| 780 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), | 765 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), |
| 781 gfx::Size(90, 60)); | 766 gfx::Size(90, 60)); |
| 782 // Scale to 30 x 20 (preserve aspect ratio). | 767 // Scale to 30 x 20 (preserve aspect ratio). |
| 783 gfx::Size output_size(30, 20); | 768 gfx::Size output_size(30, 20); |
| 784 gfx::Size html_rect_size(400, 300); | 769 gfx::Size html_rect_size(400, 300); |
| 785 bool video_frame = true; | 770 bool video_frame = true; |
| 786 PerformTestWithLeftRightRects(html_rect_size, | 771 PerformTestWithLeftRightRects(html_rect_size, |
| 787 copy_rect, | 772 copy_rect, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 kTestCompositingModes); | 935 kTestCompositingModes); |
| 951 INSTANTIATE_TEST_CASE_P( | 936 INSTANTIATE_TEST_CASE_P( |
| 952 GLAndSoftwareCompositing, | 937 GLAndSoftwareCompositing, |
| 953 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, | 938 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 954 kTestCompositingModes); | 939 kTestCompositingModes); |
| 955 | 940 |
| 956 #endif // !defined(OS_ANDROID) | 941 #endif // !defined(OS_ANDROID) |
| 957 | 942 |
| 958 } // namespace | 943 } // namespace |
| 959 } // namespace content | 944 } // namespace content |
| OLD | NEW |