示例#1
0
 public static SKData Create(IntPtr address, int length, SKDataReleaseDelegate releaseProc, object context)
 {
     if (releaseProc == null)
     {
         return(GetObject <SKData> (SkiaApi.sk_data_new_with_proc(address, (IntPtr)length, IntPtr.Zero, IntPtr.Zero)));
     }
     else
     {
         var ctx = new NativeDelegateContext(context, releaseProc);
         return(GetObject <SKData> (SkiaApi.sk_data_new_with_proc(address, (IntPtr)length, releaseDelegate, ctx.NativeContext)));
     }
 }
示例#2
0
        public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context)
        {
            IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle;

            if (releaseProc == null)
            {
                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero));
            }
            else
            {
                var ctx = new NativeDelegateContext(context, releaseProc);
                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, releaseDelegate, ctx.NativeContext));
            }
        }
示例#3
0
        public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKBitmapReleaseDelegate releaseProc, object context)
        {
            var cinfo = SKImageInfoNative.FromManaged(ref info);

            if (releaseProc == null)
            {
                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero, IntPtr.Zero));
            }
            else
            {
                var ctx = new NativeDelegateContext(context, releaseProc);
                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref cinfo, pixels, (IntPtr)rowBytes, releaseDelegate, ctx.NativeContext));
            }
        }
示例#4
0
        public static SKSurface Create(SKImageInfo info, IntPtr pixels, int rowBytes, SKSurfaceReleaseDelegate releaseProc, object context, SKSurfaceProperties props)
        {
            var cinfo = SKImageInfoNative.FromManaged(ref info);

            if (releaseProc == null)
            {
                return(GetObject <SKSurface> (SkiaApi.sk_surface_new_raster_direct(ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero, IntPtr.Zero, props?.Handle ?? IntPtr.Zero)));
            }
            else
            {
                var ctx = new NativeDelegateContext(context, releaseProc);
                return(GetObject <SKSurface> (SkiaApi.sk_surface_new_raster_direct(ref cinfo, pixels, (IntPtr)rowBytes, releaseDelegate, ctx.NativeContext, props?.Handle ?? IntPtr.Zero)));
            }
        }
示例#5
0
        public static GRGlInterface AssembleInterface(object context, GRGlGetProcDelegate get)
        {
            // if on Windows, try ANGLE
            if (PlatformConfiguration.IsWindows)
            {
                var angle = AssembleAngleInterface(context, get);
                if (angle != null)
                {
                    return(angle);
                }
            }

            // try the native default
            using (var ctx = new NativeDelegateContext(context, get)) {
                return(GetObject <GRGlInterface> (SkiaApi.gr_glinterface_assemble_interface(ctx.NativeContext, getProcDelegate)));
            }
        }
示例#6
0
文件: SKImage.cs 项目: mqp/SkiaSharp
        public static SKImage FromTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (releaseProc == null)
            {
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, ref desc, alpha, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)));
            }
            else
            {
                var ctx = new NativeDelegateContext(releaseContext, releaseProc);
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, ref desc, alpha, IntPtr.Zero, textureReleaseDelegate, ctx.NativeContext)));
            }
        }
示例#7
0
文件: SKImage.cs 项目: mqp/SkiaSharp
        public static SKImage FromPixels(SKPixmap pixmap, SKImageRasterReleaseDelegate releaseProc, object releaseContext)
        {
            if (pixmap == null)
            {
                throw new ArgumentNullException(nameof(pixmap));
            }

            if (releaseProc == null)
            {
                return(GetObject <SKImage> (SkiaApi.sk_image_new_raster(pixmap.Handle, IntPtr.Zero, IntPtr.Zero)));
            }
            else
            {
                var ctx = new NativeDelegateContext(releaseContext, releaseProc);
                return(GetObject <SKImage> (SkiaApi.sk_image_new_raster(pixmap.Handle, rasterReleaseDelegate, ctx.NativeContext)));
            }
        }
示例#8
0
        public static SKImage FromTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (texture == null)
            {
                throw new ArgumentNullException(nameof(texture));
            }

            var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;

            if (releaseProc == null)
            {
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, texture.Handle, origin, colorType, alpha, cs, IntPtr.Zero, IntPtr.Zero)));
            }
            else
            {
                var ctx = new NativeDelegateContext(releaseContext, releaseProc);
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, texture.Handle, origin, colorType, alpha, cs, textureReleaseDelegate, ctx.NativeContext)));
            }
        }
示例#9
0
 private static void SKBitmapReleaseInternal(IntPtr address, IntPtr context)
 {
     using (var ctx = NativeDelegateContext.Unwrap(context)) {
         ctx.GetDelegate <SKBitmapReleaseDelegate> () (address, ctx.ManagedContext);
     }
 }
示例#10
0
        private static IntPtr GrGLGetProcInternal(IntPtr context, string name)
        {
            var ctx = NativeDelegateContext.Unwrap(context);

            return(ctx.GetDelegate <GRGlGetProcDelegate> () (ctx.ManagedContext, name));
        }
示例#11
0
 public static GRGlInterface AssembleGlesInterface(object context, GRGlGetProcDelegate get)
 {
     using (var ctx = new NativeDelegateContext(context, get)) {
         return(GetObject <GRGlInterface> (SkiaApi.gr_glinterface_assemble_gles_interface(ctx.NativeContext, getProcDelegate)));
     }
 }
示例#12
0
文件: SKImage.cs 项目: mqp/SkiaSharp
 private static void TextureReleaseInternal(IntPtr context)
 {
     using (var ctx = NativeDelegateContext.Unwrap(context)) {
         ctx.GetDelegate <SKImageTextureReleaseDelegate> () (ctx.ManagedContext);
     }
 }
示例#13
0
文件: SKImage.cs 项目: mqp/SkiaSharp
 private static void RasterReleaseInternal(IntPtr pixels, IntPtr context)
 {
     using (var ctx = NativeDelegateContext.Unwrap(context)) {
         ctx.GetDelegate <SKImageRasterReleaseDelegate> () (pixels, ctx.ManagedContext);
     }
 }