/// <summary> /// Create new drawing context. /// </summary> /// <param name="createInfo">Create info.</param> /// <param name="disposables">Array of elements to dispose after drawing has finished.</param> public DrawingContextImpl(CreateInfo createInfo, params IDisposable[] disposables) { _dpi = createInfo.Dpi; _visualBrushRenderer = createInfo.VisualBrushRenderer; _disposables = disposables; _canTextUseLcdRendering = !createInfo.DisableTextLcdRendering; _grContext = createInfo.GrContext; _gpu = createInfo.Gpu; if (_grContext != null) { Monitor.Enter(_grContext); } Surface = createInfo.Surface; Canvas = createInfo.Canvas ?? createInfo.Surface?.Canvas; _session = createInfo.CurrentSession; if (Canvas == null) { throw new ArgumentException("Invalid create info - no Canvas provided", nameof(createInfo)); } if (!_dpi.NearlyEquals(SkiaPlatform.DefaultDpi)) { _postTransform = Matrix.CreateScale(_dpi.X / SkiaPlatform.DefaultDpi.X, _dpi.Y / SkiaPlatform.DefaultDpi.Y); } Transform = Matrix.Identity; }
/// <summary> /// Create new surface render target. /// </summary> /// <param name="createInfo">Create info.</param> public SurfaceRenderTarget(CreateInfo createInfo) { PixelSize = new PixelSize(createInfo.Width, createInfo.Height); Dpi = createInfo.Dpi; _disableLcdRendering = createInfo.DisableTextLcdRendering; _grContext = createInfo.GrContext; _gpu = createInfo.Gpu; if (!createInfo.DisableManualFbo) { _surface = _gpu?.TryCreateSurface(PixelSize, createInfo.Session); } if (_surface == null) { _surface = new SkiaSurfaceWrapper(CreateSurface(createInfo.GrContext, PixelSize.Width, PixelSize.Height, createInfo.Format)); } _canvas = _surface?.Surface.Canvas; if (_surface == null || _canvas == null) { throw new InvalidOperationException("Failed to create Skia render target surface"); } }
public PlatformRenderInterface(ISkiaGpu skiaGpu, long?maxResourceBytes = null) { if (skiaGpu != null) { _skiaGpu = skiaGpu; return; } var gl = AvaloniaLocator.Current.GetService <IWindowingPlatformGlFeature>(); if (gl != null) { _skiaGpu = new GlSkiaGpu(gl, maxResourceBytes); } }
public PlatformRenderInterface(ISkiaGpu skiaGpu, long?maxResourceBytes = null) { DefaultPixelFormat = SKImageInfo.PlatformColorType.ToPixelFormat(); if (skiaGpu != null) { _skiaGpu = skiaGpu; return; } var gl = AvaloniaLocator.Current.GetService <IPlatformOpenGlInterface>(); if (gl != null) { _skiaGpu = new GlSkiaGpu(gl, maxResourceBytes); } }
public PlatformRenderInterface(ISkiaGpu skiaGpu, long?maxResourceBytes = null) { DefaultPixelFormat = SKImageInfo.PlatformColorType.ToPixelFormat(); if (skiaGpu != null) { _skiaGpu = skiaGpu; return; } var gl = AvaloniaLocator.Current.GetService <IPlatformOpenGlInterface>(); if (gl != null) { _skiaGpu = new GlSkiaGpu(gl, maxResourceBytes); } //TODO: SKFont crashes when disposed in finalizer so we keep it alive GC.SuppressFinalize(s_font); }
public SkiaGpuRenderTarget(ISkiaGpu skiaGpu, ISkiaGpuRenderTarget renderTarget) { _skiaGpu = skiaGpu; _renderTarget = renderTarget; }