blob: 81473eec425d8a490c77a9c8356ff6eef976f670 [file] [log] [blame]
zijiehe90ea7362016-11-22 17:17:09 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/desktop_capture/test_utils.h"
zijiehe90ea7362016-11-22 17:17:09 -080012
13#include <string.h>
14
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "rtc_base/checks.h"
zijiehe90ea7362016-11-22 17:17:09 -080016
17namespace webrtc {
18
19void ClearDesktopFrame(DesktopFrame* frame) {
20 RTC_DCHECK(frame);
21 uint8_t* data = frame->data();
22 for (int i = 0; i < frame->size().height(); i++) {
23 memset(data, 0, frame->size().width() * DesktopFrame::kBytesPerPixel);
24 data += frame->stride();
25 }
26}
27
28bool DesktopFrameDataEquals(const DesktopFrame& left,
29 const DesktopFrame& right) {
30 if (!left.size().equals(right.size())) {
31 return false;
32 }
33
34 const uint8_t* left_array = left.data();
35 const uint8_t* right_array = right.data();
36 for (int i = 0; i < left.size().height(); i++) {
Yves Gerey665174f2018-06-19 15:03:05 +020037 if (memcmp(left_array, right_array,
zijiehe90ea7362016-11-22 17:17:09 -080038 DesktopFrame::kBytesPerPixel * left.size().width()) != 0) {
39 return false;
40 }
41 left_array += left.stride();
42 right_array += right.stride();
43 }
44
45 return true;
46}
47
48} // namespace webrtc