Added the pieces for the simplest GPU sample
This commit is contained in:
Родитель
58462b5d68
Коммит
76cb373357
|
@ -18,6 +18,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)SKPaint.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKDocument.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKPathEffect.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)GRContext.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKSurface.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKCanvas.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKShader.cs" />
|
||||
|
|
|
@ -42,6 +42,9 @@ using System;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Globalization;
|
||||
|
||||
using GRBackendObject = System.IntPtr;
|
||||
using GRBackendContext = System.IntPtr;
|
||||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
public enum SKCodecResult {
|
||||
|
@ -265,6 +268,14 @@ namespace SkiaSharp
|
|||
BgrVertical
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SKSurfacePropsFlags {
|
||||
DisallowAntiAlias = 1 << 0,
|
||||
DisallowDither = 1 << 1,
|
||||
UseDeviceIndependentFonts = 1 << 2,
|
||||
GammaCorrect = 1 << 3,
|
||||
}
|
||||
|
||||
public enum SKEncoding {
|
||||
Utf8, Utf16, Utf32
|
||||
}
|
||||
|
@ -457,6 +468,7 @@ namespace SkiaSharp
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SKSurfaceProps {
|
||||
public SKPixelGeometry PixelGeometry;
|
||||
public SKSurfacePropsFlags Flags;
|
||||
}
|
||||
|
||||
public enum SKZeroInitialized {
|
||||
|
@ -1141,6 +1153,9 @@ namespace SkiaSharp
|
|||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public float Height => Bottom - Top;
|
||||
public float Width => Right - Left;
|
||||
|
||||
public static SKRectI Create (int width, int height)
|
||||
{
|
||||
return new SKRectI (0, 0, width, height);
|
||||
|
@ -1163,6 +1178,9 @@ namespace SkiaSharp
|
|||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public float Height => Bottom - Top;
|
||||
public float Width => Right - Left;
|
||||
|
||||
public static SKRect Create (float width, float height)
|
||||
{
|
||||
return new SKRect (0, 0, width, height);
|
||||
|
@ -1614,5 +1632,45 @@ typeMask = Mask.Scale | Mask.RectStaysRect
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum GRSurfaceOrigin {
|
||||
TopLeft,
|
||||
BottomLeft,
|
||||
}
|
||||
|
||||
public enum GRPixelConfig {
|
||||
Unknown,
|
||||
Alpha8,
|
||||
Index8,
|
||||
Rgb565,
|
||||
Rgba4444,
|
||||
Rgba8888,
|
||||
Bgra8888,
|
||||
Srgba8888,
|
||||
Sbgra8888,
|
||||
Etc1,
|
||||
Latc,
|
||||
R11Eac,
|
||||
Astc12x12,
|
||||
RgbaFloat,
|
||||
AlphaHalf,
|
||||
RgbaHalf,
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct GRBackendRenderTargetDesc {
|
||||
public int Width;
|
||||
public int Height;
|
||||
public GRPixelConfig Config;
|
||||
public GRSurfaceOrigin Origin;
|
||||
public int SampleCount;
|
||||
public int StencilBits;
|
||||
public GRBackendObject RenderTargetHandle;
|
||||
}
|
||||
|
||||
public enum GRBackend {
|
||||
OpenGL,
|
||||
Vulkan,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// Bindings for GRContext
|
||||
//
|
||||
// Author:
|
||||
// Matthew Leibowitz
|
||||
//
|
||||
// Copyright 2016 Xamarin Inc
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
public class GRContext : SKObject
|
||||
{
|
||||
[Preserve]
|
||||
internal GRContext (IntPtr h, bool owns)
|
||||
: base (h, owns)
|
||||
{
|
||||
}
|
||||
|
||||
public static GRContext Create (GRBackend backend)
|
||||
{
|
||||
return Create (backend, IntPtr.Zero);
|
||||
}
|
||||
|
||||
public static GRContext Create (GRBackend backend, IntPtr backendContext)
|
||||
{
|
||||
return GetObject<GRContext> (SkiaApi.gr_context_create_with_defaults (backend, backendContext));
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (Handle != IntPtr.Zero && OwnsHandle) {
|
||||
SkiaApi.gr_context_unref (Handle);
|
||||
}
|
||||
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -349,6 +349,10 @@ namespace SkiaSharp
|
|||
SkiaApi.sk_canvas_draw_text_on_path (Handle, bytes, bytes.Length, path.Handle, hOffset, vOffset, paint.Handle);
|
||||
}
|
||||
|
||||
public void Flush ()
|
||||
{
|
||||
SkiaApi.sk_canvas_flush (Handle);
|
||||
}
|
||||
|
||||
public void ResetMatrix ()
|
||||
{
|
||||
|
|
|
@ -44,6 +44,16 @@ namespace SkiaSharp
|
|||
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster_direct (ref info, pixels, (IntPtr)rowBytes, ref props));
|
||||
}
|
||||
|
||||
public static SKSurface Create (GRContext context, GRBackendRenderTargetDesc desc, SKSurfaceProps props)
|
||||
{
|
||||
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_render_target (context.Handle, ref desc, ref props));
|
||||
}
|
||||
|
||||
public static SKSurface Create (GRContext context, GRBackendRenderTargetDesc desc)
|
||||
{
|
||||
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_render_target (context.Handle, ref desc, IntPtr.Zero));
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (Handle != IntPtr.Zero && OwnsHandle) {
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using GRBackendObject = System.IntPtr;
|
||||
using GRBackendContext = System.IntPtr;
|
||||
|
||||
using sk_surface_t = System.IntPtr;
|
||||
using sk_canvas_t = System.IntPtr;
|
||||
using sk_image_t = System.IntPtr;
|
||||
|
@ -42,6 +45,7 @@ using sk_path_iterator_t = System.IntPtr;
|
|||
using sk_path_effect_t = System.IntPtr;
|
||||
using sk_pixelref_factory_t = System.IntPtr;
|
||||
using sk_colortable_t = System.IntPtr;
|
||||
using gr_context_t = System.IntPtr;
|
||||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
|
@ -77,6 +81,10 @@ namespace SkiaSharp
|
|||
public extern static sk_canvas_t sk_surface_get_canvas(sk_surface_t t);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static sk_image_t sk_surface_new_image_snapshot(sk_surface_t t);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static sk_surface_t sk_surface_new_backend_render_target (gr_context_t context, ref GRBackendRenderTargetDesc desc, ref SKSurfaceProps props);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static sk_surface_t sk_surface_new_backend_render_target (gr_context_t context, ref GRBackendRenderTargetDesc desc, IntPtr propsZero);
|
||||
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static int sk_canvas_save(sk_canvas_t t);
|
||||
|
@ -173,6 +181,10 @@ namespace SkiaSharp
|
|||
public extern static bool sk_canvas_get_clip_device_bounds(sk_canvas_t t, ref SKRectI cbounds);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static bool sk_canvas_get_clip_bounds(sk_canvas_t t, ref SKRect cbounds);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static void sk_canvas_flush (sk_canvas_t canvas);
|
||||
|
||||
// Paint
|
||||
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static sk_paint_t sk_paint_new();
|
||||
|
@ -910,6 +922,13 @@ namespace SkiaSharp
|
|||
public extern static void sk_colortable_read_colors (sk_colortable_t ctable, [Out] SKColor[] colors);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static void sk_colortable_read_colors (sk_colortable_t ctable, out IntPtr colors);
|
||||
|
||||
// GRContext
|
||||
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static gr_context_t gr_context_create_with_defaults (GRBackend backend, GRBackendContext backendContext);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static void gr_context_unref (gr_context_t context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "sk_string.h"
|
||||
#include "sk_surface.h"
|
||||
#include "sk_typeface.h"
|
||||
#include "gr_context.h"
|
||||
|
||||
// Xamarin
|
||||
#include "sk_managedstream.h"
|
||||
|
@ -80,6 +81,7 @@ void** KeepSkiaCSymbols ()
|
|||
(void*)sk_matrix_map_radius,
|
||||
(void*)sk_matrix_try_invert,
|
||||
(void*)sk_colortable_new,
|
||||
(void*)gr_context_unref,
|
||||
|
||||
// Xamarin
|
||||
(void*)sk_managedstream_new,
|
||||
|
|
2
skia
2
skia
|
@ -1 +1 @@
|
|||
Subproject commit 3343ae587f9da023dfd43ed1ab12dcddf0bd097b
|
||||
Subproject commit e83f322d4ccfd5cbf5bdfbd973aa951b7171504e
|
Загрузка…
Ссылка в новой задаче