| 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/capture/video/fake_video_capture_device.h" | 5 #include "media/capture/video/fake_video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace media { | 25 namespace media { |
| 26 | 26 |
| 27 // Sweep at 600 deg/sec. | 27 // Sweep at 600 deg/sec. |
| 28 static const float kPacmanAngularVelocity = 600; | 28 static const float kPacmanAngularVelocity = 600; |
| 29 // Beep every 500 ms. | 29 // Beep every 500 ms. |
| 30 static const int kBeepInterval = 500; | 30 static const int kBeepInterval = 500; |
| 31 // Gradient travels from bottom to top in 5 seconds. | 31 // Gradient travels from bottom to top in 5 seconds. |
| 32 static const float kGradientFrequency = 1.f / 5; | 32 static const float kGradientFrequency = 1.f / 5; |
| 33 | 33 |
| 34 static const uint32_t kMinZoom = 100; | 34 static const double kMinZoom = 100.0; |
| 35 static const uint32_t kMaxZoom = 400; | 35 static const double kMaxZoom = 400.0; |
| 36 static const uint32_t kZoomStep = 1; | 36 static const double kZoomStep = 1.0; |
| 37 | 37 |
| 38 // Starting from top left, -45 deg gradient. Value at point (row, column) is | 38 // Starting from top left, -45 deg gradient. Value at point (row, column) is |
| 39 // calculated as (top_left_value + (row + column) * step) % MAX_VALUE, where | 39 // calculated as (top_left_value + (row + column) * step) % MAX_VALUE, where |
| 40 // step is MAX_VALUE / (width + height). MAX_VALUE is 255 (for 8 bit per | 40 // step is MAX_VALUE / (width + height). MAX_VALUE is 255 (for 8 bit per |
| 41 // component) or 65535 for Y16. | 41 // component) or 65535 for Y16. |
| 42 // This is handy for pixel tests where we use the squares to verify rendering. | 42 // This is handy for pixel tests where we use the squares to verify rendering. |
| 43 void DrawGradientSquares(VideoPixelFormat frame_format, | 43 void DrawGradientSquares(VideoPixelFormat frame_format, |
| 44 uint8_t* const pixels, | 44 uint8_t* const pixels, |
| 45 base::TimeDelta elapsed_time, | 45 base::TimeDelta elapsed_time, |
| 46 const gfx::Size& frame_size) { | 46 const gfx::Size& frame_size) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 void DrawPacman(VideoPixelFormat frame_format, | 83 void DrawPacman(VideoPixelFormat frame_format, |
| 84 uint8_t* const data, | 84 uint8_t* const data, |
| 85 base::TimeDelta elapsed_time, | 85 base::TimeDelta elapsed_time, |
| 86 float frame_rate, | 86 float frame_rate, |
| 87 const gfx::Size& frame_size, | 87 const gfx::Size& frame_size, |
| 88 uint32_t zoom) { | 88 double zoom) { |
| 89 // |kN32_SkColorType| stands for the appropriate RGBA/BGRA format. | 89 // |kN32_SkColorType| stands for the appropriate RGBA/BGRA format. |
| 90 const SkColorType colorspace = (frame_format == PIXEL_FORMAT_ARGB) | 90 const SkColorType colorspace = (frame_format == PIXEL_FORMAT_ARGB) |
| 91 ? kN32_SkColorType | 91 ? kN32_SkColorType |
| 92 : kAlpha_8_SkColorType; | 92 : kAlpha_8_SkColorType; |
| 93 // Skia doesn't support 16 bit alpha rendering, so we 8 bit alpha and then use | 93 // Skia doesn't support 16 bit alpha rendering, so we 8 bit alpha and then use |
| 94 // this as high byte values in 16 bit pixels. | 94 // this as high byte values in 16 bit pixels. |
| 95 const SkImageInfo info = SkImageInfo::Make( | 95 const SkImageInfo info = SkImageInfo::Make( |
| 96 frame_size.width(), frame_size.height(), colorspace, kOpaque_SkAlphaType); | 96 frame_size.width(), frame_size.height(), colorspace, kOpaque_SkAlphaType); |
| 97 SkBitmap bitmap; | 97 SkBitmap bitmap; |
| 98 bitmap.setInfo(info); | 98 bitmap.setInfo(info); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 void FakeVideoCaptureDevice::StopAndDeAllocate() { | 240 void FakeVideoCaptureDevice::StopAndDeAllocate() { |
| 241 DCHECK(thread_checker_.CalledOnValidThread()); | 241 DCHECK(thread_checker_.CalledOnValidThread()); |
| 242 client_.reset(); | 242 client_.reset(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void FakeVideoCaptureDevice::GetPhotoCapabilities( | 245 void FakeVideoCaptureDevice::GetPhotoCapabilities( |
| 246 GetPhotoCapabilitiesCallback callback) { | 246 GetPhotoCapabilitiesCallback callback) { |
| 247 mojom::PhotoCapabilitiesPtr photo_capabilities = | 247 mojom::PhotoCapabilitiesPtr photo_capabilities = |
| 248 mojom::PhotoCapabilities::New(); | 248 mojom::PhotoCapabilities::New(); |
| 249 photo_capabilities->iso = mojom::Range::New(); | 249 photo_capabilities->iso = mojom::Range::New(); |
| 250 photo_capabilities->iso->current = 100; | 250 photo_capabilities->iso->current = 100.0; |
| 251 photo_capabilities->iso->max = 100; | 251 photo_capabilities->iso->max = 100.0; |
| 252 photo_capabilities->iso->min = 100; | 252 photo_capabilities->iso->min = 100.0; |
| 253 photo_capabilities->iso->step = 0; | 253 photo_capabilities->iso->step = 0.0; |
| 254 photo_capabilities->height = mojom::Range::New(); | 254 photo_capabilities->height = mojom::Range::New(); |
| 255 photo_capabilities->height->current = capture_format_.frame_size.height(); | 255 photo_capabilities->height->current = capture_format_.frame_size.height(); |
| 256 photo_capabilities->height->max = 1080; | 256 photo_capabilities->height->max = 1080.0; |
| 257 photo_capabilities->height->min = 240; | 257 photo_capabilities->height->min = 96.0; |
| 258 photo_capabilities->height->step = 1; | 258 photo_capabilities->height->step = 1.0; |
| 259 photo_capabilities->width = mojom::Range::New(); | 259 photo_capabilities->width = mojom::Range::New(); |
| 260 photo_capabilities->width->current = capture_format_.frame_size.width(); | 260 photo_capabilities->width->current = capture_format_.frame_size.width(); |
| 261 photo_capabilities->width->max = 1920; | 261 photo_capabilities->width->max = 1920.0; |
| 262 photo_capabilities->width->min = 320; | 262 photo_capabilities->width->min = 96.0; |
| 263 photo_capabilities->width->step = 1; | 263 photo_capabilities->width->step = 1; |
| 264 photo_capabilities->zoom = mojom::Range::New(); | 264 photo_capabilities->zoom = mojom::Range::New(); |
| 265 photo_capabilities->zoom->current = current_zoom_; | 265 photo_capabilities->zoom->current = current_zoom_; |
| 266 photo_capabilities->zoom->max = kMaxZoom; | 266 photo_capabilities->zoom->max = kMaxZoom; |
| 267 photo_capabilities->zoom->min = kMinZoom; | 267 photo_capabilities->zoom->min = kMinZoom; |
| 268 photo_capabilities->zoom->step = kZoomStep; | 268 photo_capabilities->zoom->step = kZoomStep; |
| 269 photo_capabilities->focus_mode = mojom::MeteringMode::NONE; | 269 photo_capabilities->focus_mode = mojom::MeteringMode::NONE; |
| 270 photo_capabilities->exposure_mode = mojom::MeteringMode::NONE; | 270 photo_capabilities->exposure_mode = mojom::MeteringMode::NONE; |
| 271 photo_capabilities->exposure_compensation = mojom::Range::New(); | 271 photo_capabilities->exposure_compensation = mojom::Range::New(); |
| 272 photo_capabilities->white_balance_mode = mojom::MeteringMode::NONE; | 272 photo_capabilities->white_balance_mode = mojom::MeteringMode::NONE; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // Don't accumulate any debt if we are lagging behind - just post the next | 366 // Don't accumulate any debt if we are lagging behind - just post the next |
| 367 // frame immediately and continue as normal. | 367 // frame immediately and continue as normal. |
| 368 const base::TimeTicks next_execution_time = | 368 const base::TimeTicks next_execution_time = |
| 369 std::max(current_time, expected_execution_time + frame_interval); | 369 std::max(current_time, expected_execution_time + frame_interval); |
| 370 const base::TimeDelta delay = next_execution_time - current_time; | 370 const base::TimeDelta delay = next_execution_time - current_time; |
| 371 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 371 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 372 FROM_HERE, base::Bind(next_capture, next_execution_time), delay); | 372 FROM_HERE, base::Bind(next_capture, next_execution_time), delay); |
| 373 } | 373 } |
| 374 | 374 |
| 375 } // namespace media | 375 } // namespace media |
| OLD | NEW |