modify codes.
This commit is contained in:
Binary file not shown.
@@ -193,8 +193,9 @@ public class Manager : MonoBehaviour
|
|||||||
for (int i = 0; i < monitorCount; ++i) {
|
for (int i = 0; i < monitorCount; ++i) {
|
||||||
if (i == monitors.Count) {
|
if (i == monitors.Count) {
|
||||||
monitors.Add(new Monitor(i));
|
monitors.Add(new Monitor(i));
|
||||||
|
} else {
|
||||||
|
monitors[i].Reinitialize();
|
||||||
}
|
}
|
||||||
monitors[i].Reinitialize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ public class Monitor
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Texture2D errorTexture_;
|
private static Texture2D errorTexture;
|
||||||
private static readonly string errorTexturePath = "uDesktopDuplication/Textures/NotAvailable";
|
private static readonly string errorTexturePath = "uDesktopDuplication/Textures/NotAvailable";
|
||||||
|
|
||||||
private Texture2D texture_;
|
private Texture2D texture_;
|
||||||
@@ -212,8 +212,8 @@ public class Monitor
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!available) {
|
if (!available) {
|
||||||
return errorTexture_ ??
|
return errorTexture ??
|
||||||
(errorTexture_ = Resources.Load<Texture2D>(errorTexturePath));
|
(errorTexture = Resources.Load<Texture2D>(errorTexturePath));
|
||||||
}
|
}
|
||||||
if (texture_ == null) {
|
if (texture_ == null) {
|
||||||
CreateTexture();
|
CreateTexture();
|
||||||
@@ -245,11 +245,8 @@ public class Monitor
|
|||||||
|
|
||||||
if (texture_) {
|
if (texture_) {
|
||||||
if (texture_.width != w || texture_.height != h) {
|
if (texture_.width != w || texture_.height != h) {
|
||||||
if (texture_) {
|
Object.DestroyImmediate(texture_);
|
||||||
Object.Destroy(texture_);
|
texture_ = null;
|
||||||
texture_ = null;
|
|
||||||
}
|
|
||||||
shouldCreate = true;
|
|
||||||
} else {
|
} else {
|
||||||
shouldCreate = false;
|
shouldCreate = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Monitor::Monitor(int id)
|
|||||||
|
|
||||||
Monitor::~Monitor()
|
Monitor::~Monitor()
|
||||||
{
|
{
|
||||||
|
deskDupl_->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -118,25 +119,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),
|
{
|
||||||
// it is necessary to re-initialize monitors.
|
// If any monitor setting has changed (e.g. monitor size has changed),
|
||||||
Debug::Log("Monitor::Render() => DXGI_ERROR_ACCESS_LOST.");
|
// it is necessary to re-initialize monitors.
|
||||||
state_ = State::AccessLost;
|
Debug::Log("Monitor::Render() => DXGI_ERROR_ACCESS_LOST.");
|
||||||
break;
|
state_ = State::AccessLost;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DXGI_ERROR_WAIT_TIMEOUT:
|
case DXGI_ERROR_WAIT_TIMEOUT:
|
||||||
// This often occurs when timeout value is small and it is not problem.
|
{
|
||||||
// Debug::Log("Monitor::Render() => DXGI_ERROR_WAIT_TIMEOUT.");
|
// This often occurs when timeout value is small and it is not problem.
|
||||||
break;
|
// Debug::Log("Monitor::Render() => DXGI_ERROR_WAIT_TIMEOUT.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DXGI_ERROR_INVALID_CALL:
|
case DXGI_ERROR_INVALID_CALL:
|
||||||
Debug::Error("Monitor::Render() => DXGI_ERROR_INVALID_CALL.");
|
{
|
||||||
break;
|
Debug::Error("Monitor::Render() => DXGI_ERROR_INVALID_CALL.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
case E_INVALIDARG:
|
case E_INVALIDARG:
|
||||||
Debug::Error("Monitor::Render() => E_INVALIDARG.");
|
{
|
||||||
break;
|
Debug::Error("Monitor::Render() => E_INVALIDARG.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
state_ = State::Unknown;
|
{
|
||||||
Debug::Error("Monitor::Render() => Unknown Error.");
|
state_ = State::Unknown;
|
||||||
break;
|
Debug::Error("Monitor::Render() => Unknown Error.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -159,11 +170,11 @@ void Monitor::Render(UINT timeout)
|
|||||||
Debug::Error("Monitor::Render() => Texture sizes are defferent.");
|
Debug::Error("Monitor::Render() => Texture sizes are defferent.");
|
||||||
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
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user