Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: webrtc/modules/desktop_capture/test_utils.cc

Issue 2500883004: Add DesktopFrame rotation functions (Closed)
Patch Set: Resolve review comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/desktop_capture/test_utils.h ('k') | webrtc/modules/desktop_capture/test_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/desktop_capture/test_utils.cc
diff --git a/webrtc/modules/desktop_capture/test_utils.cc b/webrtc/modules/desktop_capture/test_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a9c2f86bc9ea3c5bda30b8279c647d0aabac23fe
--- /dev/null
+++ b/webrtc/modules/desktop_capture/test_utils.cc
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/desktop_capture/test_utils.h"
+
+#include <string.h>
+
+#include "webrtc/base/checks.h"
+
+namespace webrtc {
+
+void ClearDesktopFrame(DesktopFrame* frame) {
+ RTC_DCHECK(frame);
+ memset(frame->data(), 0, frame->stride() * frame->size().height());
Sergey Ulanov 2016/11/22 20:33:07 stride() may be negative (see https://codesearch.c
Hzj_jie 2016/11/22 21:56:02 Yes, I noticed this class before. Since ClearDeskt
+}
+
+bool DesktopFrameDataEquals(const DesktopFrame& left,
+ const DesktopFrame& right) {
+ if (!left.size().equals(right.size())) {
+ return false;
+ }
+ if (left.stride() == right.stride() &&
+ left.stride() == DesktopFrame::kBytesPerPixel * left.size().width()) {
Sergey Ulanov 2016/11/22 20:33:07 I don't think you need this optimization, especial
Hzj_jie 2016/11/22 21:56:02 Done.
+ return memcmp(left.data(),
+ right.data(),
+ left.stride() * left.size().height()) == 0;
+ }
+
+ const uint8_t* my_array = left.data();
Sergey Ulanov 2016/11/22 20:33:07 s/my/left/?
Hzj_jie 2016/11/22 21:56:02 Done.
+ const uint8_t* right_array = right.data();
+ for (int i = 0; i < left.size().height(); i++) {
+ if (memcmp(my_array,
+ right_array,
+ DesktopFrame::kBytesPerPixel * left.size().width()) != 0) {
+ return false;
+ }
+ my_array += left.stride();
+ right_array += right.stride();
+ }
+
+ return true;
+}
+
+} // namespace webrtc
« no previous file with comments | « webrtc/modules/desktop_capture/test_utils.h ('k') | webrtc/modules/desktop_capture/test_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698