| OLD | NEW |
| (Empty) | |
| 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 "webrtc/modules/desktop_capture/test_utils.h" |
| 12 |
| 13 #include <string.h> |
| 14 |
| 15 #include "webrtc/base/checks.h" |
| 16 |
| 17 namespace webrtc { |
| 18 |
| 19 void PaintDesktopFrame(DesktopFrame* frame, |
| 20 DesktopVector pos, |
| 21 RgbaColor color) { |
| 22 RTC_DCHECK(frame); |
| 23 RTC_DCHECK(DesktopRect::MakeSize(frame->size()).Contains(pos)); |
| 24 *reinterpret_cast<uint32_t*>(frame->GetFrameDataAtPos(pos)) = |
| 25 color.ToUInt32(); |
| 26 } |
| 27 |
| 28 void ClearDesktopFrame(DesktopFrame* frame) { |
| 29 RTC_DCHECK(frame); |
| 30 memset(frame->data(), 0, frame->stride() * frame->size().height()); |
| 31 } |
| 32 |
| 33 bool DesktopFrameDataEquals(const DesktopFrame& left, |
| 34 const DesktopFrame& right) { |
| 35 if (!left.size().equals(right.size())) { |
| 36 return false; |
| 37 } |
| 38 if (left.stride() == right.stride() && |
| 39 left.stride() == DesktopFrame::kBytesPerPixel * left.size().width()) { |
| 40 return memcmp(left.data(), |
| 41 right.data(), |
| 42 left.stride() * left.size().height()) == 0; |
| 43 } |
| 44 |
| 45 const uint8_t* my_array = left.data(); |
| 46 const uint8_t* right_array = right.data(); |
| 47 for (int i = 0; i < left.size().height(); i++) { |
| 48 if (memcmp(my_array, |
| 49 right_array, |
| 50 DesktopFrame::kBytesPerPixel * left.size().width()) != 0) { |
| 51 return false; |
| 52 } |
| 53 my_array += left.stride(); |
| 54 right_array += right.stride(); |
| 55 } |
| 56 |
| 57 return true; |
| 58 } |
| 59 |
| 60 } // namespace webrtc |
| OLD | NEW |