Browse Source

[SKIA] Fall back to direct SKBitmap call for unit tests

pull/1195/head
Nikita Tsukanov 9 years ago
parent
commit
3805317042
  1. 22
      src/Skia/Avalonia.Skia/BitmapImpl.cs

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);
} }

Loading…
Cancel
Save