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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop/message_loop_proxy.h" | 6 #include "base/message_loop/message_loop_proxy.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "content/browser/gpu/compositor_util.h" | 9 #include "content/browser/gpu/compositor_util.h" |
10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 while (true) { | 150 while (true) { |
151 ++count_attempts; | 151 ++count_attempts; |
152 base::RunLoop run_loop; | 152 base::RunLoop run_loop; |
153 GetRenderViewHost()->CopyFromBackingStore( | 153 GetRenderViewHost()->CopyFromBackingStore( |
154 gfx::Rect(), | 154 gfx::Rect(), |
155 frame_size(), | 155 frame_size(), |
156 base::Bind( | 156 base::Bind( |
157 &RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, | 157 &RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, |
158 base::Unretained(this), | 158 base::Unretained(this), |
159 run_loop.QuitClosure()), | 159 run_loop.QuitClosure()), |
160 SkBitmap::kARGB_8888_Config); | 160 kN32_SkColorType); |
161 run_loop.Run(); | 161 run_loop.Run(); |
162 | 162 |
163 if (frames_captured()) | 163 if (frames_captured()) |
164 break; | 164 break; |
165 else | 165 else |
166 GiveItSomeTime(); | 166 GiveItSomeTime(); |
167 } | 167 } |
168 | 168 |
169 EXPECT_EQ(count_attempts, callback_invoke_count()); | 169 EXPECT_EQ(count_attempts, callback_invoke_count()); |
170 EXPECT_EQ(1, frames_captured()); | 170 EXPECT_EQ(1, frames_captured()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 CopyFromBackingStore_CallbackDespiteDelete) { | 284 CopyFromBackingStore_CallbackDespiteDelete) { |
285 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 285 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
286 | 286 |
287 base::RunLoop run_loop; | 287 base::RunLoop run_loop; |
288 GetRenderViewHost()->CopyFromBackingStore( | 288 GetRenderViewHost()->CopyFromBackingStore( |
289 gfx::Rect(), | 289 gfx::Rect(), |
290 frame_size(), | 290 frame_size(), |
291 base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, | 291 base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, |
292 base::Unretained(this), | 292 base::Unretained(this), |
293 run_loop.QuitClosure()), | 293 run_loop.QuitClosure()), |
294 SkBitmap::kARGB_8888_Config); | 294 kN32_SkColorType); |
295 // Delete the surface before the callback is run. | 295 // Delete the surface before the callback is run. |
296 GetRenderWidgetHostView()->AcceleratedSurfaceRelease(); | 296 GetRenderWidgetHostView()->AcceleratedSurfaceRelease(); |
297 run_loop.Run(); | 297 run_loop.Run(); |
298 | 298 |
299 EXPECT_EQ(1, callback_invoke_count()); | 299 EXPECT_EQ(1, callback_invoke_count()); |
300 } | 300 } |
301 | 301 |
302 // Tests that the callback passed to CopyFromCompositingSurfaceToVideoFrame is | 302 // Tests that the callback passed to CopyFromCompositingSurfaceToVideoFrame is |
303 // always called, even when the RenderWidgetHost is deleting in the middle of | 303 // always called, even when the RenderWidgetHost is deleting in the middle of |
304 // an async copy. | 304 // an async copy. |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 630 } |
631 | 631 |
632 base::Callback<void(bool, const SkBitmap&)> callback = | 632 base::Callback<void(bool, const SkBitmap&)> callback = |
633 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: | 633 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: |
634 CopyFromCompositingSurfaceCallback, | 634 CopyFromCompositingSurfaceCallback, |
635 base::Unretained(this), | 635 base::Unretained(this), |
636 run_loop.QuitClosure()); | 636 run_loop.QuitClosure()); |
637 rwhvp->CopyFromCompositingSurface(copy_rect, | 637 rwhvp->CopyFromCompositingSurface(copy_rect, |
638 output_size, | 638 output_size, |
639 callback, | 639 callback, |
640 SkBitmap::kARGB_8888_Config); | 640 kN32_SkColorType); |
641 } | 641 } |
642 run_loop.Run(); | 642 run_loop.Run(); |
643 } | 643 } |
644 | 644 |
645 // Sets up |bitmap| to have size |copy_size|. It floods the left half with | 645 // Sets up |bitmap| to have size |copy_size|. It floods the left half with |
646 // #0ff and the right half with #ff0. | 646 // #0ff and the right half with #ff0. |
647 void SetupLeftRightBitmap(const gfx::Size& copy_size, SkBitmap* bitmap) { | 647 void SetupLeftRightBitmap(const gfx::Size& copy_size, SkBitmap* bitmap) { |
648 bitmap->allocN32Pixels(copy_size.width(), copy_size.height()); | 648 bitmap->allocN32Pixels(copy_size.width(), copy_size.height()); |
649 // Left half is #0ff. | 649 // Left half is #0ff. |
650 bitmap->eraseARGB(255, 0, 255, 255); | 650 bitmap->eraseARGB(255, 0, 255, 255); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 CompositingRenderWidgetHostViewBrowserTestTabCapture, | 853 CompositingRenderWidgetHostViewBrowserTestTabCapture, |
854 testing::ValuesIn(kAllCompositingModes)); | 854 testing::ValuesIn(kAllCompositingModes)); |
855 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, | 855 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, |
856 CompositingRenderWidgetHostViewTabCaptureHighDPI, | 856 CompositingRenderWidgetHostViewTabCaptureHighDPI, |
857 testing::ValuesIn(kAllCompositingModes)); | 857 testing::ValuesIn(kAllCompositingModes)); |
858 | 858 |
859 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 859 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
860 | 860 |
861 } // namespace | 861 } // namespace |
862 } // namespace content | 862 } // namespace content |
OLD | NEW |