Browse Source

Merge branch 'master' into fixes/dc-render-layers

pull/1184/head^2
Nikita Tsukanov 9 years ago
committed by GitHub
parent
commit
75b33cd999
  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
{
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 _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;
this._surface = _surface;
_surface = surface ?? throw new ArgumentNullException();
_factor = factor;
_width = width;
_height = height;
@ -103,9 +103,12 @@ namespace Avalonia.Gtk3
_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)
{
op?.RenderNow();
op?.RenderNow(null);
op?.Dispose();
}
}

1
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

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

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

@ -33,16 +33,22 @@ namespace Avalonia.Skia
PixelWidth = width;
_dpi = dpi;
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)
colorType = SKColorType.Bgra8888;
Bitmap = new SKBitmap();
var nfo = new SKImageInfo(width, height, colorType, SKAlphaType.Premul);
var plat = AvaloniaLocator.Current.GetService<IRuntimePlatform>();
var blob = plat.AllocBlob(nfo.BytesSize);
Bitmap.InstallPixels(nfo, blob.Address, nfo.RowBytes, null, ReleaseDelegate, blob);
Bitmap = new SKBitmap(width, height, colorType, SKAlphaType.Premul);
if (runtimePlatform != null)
{
Bitmap = new SKBitmap();
var nfo = new SKImageInfo(width, height, colorType, SKAlphaType.Premul);
var plat = AvaloniaLocator.Current.GetService<IRuntimePlatform>();
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);
}

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

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

Loading…
Cancel
Save