zijiehe | 90ea736 | 2016-11-22 17:17:09 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/desktop_capture/test_utils.h" |
zijiehe | 90ea736 | 2016-11-22 17:17:09 -0800 | [diff] [blame] | 12 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 13 | #include <stdint.h> |
zijiehe | 90ea736 | 2016-11-22 17:17:09 -0800 | [diff] [blame] | 14 | #include <string.h> |
| 15 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 16 | #include "modules/desktop_capture/desktop_geometry.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "rtc_base/checks.h" |
zijiehe | 90ea736 | 2016-11-22 17:17:09 -0800 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | void ClearDesktopFrame(DesktopFrame* frame) { |
| 22 | RTC_DCHECK(frame); |
| 23 | uint8_t* data = frame->data(); |
| 24 | for (int i = 0; i < frame->size().height(); i++) { |
| 25 | memset(data, 0, frame->size().width() * DesktopFrame::kBytesPerPixel); |
| 26 | data += frame->stride(); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | bool DesktopFrameDataEquals(const DesktopFrame& left, |
| 31 | const DesktopFrame& right) { |
| 32 | if (!left.size().equals(right.size())) { |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | const uint8_t* left_array = left.data(); |
| 37 | const uint8_t* right_array = right.data(); |
| 38 | for (int i = 0; i < left.size().height(); i++) { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 39 | if (memcmp(left_array, right_array, |
zijiehe | 90ea736 | 2016-11-22 17:17:09 -0800 | [diff] [blame] | 40 | DesktopFrame::kBytesPerPixel * left.size().width()) != 0) { |
| 41 | return false; |
| 42 | } |
| 43 | left_array += left.stride(); |
| 44 | right_array += right.stride(); |
| 45 | } |
| 46 | |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | } // namespace webrtc |