Add DesktopFrame::MoveFrameInfoFrom() and DesktopFrame::CopyFrameInfoFrom()

The original change https://chromium-review.googlesource.com/c/575315 and
https://chromium-review.googlesource.com/c/590508 have not been well-considered.
So this change reverts part of two changes and adds a
DesktopFrame::set_top_left() function

A DesktopFrame usually contains a very large chunk of memory, which should be
reused as much as possible to reduce the memory allocations. The size of the
memory usually controls by the DesktopFrame::size(). So it's reasonable to const
DesktopFrame::size_: changing it is wrong if the underly buffer is not large
enough.

But DesktopFrame::top_left() is a different story, same as capturer_id,
capture_time_ms and other information in the DesktopFrame, it can be changed to
any value without needing to reconstruct a DesktopFrame instance. So instead of
adding it to the constructor, a DesktopFrame::set_top_left() is added to adjust
the top-left of the DesktopFrame in the entire display coordinate.

After adding DesktopFrame::set_top_left(), we have five variables in a
DesktopFrame which is not initialized in the constructor. For any kind of
wrapper DesktopFrame, say, SharedDesktopFrame and CroppedDesktopFrame, they
needs to copy these five variables after constructing themselves. This is not
convenient and easily to be broken if an implementation forgot to copy them.

So DesktopFrame::MoveFrameInfoFrom() and DesktopFrame::CopyFrameInfoFrom() are
added to the DesktopFrame to help derived classes to copy or move these
variables in one function call.
The difference between MoveFrameInfoFrom() and CopyFrameInfoFrom() is that the
former one uses DesktopRegion::Swap() to move the DesktopRegion from the source
DesktopFrame to this instance, while the later one uses copy-operator to copy
the DesktopRegion from the source DesktopFrame.
So CopyFrameInfoFrom() is usually used when sharing a source DesktopFrame with
several clients. I.e. the source DesktopFrame should be kept unchanged. For
example, BasicDesktopFrame::CopyOf() and SharedDesktopFrame::Share().
On the other side, MoveFrameInfoFrom() is usually used when wrapping a
DesktopFrame. E.g. CroppedDesktopFrame and DesktopFrameWithCursor.

Bug: webrtc:7950
Change-Id: I8b23418960fb681d2ea1f012d1b453f514da2272
Reviewed-on: https://chromium-review.googlesource.com/622453
Commit-Queue: Zijie He <zijiehe@chromium.org>
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#19504}
7 files changed
tree: d52df0164ff68c2459c18dc36a374d1a5eb45b4f
  1. build_overrides/
  2. data/
  3. infra/
  4. resources/
  5. tools_webrtc/
  6. webrtc/
  7. .clang-format
  8. .git-blame-ignore-revs
  9. .gitignore
  10. .gn
  11. AUTHORS
  12. BUILD.gn
  13. CODE_OF_CONDUCT.md
  14. codereview.settings
  15. DEPS
  16. LICENSE
  17. license_template.txt
  18. LICENSE_THIRD_PARTY
  19. OWNERS
  20. PATENTS
  21. PRESUBMIT.py
  22. pylintrc
  23. README.md
  24. WATCHLISTS
README.md

WebRTC is a free, open software project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. The WebRTC components have been optimized to best serve this purpose.

Our mission: To enable rich, high-quality RTC applications to be developed for the browser, mobile platforms, and IoT devices, and allow them all to communicate via a common set of protocols.

The WebRTC initiative is a project supported by Google, Mozilla and Opera, amongst others.

Development

See http://www.webrtc.org/native-code/development for instructions on how to get started developing with the native code.

More info