blob: 9483bf41eabbb3b0be3d55372d3c9bf67b16ce4c [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
Yves Gerey3e707812018-11-28 16:47:49 +010013#include <stdint.h>
zijiehe90ea7362016-11-22 17:17:09 -080014#include <string.h>
15
Yves Gerey3e707812018-11-28 16:47:49 +010016#include "modules/desktop_capture/desktop_geometry.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "rtc_base/checks.h"
zijiehe90ea7362016-11-22 17:17:09 -080018
19namespace webrtc {
20
21void 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
30bool 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 Gerey665174f2018-06-19 15:03:05 +020039 if (memcmp(left_array, right_array,
zijiehe90ea7362016-11-22 17:17:09 -080040 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