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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 ++callback_invoke_count_; | 140 ++callback_invoke_count_; |
141 if (frame_captured) | 141 if (frame_captured) |
142 ++frames_captured_; | 142 ++frames_captured_; |
143 if (!quit_closure.is_null()) | 143 if (!quit_closure.is_null()) |
144 quit_closure.Run(); | 144 quit_closure.Run(); |
145 } | 145 } |
146 | 146 |
147 // Callback when using frame subscriber API. | 147 // Callback when using frame subscriber API. |
148 void FrameDelivered(const scoped_refptr<base::MessageLoopProxy>& loop, | 148 void FrameDelivered(const scoped_refptr<base::MessageLoopProxy>& loop, |
149 base::Closure quit_closure, | 149 base::Closure quit_closure, |
150 base::Time timestamp, | 150 base::TimeTicks timestamp, |
151 bool frame_captured) { | 151 bool frame_captured) { |
152 ++callback_invoke_count_; | 152 ++callback_invoke_count_; |
153 if (frame_captured) | 153 if (frame_captured) |
154 ++frames_captured_; | 154 ++frames_captured_; |
155 if (!quit_closure.is_null()) | 155 if (!quit_closure.is_null()) |
156 loop->PostTask(FROM_HERE, quit_closure); | 156 loop->PostTask(FROM_HERE, quit_closure); |
157 } | 157 } |
158 | 158 |
159 // Copy one frame using the CopyFromBackingStore API. | 159 // Copy one frame using the CopyFromBackingStore API. |
160 void RunBasicCopyFromBackingStoreTest() { | 160 void RunBasicCopyFromBackingStoreTest() { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 DISALLOW_COPY_AND_ASSIGN(NonCompositingRenderWidgetHostViewBrowserTest); | 331 DISALLOW_COPY_AND_ASSIGN(NonCompositingRenderWidgetHostViewBrowserTest); |
332 }; | 332 }; |
333 | 333 |
334 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { | 334 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { |
335 public: | 335 public: |
336 FakeFrameSubscriber( | 336 FakeFrameSubscriber( |
337 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback) | 337 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback) |
338 : callback_(callback) { | 338 : callback_(callback) { |
339 } | 339 } |
340 | 340 |
341 virtual bool ShouldCaptureFrame( | 341 virtual bool ShouldCaptureFrame(base::TimeTicks present_time, |
342 base::Time present_time, | 342 scoped_refptr<media::VideoFrame>* storage, |
343 scoped_refptr<media::VideoFrame>* storage, | 343 DeliverFrameCallback* callback) OVERRIDE { |
344 DeliverFrameCallback* callback) OVERRIDE { | |
345 // Only allow one frame capture to be made. Otherwise, the compositor could | 344 // Only allow one frame capture to be made. Otherwise, the compositor could |
346 // start multiple captures, unbounded, and eventually its own limiter logic | 345 // start multiple captures, unbounded, and eventually its own limiter logic |
347 // will begin invoking |callback| with a |false| result. This flakes out | 346 // will begin invoking |callback| with a |false| result. This flakes out |
348 // the unit tests, since they receive a "failed" callback before the later | 347 // the unit tests, since they receive a "failed" callback before the later |
349 // "success" callbacks. | 348 // "success" callbacks. |
350 if (callback_.is_null()) | 349 if (callback_.is_null()) |
351 return false; | 350 return false; |
352 *storage = media::VideoFrame::CreateBlackFrame(gfx::Size(100, 100)); | 351 *storage = media::VideoFrame::CreateBlackFrame(gfx::Size(100, 100)); |
353 *callback = callback_; | 352 *callback = callback_; |
354 callback_.Reset(); | 353 callback_.Reset(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 scoped_refptr<media::VideoFrame> second_output = | 486 scoped_refptr<media::VideoFrame> second_output = |
488 media::VideoFrame::CreateBlackFrame(frame_size()); | 487 media::VideoFrame::CreateBlackFrame(frame_size()); |
489 ASSERT_TRUE(second_output.get()); | 488 ASSERT_TRUE(second_output.get()); |
490 view->CopyFromCompositingSurfaceToVideoFrame( | 489 view->CopyFromCompositingSurfaceToVideoFrame( |
491 gfx::Rect(view->GetViewBounds().size()), | 490 gfx::Rect(view->GetViewBounds().size()), |
492 first_output, | 491 first_output, |
493 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, | 492 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, |
494 base::Unretained(this), | 493 base::Unretained(this), |
495 base::MessageLoopProxy::current(), | 494 base::MessageLoopProxy::current(), |
496 base::Closure(), | 495 base::Closure(), |
497 base::Time::Now())); | 496 base::TimeTicks::Now())); |
498 view->CopyFromCompositingSurfaceToVideoFrame( | 497 view->CopyFromCompositingSurfaceToVideoFrame( |
499 gfx::Rect(view->GetViewBounds().size()), second_output, | 498 gfx::Rect(view->GetViewBounds().size()), |
| 499 second_output, |
500 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, | 500 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, |
501 base::Unretained(this), | 501 base::Unretained(this), |
502 base::MessageLoopProxy::current(), | 502 base::MessageLoopProxy::current(), |
503 run_loop.QuitClosure(), | 503 run_loop.QuitClosure(), |
504 base::Time::Now())); | 504 base::TimeTicks::Now())); |
505 run_loop.Run(); | 505 run_loop.Run(); |
506 | 506 |
507 EXPECT_EQ(2, callback_invoke_count()); | 507 EXPECT_EQ(2, callback_invoke_count()); |
508 EXPECT_EQ(2, frames_captured()); | 508 EXPECT_EQ(2, frames_captured()); |
509 } | 509 } |
510 | 510 |
511 class CompositingRenderWidgetHostViewBrowserTestTabCapture | 511 class CompositingRenderWidgetHostViewBrowserTestTabCapture |
512 : public CompositingRenderWidgetHostViewBrowserTest { | 512 : public CompositingRenderWidgetHostViewBrowserTest { |
513 public: | 513 public: |
514 CompositingRenderWidgetHostViewBrowserTestTabCapture() | 514 CompositingRenderWidgetHostViewBrowserTestTabCapture() |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 CompositingRenderWidgetHostViewBrowserTestTabCapture, | 950 CompositingRenderWidgetHostViewBrowserTestTabCapture, |
951 testing::ValuesIn(kAllCompositingModes)); | 951 testing::ValuesIn(kAllCompositingModes)); |
952 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, | 952 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, |
953 CompositingRenderWidgetHostViewTabCaptureHighDPI, | 953 CompositingRenderWidgetHostViewTabCaptureHighDPI, |
954 testing::ValuesIn(kAllCompositingModes)); | 954 testing::ValuesIn(kAllCompositingModes)); |
955 | 955 |
956 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 956 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
957 | 957 |
958 } // namespace | 958 } // namespace |
959 } // namespace content | 959 } // namespace content |
OLD | NEW |