예제 #1
0
        public static SKSurface Create(GRContext context, GRBackendRenderTarget renderTarget, GRSurfaceOrigin origin, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (renderTarget == null)
            {
                throw new ArgumentNullException(nameof(renderTarget));
            }

            return(GetObject(SkiaApi.sk_surface_new_backend_render_target(context.Handle, renderTarget.Handle, origin, colorType.ToNative(), colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero)));
        }
예제 #2
0
        public static SKSurface CreateAsRenderTarget(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (texture == null)
            {
                throw new ArgumentNullException(nameof(texture));
            }

            return(GetObject(SkiaApi.sk_surface_new_backend_texture_as_render_target(context.Handle, texture.Handle, origin, sampleCount, colorType.ToNative(), colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero)));
        }
예제 #3
0
        public static SKImage FromAdoptedTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (texture == null)
            {
                throw new ArgumentNullException(nameof(texture));
            }

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

            return(GetObject(SkiaApi.sk_image_new_from_adopted_texture(context.Handle, texture.Handle, origin, colorType.ToNative(), alpha, cs)));
        }
예제 #4
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;
            var del = releaseProc != null && releaseContext != null
                                ? new SKImageTextureReleaseDelegate((_) => releaseProc(releaseContext))
                                : releaseProc;
            var proxy = DelegateProxies.Create(del, DelegateProxies.SKImageTextureReleaseDelegateProxy, out _, out var ctx);

            return(GetObject(SkiaApi.sk_image_new_from_texture(context.Handle, texture.Handle, origin, colorType.ToNative(), alpha, cs, proxy, (void *)ctx)));
        }
예제 #5
0
        public static SKSurface Create(GRContext context, CoreAnimation.CAMetalLayer layer, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props, out CoreAnimation.ICAMetalDrawable drawable)
        {
            void *drawablePtr;
            var   surface = GetObject(SkiaApi.sk_surface_new_metal_layer(context.Handle, (void *)layer.Handle, origin, sampleCount, colorType.ToNative(), colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero, &drawablePtr));

            drawable = ObjCRuntime.Runtime.GetINativeObject <CoreAnimation.ICAMetalDrawable> ((IntPtr)drawablePtr, true);
            return(surface);
        }
예제 #6
0
 public int GetMaxSurfaceSampleCount(SKColorType colorType) =>
 SkiaApi.gr_recording_context_get_max_surface_sample_count_for_color_type(Handle, colorType.ToNative());
예제 #7
0
 public static SKSurface Create(GRRecordingContext context, MetalKit.MTKView view, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props) =>
 GetObject(SkiaApi.sk_surface_new_metal_view(context.Handle, (void *)view.Handle, origin, sampleCount, colorType.ToNative(), colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero));