Index: webrtc/modules/desktop_capture/cropped_desktop_frame.cc |
diff --git a/webrtc/modules/desktop_capture/cropped_desktop_frame.cc b/webrtc/modules/desktop_capture/cropped_desktop_frame.cc |
index 733fe9b2adf5dc244087a04411305f7dff63afb3..b26d5b0600acf27da8d7cdf4044e93605e66c589 100644 |
--- a/webrtc/modules/desktop_capture/cropped_desktop_frame.cc |
+++ b/webrtc/modules/desktop_capture/cropped_desktop_frame.cc |
@@ -19,7 +19,8 @@ namespace webrtc { |
// A DesktopFrame that is a sub-rect of another DesktopFrame. |
class CroppedDesktopFrame : public DesktopFrame { |
public: |
- CroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect); |
+ CroppedDesktopFrame(std::unique_ptr<DesktopFrame> frame, |
+ const DesktopRect& rect); |
private: |
std::unique_ptr<DesktopFrame> frame_; |
@@ -27,23 +28,23 @@ class CroppedDesktopFrame : public DesktopFrame { |
RTC_DISALLOW_COPY_AND_ASSIGN(CroppedDesktopFrame); |
}; |
-DesktopFrame* |
-CreateCroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect) { |
- if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) { |
- delete frame; |
- return NULL; |
- } |
+std::unique_ptr<DesktopFrame> CreateCroppedDesktopFrame( |
+ std::unique_ptr<DesktopFrame> frame, |
+ const DesktopRect& rect) { |
+ if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) |
+ return nullptr; |
- return new CroppedDesktopFrame(frame, rect); |
+ return std::unique_ptr<DesktopFrame>( |
+ new CroppedDesktopFrame(std::move(frame), rect)); |
} |
-CroppedDesktopFrame::CroppedDesktopFrame(DesktopFrame* frame, |
+CroppedDesktopFrame::CroppedDesktopFrame(std::unique_ptr<DesktopFrame> frame, |
const DesktopRect& rect) |
: DesktopFrame(rect.size(), |
frame->stride(), |
frame->GetFrameDataAtPos(rect.top_left()), |
- frame->shared_memory()), |
- frame_(frame) { |
+ frame->shared_memory()) { |
+ frame_ = std::move(frame); |
} |
} // namespace webrtc |