OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_H_ | 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_H_ |
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_H_ | 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_H_ |
13 | 13 |
14 #include <DXGI1_2.h> | 14 #include <DXGI1_2.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 | 17 |
18 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
19 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 19 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 class DesktopRegion; | 23 class DesktopRegion; |
24 | 24 |
25 // A texture copied or mapped from a DXGI_OUTDUPL_FRAME_INFO and IDXGIResource. | 25 // A texture copied or mapped from a DXGI_OUTDUPL_FRAME_INFO and IDXGIResource. |
26 class DxgiTexture { | 26 class DxgiTexture { |
27 public: | 27 public: |
28 // Creates a DxgiTexture instance, which represents the DesktopRect area of | 28 // Creates a DxgiTexture instance, which represents the |desktop_size| area of |
29 // entire screen -- usually a monitor on the system. | 29 // entire screen -- usually a monitor on the system. |
30 explicit DxgiTexture(const DesktopRect& desktop_rect); | 30 explicit DxgiTexture(const DesktopSize& desktop_size); |
31 | 31 |
32 virtual ~DxgiTexture(); | 32 virtual ~DxgiTexture(); |
33 | 33 |
34 // Copies selected regions of a frame represented by frame_info and resource. | 34 // Copies selected regions of a frame represented by frame_info and resource. |
35 // Returns false if anything wrong. | 35 // Returns false if anything wrong. |
36 virtual bool CopyFrom(const DXGI_OUTDUPL_FRAME_INFO& frame_info, | 36 virtual bool CopyFrom(const DXGI_OUTDUPL_FRAME_INFO& frame_info, |
37 IDXGIResource* resource, | 37 IDXGIResource* resource) = 0; |
38 const DesktopRegion& region) = 0; | |
39 | 38 |
40 const DesktopRect& desktop_rect() const { return desktop_rect_; } | 39 const DesktopSize& desktop_size() const { return desktop_size_; } |
41 | 40 |
42 uint8_t* bits() const { return static_cast<uint8_t*>(rect_.pBits); } | 41 uint8_t* bits() const { return static_cast<uint8_t*>(rect_.pBits); } |
43 | 42 |
44 int pitch() const { return static_cast<int>(rect_.Pitch); } | 43 int pitch() const { return static_cast<int>(rect_.Pitch); } |
45 | 44 |
46 // Releases the resource currently holds by this instance. Returns false if | 45 // Releases the resource currently holds by this instance. Returns false if |
47 // anything wrong, and this instance should be deprecated in this state. bits, | 46 // anything wrong, and this instance should be deprecated in this state. bits, |
48 // pitch and AsDesktopFrame are only valid after a success CopyFrom() call, | 47 // pitch and AsDesktopFrame are only valid after a success CopyFrom() call, |
49 // but before Release() call. | 48 // but before Release() call. |
50 bool Release(); | 49 bool Release(); |
51 | 50 |
52 // Returns a DesktopFrame snapshot of a DxgiTexture instance. This | 51 // Returns a DesktopFrame snapshot of a DxgiTexture instance. This |
53 // DesktopFrame is used to copy a DxgiTexture content to another DesktopFrame | 52 // DesktopFrame is used to copy a DxgiTexture content to another DesktopFrame |
54 // only. And it should not outlive its DxgiTexture instance. | 53 // only. And it should not outlive its DxgiTexture instance. |
55 const DesktopFrame& AsDesktopFrame(); | 54 const DesktopFrame& AsDesktopFrame(); |
56 | 55 |
57 protected: | 56 protected: |
58 DXGI_MAPPED_RECT rect_ = {0}; | 57 DXGI_MAPPED_RECT rect_ = {0}; |
59 | 58 |
60 private: | 59 private: |
61 virtual bool DoRelease() = 0; | 60 virtual bool DoRelease() = 0; |
62 | 61 |
63 const DesktopRect desktop_rect_; | 62 const DesktopSize desktop_size_; |
64 std::unique_ptr<DesktopFrame> frame_; | 63 std::unique_ptr<DesktopFrame> frame_; |
65 }; | 64 }; |
66 | 65 |
67 } // namespace webrtc | 66 } // namespace webrtc |
68 | 67 |
69 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_H_ | 68 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_H_ |
OLD | NEW |