blob: 0291a90aaaf5b00cd3d704896befacca920cf31c [file] [log] [blame]
zijiehe2d618de2016-08-08 17:50:21 -07001/*
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
21namespace 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.)
27class DxgiTextureMapping : public DxgiTexture {
28 public:
29 // Creates a DxgiTextureMapping instance. Caller must maintain the lifetime
zijiehe5fea5fb2017-02-16 12:07:44 -080030 // of input |duplication| to make sure it outlives this instance.
31 explicit DxgiTextureMapping(IDXGIOutputDuplication* duplication);
zijiehe2d618de2016-08-08 17:50:21 -070032
33 ~DxgiTextureMapping() override;
34
zijiehe5fea5fb2017-02-16 12:07:44 -080035 protected:
36 bool CopyFromTexture(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
37 ID3D11Texture2D* texture) override;
zijiehe2d618de2016-08-08 17:50:21 -070038
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_