You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

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