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 "webrtc/modules/desktop_capture/cropped_desktop_frame.h" | 11 #include "webrtc/modules/desktop_capture/cropped_desktop_frame.h" |
12 | 12 |
13 namespace webrtc { | 13 namespace webrtc { |
14 | 14 |
15 // A DesktopFrame that is a sub-rect of another DesktopFrame. | 15 // A DesktopFrame that is a sub-rect of another DesktopFrame. |
16 class CroppedDesktopFrame : public DesktopFrame { | 16 class CroppedDesktopFrame : public DesktopFrame { |
17 public: | 17 public: |
18 CroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect); | 18 CroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect); |
19 | 19 |
20 private: | 20 private: |
21 rtc::scoped_ptr<DesktopFrame> frame_; | 21 rtc::scoped_ptr<DesktopFrame> frame_; |
22 | 22 |
23 DISALLOW_COPY_AND_ASSIGN(CroppedDesktopFrame); | 23 RTC_DISALLOW_COPY_AND_ASSIGN(CroppedDesktopFrame); |
24 }; | 24 }; |
25 | 25 |
26 DesktopFrame* | 26 DesktopFrame* |
27 CreateCroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect) { | 27 CreateCroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect) { |
28 if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) { | 28 if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) { |
29 delete frame; | 29 delete frame; |
30 return NULL; | 30 return NULL; |
31 } | 31 } |
32 | 32 |
33 return new CroppedDesktopFrame(frame, rect); | 33 return new CroppedDesktopFrame(frame, rect); |
34 } | 34 } |
35 | 35 |
36 CroppedDesktopFrame::CroppedDesktopFrame(DesktopFrame* frame, | 36 CroppedDesktopFrame::CroppedDesktopFrame(DesktopFrame* frame, |
37 const DesktopRect& rect) | 37 const DesktopRect& rect) |
38 : DesktopFrame(rect.size(), | 38 : DesktopFrame(rect.size(), |
39 frame->stride(), | 39 frame->stride(), |
40 frame->GetFrameDataAtPos(rect.top_left()), | 40 frame->GetFrameDataAtPos(rect.top_left()), |
41 frame->shared_memory()), | 41 frame->shared_memory()), |
42 frame_(frame) { | 42 frame_(frame) { |
43 } | 43 } |
44 | 44 |
45 } // namespace webrtc | 45 } // namespace webrtc |
OLD | NEW |