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
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,
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
#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));
}
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);
+}
#include "SkMatrixConvolutionImageFilter.h"
#include "Sk1DPathEffect.h"
#include "SkFontStyle.h"
+#include "GrContext.h"
#include "gl/GrGLInterface.h"
#include "sk_path.h"
static inline GrContext* AsGrContext(gr_context_t* p) {
return reinterpret_cast<GrContext*>(p);
}
-
-static inline gr_backend_rendertarget_desc_t* ToGrBackendRenderTargetDesc(GrBackendRenderTargetDesc* p) {
- return reinterpret_cast<gr_backend_rendertarget_desc_t*>(p);
-}
-
-static inline GrBackendRenderTargetDesc* AsGrBackendRenderTargetDesc(gr_backend_rendertarget_desc_t* p) {
- return reinterpret_cast<GrBackendRenderTargetDesc*>(p);
-}
-
-static inline gr_backend_rendertarget_desc_t& ToGrBackendRenderTargetDesc(GrBackendRenderTargetDesc& p) {
- return reinterpret_cast<gr_backend_rendertarget_desc_t&>(p);
-}
-
-static inline GrBackendRenderTargetDesc& AsGrBackendRenderTargetDesc(gr_backend_rendertarget_desc_t& p) {
- return reinterpret_cast<GrBackendRenderTargetDesc&>(p);
-}
-
-static inline const gr_backend_rendertarget_desc_t* ToGrBackendRenderTargetDesc(const GrBackendRenderTargetDesc* p) {
- return reinterpret_cast<const gr_backend_rendertarget_desc_t*>(p);
-}
-
-static inline const GrBackendRenderTargetDesc* AsGrBackendRenderTargetDesc(const gr_backend_rendertarget_desc_t* p) {
- return reinterpret_cast<const GrBackendRenderTargetDesc*>(p);
-}
-
-static inline const gr_backend_rendertarget_desc_t& ToGrBackendRenderTargetDesc(const GrBackendRenderTargetDesc& p) {
- return reinterpret_cast<const gr_backend_rendertarget_desc_t&>(p);
+static inline const GrContextOptions& AsGrContextOptions(const gr_context_options_t& p) {
+ return reinterpret_cast<const GrContextOptions&>(p);
}
static inline const GrBackendRenderTargetDesc& AsGrBackendRenderTargetDesc(const gr_backend_rendertarget_desc_t& p) {
return reinterpret_cast<const GrBackendTextureDesc&>(p);
}
-static inline gr_gl_interface_t* ToGrGLInterface(GrGLInterface* p) {
- return reinterpret_cast<gr_gl_interface_t*>(p);
+
+static inline gr_glinterface_t* ToGrGLInterface(GrGLInterface* p) {
+ return reinterpret_cast<gr_glinterface_t*>(p);
}
-static inline GrGLInterface* AsGrGLInterface(gr_gl_interface_t* p) {
+static inline GrGLInterface* AsGrGLInterface(gr_glinterface_t* p) {
return reinterpret_cast<GrGLInterface*>(p);
}
-static inline const gr_gl_interface_t* ToGrGLInterface(const GrGLInterface* p) {
- return reinterpret_cast<const gr_gl_interface_t*>(p);
+static inline const gr_glinterface_t* ToGrGLInterface(const GrGLInterface* p) {
+ return reinterpret_cast<const gr_glinterface_t*>(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<const GrGLInterface*>(p);
}