improve performance.
This commit is contained in:
@@ -3,6 +3,8 @@ using MeshForwardDirection = uDesktopDuplication.Texture.MeshForwardDirection;
|
|||||||
|
|
||||||
public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
||||||
{
|
{
|
||||||
|
[SerializeField] bool debugDraw = true;
|
||||||
|
|
||||||
public float radius = 10f;
|
public float radius = 10f;
|
||||||
public Vector3 offsetAngle = Vector3.zero;
|
public Vector3 offsetAngle = Vector3.zero;
|
||||||
|
|
||||||
@@ -80,7 +82,7 @@ public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
|||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
DebugDraw();
|
if (debugDraw) DebugDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDraw()
|
void DebugDraw()
|
||||||
|
|||||||
@@ -15,15 +15,17 @@ public class Manager : MonoBehaviour
|
|||||||
|
|
||||||
public static Manager CreateInstance()
|
public static Manager CreateInstance()
|
||||||
{
|
{
|
||||||
if (instance_) {
|
if (instance_ != null) return instance_;
|
||||||
return instance_;
|
|
||||||
}
|
|
||||||
|
|
||||||
var manager = FindObjectOfType<Manager>();
|
var manager = FindObjectOfType<Manager>();
|
||||||
if (manager) return manager;
|
if (manager) {
|
||||||
|
instance_ = manager;
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
var go = new GameObject("uDesktopDuplicationManager");
|
var go = new GameObject("uDesktopDuplicationManager");
|
||||||
return go.AddComponent<Manager>();
|
instance_ = go.AddComponent<Manager>();
|
||||||
|
return instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Monitor> monitors_ = new List<Monitor>();
|
private List<Monitor> monitors_ = new List<Monitor>();
|
||||||
@@ -74,10 +76,16 @@ public class Manager : MonoBehaviour
|
|||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
// for simple singleton
|
// for simple singleton
|
||||||
if (instance_ != null) {
|
|
||||||
|
if (instance_ == this) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instance_ != null && instance_ != this) {
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance_ = this;
|
instance_ = this;
|
||||||
|
|
||||||
Lib.SetDebugMode(debugMode);
|
Lib.SetDebugMode(debugMode);
|
||||||
@@ -134,11 +142,12 @@ public class Manager : MonoBehaviour
|
|||||||
|
|
||||||
for (int i = 0; i < monitors.Count; ++i) {
|
for (int i = 0; i < monitors.Count; ++i) {
|
||||||
var monitor = monitors[i];
|
var monitor = monitors[i];
|
||||||
|
var state = monitor.state;
|
||||||
if (
|
if (
|
||||||
monitor.state == MonitorState.NotSet ||
|
state == MonitorState.NotSet ||
|
||||||
monitor.state == MonitorState.AccessLost ||
|
state == MonitorState.AccessLost ||
|
||||||
monitor.state == MonitorState.AccessDenied ||
|
state == MonitorState.AccessDenied ||
|
||||||
monitor.state == MonitorState.SessionDisconnected
|
state == MonitorState.SessionDisconnected
|
||||||
) {
|
) {
|
||||||
reinitializeNeeded = true;
|
reinitializeNeeded = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ public class Monitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Texture2D texture_;
|
private Texture2D texture_;
|
||||||
|
private System.IntPtr texturePtr_;
|
||||||
public Texture2D texture
|
public Texture2D texture
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -253,7 +254,7 @@ public class Monitor
|
|||||||
public void Render()
|
public void Render()
|
||||||
{
|
{
|
||||||
if (texture_ && available) {
|
if (texture_ && available) {
|
||||||
Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr());
|
Lib.SetTexturePtr(id, texturePtr_);
|
||||||
GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id);
|
GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,6 +291,7 @@ public class Monitor
|
|||||||
var w = isHorizontal ? width : height;
|
var w = isHorizontal ? width : height;
|
||||||
var h = isHorizontal ? height : width;
|
var h = isHorizontal ? height : width;
|
||||||
texture_ = new Texture2D(w, h, TextureFormat.BGRA32, false);
|
texture_ = new Texture2D(w, h, TextureFormat.BGRA32, false);
|
||||||
|
texturePtr_ = texture_.GetNativeTexturePtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DestroyTexture()
|
public void DestroyTexture()
|
||||||
@@ -297,6 +299,7 @@ public class Monitor
|
|||||||
if (texture_) {
|
if (texture_) {
|
||||||
Object.Destroy(texture_);
|
Object.Destroy(texture_);
|
||||||
texture_ = null;
|
texture_ = null;
|
||||||
|
texturePtr_ = System.IntPtr.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user