Skip to content

Commit

Permalink
Needed changes before multi-monitor support
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Oct 28, 2024
1 parent af160dc commit 1785dd2
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 100 deletions.
66 changes: 52 additions & 14 deletions include/grabber/windows/DX/DxGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,59 @@
#include <vector>
#include <map>
#include <chrono>
#include <list>
#include <algorithm>
#endif

// util includes
#include <utils/PixelFormat.h>
#include <base/Grabber.h>
#include <utils/Components.h>

template <class T> void SafeRelease(T** ppT)
{
if (*ppT)
{
(*ppT)->Release();
*ppT = NULL;
}
}

struct DisplayHandle
{
QString name;
int actualDivide = -1, actualWidth = 0, actualHeight = 0;
uint targetMonitorNits = 0;
ID3D11Texture2D* d3dConvertTexture = nullptr;
ID3D11RenderTargetView* d3dRenderTargetView = nullptr;
ID3D11ShaderResourceView* d3dConvertTextureView = nullptr;
ID3D11VertexShader* d3dVertexShader = nullptr;
ID3D11PixelShader* d3dPixelShader = nullptr;
ID3D11Buffer* d3dBuffer = nullptr;
ID3D11SamplerState* d3dSampler = nullptr;
ID3D11InputLayout* d3dVertexLayout = nullptr;
IDXGIOutputDuplication* d3dDuplicate = nullptr;
ID3D11Texture2D* d3dSourceTexture = nullptr;
DXGI_OUTDUPL_DESC surfaceProperties;

DisplayHandle() = default;
DisplayHandle(const DisplayHandle&) = delete;
~DisplayHandle()
{
SafeRelease(&d3dRenderTargetView);
SafeRelease(&d3dSourceTexture);
SafeRelease(&d3dConvertTextureView);
SafeRelease(&d3dConvertTexture);
SafeRelease(&d3dVertexShader);
SafeRelease(&d3dVertexLayout);
SafeRelease(&d3dPixelShader);
SafeRelease(&d3dSampler);
SafeRelease(&d3dBuffer);
SafeRelease(&d3dDuplicate);
printf("SmartPointer is removing: DisplayHandle for %s\n", QSTRING_CSTR(name));
};
};

class DxGrabber : public Grabber
{
Q_OBJECT
Expand Down Expand Up @@ -56,6 +102,9 @@ public slots:
void restart();

private:

void captureFrame(DisplayHandle& display);

QString GetSharedLut();

void enumerateDevices(bool silent);
Expand All @@ -70,29 +119,18 @@ public slots:

bool initDirectX(QString selectedDeviceName);

bool initShaders();
HRESULT deepScaledCopy(ID3D11Texture2D* source);
bool initShaders(DisplayHandle& display);
HRESULT deepScaledCopy(DisplayHandle& display, ID3D11Texture2D* source);

QString _configurationPath;
QTimer* _timer;
QTimer* _retryTimer;
int _warningCounter;
int _actualDivide;
bool _wideGamut;

bool _dxRestartNow;
std::list<std::unique_ptr<DisplayHandle>> _handles;
ID3D11Device* _d3dDevice;
ID3D11DeviceContext* _d3dContext;
ID3D11Buffer* _d3dBuffer;
ID3D11SamplerState* _d3dSampler;
ID3D11InputLayout* _d3dVertexLayout;
ID3D11VertexShader* _d3dVertexShader;
ID3D11PixelShader* _d3dPixelShader;
ID3D11Texture2D* _d3dSourceTexture;
ID3D11Texture2D* _d3dConvertTexture;
ID3D11ShaderResourceView* _d3dConvertTextureView;
ID3D11RenderTargetView* _d3dRenderTargetView;
IDXGIOutputDuplication* _d3dDuplicate;
DXGI_OUTDUPL_DESC _surfaceProperties;
Image<ColorRgb> _cacheImage;
};
Loading

0 comments on commit 1785dd2

Please sign in to comment.