| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 fake_bounds_ = rect; | 187 fake_bounds_ = rect; |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool CanCopyToVideoFrame() const override { | 190 bool CanCopyToVideoFrame() const override { |
| 191 return controller_->CanCopyToVideoFrame(); | 191 return controller_->CanCopyToVideoFrame(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void CopyFromCompositingSurfaceToVideoFrame( | 194 void CopyFromCompositingSurfaceToVideoFrame( |
| 195 const gfx::Rect& src_subrect, | 195 const gfx::Rect& src_subrect, |
| 196 const scoped_refptr<media::VideoFrame>& target, | 196 const scoped_refptr<media::VideoFrame>& target, |
| 197 const base::Callback<void(bool)>& callback) override { | 197 const base::Callback<void(const gfx::Rect&, bool)>& callback) override { |
| 198 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor()); | 198 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor()); |
| 199 media::FillYUV( | 199 media::FillYUV( |
| 200 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c)); | 200 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c)); |
| 201 callback.Run(true); | 201 callback.Run(gfx::Rect(), true); |
| 202 controller_->SignalCopy(); | 202 controller_->SignalCopy(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void BeginFrameSubscription( | 205 void BeginFrameSubscription( |
| 206 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override { | 206 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override { |
| 207 subscriber_.reset(subscriber.release()); | 207 subscriber_.reset(subscriber.release()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void EndFrameSubscription() override { subscriber_.reset(); } | 210 void EndFrameSubscription() override { subscriber_.reset(); } |
| 211 | 211 |
| 212 // Simulate a compositor paint event for our subscriber. | 212 // Simulate a compositor paint event for our subscriber. |
| 213 void SimulateUpdate() { | 213 void SimulateUpdate() { |
| 214 const base::TimeTicks present_time = base::TimeTicks::Now(); | 214 const base::TimeTicks present_time = base::TimeTicks::Now(); |
| 215 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; | 215 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; |
| 216 scoped_refptr<media::VideoFrame> target; | 216 scoped_refptr<media::VideoFrame> target; |
| 217 if (subscriber_ && subscriber_->ShouldCaptureFrame( | 217 if (subscriber_ && subscriber_->ShouldCaptureFrame( |
| 218 gfx::Rect(), present_time, &target, &callback)) { | 218 gfx::Rect(), present_time, &target, &callback)) { |
| 219 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor()); | 219 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor()); |
| 220 media::FillYUV( | 220 media::FillYUV( |
| 221 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c)); | 221 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c)); |
| 222 BrowserThread::PostTask(BrowserThread::UI, | 222 BrowserThread::PostTask( |
| 223 FROM_HERE, | 223 BrowserThread::UI, FROM_HERE, |
| 224 base::Bind(callback, present_time, true)); | 224 base::Bind(callback, present_time, gfx::Rect(), true)); |
| 225 controller_->SignalCopy(); | 225 controller_->SignalCopy(); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 private: | 229 private: |
| 230 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber_; | 230 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber_; |
| 231 CaptureTestSourceController* const controller_; | 231 CaptureTestSourceController* const controller_; |
| 232 gfx::Rect fake_bounds_; | 232 gfx::Rect fake_bounds_; |
| 233 | 233 |
| 234 DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTestView); | 234 DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTestView); |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 policies[i], gfx::Size(1000, 1000), gfx::Size(1000, 1000)); | 1137 policies[i], gfx::Size(1000, 1000), gfx::Size(1000, 1000)); |
| 1138 RunTestForPreferredSize( | 1138 RunTestForPreferredSize( |
| 1139 policies[i], gfx::Size(1600, 1000), gfx::Size(1600, 1000)); | 1139 policies[i], gfx::Size(1600, 1000), gfx::Size(1600, 1000)); |
| 1140 RunTestForPreferredSize( | 1140 RunTestForPreferredSize( |
| 1141 policies[i], gfx::Size(837, 999), gfx::Size(837, 999)); | 1141 policies[i], gfx::Size(837, 999), gfx::Size(837, 999)); |
| 1142 } | 1142 } |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 } // namespace | 1145 } // namespace |
| 1146 } // namespace content | 1146 } // namespace content |
| OLD | NEW |