From: Matthew Leibowitz Date: Fri, 19 Aug 2016 00:18:50 +0000 (+0200) Subject: Added a few more methods for GrContext and GrGLInterface X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~128^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01b9fc27b9e0283961ac7a9a3715b09e0aa55f5b;p=platform%2Fupstream%2FlibSkiaSharp.git Added a few more methods for GrContext and GrGLInterface --- diff --git a/include/c/gr_context.h b/include/c/gr_context.h index d73236a..4dd3706 100644 --- a/include/c/gr_context.h +++ b/include/c/gr_context.h @@ -15,12 +15,22 @@ SK_C_PLUS_PLUS_BEGIN_GUARD +SK_API gr_context_t* gr_context_create(gr_backend_t backend, gr_backendcontext_t backendContext, const gr_context_options_t* options); SK_API gr_context_t* gr_context_create_with_defaults(gr_backend_t backend, gr_backendcontext_t backendContext); SK_API void gr_context_unref(gr_context_t* context); - -SK_API const gr_gl_interface_t* gr_gl_default_interface(); -SK_API const gr_gl_interface_t* gr_gl_create_native_interface(); -SK_API void gr_gl_interface_unref(gr_gl_interface_t* glInterface); +SK_API void gr_context_abandon_context(gr_context_t* context); +SK_API void gr_context_release_resources_and_abandon_context(gr_context_t* context); +SK_API void gr_context_get_resource_cache_limits(gr_context_t* context, int* maxResources, size_t* maxResourceBytes); +SK_API void gr_context_set_resource_cache_limits(gr_context_t* context, int maxResources, size_t maxResourceBytes); +SK_API void gr_context_get_resource_cache_usage(gr_context_t* context, int* maxResources, size_t* maxResourceBytes); +SK_API int gr_context_get_recommended_sample_count(gr_context_t* context, gr_pixelconfig_t config, float dpi); + +SK_API const gr_glinterface_t* gr_glinterface_default_interface(); +SK_API const gr_glinterface_t* gr_glinterface_create_native_interface(); +SK_API void gr_glinterface_unref(gr_glinterface_t* glInterface); +SK_API gr_glinterface_t* gr_glinterface_clone(gr_glinterface_t* glInterface); +SK_API bool gr_glinterface_validate(gr_glinterface_t* glInterface); +SK_API bool gr_glinterface_has_extension(gr_glinterface_t* glInterface, const char* extension); SK_C_PLUS_PLUS_END_GUARD diff --git a/include/c/sk_types.h b/include/c/sk_types.h index 29c6695..c52ed5c 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -573,6 +573,22 @@ typedef struct { typedef struct gr_context_t gr_context_t; +typedef struct { + bool fSuppressPrints; + int fMaxTextureSizeOverride; + int fMaxTileSizeOverride; + bool fSuppressDualSourceBlending; + int fBufferMapThreshold; + bool fUseDrawInsteadOfPartialRenderTargetWrite; + bool fImmediateMode; + bool fClipBatchToBounds; + bool fDrawBatchBounds; + int fMaxBatchLookback; + int fMaxBatchLookahead; + bool fUseShaderSwizzling; + bool fDoManualMipmapping; +} gr_context_options_t; + typedef enum { OPENGL_GR_BACKEND, VULKAN_GR_BACKEND, @@ -580,7 +596,7 @@ typedef enum { typedef intptr_t gr_backendcontext_t; -typedef struct gr_gl_interface_t gr_gl_interface_t; +typedef struct gr_glinterface_t gr_glinterface_t; SK_C_PLUS_PLUS_END_GUARD diff --git a/src/c/gr_context.cpp b/src/c/gr_context.cpp index df43475..6389092 100644 --- a/src/c/gr_context.cpp +++ b/src/c/gr_context.cpp @@ -12,6 +12,10 @@ #include "sk_types_priv.h" +gr_context_t* gr_context_create(gr_backend_t backend, gr_backendcontext_t backendContext, const gr_context_options_t* options) { + return ToGrContext(GrContext::Create((GrBackend)backend, backendContext, AsGrContextOptions(*options))); +} + gr_context_t* gr_context_create_with_defaults(gr_backend_t backend, gr_backendcontext_t backendContext) { return ToGrContext(GrContext::Create((GrBackend)backend, backendContext)); } @@ -20,14 +24,51 @@ void gr_context_unref(gr_context_t* context) { AsGrContext(context)->unref(); } -const gr_gl_interface_t* gr_gl_default_interface() { +void gr_context_abandon_context(gr_context_t* context) { + AsGrContext(context)->abandonContext(); +} + +void gr_context_release_resources_and_abandon_context(gr_context_t* context) { + AsGrContext(context)->releaseResourcesAndAbandonContext(); +} + +void gr_context_get_resource_cache_limits(gr_context_t* context, int* maxResources, size_t* maxResourceBytes) { + AsGrContext(context)->getResourceCacheLimits(maxResources, maxResourceBytes); +} + +void gr_context_set_resource_cache_limits(gr_context_t* context, int maxResources, size_t maxResourceBytes) { + AsGrContext(context)->setResourceCacheLimits(maxResources, maxResourceBytes); +} + +void gr_context_get_resource_cache_usage(gr_context_t* context, int* maxResources, size_t* maxResourceBytes) { + AsGrContext(context)->getResourceCacheUsage(maxResources, maxResourceBytes); +} + +int gr_context_get_recommended_sample_count(gr_context_t* context, gr_pixelconfig_t config, float dpi) { + return AsGrContext(context)->getRecommendedSampleCount((GrPixelConfig)config, dpi); +} + + +const gr_glinterface_t* gr_glinterface_default_interface() { return ToGrGLInterface(GrGLDefaultInterface()); } -const gr_gl_interface_t* gr_gl_create_native_interface() { +const gr_glinterface_t* gr_glinterface_create_native_interface() { return ToGrGLInterface(GrGLCreateNativeInterface()); } -void gr_gl_interface_unref(gr_gl_interface_t* glInterface) { +void gr_glinterface_unref(gr_glinterface_t* glInterface) { AsGrGLInterface(glInterface)->unref(); -} \ No newline at end of file +} + +gr_glinterface_t* gr_glinterface_clone(gr_glinterface_t* glInterface) { + return ToGrGLInterface(GrGLInterface::NewClone(AsGrGLInterface(glInterface))); +} + +bool gr_glinterface_validate(gr_glinterface_t* glInterface) { + return AsGrGLInterface(glInterface)->validate(); +} + +bool gr_glinterface_has_extension(gr_glinterface_t* glInterface, const char* extension) { + return AsGrGLInterface(glInterface)->hasExtension(extension); +} diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index a40ef62..d4ab708 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -24,6 +24,7 @@ #include "SkMatrixConvolutionImageFilter.h" #include "Sk1DPathEffect.h" #include "SkFontStyle.h" +#include "GrContext.h" #include "gl/GrGLInterface.h" #include "sk_path.h" @@ -452,33 +453,8 @@ static inline gr_context_t* ToGrContext(GrContext* p) { static inline GrContext* AsGrContext(gr_context_t* p) { return reinterpret_cast(p); } - -static inline gr_backend_rendertarget_desc_t* ToGrBackendRenderTargetDesc(GrBackendRenderTargetDesc* p) { - return reinterpret_cast(p); -} - -static inline GrBackendRenderTargetDesc* AsGrBackendRenderTargetDesc(gr_backend_rendertarget_desc_t* p) { - return reinterpret_cast(p); -} - -static inline gr_backend_rendertarget_desc_t& ToGrBackendRenderTargetDesc(GrBackendRenderTargetDesc& p) { - return reinterpret_cast(p); -} - -static inline GrBackendRenderTargetDesc& AsGrBackendRenderTargetDesc(gr_backend_rendertarget_desc_t& p) { - return reinterpret_cast(p); -} - -static inline const gr_backend_rendertarget_desc_t* ToGrBackendRenderTargetDesc(const GrBackendRenderTargetDesc* p) { - return reinterpret_cast(p); -} - -static inline const GrBackendRenderTargetDesc* AsGrBackendRenderTargetDesc(const gr_backend_rendertarget_desc_t* p) { - return reinterpret_cast(p); -} - -static inline const gr_backend_rendertarget_desc_t& ToGrBackendRenderTargetDesc(const GrBackendRenderTargetDesc& p) { - return reinterpret_cast(p); +static inline const GrContextOptions& AsGrContextOptions(const gr_context_options_t& p) { + return reinterpret_cast(p); } static inline const GrBackendRenderTargetDesc& AsGrBackendRenderTargetDesc(const gr_backend_rendertarget_desc_t& p) { @@ -489,19 +465,20 @@ static inline const GrBackendTextureDesc& AsGrBackendTextureDesc(const gr_backen return reinterpret_cast(p); } -static inline gr_gl_interface_t* ToGrGLInterface(GrGLInterface* p) { - return reinterpret_cast(p); + +static inline gr_glinterface_t* ToGrGLInterface(GrGLInterface* p) { + return reinterpret_cast(p); } -static inline GrGLInterface* AsGrGLInterface(gr_gl_interface_t* p) { +static inline GrGLInterface* AsGrGLInterface(gr_glinterface_t* p) { return reinterpret_cast(p); } -static inline const gr_gl_interface_t* ToGrGLInterface(const GrGLInterface* p) { - return reinterpret_cast(p); +static inline const gr_glinterface_t* ToGrGLInterface(const GrGLInterface* p) { + return reinterpret_cast(p); } -static inline const GrGLInterface* AsGrGLInterface(const gr_gl_interface_t* p) { +static inline const GrGLInterface* AsGrGLInterface(const gr_glinterface_t* p) { return reinterpret_cast(p); }