• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "modules/desktop_capture/test_utils.h"
12 
13 #include <stdint.h>
14 #include <string.h>
15 
16 #include "modules/desktop_capture/desktop_geometry.h"
17 #include "rtc_base/checks.h"
18 
19 namespace webrtc {
20 
ClearDesktopFrame(DesktopFrame * frame)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 
DesktopFrameDataEquals(const DesktopFrame & left,const DesktopFrame & right)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++) {
39     if (memcmp(left_array, right_array,
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
51