| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <memory> |
| 12 |
| 11 #include "webrtc/modules/desktop_capture/cropped_desktop_frame.h" | 13 #include "webrtc/modules/desktop_capture/cropped_desktop_frame.h" |
| 12 | 14 |
| 13 namespace webrtc { | 15 namespace webrtc { |
| 14 | 16 |
| 15 // A DesktopFrame that is a sub-rect of another DesktopFrame. | 17 // A DesktopFrame that is a sub-rect of another DesktopFrame. |
| 16 class CroppedDesktopFrame : public DesktopFrame { | 18 class CroppedDesktopFrame : public DesktopFrame { |
| 17 public: | 19 public: |
| 18 CroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect); | 20 CroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect); |
| 19 | 21 |
| 20 private: | 22 private: |
| 21 rtc::scoped_ptr<DesktopFrame> frame_; | 23 std::unique_ptr<DesktopFrame> frame_; |
| 22 | 24 |
| 23 RTC_DISALLOW_COPY_AND_ASSIGN(CroppedDesktopFrame); | 25 RTC_DISALLOW_COPY_AND_ASSIGN(CroppedDesktopFrame); |
| 24 }; | 26 }; |
| 25 | 27 |
| 26 DesktopFrame* | 28 DesktopFrame* |
| 27 CreateCroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect) { | 29 CreateCroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect) { |
| 28 if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) { | 30 if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) { |
| 29 delete frame; | 31 delete frame; |
| 30 return NULL; | 32 return NULL; |
| 31 } | 33 } |
| 32 | 34 |
| 33 return new CroppedDesktopFrame(frame, rect); | 35 return new CroppedDesktopFrame(frame, rect); |
| 34 } | 36 } |
| 35 | 37 |
| 36 CroppedDesktopFrame::CroppedDesktopFrame(DesktopFrame* frame, | 38 CroppedDesktopFrame::CroppedDesktopFrame(DesktopFrame* frame, |
| 37 const DesktopRect& rect) | 39 const DesktopRect& rect) |
| 38 : DesktopFrame(rect.size(), | 40 : DesktopFrame(rect.size(), |
| 39 frame->stride(), | 41 frame->stride(), |
| 40 frame->GetFrameDataAtPos(rect.top_left()), | 42 frame->GetFrameDataAtPos(rect.top_left()), |
| 41 frame->shared_memory()), | 43 frame->shared_memory()), |
| 42 frame_(frame) { | 44 frame_(frame) { |
| 43 } | 45 } |
| 44 | 46 |
| 45 } // namespace webrtc | 47 } // namespace webrtc |
| OLD | NEW |