blob: 0a4749afdbacbef1fa97fae0bb7cbecb8d63ff66 [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++) {
37 if (memcmp(left_array,
38 right_array,
39 DesktopFrame::kBytesPerPixel * left.size().width()) != 0) {
40 return false;
41 }
42 left_array += left.stride();
43 right_array += right.stride();
44 }
45
46 return true;
47}
48
49} // namespace webrtc