Revert "render flag"

This reverts commit ed681f4d08.
This commit is contained in:
pypy
2021-03-08 21:12:21 +09:00
parent 291169fce0
commit 260ea0a541
+34 -40
View File
@@ -20,7 +20,6 @@ namespace VRCX
private GCHandle _paintBuffer; private GCHandle _paintBuffer;
private int _width; private int _width;
private int _height; private int _height;
private bool _dirty;
public OffScreenBrowser(string address, int width, int height) public OffScreenBrowser(string address, int width, int height)
: base( : base(
@@ -62,57 +61,53 @@ namespace VRCX
public void RenderToTexture(Texture2D texture) public void RenderToTexture(Texture2D texture)
{ {
if (_dirty == true) _paintBufferLock.EnterReadLock();
try
{ {
_dirty = false; if (_width > 0 &&
_paintBufferLock.EnterReadLock(); _height > 0)
try
{ {
if (_width > 0 && var context = texture.Device.ImmediateContext;
_height > 0) var dataBox = context.MapSubresource(
texture,
0,
MapMode.WriteDiscard,
MapFlags.None
);
if (dataBox.IsEmpty == false)
{ {
var context = texture.Device.ImmediateContext; var sourcePtr = _paintBuffer.AddrOfPinnedObject();
var dataBox = context.MapSubresource( var destinationPtr = dataBox.DataPointer;
texture, var pitch = _width * 4;
0, var rowPitch = dataBox.RowPitch;
MapMode.WriteDiscard, if (pitch == rowPitch)
MapFlags.None
);
if (dataBox.IsEmpty == false)
{ {
var sourcePtr = _paintBuffer.AddrOfPinnedObject(); WinApi.CopyMemory(
var destinationPtr = dataBox.DataPointer; destinationPtr,
var pitch = _width * 4; sourcePtr,
var rowPitch = dataBox.RowPitch; (uint)(_width * _height * 4)
if (pitch == rowPitch) );
}
else
{
for (var y = _height; y > 0; --y)
{ {
WinApi.CopyMemory( WinApi.CopyMemory(
destinationPtr, destinationPtr,
sourcePtr, sourcePtr,
(uint)(_width * _height * 4) (uint)pitch
); );
} sourcePtr += pitch;
else destinationPtr += rowPitch;
{
for (var y = _height; y > 0; --y)
{
WinApi.CopyMemory(
destinationPtr,
sourcePtr,
(uint)pitch
);
sourcePtr += pitch;
destinationPtr += rowPitch;
}
} }
} }
context.UnmapSubresource(texture, 0);
} }
context.UnmapSubresource(texture, 0);
} }
finally }
{ finally
_paintBufferLock.ExitReadLock(); {
} _paintBufferLock.ExitReadLock();
} }
} }
@@ -178,7 +173,6 @@ namespace VRCX
{ {
_paintBufferLock.ExitWriteLock(); _paintBufferLock.ExitWriteLock();
} }
_dirty = true;
} }
} }