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

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

Issue 2500883004: Add DesktopFrame rotation functions (Closed)
Patch Set: 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
Index: webrtc/modules/desktop_capture/desktop_frame.cc
diff --git a/webrtc/modules/desktop_capture/desktop_frame.cc b/webrtc/modules/desktop_capture/desktop_frame.cc
index dfc0928b6631b83522e498dd07224c1c59e2bf8b..a1ee33b2c52c888522c2be804c94e1ee8e9bd111 100644
--- a/webrtc/modules/desktop_capture/desktop_frame.cc
+++ b/webrtc/modules/desktop_capture/desktop_frame.cc
@@ -57,6 +57,44 @@ uint8_t* DesktopFrame::GetFrameDataAtPos(const DesktopVector& pos) const {
return data() + stride() * pos.y() + DesktopFrame::kBytesPerPixel * pos.x();
}
+bool DesktopFrame::DataEquals(const DesktopFrame& other) const {
+ if (!size().equals(other.size())) {
+ return false;
+ }
+ if (stride() == other.stride() &&
+ stride() == DesktopFrame::kBytesPerPixel * size().width()) {
+ return memcmp(data(), other.data(), stride() * size().height()) == 0;
+ }
+
+ const uint8_t* my_array = data();
+ const uint8_t* other_array = other.data();
+ for (int i = 0; i < size().height(); i++) {
+ const uint8_t* my_this_line = my_array;
+ const uint8_t* other_this_line = other_array;
+ for (int j = 0; j < size().width(); j++) {
+ if (memcmp(my_this_line, other_this_line, kBytesPerPixel)
+ != 0) {
+ return false;
+ }
+ my_this_line += kBytesPerPixel;
+ other_this_line += kBytesPerPixel;
+ }
+ my_array += stride();
+ other_array += other.stride();
+ }
+
+ return true;
+}
+
+void DesktopFrame::Paint(DesktopVector pos, RgbaColor color) {
+ RTC_DCHECK(DesktopRect::MakeSize(size()).Contains(pos));
+ *reinterpret_cast<uint32_t*>(GetFrameDataAtPos(pos)) = color.ToUInt32();
+}
+
+void DesktopFrame::Clear() {
+ memset(data(), 0, stride() * size().height());
+}
+
BasicDesktopFrame::BasicDesktopFrame(DesktopSize size)
: DesktopFrame(size, kBytesPerPixel * size.width(),
new uint8_t[kBytesPerPixel * size.width() * size.height()],

Powered by Google App Engine
This is Rietveld 408576698