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 "media/video/capture/fake_video_capture_device.h" | 5 #include "media/video/capture/fake_video_capture_device.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 void FakeVideoCaptureDevice::OnCaptureTask() { | 99 void FakeVideoCaptureDevice::OnCaptureTask() { |
100 if (!client_) | 100 if (!client_) |
101 return; | 101 return; |
102 | 102 |
103 const size_t frame_size = | 103 const size_t frame_size = |
104 VideoFrame::AllocationSize(VideoFrame::I420, capture_format_.frame_size); | 104 VideoFrame::AllocationSize(VideoFrame::I420, capture_format_.frame_size); |
105 memset(fake_frame_.get(), 0, frame_size); | 105 memset(fake_frame_.get(), 0, frame_size); |
106 | 106 |
| 107 SkImageInfo info = SkImageInfo::MakeA8(capture_format_.frame_size.width(), |
| 108 capture_format_.frame_size.height()); |
107 SkBitmap bitmap; | 109 SkBitmap bitmap; |
108 bitmap.setConfig(SkBitmap::kA8_Config, | 110 bitmap.installPixels(info, fake_frame_.get(), info.width()); |
109 capture_format_.frame_size.width(), | |
110 capture_format_.frame_size.height(), | |
111 capture_format_.frame_size.width()), | |
112 bitmap.setPixels(fake_frame_.get()); | |
113 SkCanvas canvas(bitmap); | 111 SkCanvas canvas(bitmap); |
114 | 112 |
115 // Draw a sweeping circle to show an animation. | 113 // Draw a sweeping circle to show an animation. |
116 int radius = std::min(capture_format_.frame_size.width(), | 114 int radius = std::min(capture_format_.frame_size.width(), |
117 capture_format_.frame_size.height()) / 4; | 115 capture_format_.frame_size.height()) / 4; |
118 SkRect rect = | 116 SkRect rect = |
119 SkRect::MakeXYWH(capture_format_.frame_size.width() / 2 - radius, | 117 SkRect::MakeXYWH(capture_format_.frame_size.width() / 2 - radius, |
120 capture_format_.frame_size.height() / 2 - radius, | 118 capture_format_.frame_size.height() / 2 - radius, |
121 2 * radius, | 119 2 * radius, |
122 2 * radius); | 120 2 * radius); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 DCHECK_EQ(capture_format_.pixel_format, PIXEL_FORMAT_I420); | 179 DCHECK_EQ(capture_format_.pixel_format, PIXEL_FORMAT_I420); |
182 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution " | 180 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution " |
183 << capture_format_.frame_size.ToString(); | 181 << capture_format_.frame_size.ToString(); |
184 | 182 |
185 const size_t fake_frame_size = | 183 const size_t fake_frame_size = |
186 VideoFrame::AllocationSize(VideoFrame::I420, capture_format_.frame_size); | 184 VideoFrame::AllocationSize(VideoFrame::I420, capture_format_.frame_size); |
187 fake_frame_.reset(new uint8[fake_frame_size]); | 185 fake_frame_.reset(new uint8[fake_frame_size]); |
188 } | 186 } |
189 | 187 |
190 } // namespace media | 188 } // namespace media |
OLD | NEW |