From: Matthew Leibowitz Date: Thu, 23 Mar 2017 14:47:04 +0000 (-0400) Subject: Added some more surface members X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~62 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=842691f72dcfd62a50f915f82c799704e45668f0;p=platform%2Fupstream%2FlibSkiaSharp.git Added some more surface members --- diff --git a/include/c/sk_surface.h b/include/c/sk_surface.h index c7eb115..3d00c89 100644 --- a/include/c/sk_surface.h +++ b/include/c/sk_surface.h @@ -98,6 +98,14 @@ SK_C_API sk_surface_t* sk_surface_new_backend_texture_as_render_target(gr_contex SK_C_API sk_surface_t* sk_surface_new_render_target(gr_context_t* context, bool budgeted, const sk_imageinfo_t* info, int sampleCount, const sk_surfaceprops_t* props); +SK_C_API void sk_surface_draw(sk_surface_t* surface, sk_canvas_t* canvas, float x, float y, const sk_paint_t* paint); + +SK_C_API bool sk_surface_peek_pixels(sk_surface_t* surface, sk_pixmap_t* pixmap); + +SK_C_API bool sk_surface_read_pixels(sk_surface_t* surface, sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY); + +SK_C_API void sk_surface_get_props(sk_surface_t* surface, sk_surfaceprops_t* props); + SK_C_PLUS_PLUS_END_GUARD #endif diff --git a/src/c/sk_surface.cpp b/src/c/sk_surface.cpp index 71cfc53..b97ae25 100644 --- a/src/c/sk_surface.cpp +++ b/src/c/sk_surface.cpp @@ -94,3 +94,22 @@ sk_surface_t* sk_surface_new_render_target(gr_context_t* context, bool budgeted, } return ToSurface(SkSurface::MakeRenderTarget(AsGrContext(context), (SkBudgeted)budgeted, info, sampleCount, surfProps).release()); } + +void sk_surface_draw(sk_surface_t* surface, sk_canvas_t* canvas, float x, float y, const sk_paint_t* paint) { + AsSurface(surface)->draw(AsCanvas(canvas), x, y, AsPaint(paint)); +} + +bool sk_surface_peek_pixels(sk_surface_t* surface, sk_pixmap_t* pixmap) { + return AsSurface(surface)->peekPixels(AsPixmap(pixmap)); +} + +bool sk_surface_read_pixels(sk_surface_t* surface, sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY) { + SkImageInfo info; + from_c(*dstInfo, &info); + return AsSurface(surface)->readPixels(info, dstPixels, dstRowBytes, srcX, srcY); +} + +void sk_surface_get_props(sk_surface_t* surface, sk_surfaceprops_t* props) { + SkSurfaceProps skProps = AsSurface(surface)->props(); + from_sk(&skProps, props); +} diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index 1a82429..43eb05e 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -781,4 +781,11 @@ static inline void from_c(const sk_surfaceprops_t* cprops, SkSurfaceProps* props *props = SkSurfaceProps(cprops->flags, (SkPixelGeometry)cprops->pixelGeometry); } +static inline void from_sk(const SkSurfaceProps* props, sk_surfaceprops_t* cprops) { + *cprops = { + (sk_pixelgeometry_t)props->pixelGeometry(), + (sk_surfaceprops_flags_t)props->flags() + }; +} + #endif