Skip to content

Commit

Permalink
Initial multi-monitor support
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Oct 30, 2024
1 parent c55be9d commit 1b2898b
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 34 deletions.
2 changes: 2 additions & 0 deletions include/base/Grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public slots:

int getTargetSystemFrameDimension(int& targetSizeX, int& targetSizeY);

int getTargetSystemFrameDimension(int actualWidth, int actualHeight, int& targetSizeX, int& targetSizeY);

void processSystemFrameBGRA(uint8_t* source, int lineSize = 0, bool useLut = true);

void processSystemFrameBGR(uint8_t* source, int lineSize = 0);
Expand Down
8 changes: 5 additions & 3 deletions include/grabber/windows/DX/DxGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ template <class T> void SafeRelease(T** ppT)
struct DisplayHandle
{
QString name;
int warningCounter = 6;
bool wideGamut = false;
int actualDivide = -1, actualWidth = 0, actualHeight = 0;
uint targetMonitorNits = 0;
ID3D11Texture2D* d3dConvertTexture = nullptr;
Expand All @@ -51,7 +53,7 @@ struct DisplayHandle
ID3D11InputLayout* d3dVertexLayout = nullptr;
IDXGIOutputDuplication* d3dDuplicate = nullptr;
ID3D11Texture2D* d3dSourceTexture = nullptr;
DXGI_OUTDUPL_DESC surfaceProperties;
DXGI_OUTDUPL_DESC surfaceProperties{};

DisplayHandle() = default;
DisplayHandle(const DisplayHandle&) = delete;
Expand Down Expand Up @@ -107,6 +109,8 @@ public slots:

void captureFrame(DisplayHandle& display);

int captureFrame(DisplayHandle& display, Image<ColorRgb>& image);

QString GetSharedLut();

void enumerateDevices(bool silent);
Expand All @@ -127,8 +131,6 @@ public slots:
QString _configurationPath;
QTimer* _timer;
QTimer* _retryTimer;
int _warningCounter;
bool _wideGamut;
bool _multiMonitor;

bool _dxRestartNow;
Expand Down
2 changes: 2 additions & 0 deletions include/image/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Image

void gradientVBox(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t r, uint8_t g, uint8_t b);

void insertHorizontal(int x, Image<ColorSpace>& source);

unsigned width() const;

unsigned height() const;
Expand Down
28 changes: 28 additions & 0 deletions sources/base/Grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,34 @@ int Grabber::getTargetSystemFrameDimension(int& targetSizeX, int& targetSizeY)
return divide;
}

int Grabber::getTargetSystemFrameDimension(int actualWidth, int actualHeight, int& targetSizeX, int& targetSizeY)
{
int startX = _cropLeft;
int startY = _cropTop;
int realSizeX = actualWidth - startX - _cropRight;
int realSizeY = actualHeight - startY - _cropBottom;

if (realSizeX <= 16 || realSizeY <= 16)
{
realSizeX = actualWidth;
realSizeY = actualHeight;
}

int checkWidth = realSizeX;
int divide = 1;

while (checkWidth > _width)
{
divide++;
checkWidth = realSizeX / divide;
}

targetSizeX = realSizeX / divide;
targetSizeY = realSizeY / divide;

return divide;
}

void Grabber::processSystemFrameBGRA(uint8_t* source, int lineSize, bool useLut)
{
int targetSizeX, targetSizeY;
Expand Down
Loading

0 comments on commit 1b2898b

Please sign in to comment.