|
|
|
@ -25,7 +25,6 @@ public class MotionElement( |
|
|
|
private int _frameSize; |
|
|
|
private int _frameSize; |
|
|
|
private PipeReader _pipeReader; |
|
|
|
private PipeReader _pipeReader; |
|
|
|
private SKPointI _point; |
|
|
|
private SKPointI _point; |
|
|
|
private SKBitmap _canvasBitmap; |
|
|
|
|
|
|
|
private SKBitmap _motionFrameBitmap; |
|
|
|
private SKBitmap _motionFrameBitmap; |
|
|
|
private TimeSpan _startTime; |
|
|
|
private TimeSpan _startTime; |
|
|
|
private TimeSpan _endTime; |
|
|
|
private TimeSpan _endTime; |
|
|
|
@ -55,7 +54,6 @@ public class MotionElement( |
|
|
|
|
|
|
|
|
|
|
|
_cancellationTokenSource?.Dispose(); |
|
|
|
_cancellationTokenSource?.Dispose(); |
|
|
|
|
|
|
|
|
|
|
|
_canvasBitmap?.Dispose(); |
|
|
|
|
|
|
|
_motionFrameBitmap?.Dispose(); |
|
|
|
_motionFrameBitmap?.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -119,12 +117,6 @@ public class MotionElement( |
|
|
|
|
|
|
|
|
|
|
|
_frameSize = targetSize.Width * targetSize.Height * 4; |
|
|
|
_frameSize = targetSize.Width * targetSize.Height * 4; |
|
|
|
|
|
|
|
|
|
|
|
_canvasBitmap = new SKBitmap( |
|
|
|
|
|
|
|
context.FrameSize.Width, |
|
|
|
|
|
|
|
context.FrameSize.Height, |
|
|
|
|
|
|
|
SKColorType.Bgra8888, |
|
|
|
|
|
|
|
SKAlphaType.Unpremul); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_motionFrameBitmap = new SKBitmap( |
|
|
|
_motionFrameBitmap = new SKBitmap( |
|
|
|
targetSize.Width, |
|
|
|
targetSize.Width, |
|
|
|
targetSize.Height, |
|
|
|
targetSize.Height, |
|
|
|
@ -235,7 +227,7 @@ public class MotionElement( |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (contentTime <= _endTime) |
|
|
|
if (contentTime <= _endTime) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new PreparedElementImage(_canvasBitmap, SKPointI.Empty, 1.0f, ZIndex, false); |
|
|
|
return new PreparedElementImage(_motionFrameBitmap, _point, 1.0f, ZIndex, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_state = MotionElementState.Finished; |
|
|
|
_state = MotionElementState.Finished; |
|
|
|
@ -260,18 +252,11 @@ public class MotionElement( |
|
|
|
sequence.CopyTo(pixmap.GetPixelSpan()); |
|
|
|
sequence.CopyTo(pixmap.GetPixelSpan()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_canvasBitmap.Erase(SKColors.Transparent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (var canvas = new SKCanvas(_canvasBitmap)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
canvas.DrawBitmap(_motionFrameBitmap, _point); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// mark this frame as consumed
|
|
|
|
// mark this frame as consumed
|
|
|
|
consumed = sequence.End; |
|
|
|
consumed = sequence.End; |
|
|
|
|
|
|
|
|
|
|
|
// we are done, return the frame
|
|
|
|
// we are done, return the frame
|
|
|
|
return new PreparedElementImage(_canvasBitmap, SKPointI.Empty, 1.0f, ZIndex, false); |
|
|
|
return new PreparedElementImage(_motionFrameBitmap, _point, 1.0f, ZIndex, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (readResult.IsCompleted) |
|
|
|
if (readResult.IsCompleted) |
|
|
|
@ -281,7 +266,7 @@ public class MotionElement( |
|
|
|
if (motionElement.EndBehavior is MotionEndBehavior.Hold) |
|
|
|
if (motionElement.EndBehavior is MotionEndBehavior.Hold) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_state = MotionElementState.Holding; |
|
|
|
_state = MotionElementState.Holding; |
|
|
|
return new PreparedElementImage(_canvasBitmap, SKPointI.Empty, 1.0f, ZIndex, false); |
|
|
|
return new PreparedElementImage(_motionFrameBitmap, _point, 1.0f, ZIndex, false); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|