forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace SkiaGraphicsView with local patch (#135)
This commit will be revert when upstream code is updated
- Loading branch information
1 parent
6fc0894
commit 8ea938f
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/Core/src/Handlers/GraphicsView/GraphicsViewHandler.Tizen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#nullable disable | ||
using ElmSharp; | ||
using SkiaSharp.Views.Tizen; | ||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.Graphics.Skia; | ||
|
||
namespace Microsoft.Maui.Platform.Tizen | ||
{ | ||
// TODO. Remove it | ||
// This class a temporary used, until Microsoft.Maui.Graphics.Skia.Views.SkiaGraphicsView is updated on upstream. | ||
public class SkiaGraphicsView : SKCanvasView | ||
{ | ||
private IDrawable _drawable; | ||
private SkiaCanvas _canvas; | ||
private ScalingCanvas _scalingCanvas; | ||
|
||
public SkiaGraphicsView(EvasObject parent, IDrawable drawable = null) : base(parent) | ||
{ | ||
_canvas = new SkiaCanvas(); | ||
_scalingCanvas = new ScalingCanvas(_canvas); | ||
Drawable = drawable; | ||
PaintSurface += OnPaintSurface; | ||
} | ||
|
||
public float DeviceScalingFactor { get; set; } | ||
|
||
public IDrawable Drawable | ||
{ | ||
get => _drawable; | ||
set | ||
{ | ||
_drawable = value; | ||
Invalidate(); | ||
} | ||
} | ||
|
||
protected virtual void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e) | ||
{ | ||
if (_drawable == null) return; | ||
|
||
var skiaCanvas = e.Surface.Canvas; | ||
skiaCanvas.Clear(); | ||
|
||
_canvas.Canvas = skiaCanvas; | ||
_scalingCanvas.ResetState(); | ||
|
||
float width = e.Info.Width; | ||
float height = e.Info.Height; | ||
if (DeviceScalingFactor > 0) | ||
{ | ||
width = width / DeviceScalingFactor; | ||
height = height / DeviceScalingFactor; | ||
} | ||
|
||
_scalingCanvas.SaveState(); | ||
if (DeviceScalingFactor > 0) | ||
_scalingCanvas.Scale(DeviceScalingFactor, DeviceScalingFactor); | ||
_drawable.Draw(_scalingCanvas, new RectangleF(0, 0, width, height)); | ||
_scalingCanvas.RestoreState(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters