zijiehe | 2d618de | 2016-08-08 17:50:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_MAPPING_H_ |
| 12 | #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_MAPPING_H_ |
| 13 | |
| 14 | #include <D3D11.h> |
| 15 | #include <DXGI1_2.h> |
| 16 | |
| 17 | #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
| 18 | #include "webrtc/modules/desktop_capture/desktop_region.h" |
| 19 | #include "webrtc/modules/desktop_capture/win/dxgi_texture.h" |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | // A DxgiTexture which directly maps bitmap from IDXGIResource. This class is |
| 24 | // used when DXGI_OUTDUPL_DESC.DesktopImageInSystemMemory is true. (This usually |
| 25 | // means the video card shares main memory with CPU, instead of having its own |
| 26 | // individual memory.) |
| 27 | class DxgiTextureMapping : public DxgiTexture { |
| 28 | public: |
| 29 | // Creates a DxgiTextureMapping instance. Caller must maintain the lifetime |
zijiehe | 5fea5fb | 2017-02-16 12:07:44 -0800 | [diff] [blame] | 30 | // of input |duplication| to make sure it outlives this instance. |
| 31 | explicit DxgiTextureMapping(IDXGIOutputDuplication* duplication); |
zijiehe | 2d618de | 2016-08-08 17:50:21 -0700 | [diff] [blame] | 32 | |
| 33 | ~DxgiTextureMapping() override; |
| 34 | |
zijiehe | 5fea5fb | 2017-02-16 12:07:44 -0800 | [diff] [blame] | 35 | protected: |
| 36 | bool CopyFromTexture(const DXGI_OUTDUPL_FRAME_INFO& frame_info, |
| 37 | ID3D11Texture2D* texture) override; |
zijiehe | 2d618de | 2016-08-08 17:50:21 -0700 | [diff] [blame] | 38 | |
| 39 | bool DoRelease() override; |
| 40 | |
| 41 | private: |
| 42 | IDXGIOutputDuplication* const duplication_; |
| 43 | }; |
| 44 | |
| 45 | } // namespace webrtc |
| 46 | |
| 47 | #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_MAPPING_H_ |