16 wr =
QRect(wr.topLeft() *
w->devicePixelRatio(), wr.size() *
w->devicePixelRatio());
17 const QPoint center = wr.center();
18 IDXGIOutput *currentOutput =
nullptr;
19 IDXGIOutput *
output =
nullptr;
20 for (UINT
i = 0; adapter->EnumOutputs(
i, &
output) != DXGI_ERROR_NOT_FOUND; ++
i) {
21 DXGI_OUTPUT_DESC desc;
23 const RECT
r = desc.DesktopCoordinates;
33 ok = SUCCEEDED(currentOutput->QueryInterface(__uuidof(IDXGIOutput6),
reinterpret_cast<void **
>(
result)));
34 currentOutput->Release();
52 QVector<DISPLAYCONFIG_PATH_INFO> pathInfos;
53 uint32_t pathInfoCount, modeInfoCount;
56 if (GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathInfoCount, &modeInfoCount) == ERROR_SUCCESS) {
57 pathInfos.resize(pathInfoCount);
58 QVector<DISPLAYCONFIG_MODE_INFO> modeInfos(modeInfoCount);
59 result = QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathInfoCount, pathInfos.data(), &modeInfoCount, modeInfos.data(),
nullptr);
63 }
while (
result == ERROR_INSUFFICIENT_BUFFER);
65 MONITORINFOEX monitorInfo = {};
66 monitorInfo.cbSize =
sizeof(monitorInfo);
67 GetMonitorInfo(outputDesc.Monitor, &monitorInfo);
69 for (
const DISPLAYCONFIG_PATH_INFO &
info : pathInfos) {
70 DISPLAYCONFIG_SOURCE_DEVICE_NAME deviceName = {};
71 deviceName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME;
72 deviceName.header.
size =
sizeof(deviceName);
73 deviceName.header.adapterId =
info.sourceInfo.adapterId;
74 deviceName.header.id =
info.sourceInfo.id;
75 if (DisplayConfigGetDeviceInfo(&deviceName.header) == ERROR_SUCCESS) {
76 if (!wcscmp(monitorInfo.szDevice, deviceName.viewGdiDeviceName)) {
77 DISPLAYCONFIG_SDR_WHITE_LEVEL whiteLevel = {};
78 whiteLevel.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL;
79 whiteLevel.header.size =
sizeof(DISPLAYCONFIG_SDR_WHITE_LEVEL);
80 whiteLevel.header.adapterId =
info.targetInfo.adapterId;
81 whiteLevel.header.id =
info.targetInfo.id;
82 if (DisplayConfigGetDeviceInfo(&whiteLevel.header) == ERROR_SUCCESS)
83 return whiteLevel.SDRWhiteLevel * 80 / 1000.0f;
108 typedef HRESULT (__stdcall *DCompositionCreateDeviceFuncPtr)(
109 _In_opt_ IDXGIDevice *dxgiDevice,
111 _Outptr_
void **dcompositionDevice);
112 DCompositionCreateDeviceFuncPtr
func =
reinterpret_cast<DCompositionCreateDeviceFuncPtr
>(
113 dcomplib.resolve(
"DCompositionCreateDevice"));
115 qWarning(
"Unable to resolve DCompositionCreateDevice, perhaps dcomp.dll is missing?");
118 IDCompositionDevice *
device =
nullptr;
119 HRESULT hr =
func(
nullptr, __uuidof(IDCompositionDevice),
reinterpret_cast<void **
>(&
device));
121 qWarning(
"Failed to create Direct Composition device: %s",
122 qPrintable(QSystemError::windowsComString(hr)));