fix indent

This commit is contained in:
hecomi
2016-11-16 02:04:13 +09:00
parent 7b3990107d
commit 77c95ab1bb
8 changed files with 156 additions and 156 deletions
+7 -7
View File
@@ -30,13 +30,13 @@ public enum MonitorRotation
public enum MonitorState public enum MonitorState
{ {
NotSet = -1, NotSet = -1,
Available = 0, Available = 0,
InvalidArg = 1, InvalidArg = 1,
AccessDenied = 2, AccessDenied = 2,
Unsupported = 3, Unsupported = 3,
CurrentlyNotAvailable = 4, CurrentlyNotAvailable = 4,
SessionDisconnected = 5, SessionDisconnected = 5,
AccessLost = 6, AccessLost = 6,
TextureSizeInconsistent = 7, TextureSizeInconsistent = 7,
Unknown = 999, Unknown = 999,
@@ -33,7 +33,7 @@ enum class Message
{ {
None = -1, None = -1,
Reinitialized = 0, Reinitialized = 0,
TextureSizeChanged = 1, TextureSizeChanged = 1,
}; };
void SendMessageToUnity(Message message); void SendMessageToUnity(Message message);
@@ -54,19 +54,19 @@ void Cursor::UpdateBuffer(const DXGI_OUTDUPL_FRAME_INFO& frameInfo)
apiBuffer_ = std::make_unique<BYTE[]>(apiBufferSize_); apiBuffer_ = std::make_unique<BYTE[]>(apiBufferSize_);
} }
if (!apiBuffer_) if (!apiBuffer_)
{ {
return; return;
} }
// Get mouse pointer information // Get mouse pointer information
UINT bufferSize; UINT bufferSize;
DXGI_OUTDUPL_POINTER_SHAPE_INFO shapeInfo; DXGI_OUTDUPL_POINTER_SHAPE_INFO shapeInfo;
const auto hr = monitor_->GetDeskDupl()->GetFramePointerShape( const auto hr = monitor_->GetDeskDupl()->GetFramePointerShape(
apiBufferSize_, apiBufferSize_,
apiBuffer_.get(), apiBuffer_.get(),
&bufferSize, &bufferSize,
&shapeInfo); &shapeInfo);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -175,11 +175,11 @@ void Cursor::UpdateTexture()
return; return;
} }
{ {
ComPtr<ID3D11DeviceContext> context; ComPtr<ID3D11DeviceContext> context;
GetDevice()->GetImmediateContext(&context); GetDevice()->GetImmediateContext(&context);
context->CopySubresourceRegion(texture.Get(), 0, 0, 0, 0, monitor_->GetUnityTexture(), 0, &box); context->CopySubresourceRegion(texture.Get(), 0, 0, 0, 0, monitor_->GetUnityTexture(), 0, &box);
} }
ComPtr<IDXGISurface> surface; ComPtr<IDXGISurface> surface;
if (FAILED(texture.As(&surface))) if (FAILED(texture.As(&surface)))
@@ -28,6 +28,6 @@ void Debug::Finalize()
Debug::Log("Stop"); Debug::Log("Stop");
fs_.close(); fs_.close();
} }
Debug::SetLogFunc(nullptr); Debug::SetLogFunc(nullptr);
Debug::SetErrorFunc(nullptr); Debug::SetErrorFunc(nullptr);
} }
@@ -87,34 +87,34 @@ private:
Flush(level); Flush(level);
} }
static void OutputTime() static void OutputTime()
{ {
auto t = time(nullptr); auto t = time(nullptr);
tm tm; tm tm;
localtime_s(&tm, &t); localtime_s(&tm, &t);
char buf[64]; char buf[64];
strftime(buf, 64, "%F %T", &tm); strftime(buf, 64, "%F %T", &tm);
Output("[");; Output("[");;
Output(buf); Output(buf);
Output("]"); Output("]");
} }
public: public:
template <class Arg, class... RestArgs> template <class Arg, class... RestArgs>
static void Log(Arg&& arg, RestArgs&&... restArgs) static void Log(Arg&& arg, RestArgs&&... restArgs)
{ {
Output("[uDD::Log]"); Output("[uDD::Log]");
OutputTime(); OutputTime();
Output(" "); Output(" ");
_Log(Level::Log, std::forward<Arg>(arg), std::forward<RestArgs>(restArgs)...); _Log(Level::Log, std::forward<Arg>(arg), std::forward<RestArgs>(restArgs)...);
} }
template <class Arg, class... RestArgs> template <class Arg, class... RestArgs>
static void Error(Arg&& arg, RestArgs&&... restArgs) static void Error(Arg&& arg, RestArgs&&... restArgs)
{ {
Output("[uDD::Err]"); Output("[uDD::Err]");
OutputTime(); OutputTime();
Output(" "); Output(" ");
_Log(Level::Error, std::forward<Arg>(arg), std::forward<RestArgs>(restArgs)...); _Log(Level::Error, std::forward<Arg>(arg), std::forward<RestArgs>(restArgs)...);
} }
@@ -18,94 +18,94 @@ Monitor::Monitor(int id)
Monitor::~Monitor() Monitor::~Monitor()
{ {
if (deskDupl_) if (deskDupl_)
{ {
deskDupl_->Release(); deskDupl_->Release();
deskDupl_ = nullptr; deskDupl_ = nullptr;
} }
} }
void Monitor::Initialize(IDXGIOutput* output) void Monitor::Initialize(IDXGIOutput* output)
{ {
if (FAILED(output->GetDesc(&outputDesc_))) if (FAILED(output->GetDesc(&outputDesc_)))
{ {
Debug::Error("Monitor::Initialize() => IDXGIOutput::GetDesc() failed."); Debug::Error("Monitor::Initialize() => IDXGIOutput::GetDesc() failed.");
return; return;
} }
monitorInfo_.cbSize = sizeof(MONITORINFOEX); monitorInfo_.cbSize = sizeof(MONITORINFOEX);
if (!GetMonitorInfo(outputDesc_.Monitor, &monitorInfo_)) if (!GetMonitorInfo(outputDesc_.Monitor, &monitorInfo_))
{ {
Debug::Error("Monitor::Initialize() => GetMonitorInfo() failed."); Debug::Error("Monitor::Initialize() => GetMonitorInfo() failed.");
return; return;
} }
else else
{ {
const auto rect = monitorInfo_.rcMonitor; const auto rect = monitorInfo_.rcMonitor;
width_ = rect.right - rect.left; width_ = rect.right - rect.left;
height_ = rect.bottom - rect.top; height_ = rect.bottom - rect.top;
} }
if (FAILED(GetDpiForMonitor(outputDesc_.Monitor, MDT_RAW_DPI, &dpiX_, &dpiY_))) if (FAILED(GetDpiForMonitor(outputDesc_.Monitor, MDT_RAW_DPI, &dpiX_, &dpiY_)))
{ {
Debug::Error("Monitor::Initialize() => GetDpiForMonitor() failed."); Debug::Error("Monitor::Initialize() => GetDpiForMonitor() failed.");
return; return;
} }
auto output1 = reinterpret_cast<IDXGIOutput1*>(output); auto output1 = reinterpret_cast<IDXGIOutput1*>(output);
switch (output1->DuplicateOutput(GetDevice().Get(), &deskDupl_)) switch (output1->DuplicateOutput(GetDevice().Get(), &deskDupl_))
{ {
case S_OK: case S_OK:
{ {
state_ = State::Available; state_ = State::Available;
Debug::Log("Monitor::Initialize() => OK."); Debug::Log("Monitor::Initialize() => OK.");
Debug::Log(" ID : ", GetId()); Debug::Log(" ID : ", GetId());
Debug::Log(" Size : (", GetWidth(), ", ", GetHeight(), ")"); Debug::Log(" Size : (", GetWidth(), ", ", GetHeight(), ")");
Debug::Log(" DPI : (", GetDpiX(), ", ", GetDpiY(), ")"); Debug::Log(" DPI : (", GetDpiX(), ", ", GetDpiY(), ")");
break; break;
} }
case E_INVALIDARG: case E_INVALIDARG:
{ {
state_ = State::InvalidArg; state_ = State::InvalidArg;
Debug::Error("Monitor::Initialize() => Invalid arguments."); Debug::Error("Monitor::Initialize() => Invalid arguments.");
break; break;
} }
case E_ACCESSDENIED: case E_ACCESSDENIED:
{ {
// For example, when the user presses Ctrl + Alt + Delete and the screen // For example, when the user presses Ctrl + Alt + Delete and the screen
// switches to admin screen, this error occurs. // switches to admin screen, this error occurs.
state_ = State::AccessDenied; state_ = State::AccessDenied;
Debug::Error("Monitor::Initialize() => Access denied."); Debug::Error("Monitor::Initialize() => Access denied.");
break; break;
} }
case DXGI_ERROR_UNSUPPORTED: case DXGI_ERROR_UNSUPPORTED:
{ {
// If the display adapter on the computer is running under the Microsoft Hybrid system, // If the display adapter on the computer is running under the Microsoft Hybrid system,
// this error occurs. // this error occurs.
state_ = State::Unsupported; state_ = State::Unsupported;
Debug::Error("Monitor::Initialize() => Unsupported display."); Debug::Error("Monitor::Initialize() => Unsupported display.");
break; break;
} }
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE: case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
{ {
// When other application use Desktop Duplication API, this error occurs. // When other application use Desktop Duplication API, this error occurs.
state_ = State::CurrentlyNotAvailable; state_ = State::CurrentlyNotAvailable;
Debug::Error("Monitor::Initialize() => Currently not available."); Debug::Error("Monitor::Initialize() => Currently not available.");
break; break;
} }
case DXGI_ERROR_SESSION_DISCONNECTED: case DXGI_ERROR_SESSION_DISCONNECTED:
{ {
state_ = State::SessionDisconnected; state_ = State::SessionDisconnected;
Debug::Error("Monitor::Initialize() => Session disconnected."); Debug::Error("Monitor::Initialize() => Session disconnected.");
break; break;
} }
default: default:
{ {
state_ = State::Unknown; state_ = State::Unknown;
Debug::Error("Monitor::Render() => Unknown Error."); Debug::Error("Monitor::Render() => Unknown Error.");
break; break;
} }
} }
} }
@@ -123,35 +123,35 @@ void Monitor::Render(UINT timeout)
switch (hr) switch (hr)
{ {
case DXGI_ERROR_ACCESS_LOST: case DXGI_ERROR_ACCESS_LOST:
{ {
// If any monitor setting has changed (e.g. monitor size has changed), // If any monitor setting has changed (e.g. monitor size has changed),
// it is necessary to re-initialize monitors. // it is necessary to re-initialize monitors.
Debug::Log("Monitor::Render() => DXGI_ERROR_ACCESS_LOST."); Debug::Log("Monitor::Render() => DXGI_ERROR_ACCESS_LOST.");
state_ = State::AccessLost; state_ = State::AccessLost;
break; break;
} }
case DXGI_ERROR_WAIT_TIMEOUT: case DXGI_ERROR_WAIT_TIMEOUT:
{ {
// This often occurs when timeout value is small and it is not problem. // This often occurs when timeout value is small and it is not problem.
// Debug::Log("Monitor::Render() => DXGI_ERROR_WAIT_TIMEOUT."); // Debug::Log("Monitor::Render() => DXGI_ERROR_WAIT_TIMEOUT.");
break; break;
} }
case DXGI_ERROR_INVALID_CALL: case DXGI_ERROR_INVALID_CALL:
{ {
Debug::Error("Monitor::Render() => DXGI_ERROR_INVALID_CALL."); Debug::Error("Monitor::Render() => DXGI_ERROR_INVALID_CALL.");
break; break;
} }
case E_INVALIDARG: case E_INVALIDARG:
{ {
Debug::Error("Monitor::Render() => E_INVALIDARG."); Debug::Error("Monitor::Render() => E_INVALIDARG.");
break; break;
} }
default: default:
{ {
state_ = State::Unknown; state_ = State::Unknown;
Debug::Error("Monitor::Render() => Unknown Error."); Debug::Error("Monitor::Render() => Unknown Error.");
break; break;
} }
} }
return; return;
} }
@@ -159,11 +159,11 @@ void Monitor::Render(UINT timeout)
if (unityTexture_) if (unityTexture_)
{ {
ID3D11Texture2D* texture; ID3D11Texture2D* texture;
if (FAILED(resource.CopyTo(&texture))) if (FAILED(resource.CopyTo(&texture)))
{ {
Debug::Error("Monitor::Render() => resource.As() failed."); Debug::Error("Monitor::Render() => resource.As() failed.");
return; return;
} }
D3D11_TEXTURE2D_DESC srcDesc, dstDesc; D3D11_TEXTURE2D_DESC srcDesc, dstDesc;
texture->GetDesc(&srcDesc); texture->GetDesc(&srcDesc);
@@ -175,10 +175,10 @@ void Monitor::Render(UINT timeout)
Debug::Error(" Source : (", srcDesc.Width, ", ", srcDesc.Height, ")"); Debug::Error(" Source : (", srcDesc.Width, ", ", srcDesc.Height, ")");
Debug::Error(" Dest : (", dstDesc.Width, ", ", dstDesc.Height, ")"); Debug::Error(" Dest : (", dstDesc.Width, ", ", dstDesc.Height, ")");
//Debug::Log(" => Try modifying width/height using reported value from DDA."); //Debug::Log(" => Try modifying width/height using reported value from DDA.");
//width_ = srcDesc.Width; //width_ = srcDesc.Width;
//height_ = srcDesc.Height; //height_ = srcDesc.Height;
state_ = MonitorState::TextureSizeInconsistent; state_ = MonitorState::TextureSizeInconsistent;
//SendMessageToUnity(Message::TextureSizeChanged); //SendMessageToUnity(Message::TextureSizeChanged);
} }
else else
{ {
@@ -296,11 +296,11 @@ int Monitor::GetDpiY() const
int Monitor::GetWidth() const int Monitor::GetWidth() const
{ {
return width_; return width_;
} }
int Monitor::GetHeight() const int Monitor::GetHeight() const
{ {
return height_; return height_;
} }
@@ -17,7 +17,7 @@ enum class MonitorState
CurrentlyNotAvailable = 4, CurrentlyNotAvailable = 4,
SessionDisconnected = 5, SessionDisconnected = 5,
AccessLost = 6, AccessLost = 6,
TextureSizeInconsistent = 7, TextureSizeInconsistent = 7,
Unknown = 999, Unknown = 999,
}; };
@@ -54,7 +54,7 @@ public:
private: private:
int id_ = -1; int id_ = -1;
UINT dpiX_ = -1, dpiY_ = -1; UINT dpiX_ = -1, dpiY_ = -1;
int width_ = -1, height_ = -1; int width_ = -1, height_ = -1;
State state_ = State::NotSet; State state_ = State::NotSet;
std::unique_ptr<Cursor> cursor_; std::unique_ptr<Cursor> cursor_;
IDXGIOutputDuplication* deskDupl_ = nullptr; IDXGIOutputDuplication* deskDupl_ = nullptr;
@@ -35,11 +35,11 @@ void MonitorManager::Initialize()
// Get factory // Get factory
ComPtr<IDXGIFactory1> factory; ComPtr<IDXGIFactory1> factory;
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory))))
{ {
Debug::Error("MonitorManager::Initialize() => CreateDXGIFactory1() failed."); Debug::Error("MonitorManager::Initialize() => CreateDXGIFactory1() failed.");
return; return;
} }
// Check all display adapters // Check all display adapters
int id = 0; int id = 0;
@@ -47,7 +47,7 @@ void MonitorManager::Initialize()
for (int i = 0; (factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND); ++i) for (int i = 0; (factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND); ++i)
{ {
// Search the main monitor from all outputs // Search the main monitor from all outputs
ComPtr<IDXGIOutput> output; ComPtr<IDXGIOutput> output;
for (int j = 0; (adapter->EnumOutputs(j, &output) != DXGI_ERROR_NOT_FOUND); ++j) for (int j = 0; (adapter->EnumOutputs(j, &output) != DXGI_ERROR_NOT_FOUND); ++j)
{ {
auto monitor = std::make_shared<Monitor>(id++); auto monitor = std::make_shared<Monitor>(id++);
@@ -81,24 +81,24 @@ void MonitorManager::Reinitialize()
bool MonitorManager::HasMonitorCountChanged() const bool MonitorManager::HasMonitorCountChanged() const
{ {
ComPtr<IDXGIFactory1> factory; ComPtr<IDXGIFactory1> factory;
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory))))
{ {
Debug::Error("MonitorManager::CheckMonitorConnection() => CreateDXGIFactory1() failed."); Debug::Error("MonitorManager::CheckMonitorConnection() => CreateDXGIFactory1() failed.");
return false; return false;
} }
int id = 0; int id = 0;
ComPtr<IDXGIAdapter1> adapter; ComPtr<IDXGIAdapter1> adapter;
for (int i = 0; (factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND); ++i) for (int i = 0; (factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND); ++i)
{ {
ComPtr<IDXGIOutput> output; ComPtr<IDXGIOutput> output;
for (int j = 0; (adapter->EnumOutputs(j, &output) != DXGI_ERROR_NOT_FOUND); ++j) for (int j = 0; (adapter->EnumOutputs(j, &output) != DXGI_ERROR_NOT_FOUND); ++j)
{ {
id++; id++;
} }
} }
return monitors_.size() != id; return monitors_.size() != id;
} }