| 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 "base/barrier_closure.h" | 5 #include "base/barrier_closure.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 if (response == READBACK_SUCCESS) { | 115 if (response == READBACK_SUCCESS) { |
| 116 ++frames_captured_; | 116 ++frames_captured_; |
| 117 EXPECT_FALSE(bitmap.empty()); | 117 EXPECT_FALSE(bitmap.empty()); |
| 118 } | 118 } |
| 119 if (!quit_closure.is_null()) | 119 if (!quit_closure.is_null()) |
| 120 quit_closure.Run(); | 120 quit_closure.Run(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Callback when using CopyFromCompositingSurfaceToVideoFrame() API. | 123 // Callback when using CopyFromCompositingSurfaceToVideoFrame() API. |
| 124 void FinishCopyFromCompositingSurface(const base::Closure& quit_closure, | 124 void FinishCopyFromCompositingSurface(const base::Closure& quit_closure, |
| 125 const gfx::Rect& region_in_frame, |
| 125 bool frame_captured) { | 126 bool frame_captured) { |
| 126 ++callback_invoke_count_; | 127 ++callback_invoke_count_; |
| 127 if (frame_captured) | 128 if (frame_captured) |
| 128 ++frames_captured_; | 129 ++frames_captured_; |
| 129 if (!quit_closure.is_null()) | 130 if (!quit_closure.is_null()) |
| 130 quit_closure.Run(); | 131 quit_closure.Run(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 // Callback when using frame subscriber API. | 134 // Callback when using frame subscriber API. |
| 134 void FrameDelivered( | 135 void FrameDelivered( |
| 135 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 136 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 136 base::Closure quit_closure, | 137 base::Closure quit_closure, |
| 137 base::TimeTicks timestamp, | 138 base::TimeTicks timestamp, |
| 139 const gfx::Rect& region_in_frame, |
| 138 bool frame_captured) { | 140 bool frame_captured) { |
| 139 ++callback_invoke_count_; | 141 ++callback_invoke_count_; |
| 140 if (frame_captured) | 142 if (frame_captured) |
| 141 ++frames_captured_; | 143 ++frames_captured_; |
| 142 if (!quit_closure.is_null()) | 144 if (!quit_closure.is_null()) |
| 143 task_runner->PostTask(FROM_HERE, quit_closure); | 145 task_runner->PostTask(FROM_HERE, quit_closure); |
| 144 } | 146 } |
| 145 | 147 |
| 146 // Copy one frame using the CopyFromBackingStore API. | 148 // Copy one frame using the CopyFromBackingStore API. |
| 147 void RunBasicCopyFromBackingStoreTest() { | 149 void RunBasicCopyFromBackingStoreTest() { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } | 488 } |
| 487 } | 489 } |
| 488 EXPECT_LT(fails, 10); | 490 EXPECT_LT(fails, 10); |
| 489 | 491 |
| 490 quit_callback.Run(); | 492 quit_callback.Run(); |
| 491 } | 493 } |
| 492 | 494 |
| 493 void ReadbackRequestCallbackForVideo( | 495 void ReadbackRequestCallbackForVideo( |
| 494 scoped_refptr<media::VideoFrame> video_frame, | 496 scoped_refptr<media::VideoFrame> video_frame, |
| 495 base::Closure quit_callback, | 497 base::Closure quit_callback, |
| 498 const gfx::Rect& region_in_frame, |
| 496 bool result) { | 499 bool result) { |
| 497 if (!result) { | 500 if (!result) { |
| 498 readback_response_ = READBACK_TO_VIDEO_FRAME_FAILED; | 501 readback_response_ = READBACK_TO_VIDEO_FRAME_FAILED; |
| 499 quit_callback.Run(); | 502 quit_callback.Run(); |
| 500 return; | 503 return; |
| 501 } | 504 } |
| 502 | 505 |
| 503 media::SkCanvasVideoRenderer video_renderer; | 506 media::SkCanvasVideoRenderer video_renderer; |
| 504 | 507 |
| 505 SkBitmap bitmap; | 508 SkBitmap bitmap; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 // Exclude the middle two columns which are blended between the two | 603 // Exclude the middle two columns which are blended between the two |
| 601 // sides. | 604 // sides. |
| 602 SetExcludeRect( | 605 SetExcludeRect( |
| 603 gfx::Rect(output_size.width() / 2 - 1, 0, 2, output_size.height())); | 606 gfx::Rect(output_size.width() / 2 - 1, 0, 2, output_size.height())); |
| 604 | 607 |
| 605 scoped_refptr<media::VideoFrame> video_frame = | 608 scoped_refptr<media::VideoFrame> video_frame = |
| 606 media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_YV12, | 609 media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_YV12, |
| 607 output_size, gfx::Rect(output_size), | 610 output_size, gfx::Rect(output_size), |
| 608 output_size, base::TimeDelta()); | 611 output_size, base::TimeDelta()); |
| 609 | 612 |
| 610 base::Callback<void(bool success)> callback = | 613 base::Callback<void(const gfx::Rect& rect, bool success)> callback = |
| 611 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: | 614 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: |
| 612 ReadbackRequestCallbackForVideo, | 615 ReadbackRequestCallbackForVideo, |
| 613 base::Unretained(this), | 616 base::Unretained(this), video_frame, |
| 614 video_frame, | |
| 615 run_loop.QuitClosure()); | 617 run_loop.QuitClosure()); |
| 616 rwhv->CopyFromCompositingSurfaceToVideoFrame( | 618 rwhv->CopyFromCompositingSurfaceToVideoFrame( |
| 617 copy_rect, video_frame, callback); | 619 copy_rect, video_frame, callback); |
| 618 } else { | 620 } else { |
| 619 if (!content::GpuDataManager::GetInstance() | 621 if (!content::GpuDataManager::GetInstance() |
| 620 ->CanUseGpuBrowserCompositor()) { | 622 ->CanUseGpuBrowserCompositor()) { |
| 621 // Skia rendering can cause color differences, particularly in the | 623 // Skia rendering can cause color differences, particularly in the |
| 622 // middle two columns. | 624 // middle two columns. |
| 623 SetAllowableError(2); | 625 SetAllowableError(2); |
| 624 SetExcludeRect(gfx::Rect(output_size.width() / 2 - 1, 0, 2, | 626 SetExcludeRect(gfx::Rect(output_size.width() / 2 - 1, 0, 2, |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 kTestCompositingModes); | 997 kTestCompositingModes); |
| 996 INSTANTIATE_TEST_CASE_P( | 998 INSTANTIATE_TEST_CASE_P( |
| 997 GLAndSoftwareCompositing, | 999 GLAndSoftwareCompositing, |
| 998 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, | 1000 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 999 kTestCompositingModes); | 1001 kTestCompositingModes); |
| 1000 | 1002 |
| 1001 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 1003 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 1002 | 1004 |
| 1003 } // namespace | 1005 } // namespace |
| 1004 } // namespace content | 1006 } // namespace content |
| OLD | NEW |