test_utils.cc (1492B)
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 <cstdint> 14 #include <cstring> 15 16 #include "modules/desktop_capture/desktop_frame.h" 17 #include "modules/desktop_capture/desktop_geometry.h" 18 #include "rtc_base/checks.h" 19 20 namespace webrtc { 21 22 void ClearDesktopFrame(DesktopFrame* frame) { 23 RTC_DCHECK(frame); 24 uint8_t* data = frame->data(); 25 for (int i = 0; i < frame->size().height(); i++) { 26 memset(data, 0, frame->size().width() * DesktopFrame::kBytesPerPixel); 27 data += frame->stride(); 28 } 29 } 30 31 bool DesktopFrameDataEquals(const DesktopFrame& left, 32 const DesktopFrame& right) { 33 if (!left.size().equals(right.size())) { 34 return false; 35 } 36 37 const uint8_t* left_array = left.data(); 38 const uint8_t* right_array = right.data(); 39 for (int i = 0; i < left.size().height(); i++) { 40 if (memcmp(left_array, right_array, 41 DesktopFrame::kBytesPerPixel * left.size().width()) != 0) { 42 return false; 43 } 44 left_array += left.stride(); 45 right_array += right.stride(); 46 } 47 48 return true; 49 } 50 51 } // namespace webrtc