Browse Source

Merge branch 'master' into fixes/1178-rendering-artifacts

pull/1181/head
Nikita Tsukanov 9 years ago
committed by GitHub
parent
commit
05240d92ea
  1. 2
      src/Gtk/Avalonia.Gtk3/IDeferredRenderOperation.cs
  2. 11
      src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs
  3. 2
      src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs
  4. 1
      src/Shared/PlatformSupport/StandardRuntimePlatform.cs
  5. 22
      src/Skia/Avalonia.Skia/BitmapImpl.cs
  6. 7
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs

2
src/Gtk/Avalonia.Gtk3/IDeferredRenderOperation.cs

@ -4,6 +4,6 @@ namespace Avalonia.Gtk3
{ {
public interface IDeferredRenderOperation : IDisposable public interface IDeferredRenderOperation : IDisposable
{ {
void RenderNow(); void RenderNow(IntPtr? ctx);
} }
} }

11
src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs

@ -88,10 +88,10 @@ namespace Avalonia.Gtk3
private readonly int _width; private readonly int _width;
private readonly int _height; private readonly int _height;
public RenderOp(GtkWidget widget, ManagedCairoSurface _surface, double factor, int width, int height) public RenderOp(GtkWidget widget, ManagedCairoSurface surface, double factor, int width, int height)
{ {
_widget = widget; _widget = widget;
this._surface = _surface; _surface = surface ?? throw new ArgumentNullException();
_factor = factor; _factor = factor;
_width = width; _width = width;
_height = height; _height = height;
@ -103,9 +103,12 @@ namespace Avalonia.Gtk3
_surface = null; _surface = null;
} }
public void RenderNow() public void RenderNow(IntPtr? ctx)
{ {
DrawToWidget(_widget, _surface.Surface, _width, _height, _factor); if(ctx.HasValue)
Draw(ctx.Value, _surface.Surface, _factor);
else
DrawToWidget(_widget, _surface.Surface, _width, _height, _factor);
} }
} }

2
src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs

@ -286,7 +286,7 @@ namespace Avalonia.Gtk3
} }
if (op != null) if (op != null)
{ {
op?.RenderNow(); op?.RenderNow(null);
op?.Dispose(); op?.Dispose();
} }
} }

1
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@ -76,6 +76,7 @@ namespace Avalonia.Shared.PlatformSupport
GC.RemoveMemoryPressure(Size); GC.RemoveMemoryPressure(Size);
IsDisposed = true; IsDisposed = true;
Address = IntPtr.Zero; Address = IntPtr.Zero;
Size = 0;
} }
} }

22
src/Skia/Avalonia.Skia/BitmapImpl.cs

@ -33,16 +33,22 @@ namespace Avalonia.Skia
PixelWidth = width; PixelWidth = width;
_dpi = dpi; _dpi = dpi;
var colorType = fmt?.ToSkColorType() ?? SKImageInfo.PlatformColorType; var colorType = fmt?.ToSkColorType() ?? SKImageInfo.PlatformColorType;
var runtime = AvaloniaLocator.Current?.GetService<IRuntimePlatform>()?.GetRuntimeInfo(); var runtimePlatform = AvaloniaLocator.Current?.GetService<IRuntimePlatform>();
var runtime = runtimePlatform?.GetRuntimeInfo();
if (runtime?.IsDesktop == true && runtime?.OperatingSystem == OperatingSystemType.Linux) if (runtime?.IsDesktop == true && runtime?.OperatingSystem == OperatingSystemType.Linux)
colorType = SKColorType.Bgra8888; colorType = SKColorType.Bgra8888;
Bitmap = new SKBitmap(); if (runtimePlatform != null)
var nfo = new SKImageInfo(width, height, colorType, SKAlphaType.Premul); {
var plat = AvaloniaLocator.Current.GetService<IRuntimePlatform>(); Bitmap = new SKBitmap();
var blob = plat.AllocBlob(nfo.BytesSize); var nfo = new SKImageInfo(width, height, colorType, SKAlphaType.Premul);
Bitmap.InstallPixels(nfo, blob.Address, nfo.RowBytes, null, ReleaseDelegate, blob); var plat = AvaloniaLocator.Current.GetService<IRuntimePlatform>();
Bitmap = new SKBitmap(width, height, colorType, SKAlphaType.Premul); var blob = plat.AllocBlob(nfo.BytesSize);
Bitmap.InstallPixels(nfo, blob.Address, nfo.RowBytes, null, ReleaseDelegate, blob);
}
else
Bitmap = new SKBitmap(width, height, colorType, SKAlphaType.Premul);
Bitmap.Erase(SKColor.Empty); Bitmap.Erase(SKColor.Empty);
} }

7
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -112,6 +112,7 @@ namespace Avalonia.Skia
public readonly SKPaint Paint; public readonly SKPaint Paint;
private IDisposable _disposable1; private IDisposable _disposable1;
private IDisposable _disposable2;
public IDisposable ApplyTo(SKPaint paint) public IDisposable ApplyTo(SKPaint paint)
{ {
@ -127,6 +128,8 @@ namespace Avalonia.Skia
{ {
if (_disposable1 == null) if (_disposable1 == null)
_disposable1 = disposable; _disposable1 = disposable;
else if (_disposable2 == null)
_disposable2 = disposable;
else else
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
@ -135,12 +138,14 @@ namespace Avalonia.Skia
{ {
Paint = paint; Paint = paint;
_disposable1 = null; _disposable1 = null;
_disposable2 = null;
} }
public void Dispose() public void Dispose()
{ {
Paint?.Dispose(); Paint?.Dispose();
_disposable1?.Dispose(); _disposable1?.Dispose();
_disposable2?.Dispose();
} }
} }
@ -221,8 +226,8 @@ namespace Avalonia.Skia
_visualBrushRenderer.RenderVisualBrush(ctx, visualBrush); _visualBrushRenderer.RenderVisualBrush(ctx, visualBrush);
} }
rv.AddDisposable(tileBrushImage);
tileBrushImage = intermediate; tileBrushImage = intermediate;
rv.AddDisposable(tileBrushImage);
} }
} }
else else

Loading…
Cancel
Save