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/media/capture/web_contents_video_capture_device.h" | 5 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/debug/debugger.h" | 8 #include "base/debug/debugger.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 main_frame_routing_id, swapped_out), | 239 main_frame_routing_id, swapped_out), |
240 controller_(controller) { | 240 controller_(controller) { |
241 // Override the default view installed by TestRenderViewHost; we need | 241 // Override the default view installed by TestRenderViewHost; we need |
242 // our special subclass which has mocked-out tab capture support. | 242 // our special subclass which has mocked-out tab capture support. |
243 RenderWidgetHostView* old_view = GetView(); | 243 RenderWidgetHostView* old_view = GetView(); |
244 SetView(new CaptureTestView(this, controller)); | 244 SetView(new CaptureTestView(this, controller)); |
245 delete old_view; | 245 delete old_view; |
246 } | 246 } |
247 | 247 |
248 // TestRenderViewHost overrides. | 248 // TestRenderViewHost overrides. |
249 void CopyFromBackingStore( | 249 void CopyFromBackingStore(const gfx::Rect& src_rect, |
250 const gfx::Rect& src_rect, | 250 const gfx::Size& accelerated_dst_size, |
251 const gfx::Size& accelerated_dst_size, | 251 ReadbackRequestCallback& callback, |
252 const base::Callback<void(bool, const SkBitmap&)>& callback, | 252 const SkColorType color_type) override { |
253 const SkColorType color_type) override { | |
254 gfx::Size size = controller_->GetCopyResultSize(); | 253 gfx::Size size = controller_->GetCopyResultSize(); |
255 SkColor color = controller_->GetSolidColor(); | 254 SkColor color = controller_->GetSolidColor(); |
256 | 255 |
257 // Although it's not necessary, use a PlatformBitmap here (instead of a | 256 // Although it's not necessary, use a PlatformBitmap here (instead of a |
258 // regular SkBitmap) to exercise possible threading issues. | 257 // regular SkBitmap) to exercise possible threading issues. |
259 skia::PlatformBitmap output; | 258 skia::PlatformBitmap output; |
260 EXPECT_TRUE(output.Allocate(size.width(), size.height(), false)); | 259 EXPECT_TRUE(output.Allocate(size.width(), size.height(), false)); |
261 { | 260 { |
262 SkAutoLockPixels locker(output.GetBitmap()); | 261 SkAutoLockPixels locker(output.GetBitmap()); |
263 output.GetBitmap().eraseColor(color); | 262 output.GetBitmap().eraseColor(color); |
264 } | 263 } |
265 callback.Run(true, output.GetBitmap()); | 264 callback.Run(output.GetBitmap(), content::READBACK_SUCCESS); |
266 controller_->SignalCopy(); | 265 controller_->SignalCopy(); |
267 } | 266 } |
268 | 267 |
269 private: | 268 private: |
270 CaptureTestSourceController* controller_; | 269 CaptureTestSourceController* controller_; |
271 | 270 |
272 DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTestRenderViewHost); | 271 DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTestRenderViewHost); |
273 }; | 272 }; |
274 | 273 |
275 #if defined(COMPILER_MSVC) | 274 #if defined(COMPILER_MSVC) |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 source()->SetSolidColor(SK_ColorGREEN); | 842 source()->SetSolidColor(SK_ColorGREEN); |
844 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 843 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
845 source()->SetSolidColor(SK_ColorRED); | 844 source()->SetSolidColor(SK_ColorRED); |
846 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); | 845 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); |
847 | 846 |
848 device()->StopAndDeAllocate(); | 847 device()->StopAndDeAllocate(); |
849 } | 848 } |
850 | 849 |
851 } // namespace | 850 } // namespace |
852 } // namespace content | 851 } // namespace content |
OLD | NEW |