|
|
|
@ -7,6 +7,8 @@ using Avalonia.Utilities; |
|
|
|
|
|
|
|
namespace Avalonia.Rendering.SceneGraph |
|
|
|
{ |
|
|
|
using Avalonia.Visuals.Media.Imaging; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A node in the scene graph which represents an image draw.
|
|
|
|
/// </summary>
|
|
|
|
@ -20,7 +22,8 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
/// <param name="opacity">The draw opacity.</param>
|
|
|
|
/// <param name="sourceRect">The source rect.</param>
|
|
|
|
/// <param name="destRect">The destination rect.</param>
|
|
|
|
public ImageNode(Matrix transform, IRef<IBitmapImpl> source, double opacity, Rect sourceRect, Rect destRect) |
|
|
|
/// <param name="scalingMode"></param>
|
|
|
|
public ImageNode(Matrix transform, IRef<IBitmapImpl> source, double opacity, Rect sourceRect, Rect destRect, BitmapScalingMode scalingMode) |
|
|
|
: base(destRect, transform, null) |
|
|
|
{ |
|
|
|
Transform = transform; |
|
|
|
@ -28,8 +31,11 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
Opacity = opacity; |
|
|
|
SourceRect = sourceRect; |
|
|
|
DestRect = destRect; |
|
|
|
ScalingMode = scalingMode; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the transform with which the node will be drawn.
|
|
|
|
/// </summary>
|
|
|
|
@ -55,6 +61,14 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
/// </summary>
|
|
|
|
public Rect DestRect { get; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the scaling mode.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>
|
|
|
|
/// The scaling mode.
|
|
|
|
/// </value>
|
|
|
|
public BitmapScalingMode ScalingMode { get; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Determines if this draw operation equals another.
|
|
|
|
/// </summary>
|
|
|
|
@ -63,18 +77,20 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
/// <param name="opacity">The opacity of the other draw operation.</param>
|
|
|
|
/// <param name="sourceRect">The source rect of the other draw operation.</param>
|
|
|
|
/// <param name="destRect">The dest rect of the other draw operation.</param>
|
|
|
|
/// <param name="scalingMode"></param>
|
|
|
|
/// <returns>True if the draw operations are the same, otherwise false.</returns>
|
|
|
|
/// <remarks>
|
|
|
|
/// The properties of the other draw operation are passed in as arguments to prevent
|
|
|
|
/// allocation of a not-yet-constructed draw operation object.
|
|
|
|
/// </remarks>
|
|
|
|
public bool Equals(Matrix transform, IRef<IBitmapImpl> source, double opacity, Rect sourceRect, Rect destRect) |
|
|
|
public bool Equals(Matrix transform, IRef<IBitmapImpl> source, double opacity, Rect sourceRect, Rect destRect, BitmapScalingMode scalingMode) |
|
|
|
{ |
|
|
|
return transform == Transform && |
|
|
|
Equals(source.Item, Source.Item) && |
|
|
|
opacity == Opacity && |
|
|
|
sourceRect == SourceRect && |
|
|
|
destRect == DestRect; |
|
|
|
destRect == DestRect && |
|
|
|
scalingMode == ScalingMode; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
@ -83,7 +99,7 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
// TODO: Probably need to introduce some kind of locking mechanism in the case of
|
|
|
|
// WriteableBitmap.
|
|
|
|
context.Transform = Transform; |
|
|
|
context.DrawImage(Source, Opacity, SourceRect, DestRect); |
|
|
|
context.DrawImage(Source, Opacity, SourceRect, DestRect, ScalingMode); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|