| Index: webrtc/modules/desktop_capture/win/dxgi_texture.cc
|
| diff --git a/webrtc/modules/desktop_capture/win/dxgi_texture.cc b/webrtc/modules/desktop_capture/win/dxgi_texture.cc
|
| index 9af8a06cd5e009d188c357319485a91a9d20e04a..27ccbf6230c7f9c44f7885eb69f30618c5bc264d 100644
|
| --- a/webrtc/modules/desktop_capture/win/dxgi_texture.cc
|
| +++ b/webrtc/modules/desktop_capture/win/dxgi_texture.cc
|
| @@ -10,7 +10,15 @@
|
|
|
| #include "webrtc/modules/desktop_capture/win/dxgi_texture.h"
|
|
|
| +#include <comdef.h>
|
| +#include <wrl/client.h>
|
| +#include <D3D11.h>
|
| +
|
| +#include "webrtc/base/checks.h"
|
| #include "webrtc/modules/desktop_capture/desktop_region.h"
|
| +#include "webrtc/system_wrappers/include/logging.h"
|
| +
|
| +using Microsoft::WRL::ComPtr;
|
|
|
| namespace webrtc {
|
|
|
| @@ -29,10 +37,33 @@ class DxgiDesktopFrame : public DesktopFrame {
|
|
|
| } // namespace
|
|
|
| -DxgiTexture::DxgiTexture(const DesktopSize& desktop_size)
|
| - : desktop_size_(desktop_size) {}
|
| +DxgiTexture::DxgiTexture() = default;
|
| +DxgiTexture::~DxgiTexture() = default;
|
|
|
| -DxgiTexture::~DxgiTexture() {}
|
| +bool DxgiTexture::CopyFrom(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
|
| + IDXGIResource* resource) {
|
| + RTC_DCHECK(resource && frame_info.AccumulatedFrames > 0);
|
| + ComPtr<ID3D11Texture2D> texture;
|
| + _com_error error = resource->QueryInterface(
|
| + __uuidof(ID3D11Texture2D),
|
| + reinterpret_cast<void**>(texture.GetAddressOf()));
|
| + if (error.Error() != S_OK || !texture) {
|
| + LOG(LS_ERROR) << "Failed to convert IDXGIResource to ID3D11Texture2D, "
|
| + "error "
|
| + << error.ErrorMessage() << ", code " << error.Error();
|
| + return false;
|
| + }
|
| +
|
| + D3D11_TEXTURE2D_DESC desc = {0};
|
| + texture->GetDesc(&desc);
|
| + desktop_size_.set(desc.Width, desc.Height);
|
| + if (resolution_change_detector_.IsChanged(desktop_size_)) {
|
| + LOG(LS_ERROR) << "Texture size is not consistent with current DxgiTexture.";
|
| + return false;
|
| + }
|
| +
|
| + return CopyFromTexture(frame_info, texture.Get());
|
| +}
|
|
|
| const DesktopFrame& DxgiTexture::AsDesktopFrame() {
|
| if (!frame_) {
|
| @@ -46,4 +77,8 @@ bool DxgiTexture::Release() {
|
| return DoRelease();
|
| }
|
|
|
| +DXGI_MAPPED_RECT* DxgiTexture::rect() {
|
| + return &rect_;
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|