mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
enhance: do NOT use render target when there's only added or delete image.
This commit is contained in:
parent
dde5d4a2a8
commit
4e8e39d2fe
1 changed files with 20 additions and 27 deletions
|
@ -244,42 +244,35 @@ namespace SourceGit.Views
|
||||||
var right = NewImage;
|
var right = NewImage;
|
||||||
var drawLeft = left != null && alpha < 1.0;
|
var drawLeft = left != null && alpha < 1.0;
|
||||||
var drawRight = right != null && alpha > 0;
|
var drawRight = right != null && alpha > 0;
|
||||||
var psize = left == null ? right.PixelSize : left.PixelSize;
|
|
||||||
var dpi = left == null ? right.Dpi : left.Dpi;
|
|
||||||
|
|
||||||
using (var rt = new RenderTargetBitmap(psize, dpi))
|
if (drawLeft && drawRight)
|
||||||
{
|
{
|
||||||
var rtRect = new Rect(rt.Size);
|
using (var rt = new RenderTargetBitmap(right.PixelSize, right.Dpi))
|
||||||
using (var dc = rt.CreateDrawingContext())
|
|
||||||
{
|
{
|
||||||
if (drawLeft)
|
var rtRect = new Rect(rt.Size);
|
||||||
{
|
using (var dc = rt.CreateDrawingContext())
|
||||||
if (drawRight)
|
|
||||||
{
|
|
||||||
using (dc.PushRenderOptions(RO_SRC))
|
|
||||||
using (dc.PushOpacity(1 - alpha))
|
|
||||||
dc.DrawImage(left, rtRect);
|
|
||||||
|
|
||||||
using (dc.PushRenderOptions(RO_DST))
|
|
||||||
using (dc.PushOpacity(alpha))
|
|
||||||
dc.DrawImage(right, rtRect);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
using (dc.PushRenderOptions(RO_SRC))
|
|
||||||
using (dc.PushOpacity(1 - alpha))
|
|
||||||
dc.DrawImage(left, rtRect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (drawRight)
|
|
||||||
{
|
{
|
||||||
using (dc.PushRenderOptions(RO_SRC))
|
using (dc.PushRenderOptions(RO_SRC))
|
||||||
|
using (dc.PushOpacity(1 - alpha))
|
||||||
|
dc.DrawImage(left, rtRect);
|
||||||
|
|
||||||
|
using (dc.PushRenderOptions(RO_DST))
|
||||||
using (dc.PushOpacity(alpha))
|
using (dc.PushOpacity(alpha))
|
||||||
dc.DrawImage(right, rtRect);
|
dc.DrawImage(right, rtRect);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
context.DrawImage(rt, rtRect, rect);
|
context.DrawImage(rt, rtRect, rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (drawLeft)
|
||||||
|
{
|
||||||
|
using (context.PushOpacity(1 - alpha))
|
||||||
|
context.DrawImage(left, rect);
|
||||||
|
}
|
||||||
|
else if (drawRight)
|
||||||
|
{
|
||||||
|
using (context.PushOpacity(alpha))
|
||||||
|
context.DrawImage(right, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue