From 682553a5a2cbdff61a33182e609b3f255fb4b34b Mon Sep 17 00:00:00 2001 From: hecomi Date: Sun, 20 May 2018 02:08:18 +0900 Subject: [PATCH] tweak code. --- .../uDesktopDuplication/Duplicator.h | 2 +- .../uDesktopDuplication/Monitor.cpp | 53 ++++++++++--------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Plugins/uDesktopDuplication/uDesktopDuplication/Duplicator.h b/Plugins/uDesktopDuplication/uDesktopDuplication/Duplicator.h index 38795d9..86fb635 100644 --- a/Plugins/uDesktopDuplication/uDesktopDuplication/Duplicator.h +++ b/Plugins/uDesktopDuplication/uDesktopDuplication/Duplicator.h @@ -84,7 +84,7 @@ private: Microsoft::WRL::ComPtr dupl_; Frame lastFrame_; UINT lastFrameId_ = 0; - bool isFrameAquired_ = false; + bool isFrameAcquired_ = false; volatile bool shouldRun_ = false; std::thread thread_; diff --git a/Plugins/uDesktopDuplication/uDesktopDuplication/Monitor.cpp b/Plugins/uDesktopDuplication/uDesktopDuplication/Monitor.cpp index 055cc62..e363bb3 100644 --- a/Plugins/uDesktopDuplication/uDesktopDuplication/Monitor.cpp +++ b/Plugins/uDesktopDuplication/uDesktopDuplication/Monitor.cpp @@ -81,32 +81,35 @@ void Monitor::Render() if (frame.id == lastFrameId_) return; lastFrameId_ = frame.id; - if (unityTexture_) - { - D3D11_TEXTURE2D_DESC srcDesc, dstDesc; - frame.texture->GetDesc(&srcDesc); - unityTexture_->GetDesc(&dstDesc); - if (srcDesc.Width != dstDesc.Width || - srcDesc.Height != dstDesc.Height) - { - Debug::Error("Monitor::Render() => Texture sizes are defferent."); - Debug::Error(" Source : (", srcDesc.Width, ", ", srcDesc.Height, ")"); - Debug::Error(" Dest : (", dstDesc.Width, ", ", dstDesc.Height, ")"); - return; - } - else - { - ComPtr context; - GetDevice()->GetImmediateContext(&context); - context->CopyResource(unityTexture_, frame.texture.Get()); + if (unityTexture_ == nullptr) + { + Debug::Error("Monitor::Render() => Target texture has not been set yet.."); + return; + } - auto& manager = GetMonitorManager(); - if (id_ == manager->GetCursorMonitorId()) - { - manager->GetCursor()->Draw(unityTexture_); - } - } - } + D3D11_TEXTURE2D_DESC srcDesc, dstDesc; + frame.texture->GetDesc(&srcDesc); + unityTexture_->GetDesc(&dstDesc); + if (srcDesc.Width != dstDesc.Width || + srcDesc.Height != dstDesc.Height) + { + Debug::Error("Monitor::Render() => Texture sizes are defferent."); + Debug::Error(" Source : (", srcDesc.Width, ", ", srcDesc.Height, ")"); + Debug::Error(" Dest : (", dstDesc.Width, ", ", dstDesc.Height, ")"); + return; + } + else + { + ComPtr context; + GetDevice()->GetImmediateContext(&context); + context->CopyResource(unityTexture_, frame.texture.Get()); + + auto& manager = GetMonitorManager(); + if (id_ == manager->GetCursorMonitorId()) + { + manager->GetCursor()->Draw(unityTexture_); + } + } if (UseGetPixels()) {