예제 #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);
     }
 }