fix indent.
This commit is contained in:
@@ -73,7 +73,7 @@ void Cursor::UpdateBuffer(const DXGI_OUTDUPL_FRAME_INFO& frameInfo)
|
|||||||
Debug::Error("Cursor::UpdateBuffer() => GetFramePointerShape() failed.");
|
Debug::Error("Cursor::UpdateBuffer() => GetFramePointerShape() failed.");
|
||||||
apiBuffer_.reset();
|
apiBuffer_.reset();
|
||||||
apiBufferSize_ = 0;
|
apiBufferSize_ = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shapeInfo_ = shapeInfo;
|
shapeInfo_ = shapeInfo;
|
||||||
@@ -94,7 +94,7 @@ void Cursor::UpdateTexture()
|
|||||||
const auto cursorImageHeight = GetHeight();
|
const auto cursorImageHeight = GetHeight();
|
||||||
const auto cursorImagePitch = GetPitch();
|
const auto cursorImagePitch = GetPitch();
|
||||||
|
|
||||||
// Captured area
|
// Captured area
|
||||||
auto capturedImageWidth = cursorImageWidth;
|
auto capturedImageWidth = cursorImageWidth;
|
||||||
auto capturedImageHeight = cursorImageHeight;
|
auto capturedImageHeight = cursorImageHeight;
|
||||||
|
|
||||||
@@ -106,23 +106,23 @@ void Cursor::UpdateTexture()
|
|||||||
bgra32Buffer_ = std::make_unique<BYTE[]>(bgra32BufferSize_);
|
bgra32Buffer_ = std::make_unique<BYTE[]>(bgra32BufferSize_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check buffers
|
// Check buffers
|
||||||
if (!bgra32Buffer_ || !apiBuffer_)
|
if (!bgra32Buffer_ || !apiBuffer_)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If masked, copy the desktop image and merge it with masked image.
|
// If masked, copy the desktop image and merge it with masked image.
|
||||||
if (isMono || isColorMask)
|
if (isMono || isColorMask)
|
||||||
{
|
{
|
||||||
const auto monitorWidth = monitor_->GetWidth();
|
const auto monitorWidth = monitor_->GetWidth();
|
||||||
const auto monitorHeight = monitor_->GetHeight();
|
const auto monitorHeight = monitor_->GetHeight();
|
||||||
const auto monitorRot = static_cast<DXGI_MODE_ROTATION>(monitor_->GetRotation());
|
const auto monitorRot = static_cast<DXGI_MODE_ROTATION>(monitor_->GetRotation());
|
||||||
const auto isVertical =
|
const auto isVertical =
|
||||||
monitorRot == DXGI_MODE_ROTATION_ROTATE90 ||
|
monitorRot == DXGI_MODE_ROTATION_ROTATE90 ||
|
||||||
monitorRot == DXGI_MODE_ROTATION_ROTATE270;
|
monitorRot == DXGI_MODE_ROTATION_ROTATE270;
|
||||||
const auto desktopImageWidth = !isVertical ? monitorWidth : monitorHeight;
|
const auto desktopImageWidth = !isVertical ? monitorWidth : monitorHeight;
|
||||||
const auto desktopImageHeight = !isVertical ? monitorHeight : monitorWidth;
|
const auto desktopImageHeight = !isVertical ? monitorHeight : monitorWidth;
|
||||||
|
|
||||||
auto x = x_;
|
auto x = x_;
|
||||||
auto y = y_;
|
auto y = y_;
|
||||||
@@ -158,56 +158,56 @@ void Cursor::UpdateTexture()
|
|||||||
box.front = 0;
|
box.front = 0;
|
||||||
box.back = 1;
|
box.back = 1;
|
||||||
|
|
||||||
switch (monitorRot)
|
switch (monitorRot)
|
||||||
{
|
{
|
||||||
case DXGI_MODE_ROTATION_ROTATE90:
|
case DXGI_MODE_ROTATION_ROTATE90:
|
||||||
{
|
{
|
||||||
box.left = y;
|
box.left = y;
|
||||||
box.top = monitorWidth - x - capturedImageWidth;
|
box.top = monitorWidth - x - capturedImageWidth;
|
||||||
box.right = y + capturedImageWidth;
|
box.right = y + capturedImageWidth;
|
||||||
box.bottom = monitorWidth - x;
|
box.bottom = monitorWidth - x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DXGI_MODE_ROTATION_ROTATE180:
|
case DXGI_MODE_ROTATION_ROTATE180:
|
||||||
{
|
{
|
||||||
box.left = monitorWidth - x - capturedImageWidth;
|
box.left = monitorWidth - x - capturedImageWidth;
|
||||||
box.top = monitorHeight - y - capturedImageHeight;
|
box.top = monitorHeight - y - capturedImageHeight;
|
||||||
box.right = monitorWidth - x;
|
box.right = monitorWidth - x;
|
||||||
box.bottom = monitorHeight - y;
|
box.bottom = monitorHeight - y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DXGI_MODE_ROTATION_ROTATE270:
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
{
|
{
|
||||||
box.left = monitorHeight - y - capturedImageHeight;
|
box.left = monitorHeight - y - capturedImageHeight;
|
||||||
box.top = x;
|
box.top = x;
|
||||||
box.right = monitorHeight - y;
|
box.right = monitorHeight - y;
|
||||||
box.bottom = x + capturedImageWidth;
|
box.bottom = x + capturedImageWidth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DXGI_MODE_ROTATION_IDENTITY:
|
case DXGI_MODE_ROTATION_IDENTITY:
|
||||||
case DXGI_MODE_ROTATION_UNSPECIFIED:
|
case DXGI_MODE_ROTATION_UNSPECIFIED:
|
||||||
{
|
{
|
||||||
box.left = x;
|
box.left = x;
|
||||||
box.top = y;
|
box.top = y;
|
||||||
box.right = x + capturedImageWidth;
|
box.right = x + capturedImageWidth;
|
||||||
box.bottom = y + capturedImageHeight;
|
box.bottom = y + capturedImageHeight;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (box.left < 0 ||
|
if (box.left < 0 ||
|
||||||
box.top < 0 ||
|
box.top < 0 ||
|
||||||
box.right >= static_cast<UINT>(desktopImageWidth) ||
|
box.right >= static_cast<UINT>(desktopImageWidth) ||
|
||||||
box.bottom >= static_cast<UINT>(desktopImageHeight))
|
box.bottom >= static_cast<UINT>(desktopImageHeight))
|
||||||
{
|
{
|
||||||
Debug::Error("Cursor::UpdateTexture() => box is out of area.");
|
Debug::Error("Cursor::UpdateTexture() => box is out of area.");
|
||||||
Debug::Error(
|
Debug::Error(
|
||||||
" ",
|
" ",
|
||||||
"(", box.left, ", ", box.top, ")",
|
"(", box.left, ", ", box.top, ")",
|
||||||
" ~ (", box.right, ", ", box.bottom, ") > ",
|
" ~ (", box.right, ", ", box.bottom, ") > ",
|
||||||
"(", desktopImageWidth, ", ", desktopImageHeight, ")");
|
"(", desktopImageWidth, ", ", desktopImageHeight, ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor_->GetUnityTexture() == nullptr)
|
if (monitor_->GetUnityTexture() == nullptr)
|
||||||
{
|
{
|
||||||
@@ -259,26 +259,26 @@ void Cursor::UpdateTexture()
|
|||||||
const auto desktop32 = reinterpret_cast<UINT*>(mappedSurface.pBits);
|
const auto desktop32 = reinterpret_cast<UINT*>(mappedSurface.pBits);
|
||||||
const UINT desktopPitch = mappedSurface.Pitch / sizeof(UINT);
|
const UINT desktopPitch = mappedSurface.Pitch / sizeof(UINT);
|
||||||
|
|
||||||
// Take the monitor orientation into consideration.
|
// Take the monitor orientation into consideration.
|
||||||
const auto getDesktop32 = [&](int col, int row)
|
const auto getDesktop32 = [&](int col, int row)
|
||||||
{
|
{
|
||||||
switch (monitorRot)
|
switch (monitorRot)
|
||||||
{
|
{
|
||||||
case DXGI_MODE_ROTATION_ROTATE90:
|
case DXGI_MODE_ROTATION_ROTATE90:
|
||||||
return desktop32[(capturedImageWidth - 1 - col) * desktopPitch + row];
|
return desktop32[(capturedImageWidth - 1 - col) * desktopPitch + row];
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE180:
|
case DXGI_MODE_ROTATION_ROTATE180:
|
||||||
return desktop32[(capturedImageHeight - 1 - row) * desktopPitch + (capturedImageWidth - 1 - col)];
|
return desktop32[(capturedImageHeight - 1 - row) * desktopPitch + (capturedImageWidth - 1 - col)];
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE270:
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
return desktop32[col * desktopPitch + (capturedImageHeight - 1 - row)];
|
return desktop32[col * desktopPitch + (capturedImageHeight - 1 - row)];
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_IDENTITY:
|
case DXGI_MODE_ROTATION_IDENTITY:
|
||||||
case DXGI_MODE_ROTATION_UNSPECIFIED:
|
case DXGI_MODE_ROTATION_UNSPECIFIED:
|
||||||
return desktop32[row * desktopPitch + col];
|
return desktop32[row * desktopPitch + col];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Access RGBA values at the same time
|
// Access RGBA values at the same time
|
||||||
auto output32 = reinterpret_cast<UINT*>(bgra32Buffer_.get());
|
auto output32 = reinterpret_cast<UINT*>(bgra32Buffer_.get());
|
||||||
|
|||||||
@@ -36,46 +36,46 @@ extern "C"
|
|||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API FinalizeUDD()
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API FinalizeUDD()
|
||||||
{
|
{
|
||||||
if (!g_manager) return;
|
if (!g_manager) return;
|
||||||
|
|
||||||
g_manager.reset();
|
g_manager.reset();
|
||||||
|
|
||||||
std::queue<Message> empty;
|
std::queue<Message> empty;
|
||||||
g_messages.swap(empty);
|
g_messages.swap(empty);
|
||||||
|
|
||||||
Debug::Finalize();
|
Debug::Finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType event)
|
void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType event)
|
||||||
{
|
{
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
case kUnityGfxDeviceEventInitialize:
|
case kUnityGfxDeviceEventInitialize:
|
||||||
{
|
{
|
||||||
InitializeUDD();
|
InitializeUDD();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kUnityGfxDeviceEventShutdown:
|
case kUnityGfxDeviceEventShutdown:
|
||||||
{
|
{
|
||||||
FinalizeUDD();
|
FinalizeUDD();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces)
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces)
|
||||||
{
|
{
|
||||||
g_unity = unityInterfaces;
|
g_unity = unityInterfaces;
|
||||||
InitializeUDD();
|
InitializeUDD();
|
||||||
|
|
||||||
auto unityGraphics = g_unity->Get<IUnityGraphics>();
|
auto unityGraphics = g_unity->Get<IUnityGraphics>();
|
||||||
unityGraphics->RegisterDeviceEventCallback(OnGraphicsDeviceEvent);
|
unityGraphics->RegisterDeviceEventCallback(OnGraphicsDeviceEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginUnload()
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginUnload()
|
||||||
{
|
{
|
||||||
auto unityGraphics = g_unity->Get<IUnityGraphics>();
|
auto unityGraphics = g_unity->Get<IUnityGraphics>();
|
||||||
unityGraphics->UnregisterDeviceEventCallback(OnGraphicsDeviceEvent);
|
unityGraphics->UnregisterDeviceEventCallback(OnGraphicsDeviceEvent);
|
||||||
|
|
||||||
FinalizeUDD();
|
FinalizeUDD();
|
||||||
g_unity = nullptr;
|
g_unity = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user