Chromium Code Reviews| 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(), right.data(), | |
| 41 left.stride() * left.size().height()) == 0; | |
| 42 } | |
| 43 | |
| 44 const uint8_t* my_array = left.data(); | |
| 45 const uint8_t* right_array = right.data(); | |
| 46 for (int i = 0; i < left.size().height(); i++) { | |
| 47 const uint8_t* my_this_line = my_array; | |
| 48 const uint8_t* right_this_line = right_array; | |
| 49 for (int j = 0; j < left.size().width(); j++) { | |
| 50 if (memcmp(my_this_line, right_this_line, DesktopFrame::kBytesPerPixel) != | |
|
Sergey Ulanov
2016/11/15 20:50:23
Why not compare the whole line, instead of compari
Hzj_jie
2016/11/16 01:18:33
Done.
| |
| 51 0) { | |
| 52 return false; | |
| 53 } | |
| 54 my_this_line += DesktopFrame::kBytesPerPixel; | |
| 55 right_this_line += DesktopFrame::kBytesPerPixel; | |
| 56 } | |
| 57 my_array += left.stride(); | |
| 58 right_array += right.stride(); | |
| 59 } | |
| 60 | |
| 61 return true; | |
| 62 } | |
| 63 | |
| 64 } // namespace webrtc | |
| OLD | NEW |