Do not crop DesktopFrame if the size won't change
CreateCroppedDesktopFrame() does not need to create a CroppedDesktopFrame if the size won't change. Bug: webrtc:8039 Change-Id: Ie6789a4b473b69bced94c4a25a68f1da6bb3510e Reviewed-on: https://chromium-review.googlesource.com/587808 Commit-Queue: Zijie He <zijiehe@chromium.org> Reviewed-by: Jamie Walch <jamiewalch@chromium.org> Cr-Commit-Position: refs/heads/master@{#19163}
This commit is contained in:
parent
2059bb3e4b
commit
9c0914f938
@ -12,6 +12,7 @@
|
||||
|
||||
#include "webrtc/modules/desktop_capture/cropped_desktop_frame.h"
|
||||
|
||||
#include "webrtc/rtc_base/checks.h"
|
||||
#include "webrtc/rtc_base/constructormagic.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -31,8 +32,15 @@ class CroppedDesktopFrame : public DesktopFrame {
|
||||
std::unique_ptr<DesktopFrame> CreateCroppedDesktopFrame(
|
||||
std::unique_ptr<DesktopFrame> frame,
|
||||
const DesktopRect& rect) {
|
||||
if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect))
|
||||
RTC_DCHECK(frame);
|
||||
|
||||
if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (frame->size().equals(rect.size())) {
|
||||
return frame;
|
||||
}
|
||||
|
||||
return std::unique_ptr<DesktopFrame>(
|
||||
new CroppedDesktopFrame(std::move(frame), rect));
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Creates a DesktopFrame to contain only the area of |rect| in the original
|
||||
// |frame|.
|
||||
// |frame| should not be nullptr. |rect| is in |frame| coordinate, i.e.
|
||||
// |frame|->top_left() does not impact the area of |rect|.
|
||||
// Returns nullptr frame if |rect| is not contained by the bounds of |frame|.
|
||||
std::unique_ptr<DesktopFrame> CreateCroppedDesktopFrame(
|
||||
std::unique_ptr<DesktopFrame> frame,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user