├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── cairo.go ├── cairo.yml ├── cairo_platform.go ├── cairo_platform_osx.go ├── cairo_platform_osx_ext.go ├── cairogl ├── platform_default.go ├── platform_osx.go └── surface.go ├── cgo_helpers.c ├── cgo_helpers.go ├── cgo_helpers.h ├── cmd ├── cairo-example-glfw │ ├── main.go │ └── screenshot.png └── cairo-example-quartz │ ├── main.go │ └── out.png ├── const.go ├── deps └── darwin_amd64 │ ├── libcairo-1.15.11.a │ ├── libfontconfig.a │ ├── libfreetype.a │ ├── libpixman-1.a │ └── libpng16.a ├── doc.go ├── include ├── cairo-deprecated.h ├── cairo-features.h ├── cairo-ft.h ├── cairo-gl.h ├── cairo-gobject.h ├── cairo-pdf.h ├── cairo-ps.h ├── cairo-quartz-image.h ├── cairo-quartz.h ├── cairo-script-interpreter.h ├── cairo-script.h ├── cairo-svg.h ├── cairo-tee.h ├── cairo-version.h ├── cairo-xlib-xrender.h ├── cairo-xlib.h └── cairo.h └── types.go /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2018 Maxim Kupriianov 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: gen 2 | 3 | gen: 4 | c-for-go -out .. cairo.yml 5 | 6 | clean: 7 | rm -f cgo_helpers.go cgo_helpers.h cgo_helpers.c 8 | rm -f doc.go types.go const.go 9 | rm -f cairo.go 10 | 11 | test: 12 | go build 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## cairo bindings 2 | 3 | Work In Progress. 4 | 5 | Full Cairo bindings with examples: 6 | * Quartz-backed rendering for OS X; 7 | * GLFW crossplatform OpenGL 2.1 surface support. 8 | 9 | ### Installation 10 | 11 | To use libcairo and dependencies shipped with this package (`darwin_amd64` at the moment): 12 | ``` 13 | $ go get github.com/golang-ui/cairo/cmd/cairo-example-glfw 14 | ``` 15 | 16 | To dynamically link against external libcairo (via pkg-config, `darwin` systems at the moment): 17 | ``` 18 | $ go get -tags external github.com/golang-ui/cairo/cmd/cairo-example-glfw 19 | ``` 20 | 21 | ### Examples 22 | 23 | cairo-example-glfw 24 | 25 | ### LICENSE 26 | 27 | MIT 28 | -------------------------------------------------------------------------------- /cairo.yml: -------------------------------------------------------------------------------- 1 | --- 2 | GENERATOR: 3 | PackageName: cairo 4 | PackageDescription: "Package cairo provides Go bindings for Cairo." 5 | PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS." 6 | Includes: ["include/cairo.h"] 7 | Options: 8 | SafeStrings: true 9 | 10 | PARSER: 11 | IncludePaths: 12 | - "include/" 13 | SourcesPaths: 14 | - "include/cairo.h" 15 | IgnoredPaths: 16 | - "include/cairo-deprecated.h" 17 | Defines: 18 | CAIRO_HAS_FC_FONT: 1 19 | CAIRO_HAS_FT_FONT: 1 20 | CAIRO_HAS_GOBJECT_FUNCTIONS: 1 21 | CAIRO_HAS_IMAGE_SURFACE: 1 22 | CAIRO_HAS_MIME_SURFACE: 1 23 | CAIRO_HAS_OBSERVER_SURFACE: 1 24 | CAIRO_HAS_PDF_SURFACE: 1 25 | CAIRO_HAS_PNG_FUNCTIONS: 1 26 | CAIRO_HAS_PS_SURFACE: 1 27 | CAIRO_HAS_RECORDING_SURFACE: 1 28 | CAIRO_HAS_SCRIPT_SURFACE: 1 29 | CAIRO_HAS_SVG_SURFACE: 1 30 | CAIRO_HAS_TEE_SURFACE: 1 31 | CAIRO_HAS_USER_FONT: 1 32 | # CAIRO_HAS_QUARTZ_SURFACE: 1 33 | TRANSLATOR: 34 | ConstRules: 35 | defines: expand 36 | PtrTips: 37 | function: 38 | - {target: ".", tips: [ref,ref,ref,ref,ref,ref,ref]} 39 | Rules: 40 | global: 41 | - {transform: lower} 42 | - {action: accept, from: "(?i)^cairo_"} 43 | - {action: replace, from: "^cairo_t$", to: Cairo} 44 | - {action: replace, from: "^cairo_", to: _} 45 | - {transform: export} 46 | const: 47 | - {action: ignore, from: "cairo_get_font_extents$"} 48 | - {action: ignore, from: "cairo_get_status"} 49 | function: 50 | - {action: replace, from: "^_text_extents$", to: "_get_text_extents"} 51 | - {action: replace, from: "^_font_extents$", to: "_get_font_extents"} 52 | - {action: replace, from: "^_rectangle$", to: "_make_rectangle"} 53 | - {action: replace, from: "^_version$", to: "_get_version"} 54 | - {action: ignore, from: "cairo_surface_get_mime_data$"} 55 | - {action: replace, from: "^_status$", to: "_get_status"} 56 | type: 57 | - {action: replace, from: "_t$"} 58 | private: 59 | - {transform: unexport} 60 | post-global: 61 | - {action: replace, from: _$} 62 | - {load: snakecase} 63 | -------------------------------------------------------------------------------- /cairo_platform.go: -------------------------------------------------------------------------------- 1 | package cairo 2 | 3 | /* 4 | #cgo CFLAGS: -DCAIRO_HAS_FT_FONT 5 | #cgo CFLAGS: -DCAIRO_HAS_FC_FONT 6 | #cgo CFLAGS: -DCAIRO_HAS_IMAGE_SURFACE 7 | #cgo CFLAGS: -DCAIRO_HAS_MIME_SURFACE 8 | #cgo CFLAGS: -DCAIRO_HAS_PNG_FUNCTIONS 9 | #cgo CFLAGS: -DCAIRO_HAS_RECORDING_SURFACE 10 | #cgo CFLAGS: -DCAIRO_HAS_SCRIPT_SURFACE 11 | #cgo CFLAGS: -DCAIRO_HAS_TEE_SURFACE 12 | #cgo CFLAGS: -DCAIRO_HAS_USER_FONT 13 | 14 | #include "include/cairo.h" 15 | #include "include/cairo-deprecated.h" 16 | */ 17 | import "C" 18 | 19 | // #undef CAIRO_HAS_GOBJECT_FUNCTIONS 20 | // #undef CAIRO_HAS_BEOS_SURFACE 21 | // #undef CAIRO_HAS_COGL_SURFACE 22 | // #undef CAIRO_HAS_DIRECTFB_SURFACE 23 | // #undef CAIRO_HAS_DRM_SURFACE 24 | // #undef CAIRO_HAS_EGL_FUNCTIONS 25 | // #undef CAIRO_HAS_GALLIUM_SURFACE 26 | // #undef CAIRO_HAS_GLESV2_SURFACE 27 | // #undef CAIRO_HAS_GLX_FUNCTIONS 28 | // #undef CAIRO_HAS_GL_SURFACE 29 | // #undef CAIRO_HAS_OS2_SURFACE 30 | // #undef CAIRO_HAS_QT_SURFACE 31 | // #undef CAIRO_HAS_SKIA_SURFACE 32 | // #undef CAIRO_HAS_VG_SURFACE 33 | // #undef CAIRO_HAS_WGL_FUNCTIONS 34 | // #undef CAIRO_HAS_WIN32_FONT 35 | // #undef CAIRO_HAS_WIN32_SURFACE 36 | // #undef CAIRO_HAS_XCB_SHM_FUNCTIONS 37 | // #undef CAIRO_HAS_XCB_SURFACE 38 | // #undef CAIRO_HAS_XLIB_SURFACE 39 | // #undef CAIRO_HAS_XLIB_XCB_FUNCTIONS 40 | // #undef CAIRO_HAS_XLIB_XRENDER_SURFACE 41 | // #undef CAIRO_HAS_XML_SURFACE 42 | -------------------------------------------------------------------------------- /cairo_platform_osx.go: -------------------------------------------------------------------------------- 1 | //+build darwin 2 | //+build !external 3 | 4 | package cairo 5 | 6 | /* 7 | #cgo darwin LDFLAGS: -L./deps/darwin_amd64 -lcairo-1.15.11 -lfontconfig -lfreetype -lpixman-1 -lpng16 -lz -lbz2 -lexpat 8 | #cgo darwin LDFLAGS: -framework ApplicationServices -framework CoreFoundation -framework CoreGraphics 9 | #cgo darwin CFLAGS: -DCAIRO_HAS_QUARTZ_FONT 10 | #cgo darwin CFLAGS: -DCAIRO_HAS_QUARTZ_IMAGE_SURFACE 11 | #cgo darwin CFLAGS: -DCAIRO_HAS_QUARTZ_SURFACE 12 | 13 | #include "include/cairo-quartz.h" 14 | */ 15 | import "C" 16 | 17 | import "unsafe" 18 | 19 | func QuartzSurfaceCreate(format Format, width uint32, height uint32) *Surface { 20 | cformat, _ := (C.cairo_format_t)(format), cgoAllocsUnknown 21 | cwidth, _ := (C.uint)(width), cgoAllocsUnknown 22 | cheight, _ := (C.uint)(height), cgoAllocsUnknown 23 | __ret := C.cairo_quartz_surface_create(cformat, cwidth, cheight) 24 | __v := *(**Surface)(unsafe.Pointer(&__ret)) 25 | return __v 26 | } 27 | 28 | func QuartzSurfaceCreateForCGContext(ctx C.CGContextRef, width uint32, height uint32) *Surface { 29 | cwidth, _ := (C.uint)(width), cgoAllocsUnknown 30 | cheight, _ := (C.uint)(height), cgoAllocsUnknown 31 | __ret := C.cairo_quartz_surface_create_for_cg_context(ctx, cwidth, cheight) 32 | __v := *(**Surface)(unsafe.Pointer(&__ret)) 33 | return __v 34 | } 35 | 36 | // QuartzSurfaceGetCgContext function as declared in cairo/cairo-quartz.h:57 37 | func QuartzSurfaceGetCgContext(surface *Surface) C.CGContextRef { 38 | csurface, _ := (*C.cairo_surface_t)(unsafe.Pointer(surface)), cgoAllocsUnknown 39 | __ret := C.cairo_quartz_surface_get_cg_context(csurface) 40 | __v := (C.CGContextRef)(__ret) 41 | return __v 42 | } 43 | -------------------------------------------------------------------------------- /cairo_platform_osx_ext.go: -------------------------------------------------------------------------------- 1 | //+build darwin 2 | //+build external 3 | 4 | package cairo 5 | 6 | /* 7 | #cgo darwin pkg-config: cairo 8 | #cgo darwin CFLAGS: -DCAIRO_HAS_QUARTZ_FONT 9 | #cgo darwin CFLAGS: -DCAIRO_HAS_QUARTZ_IMAGE_SURFACE 10 | #cgo darwin CFLAGS: -DCAIRO_HAS_QUARTZ_SURFACE 11 | 12 | #include "include/cairo-quartz.h" 13 | */ 14 | import "C" 15 | 16 | import "unsafe" 17 | 18 | func QuartzSurfaceCreate(format Format, width uint32, height uint32) *Surface { 19 | cformat, _ := (C.cairo_format_t)(format), cgoAllocsUnknown 20 | cwidth, _ := (C.uint)(width), cgoAllocsUnknown 21 | cheight, _ := (C.uint)(height), cgoAllocsUnknown 22 | __ret := C.cairo_quartz_surface_create(cformat, cwidth, cheight) 23 | __v := *(**Surface)(unsafe.Pointer(&__ret)) 24 | return __v 25 | } 26 | 27 | func QuartzSurfaceCreateForCGContext(ctx C.CGContextRef, width uint32, height uint32) *Surface { 28 | cwidth, _ := (C.uint)(width), cgoAllocsUnknown 29 | cheight, _ := (C.uint)(height), cgoAllocsUnknown 30 | __ret := C.cairo_quartz_surface_create_for_cg_context(ctx, cwidth, cheight) 31 | __v := *(**Surface)(unsafe.Pointer(&__ret)) 32 | return __v 33 | } 34 | 35 | // QuartzSurfaceGetCgContext function as declared in cairo/cairo-quartz.h:57 36 | func QuartzSurfaceGetCgContext(surface *Surface) C.CGContextRef { 37 | csurface, _ := (*C.cairo_surface_t)(unsafe.Pointer(surface)), cgoAllocsUnknown 38 | __ret := C.cairo_quartz_surface_get_cg_context(csurface) 39 | __v := (C.CGContextRef)(__ret) 40 | return __v 41 | } 42 | -------------------------------------------------------------------------------- /cairogl/platform_default.go: -------------------------------------------------------------------------------- 1 | package cairogl 2 | 3 | // #include 4 | import "C" 5 | import ( 6 | "unsafe" 7 | 8 | "github.com/golang-ui/cairo" 9 | ) 10 | 11 | type platformSurface struct { 12 | Buffer unsafe.Pointer 13 | Surface *cairo.Surface 14 | } 15 | 16 | func newPlatformSurface(width, height int) *platformSurface { 17 | const bpp = 4 18 | buffer := allocSurfaceMemory(width * height * bpp) 19 | return &platformSurface{ 20 | Buffer: buffer, 21 | Surface: cairo.ImageSurfaceCreateForData( 22 | (*byte)(buffer), cairo.FormatArgb32, int32(width), int32(height), int32(bpp*width), 23 | ), 24 | } 25 | } 26 | 27 | func (p *platformSurface) Destroy() { 28 | if p.Surface != nil { 29 | cairo.SurfaceDestroy(p.Surface) 30 | p.Surface = nil 31 | } 32 | if p.Buffer != nil { 33 | C.free(p.Buffer) 34 | p.Buffer = nil 35 | } 36 | } 37 | 38 | var sizeOfuint8 = unsafe.Sizeof(uint8(0)) 39 | 40 | func allocSurfaceMemory(n int) unsafe.Pointer { 41 | mem, err := C.calloc(C.size_t(n), C.size_t(sizeOfuint8)) 42 | if err != nil { 43 | panic("memory alloc error: " + err.Error()) 44 | } 45 | return mem 46 | } 47 | -------------------------------------------------------------------------------- /cairogl/platform_osx.go: -------------------------------------------------------------------------------- 1 | //+build none 2 | 3 | package cairogl 4 | 5 | import ( 6 | "log" 7 | "unsafe" 8 | 9 | "github.com/golang-ui/cairo" 10 | ) 11 | 12 | type platformSurface struct { 13 | Buffer unsafe.Pointer 14 | Surface *cairo.Surface 15 | } 16 | 17 | // EXPEREMENTAL — NOT READY 18 | 19 | func newPlatformSurface(width, height int) *platformSurface { 20 | surface := cairo.QuartzSurfaceCreate(cairo.FormatA1, uint32(width), uint32(height)) 21 | cairo.SurfaceFlush(surface) 22 | log.Println(surface, 23 | cairo.ImageSurfaceGetFormat(surface), 24 | cairo.ImageSurfaceGetWidth(surface), 25 | cairo.ImageSurfaceGetHeight(surface), 26 | cairo.ImageSurfaceGetStride(surface), 27 | cairo.ImageSurfaceGetData(surface), 28 | ) 29 | return &platformSurface{ 30 | Buffer: unsafe.Pointer(cairo.ImageSurfaceGetData(surface)), 31 | Surface: surface, 32 | } 33 | } 34 | 35 | func (p *platformSurface) Destroy() { 36 | if p.Surface != nil { 37 | cairo.SurfaceDestroy(p.Surface) 38 | p.Surface = nil 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /cairogl/surface.go: -------------------------------------------------------------------------------- 1 | package cairogl 2 | 3 | import ( 4 | "sync" 5 | 6 | "github.com/go-gl/gl/v2.1/gl" 7 | "github.com/golang-ui/cairo" 8 | ) 9 | 10 | type Surface struct { 11 | mux *sync.RWMutex 12 | platform *platformSurface 13 | context *cairo.Cairo 14 | width int 15 | height int 16 | tex_id uint32 17 | } 18 | 19 | func NewSurface(width, height int) *Surface { 20 | s := &Surface{ 21 | mux: new(sync.RWMutex), 22 | width: width, 23 | height: height, 24 | platform: newPlatformSurface(width, height), 25 | } 26 | s.context = cairo.Create(s.platform.Surface) 27 | 28 | gl.Disable(gl.DEPTH_TEST) 29 | gl.Enable(gl.BLEND) 30 | gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) 31 | gl.Enable(gl.TEXTURE_RECTANGLE_ARB) 32 | 33 | gl.MatrixMode(gl.PROJECTION) 34 | gl.LoadIdentity() 35 | gl.Ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) 36 | 37 | gl.DeleteTextures(1, &s.tex_id) 38 | gl.GenTextures(1, &s.tex_id) 39 | gl.BindTexture(gl.TEXTURE_RECTANGLE_ARB, s.tex_id) 40 | gl.TexEnvi(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.DECAL) 41 | 42 | return s 43 | } 44 | 45 | func (s *Surface) Surface() *cairo.Surface { 46 | s.mux.RLock() 47 | ss := s.platform.Surface 48 | s.mux.RUnlock() 49 | return ss 50 | } 51 | 52 | func (s *Surface) Context() *cairo.Cairo { 53 | s.mux.RLock() 54 | cr := s.context 55 | s.mux.RUnlock() 56 | return cr 57 | } 58 | 59 | func (s *Surface) Destroy() { 60 | s.mux.Lock() 61 | defer s.mux.Unlock() 62 | 63 | if s.context != nil { 64 | cairo.Destroy(s.context) 65 | s.context = nil 66 | } 67 | if s.platform != nil { 68 | s.platform.Destroy() 69 | } 70 | } 71 | 72 | func (s *Surface) Size() (int, int) { 73 | s.mux.RLock() 74 | w, h := s.width, s.height 75 | s.mux.RUnlock() 76 | return w, h 77 | } 78 | 79 | func (s *Surface) Width() int { 80 | s.mux.RLock() 81 | w := s.width 82 | s.mux.RUnlock() 83 | return w 84 | } 85 | 86 | func (s *Surface) Height() int { 87 | s.mux.RLock() 88 | h := s.height 89 | s.mux.RUnlock() 90 | return h 91 | } 92 | 93 | func (s *Surface) Update(width, height int) { 94 | s.mux.RLock() 95 | w, h := s.width, s.height 96 | s.mux.RUnlock() 97 | 98 | if width != w || height != h { 99 | s.Destroy() 100 | s.mux.Lock() 101 | tmp := s.mux 102 | *s = *NewSurface(width, height) 103 | s.mux = tmp 104 | s.mux.Unlock() 105 | } 106 | } 107 | 108 | func (s *Surface) Draw() { 109 | s.mux.RLock() 110 | 111 | gl.MatrixMode(gl.MODELVIEW) 112 | gl.LoadIdentity() 113 | gl.Viewport(0, 0, int32(s.width), int32(s.height)) 114 | gl.Clear(gl.COLOR_BUFFER_BIT) 115 | 116 | gl.PushMatrix() 117 | gl.Enable(gl.TEXTURE_RECTANGLE_ARB) 118 | gl.Enable(gl.TEXTURE_2D) 119 | 120 | gl.TexImage2D(gl.TEXTURE_RECTANGLE_ARB, 0, gl.RGBA8, 121 | int32(s.width), int32(s.height), 0, 122 | gl.BGRA, gl.UNSIGNED_BYTE, s.platform.Buffer) 123 | 124 | gl.Begin(gl.QUADS) 125 | gl.TexCoord2f(0.0, float32(s.height)) 126 | gl.Vertex2f(-1.0, -1.0) 127 | 128 | gl.TexCoord2f(float32(s.width), float32(s.height)) 129 | gl.Vertex2f(1.0, -1.0) 130 | 131 | gl.TexCoord2f(float32(s.width), 0.0) 132 | gl.Vertex2f(1.0, 1.0) 133 | 134 | gl.TexCoord2f(0.0, 0.0) 135 | gl.Vertex2f(-1.0, 1.0) 136 | gl.End() 137 | 138 | gl.Disable(gl.TEXTURE_2D) 139 | gl.Disable(gl.TEXTURE_RECTANGLE_ARB) 140 | gl.PopMatrix() 141 | 142 | s.mux.RUnlock() 143 | } 144 | -------------------------------------------------------------------------------- /cgo_helpers.c: -------------------------------------------------------------------------------- 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. 2 | 3 | // WARNING: This file has automatically been generated on Thu, 11 Jan 2018 16:22:52 MSK. 4 | // By https://git.io/c-for-go. DO NOT EDIT. 5 | 6 | #include "_cgo_export.h" 7 | #include "cgo_helpers.h" 8 | 9 | void cairo_destroy_func_t_6936ee15(void* data) { 10 | destroyFunc6936EE15(data); 11 | } 12 | 13 | cairo_status_t cairo_write_func_t_f4dfc69(void* closure, unsigned char* data, unsigned int length) { 14 | return writeFuncF4DFC69(closure, data, length); 15 | } 16 | 17 | cairo_status_t cairo_read_func_t_69800aa2(void* closure, unsigned char* data, unsigned int length) { 18 | return readFunc69800AA2(closure, data, length); 19 | } 20 | 21 | cairo_status_t cairo_user_scaled_font_init_func_t_87c5d9cb(cairo_scaled_font_t* scaled_font, cairo_t* cr, cairo_font_extents_t* extents) { 22 | return userScaledFontInitFunc87C5D9CB(scaled_font, cr, extents); 23 | } 24 | 25 | cairo_status_t cairo_user_scaled_font_render_glyph_func_t_32c7be76(cairo_scaled_font_t* scaled_font, unsigned long int glyph, cairo_t* cr, cairo_text_extents_t* extents) { 26 | return userScaledFontRenderGlyphFunc32C7BE76(scaled_font, glyph, cr, extents); 27 | } 28 | 29 | cairo_status_t cairo_user_scaled_font_text_to_glyphs_func_t_5fc4fffd(cairo_scaled_font_t* scaled_font, char* utf8, int utf8_len, cairo_glyph_t** glyphs, int* num_glyphs, cairo_text_cluster_t** clusters, int* num_clusters, cairo_text_cluster_flags_t* cluster_flags) { 30 | return userScaledFontTextToGlyphsFunc5FC4FFFD(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, cluster_flags); 31 | } 32 | 33 | cairo_status_t cairo_user_scaled_font_unicode_to_glyph_func_t_d4a3aae6(cairo_scaled_font_t* scaled_font, unsigned long int unicode, unsigned long int* glyph_index) { 34 | return userScaledFontUnicodeToGlyphFuncD4A3AAE6(scaled_font, unicode, glyph_index); 35 | } 36 | 37 | void cairo_surface_observer_callback_t_9f372381(cairo_surface_t* observer, cairo_surface_t* target, void* data) { 38 | surfaceObserverCallback9F372381(observer, target, data); 39 | } 40 | 41 | cairo_surface_t* cairo_raster_source_acquire_func_t_e7404447(cairo_pattern_t* pattern, void* callback_data, cairo_surface_t* target, cairo_rectangle_int_t* extents) { 42 | return rasterSourceAcquireFuncE7404447(pattern, callback_data, target, extents); 43 | } 44 | 45 | void cairo_raster_source_release_func_t_659bfe43(cairo_pattern_t* pattern, void* callback_data, cairo_surface_t* surface) { 46 | rasterSourceReleaseFunc659BFE43(pattern, callback_data, surface); 47 | } 48 | 49 | cairo_status_t cairo_raster_source_snapshot_func_t_518a3707(cairo_pattern_t* pattern, void* callback_data) { 50 | return rasterSourceSnapshotFunc518A3707(pattern, callback_data); 51 | } 52 | 53 | cairo_status_t cairo_raster_source_copy_func_t_84d80d8b(cairo_pattern_t* pattern, void* callback_data, cairo_pattern_t* other) { 54 | return rasterSourceCopyFunc84D80D8B(pattern, callback_data, other); 55 | } 56 | 57 | void cairo_raster_source_finish_func_t_ece7e85b(cairo_pattern_t* pattern, void* callback_data) { 58 | rasterSourceFinishFuncECE7E85B(pattern, callback_data); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /cgo_helpers.go: -------------------------------------------------------------------------------- 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. 2 | 3 | // WARNING: This file has automatically been generated on Thu, 11 Jan 2018 16:22:52 MSK. 4 | // By https://git.io/c-for-go. DO NOT EDIT. 5 | 6 | package cairo 7 | 8 | /* 9 | #include "include/cairo.h" 10 | #include 11 | #include "cgo_helpers.h" 12 | */ 13 | import "C" 14 | import ( 15 | "runtime" 16 | "sync" 17 | "unsafe" 18 | ) 19 | 20 | // Ref returns a reference to C object as it is. 21 | func (x *Cairo) Ref() *C.cairo_t { 22 | if x == nil { 23 | return nil 24 | } 25 | return (*C.cairo_t)(unsafe.Pointer(x)) 26 | } 27 | 28 | // Free cleanups the referenced memory using C free. 29 | func (x *Cairo) Free() { 30 | if x != nil { 31 | C.free(unsafe.Pointer(x)) 32 | } 33 | } 34 | 35 | // NewCairoRef converts the C object reference into a raw struct reference without wrapping. 36 | func NewCairoRef(ref unsafe.Pointer) *Cairo { 37 | return (*Cairo)(ref) 38 | } 39 | 40 | // NewCairo allocates a new C object of this type and converts the reference into 41 | // a raw struct reference without wrapping. 42 | func NewCairo() *Cairo { 43 | return (*Cairo)(allocCairoMemory(1)) 44 | } 45 | 46 | // allocCairoMemory allocates memory for type C.cairo_t in C. 47 | // The caller is responsible for freeing the this memory via C.free. 48 | func allocCairoMemory(n int) unsafe.Pointer { 49 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfCairoValue)) 50 | if err != nil { 51 | panic("memory alloc error: " + err.Error()) 52 | } 53 | return mem 54 | } 55 | 56 | const sizeOfCairoValue = unsafe.Sizeof([1]C.cairo_t{}) 57 | 58 | // cgoAllocMap stores pointers to C allocated memory for future reference. 59 | type cgoAllocMap struct { 60 | mux sync.RWMutex 61 | m map[unsafe.Pointer]struct{} 62 | } 63 | 64 | var cgoAllocsUnknown = new(cgoAllocMap) 65 | 66 | func (a *cgoAllocMap) Add(ptr unsafe.Pointer) { 67 | a.mux.Lock() 68 | if a.m == nil { 69 | a.m = make(map[unsafe.Pointer]struct{}) 70 | } 71 | a.m[ptr] = struct{}{} 72 | a.mux.Unlock() 73 | } 74 | 75 | func (a *cgoAllocMap) IsEmpty() bool { 76 | a.mux.RLock() 77 | isEmpty := len(a.m) == 0 78 | a.mux.RUnlock() 79 | return isEmpty 80 | } 81 | 82 | func (a *cgoAllocMap) Borrow(b *cgoAllocMap) { 83 | if b == nil || b.IsEmpty() { 84 | return 85 | } 86 | b.mux.Lock() 87 | a.mux.Lock() 88 | for ptr := range b.m { 89 | if a.m == nil { 90 | a.m = make(map[unsafe.Pointer]struct{}) 91 | } 92 | a.m[ptr] = struct{}{} 93 | delete(b.m, ptr) 94 | } 95 | a.mux.Unlock() 96 | b.mux.Unlock() 97 | } 98 | 99 | func (a *cgoAllocMap) Free() { 100 | a.mux.Lock() 101 | for ptr := range a.m { 102 | C.free(ptr) 103 | delete(a.m, ptr) 104 | } 105 | a.mux.Unlock() 106 | } 107 | 108 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 109 | func (x *Cairo) PassRef() *C.cairo_t { 110 | if x == nil { 111 | x = (*Cairo)(allocCairoMemory(1)) 112 | } 113 | return (*C.cairo_t)(unsafe.Pointer(x)) 114 | } 115 | 116 | // Ref returns a reference to C object as it is. 117 | func (x *Surface) Ref() *C.cairo_surface_t { 118 | if x == nil { 119 | return nil 120 | } 121 | return (*C.cairo_surface_t)(unsafe.Pointer(x)) 122 | } 123 | 124 | // Free cleanups the referenced memory using C free. 125 | func (x *Surface) Free() { 126 | if x != nil { 127 | C.free(unsafe.Pointer(x)) 128 | } 129 | } 130 | 131 | // NewSurfaceRef converts the C object reference into a raw struct reference without wrapping. 132 | func NewSurfaceRef(ref unsafe.Pointer) *Surface { 133 | return (*Surface)(ref) 134 | } 135 | 136 | // NewSurface allocates a new C object of this type and converts the reference into 137 | // a raw struct reference without wrapping. 138 | func NewSurface() *Surface { 139 | return (*Surface)(allocSurfaceMemory(1)) 140 | } 141 | 142 | // allocSurfaceMemory allocates memory for type C.cairo_surface_t in C. 143 | // The caller is responsible for freeing the this memory via C.free. 144 | func allocSurfaceMemory(n int) unsafe.Pointer { 145 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSurfaceValue)) 146 | if err != nil { 147 | panic("memory alloc error: " + err.Error()) 148 | } 149 | return mem 150 | } 151 | 152 | const sizeOfSurfaceValue = unsafe.Sizeof([1]C.cairo_surface_t{}) 153 | 154 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 155 | func (x *Surface) PassRef() *C.cairo_surface_t { 156 | if x == nil { 157 | x = (*Surface)(allocSurfaceMemory(1)) 158 | } 159 | return (*C.cairo_surface_t)(unsafe.Pointer(x)) 160 | } 161 | 162 | // Ref returns a reference to C object as it is. 163 | func (x *Device) Ref() *C.cairo_device_t { 164 | if x == nil { 165 | return nil 166 | } 167 | return (*C.cairo_device_t)(unsafe.Pointer(x)) 168 | } 169 | 170 | // Free cleanups the referenced memory using C free. 171 | func (x *Device) Free() { 172 | if x != nil { 173 | C.free(unsafe.Pointer(x)) 174 | } 175 | } 176 | 177 | // NewDeviceRef converts the C object reference into a raw struct reference without wrapping. 178 | func NewDeviceRef(ref unsafe.Pointer) *Device { 179 | return (*Device)(ref) 180 | } 181 | 182 | // NewDevice allocates a new C object of this type and converts the reference into 183 | // a raw struct reference without wrapping. 184 | func NewDevice() *Device { 185 | return (*Device)(allocDeviceMemory(1)) 186 | } 187 | 188 | // allocDeviceMemory allocates memory for type C.cairo_device_t in C. 189 | // The caller is responsible for freeing the this memory via C.free. 190 | func allocDeviceMemory(n int) unsafe.Pointer { 191 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfDeviceValue)) 192 | if err != nil { 193 | panic("memory alloc error: " + err.Error()) 194 | } 195 | return mem 196 | } 197 | 198 | const sizeOfDeviceValue = unsafe.Sizeof([1]C.cairo_device_t{}) 199 | 200 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 201 | func (x *Device) PassRef() *C.cairo_device_t { 202 | if x == nil { 203 | x = (*Device)(allocDeviceMemory(1)) 204 | } 205 | return (*C.cairo_device_t)(unsafe.Pointer(x)) 206 | } 207 | 208 | // allocMatrixMemory allocates memory for type C.cairo_matrix_t in C. 209 | // The caller is responsible for freeing the this memory via C.free. 210 | func allocMatrixMemory(n int) unsafe.Pointer { 211 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfMatrixValue)) 212 | if err != nil { 213 | panic("memory alloc error: " + err.Error()) 214 | } 215 | return mem 216 | } 217 | 218 | const sizeOfMatrixValue = unsafe.Sizeof([1]C.cairo_matrix_t{}) 219 | 220 | // Ref returns the underlying reference to C object or nil if struct is nil. 221 | func (x *Matrix) Ref() *C.cairo_matrix_t { 222 | if x == nil { 223 | return nil 224 | } 225 | return x.ref6fd9c783 226 | } 227 | 228 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 229 | // Does nothing if struct is nil or has no allocation map. 230 | func (x *Matrix) Free() { 231 | if x != nil && x.allocs6fd9c783 != nil { 232 | x.allocs6fd9c783.(*cgoAllocMap).Free() 233 | x.ref6fd9c783 = nil 234 | } 235 | } 236 | 237 | // NewMatrixRef creates a new wrapper struct with underlying reference set to the original C object. 238 | // Returns nil if the provided pointer to C object is nil too. 239 | func NewMatrixRef(ref unsafe.Pointer) *Matrix { 240 | if ref == nil { 241 | return nil 242 | } 243 | obj := new(Matrix) 244 | obj.ref6fd9c783 = (*C.cairo_matrix_t)(unsafe.Pointer(ref)) 245 | return obj 246 | } 247 | 248 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 249 | // from this wrapping struct, counting allocations into an allocation map. 250 | func (x *Matrix) PassRef() (*C.cairo_matrix_t, *cgoAllocMap) { 251 | if x == nil { 252 | return nil, nil 253 | } else if x.ref6fd9c783 != nil { 254 | return x.ref6fd9c783, nil 255 | } 256 | mem6fd9c783 := allocMatrixMemory(1) 257 | ref6fd9c783 := (*C.cairo_matrix_t)(mem6fd9c783) 258 | allocs6fd9c783 := new(cgoAllocMap) 259 | allocs6fd9c783.Add(mem6fd9c783) 260 | 261 | var cxx_allocs *cgoAllocMap 262 | ref6fd9c783.xx, cxx_allocs = (C.double)(x.Xx), cgoAllocsUnknown 263 | allocs6fd9c783.Borrow(cxx_allocs) 264 | 265 | var cyx_allocs *cgoAllocMap 266 | ref6fd9c783.yx, cyx_allocs = (C.double)(x.Yx), cgoAllocsUnknown 267 | allocs6fd9c783.Borrow(cyx_allocs) 268 | 269 | var cxy_allocs *cgoAllocMap 270 | ref6fd9c783.xy, cxy_allocs = (C.double)(x.Xy), cgoAllocsUnknown 271 | allocs6fd9c783.Borrow(cxy_allocs) 272 | 273 | var cyy_allocs *cgoAllocMap 274 | ref6fd9c783.yy, cyy_allocs = (C.double)(x.Yy), cgoAllocsUnknown 275 | allocs6fd9c783.Borrow(cyy_allocs) 276 | 277 | var cx0_allocs *cgoAllocMap 278 | ref6fd9c783.x0, cx0_allocs = (C.double)(x.X0), cgoAllocsUnknown 279 | allocs6fd9c783.Borrow(cx0_allocs) 280 | 281 | var cy0_allocs *cgoAllocMap 282 | ref6fd9c783.y0, cy0_allocs = (C.double)(x.Y0), cgoAllocsUnknown 283 | allocs6fd9c783.Borrow(cy0_allocs) 284 | 285 | x.ref6fd9c783 = ref6fd9c783 286 | x.allocs6fd9c783 = allocs6fd9c783 287 | return ref6fd9c783, allocs6fd9c783 288 | 289 | } 290 | 291 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 292 | func (x Matrix) PassValue() (C.cairo_matrix_t, *cgoAllocMap) { 293 | if x.ref6fd9c783 != nil { 294 | return *x.ref6fd9c783, nil 295 | } 296 | ref, allocs := x.PassRef() 297 | return *ref, allocs 298 | } 299 | 300 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 301 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 302 | func (x *Matrix) Deref() { 303 | if x.ref6fd9c783 == nil { 304 | return 305 | } 306 | x.Xx = (float64)(x.ref6fd9c783.xx) 307 | x.Yx = (float64)(x.ref6fd9c783.yx) 308 | x.Xy = (float64)(x.ref6fd9c783.xy) 309 | x.Yy = (float64)(x.ref6fd9c783.yy) 310 | x.X0 = (float64)(x.ref6fd9c783.x0) 311 | x.Y0 = (float64)(x.ref6fd9c783.y0) 312 | } 313 | 314 | // Ref returns a reference to C object as it is. 315 | func (x *Pattern) Ref() *C.cairo_pattern_t { 316 | if x == nil { 317 | return nil 318 | } 319 | return (*C.cairo_pattern_t)(unsafe.Pointer(x)) 320 | } 321 | 322 | // Free cleanups the referenced memory using C free. 323 | func (x *Pattern) Free() { 324 | if x != nil { 325 | C.free(unsafe.Pointer(x)) 326 | } 327 | } 328 | 329 | // NewPatternRef converts the C object reference into a raw struct reference without wrapping. 330 | func NewPatternRef(ref unsafe.Pointer) *Pattern { 331 | return (*Pattern)(ref) 332 | } 333 | 334 | // NewPattern allocates a new C object of this type and converts the reference into 335 | // a raw struct reference without wrapping. 336 | func NewPattern() *Pattern { 337 | return (*Pattern)(allocPatternMemory(1)) 338 | } 339 | 340 | // allocPatternMemory allocates memory for type C.cairo_pattern_t in C. 341 | // The caller is responsible for freeing the this memory via C.free. 342 | func allocPatternMemory(n int) unsafe.Pointer { 343 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPatternValue)) 344 | if err != nil { 345 | panic("memory alloc error: " + err.Error()) 346 | } 347 | return mem 348 | } 349 | 350 | const sizeOfPatternValue = unsafe.Sizeof([1]C.cairo_pattern_t{}) 351 | 352 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 353 | func (x *Pattern) PassRef() *C.cairo_pattern_t { 354 | if x == nil { 355 | x = (*Pattern)(allocPatternMemory(1)) 356 | } 357 | return (*C.cairo_pattern_t)(unsafe.Pointer(x)) 358 | } 359 | 360 | func (x DestroyFunc) PassRef() (ref *C.cairo_destroy_func_t, allocs *cgoAllocMap) { 361 | if x == nil { 362 | return nil, nil 363 | } 364 | if destroyFunc6936EE15Func == nil { 365 | destroyFunc6936EE15Func = x 366 | } 367 | return (*C.cairo_destroy_func_t)(C.cairo_destroy_func_t_6936ee15), nil 368 | } 369 | 370 | func (x DestroyFunc) PassValue() (ref C.cairo_destroy_func_t, allocs *cgoAllocMap) { 371 | if x == nil { 372 | return nil, nil 373 | } 374 | if destroyFunc6936EE15Func == nil { 375 | destroyFunc6936EE15Func = x 376 | } 377 | return (C.cairo_destroy_func_t)(C.cairo_destroy_func_t_6936ee15), nil 378 | } 379 | 380 | func NewDestroyFuncRef(ref unsafe.Pointer) *DestroyFunc { 381 | return (*DestroyFunc)(ref) 382 | } 383 | 384 | //export destroyFunc6936EE15 385 | func destroyFunc6936EE15(cdata unsafe.Pointer) { 386 | if destroyFunc6936EE15Func != nil { 387 | data6936ee15 := (unsafe.Pointer)(unsafe.Pointer(cdata)) 388 | destroyFunc6936EE15Func(data6936ee15) 389 | return 390 | } 391 | panic("callback func has not been set (race?)") 392 | } 393 | 394 | var destroyFunc6936EE15Func DestroyFunc 395 | 396 | // allocUserDataKeyMemory allocates memory for type C.cairo_user_data_key_t in C. 397 | // The caller is responsible for freeing the this memory via C.free. 398 | func allocUserDataKeyMemory(n int) unsafe.Pointer { 399 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfUserDataKeyValue)) 400 | if err != nil { 401 | panic("memory alloc error: " + err.Error()) 402 | } 403 | return mem 404 | } 405 | 406 | const sizeOfUserDataKeyValue = unsafe.Sizeof([1]C.cairo_user_data_key_t{}) 407 | 408 | // Ref returns the underlying reference to C object or nil if struct is nil. 409 | func (x *UserDataKey) Ref() *C.cairo_user_data_key_t { 410 | if x == nil { 411 | return nil 412 | } 413 | return x.refb2afcf30 414 | } 415 | 416 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 417 | // Does nothing if struct is nil or has no allocation map. 418 | func (x *UserDataKey) Free() { 419 | if x != nil && x.allocsb2afcf30 != nil { 420 | x.allocsb2afcf30.(*cgoAllocMap).Free() 421 | x.refb2afcf30 = nil 422 | } 423 | } 424 | 425 | // NewUserDataKeyRef creates a new wrapper struct with underlying reference set to the original C object. 426 | // Returns nil if the provided pointer to C object is nil too. 427 | func NewUserDataKeyRef(ref unsafe.Pointer) *UserDataKey { 428 | if ref == nil { 429 | return nil 430 | } 431 | obj := new(UserDataKey) 432 | obj.refb2afcf30 = (*C.cairo_user_data_key_t)(unsafe.Pointer(ref)) 433 | return obj 434 | } 435 | 436 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 437 | // from this wrapping struct, counting allocations into an allocation map. 438 | func (x *UserDataKey) PassRef() (*C.cairo_user_data_key_t, *cgoAllocMap) { 439 | if x == nil { 440 | return nil, nil 441 | } else if x.refb2afcf30 != nil { 442 | return x.refb2afcf30, nil 443 | } 444 | memb2afcf30 := allocUserDataKeyMemory(1) 445 | refb2afcf30 := (*C.cairo_user_data_key_t)(memb2afcf30) 446 | allocsb2afcf30 := new(cgoAllocMap) 447 | allocsb2afcf30.Add(memb2afcf30) 448 | 449 | var cunused_allocs *cgoAllocMap 450 | refb2afcf30.unused, cunused_allocs = (C.int)(x.Unused), cgoAllocsUnknown 451 | allocsb2afcf30.Borrow(cunused_allocs) 452 | 453 | x.refb2afcf30 = refb2afcf30 454 | x.allocsb2afcf30 = allocsb2afcf30 455 | return refb2afcf30, allocsb2afcf30 456 | 457 | } 458 | 459 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 460 | func (x UserDataKey) PassValue() (C.cairo_user_data_key_t, *cgoAllocMap) { 461 | if x.refb2afcf30 != nil { 462 | return *x.refb2afcf30, nil 463 | } 464 | ref, allocs := x.PassRef() 465 | return *ref, allocs 466 | } 467 | 468 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 469 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 470 | func (x *UserDataKey) Deref() { 471 | if x.refb2afcf30 == nil { 472 | return 473 | } 474 | x.Unused = (int32)(x.refb2afcf30.unused) 475 | } 476 | 477 | // packPUcharString creates a Go string backed by *C.uchar and avoids copying. 478 | func packPUcharString(p *C.uchar) (raw string) { 479 | if p != nil && *p != 0 { 480 | h := (*stringHeader)(unsafe.Pointer(&raw)) 481 | h.Data = uintptr(unsafe.Pointer(p)) 482 | for *p != 0 { 483 | p = (*C.uchar)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + 1)) // p++ 484 | } 485 | h.Len = int(uintptr(unsafe.Pointer(p)) - h.Data) 486 | } 487 | return 488 | } 489 | 490 | type stringHeader struct { 491 | Data uintptr 492 | Len int 493 | } 494 | 495 | // RawString reperesents a string backed by data on the C side. 496 | type RawString string 497 | 498 | // Copy returns a Go-managed copy of raw string. 499 | func (raw RawString) Copy() string { 500 | if len(raw) == 0 { 501 | return "" 502 | } 503 | h := (*stringHeader)(unsafe.Pointer(&raw)) 504 | return C.GoStringN((*C.char)(unsafe.Pointer(h.Data)), C.int(h.Len)) 505 | } 506 | 507 | func (x WriteFunc) PassRef() (ref *C.cairo_write_func_t, allocs *cgoAllocMap) { 508 | if x == nil { 509 | return nil, nil 510 | } 511 | if writeFuncF4DFC69Func == nil { 512 | writeFuncF4DFC69Func = x 513 | } 514 | return (*C.cairo_write_func_t)(C.cairo_write_func_t_f4dfc69), nil 515 | } 516 | 517 | func (x WriteFunc) PassValue() (ref C.cairo_write_func_t, allocs *cgoAllocMap) { 518 | if x == nil { 519 | return nil, nil 520 | } 521 | if writeFuncF4DFC69Func == nil { 522 | writeFuncF4DFC69Func = x 523 | } 524 | return (C.cairo_write_func_t)(C.cairo_write_func_t_f4dfc69), nil 525 | } 526 | 527 | func NewWriteFuncRef(ref unsafe.Pointer) *WriteFunc { 528 | return (*WriteFunc)(ref) 529 | } 530 | 531 | //export writeFuncF4DFC69 532 | func writeFuncF4DFC69(cclosure unsafe.Pointer, cdata *C.uchar, clength C.uint) C.cairo_status_t { 533 | if writeFuncF4DFC69Func != nil { 534 | closuref4dfc69 := (unsafe.Pointer)(unsafe.Pointer(cclosure)) 535 | dataf4dfc69 := packPUcharString(cdata) 536 | lengthf4dfc69 := (uint32)(clength) 537 | retf4dfc69 := writeFuncF4DFC69Func(closuref4dfc69, dataf4dfc69, lengthf4dfc69) 538 | ret, _ := (C.cairo_status_t)(retf4dfc69), cgoAllocsUnknown 539 | return ret 540 | } 541 | panic("callback func has not been set (race?)") 542 | } 543 | 544 | var writeFuncF4DFC69Func WriteFunc 545 | 546 | func (x ReadFunc) PassRef() (ref *C.cairo_read_func_t, allocs *cgoAllocMap) { 547 | if x == nil { 548 | return nil, nil 549 | } 550 | if readFunc69800AA2Func == nil { 551 | readFunc69800AA2Func = x 552 | } 553 | return (*C.cairo_read_func_t)(C.cairo_read_func_t_69800aa2), nil 554 | } 555 | 556 | func (x ReadFunc) PassValue() (ref C.cairo_read_func_t, allocs *cgoAllocMap) { 557 | if x == nil { 558 | return nil, nil 559 | } 560 | if readFunc69800AA2Func == nil { 561 | readFunc69800AA2Func = x 562 | } 563 | return (C.cairo_read_func_t)(C.cairo_read_func_t_69800aa2), nil 564 | } 565 | 566 | func NewReadFuncRef(ref unsafe.Pointer) *ReadFunc { 567 | return (*ReadFunc)(ref) 568 | } 569 | 570 | //export readFunc69800AA2 571 | func readFunc69800AA2(cclosure unsafe.Pointer, cdata *C.uchar, clength C.uint) C.cairo_status_t { 572 | if readFunc69800AA2Func != nil { 573 | closure69800aa2 := (unsafe.Pointer)(unsafe.Pointer(cclosure)) 574 | data69800aa2 := (*byte)(unsafe.Pointer(cdata)) 575 | length69800aa2 := (uint32)(clength) 576 | ret69800aa2 := readFunc69800AA2Func(closure69800aa2, data69800aa2, length69800aa2) 577 | ret, _ := (C.cairo_status_t)(ret69800aa2), cgoAllocsUnknown 578 | return ret 579 | } 580 | panic("callback func has not been set (race?)") 581 | } 582 | 583 | var readFunc69800AA2Func ReadFunc 584 | 585 | // allocRectangleIntMemory allocates memory for type C.cairo_rectangle_int_t in C. 586 | // The caller is responsible for freeing the this memory via C.free. 587 | func allocRectangleIntMemory(n int) unsafe.Pointer { 588 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfRectangleIntValue)) 589 | if err != nil { 590 | panic("memory alloc error: " + err.Error()) 591 | } 592 | return mem 593 | } 594 | 595 | const sizeOfRectangleIntValue = unsafe.Sizeof([1]C.cairo_rectangle_int_t{}) 596 | 597 | // Ref returns the underlying reference to C object or nil if struct is nil. 598 | func (x *RectangleInt) Ref() *C.cairo_rectangle_int_t { 599 | if x == nil { 600 | return nil 601 | } 602 | return x.ref182a0d2b 603 | } 604 | 605 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 606 | // Does nothing if struct is nil or has no allocation map. 607 | func (x *RectangleInt) Free() { 608 | if x != nil && x.allocs182a0d2b != nil { 609 | x.allocs182a0d2b.(*cgoAllocMap).Free() 610 | x.ref182a0d2b = nil 611 | } 612 | } 613 | 614 | // NewRectangleIntRef creates a new wrapper struct with underlying reference set to the original C object. 615 | // Returns nil if the provided pointer to C object is nil too. 616 | func NewRectangleIntRef(ref unsafe.Pointer) *RectangleInt { 617 | if ref == nil { 618 | return nil 619 | } 620 | obj := new(RectangleInt) 621 | obj.ref182a0d2b = (*C.cairo_rectangle_int_t)(unsafe.Pointer(ref)) 622 | return obj 623 | } 624 | 625 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 626 | // from this wrapping struct, counting allocations into an allocation map. 627 | func (x *RectangleInt) PassRef() (*C.cairo_rectangle_int_t, *cgoAllocMap) { 628 | if x == nil { 629 | return nil, nil 630 | } else if x.ref182a0d2b != nil { 631 | return x.ref182a0d2b, nil 632 | } 633 | mem182a0d2b := allocRectangleIntMemory(1) 634 | ref182a0d2b := (*C.cairo_rectangle_int_t)(mem182a0d2b) 635 | allocs182a0d2b := new(cgoAllocMap) 636 | allocs182a0d2b.Add(mem182a0d2b) 637 | 638 | var cx_allocs *cgoAllocMap 639 | ref182a0d2b.x, cx_allocs = (C.int)(x.X), cgoAllocsUnknown 640 | allocs182a0d2b.Borrow(cx_allocs) 641 | 642 | var cy_allocs *cgoAllocMap 643 | ref182a0d2b.y, cy_allocs = (C.int)(x.Y), cgoAllocsUnknown 644 | allocs182a0d2b.Borrow(cy_allocs) 645 | 646 | var cwidth_allocs *cgoAllocMap 647 | ref182a0d2b.width, cwidth_allocs = (C.int)(x.Width), cgoAllocsUnknown 648 | allocs182a0d2b.Borrow(cwidth_allocs) 649 | 650 | var cheight_allocs *cgoAllocMap 651 | ref182a0d2b.height, cheight_allocs = (C.int)(x.Height), cgoAllocsUnknown 652 | allocs182a0d2b.Borrow(cheight_allocs) 653 | 654 | x.ref182a0d2b = ref182a0d2b 655 | x.allocs182a0d2b = allocs182a0d2b 656 | return ref182a0d2b, allocs182a0d2b 657 | 658 | } 659 | 660 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 661 | func (x RectangleInt) PassValue() (C.cairo_rectangle_int_t, *cgoAllocMap) { 662 | if x.ref182a0d2b != nil { 663 | return *x.ref182a0d2b, nil 664 | } 665 | ref, allocs := x.PassRef() 666 | return *ref, allocs 667 | } 668 | 669 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 670 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 671 | func (x *RectangleInt) Deref() { 672 | if x.ref182a0d2b == nil { 673 | return 674 | } 675 | x.X = (int32)(x.ref182a0d2b.x) 676 | x.Y = (int32)(x.ref182a0d2b.y) 677 | x.Width = (int32)(x.ref182a0d2b.width) 678 | x.Height = (int32)(x.ref182a0d2b.height) 679 | } 680 | 681 | // allocRectangleMemory allocates memory for type C.cairo_rectangle_t in C. 682 | // The caller is responsible for freeing the this memory via C.free. 683 | func allocRectangleMemory(n int) unsafe.Pointer { 684 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfRectangleValue)) 685 | if err != nil { 686 | panic("memory alloc error: " + err.Error()) 687 | } 688 | return mem 689 | } 690 | 691 | const sizeOfRectangleValue = unsafe.Sizeof([1]C.cairo_rectangle_t{}) 692 | 693 | // Ref returns the underlying reference to C object or nil if struct is nil. 694 | func (x *Rectangle) Ref() *C.cairo_rectangle_t { 695 | if x == nil { 696 | return nil 697 | } 698 | return x.ref9b663fb6 699 | } 700 | 701 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 702 | // Does nothing if struct is nil or has no allocation map. 703 | func (x *Rectangle) Free() { 704 | if x != nil && x.allocs9b663fb6 != nil { 705 | x.allocs9b663fb6.(*cgoAllocMap).Free() 706 | x.ref9b663fb6 = nil 707 | } 708 | } 709 | 710 | // NewRectangleRef creates a new wrapper struct with underlying reference set to the original C object. 711 | // Returns nil if the provided pointer to C object is nil too. 712 | func NewRectangleRef(ref unsafe.Pointer) *Rectangle { 713 | if ref == nil { 714 | return nil 715 | } 716 | obj := new(Rectangle) 717 | obj.ref9b663fb6 = (*C.cairo_rectangle_t)(unsafe.Pointer(ref)) 718 | return obj 719 | } 720 | 721 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 722 | // from this wrapping struct, counting allocations into an allocation map. 723 | func (x *Rectangle) PassRef() (*C.cairo_rectangle_t, *cgoAllocMap) { 724 | if x == nil { 725 | return nil, nil 726 | } else if x.ref9b663fb6 != nil { 727 | return x.ref9b663fb6, nil 728 | } 729 | mem9b663fb6 := allocRectangleMemory(1) 730 | ref9b663fb6 := (*C.cairo_rectangle_t)(mem9b663fb6) 731 | allocs9b663fb6 := new(cgoAllocMap) 732 | allocs9b663fb6.Add(mem9b663fb6) 733 | 734 | var cx_allocs *cgoAllocMap 735 | ref9b663fb6.x, cx_allocs = (C.double)(x.X), cgoAllocsUnknown 736 | allocs9b663fb6.Borrow(cx_allocs) 737 | 738 | var cy_allocs *cgoAllocMap 739 | ref9b663fb6.y, cy_allocs = (C.double)(x.Y), cgoAllocsUnknown 740 | allocs9b663fb6.Borrow(cy_allocs) 741 | 742 | var cwidth_allocs *cgoAllocMap 743 | ref9b663fb6.width, cwidth_allocs = (C.double)(x.Width), cgoAllocsUnknown 744 | allocs9b663fb6.Borrow(cwidth_allocs) 745 | 746 | var cheight_allocs *cgoAllocMap 747 | ref9b663fb6.height, cheight_allocs = (C.double)(x.Height), cgoAllocsUnknown 748 | allocs9b663fb6.Borrow(cheight_allocs) 749 | 750 | x.ref9b663fb6 = ref9b663fb6 751 | x.allocs9b663fb6 = allocs9b663fb6 752 | return ref9b663fb6, allocs9b663fb6 753 | 754 | } 755 | 756 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 757 | func (x Rectangle) PassValue() (C.cairo_rectangle_t, *cgoAllocMap) { 758 | if x.ref9b663fb6 != nil { 759 | return *x.ref9b663fb6, nil 760 | } 761 | ref, allocs := x.PassRef() 762 | return *ref, allocs 763 | } 764 | 765 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 766 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 767 | func (x *Rectangle) Deref() { 768 | if x.ref9b663fb6 == nil { 769 | return 770 | } 771 | x.X = (float64)(x.ref9b663fb6.x) 772 | x.Y = (float64)(x.ref9b663fb6.y) 773 | x.Width = (float64)(x.ref9b663fb6.width) 774 | x.Height = (float64)(x.ref9b663fb6.height) 775 | } 776 | 777 | // allocRectangleListMemory allocates memory for type C.cairo_rectangle_list_t in C. 778 | // The caller is responsible for freeing the this memory via C.free. 779 | func allocRectangleListMemory(n int) unsafe.Pointer { 780 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfRectangleListValue)) 781 | if err != nil { 782 | panic("memory alloc error: " + err.Error()) 783 | } 784 | return mem 785 | } 786 | 787 | const sizeOfRectangleListValue = unsafe.Sizeof([1]C.cairo_rectangle_list_t{}) 788 | 789 | type sliceHeader struct { 790 | Data uintptr 791 | Len int 792 | Cap int 793 | } 794 | 795 | const sizeOfPtr = unsafe.Sizeof(&struct{}{}) 796 | 797 | // unpackSRectangle transforms a sliced Go data structure into plain C format. 798 | func unpackSRectangle(x []Rectangle) (unpacked *C.cairo_rectangle_t, allocs *cgoAllocMap) { 799 | if x == nil { 800 | return nil, nil 801 | } 802 | allocs = new(cgoAllocMap) 803 | defer runtime.SetFinalizer(&unpacked, func(**C.cairo_rectangle_t) { 804 | go allocs.Free() 805 | }) 806 | 807 | len0 := len(x) 808 | mem0 := allocRectangleMemory(len0) 809 | allocs.Add(mem0) 810 | h0 := &sliceHeader{ 811 | Data: uintptr(mem0), 812 | Cap: len0, 813 | Len: len0, 814 | } 815 | v0 := *(*[]C.cairo_rectangle_t)(unsafe.Pointer(h0)) 816 | for i0 := range x { 817 | allocs0 := new(cgoAllocMap) 818 | v0[i0], allocs0 = x[i0].PassValue() 819 | allocs.Borrow(allocs0) 820 | } 821 | h := (*sliceHeader)(unsafe.Pointer(&v0)) 822 | unpacked = (*C.cairo_rectangle_t)(unsafe.Pointer(h.Data)) 823 | return 824 | } 825 | 826 | // packSRectangle reads sliced Go data structure out from plain C format. 827 | func packSRectangle(v []Rectangle, ptr0 *C.cairo_rectangle_t) { 828 | const m = 0x7fffffff 829 | for i0 := range v { 830 | ptr1 := (*(*[m / sizeOfRectangleValue]C.cairo_rectangle_t)(unsafe.Pointer(ptr0)))[i0] 831 | v[i0] = *NewRectangleRef(unsafe.Pointer(&ptr1)) 832 | } 833 | } 834 | 835 | // Ref returns the underlying reference to C object or nil if struct is nil. 836 | func (x *RectangleList) Ref() *C.cairo_rectangle_list_t { 837 | if x == nil { 838 | return nil 839 | } 840 | return x.ref149ca897 841 | } 842 | 843 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 844 | // Does nothing if struct is nil or has no allocation map. 845 | func (x *RectangleList) Free() { 846 | if x != nil && x.allocs149ca897 != nil { 847 | x.allocs149ca897.(*cgoAllocMap).Free() 848 | x.ref149ca897 = nil 849 | } 850 | } 851 | 852 | // NewRectangleListRef creates a new wrapper struct with underlying reference set to the original C object. 853 | // Returns nil if the provided pointer to C object is nil too. 854 | func NewRectangleListRef(ref unsafe.Pointer) *RectangleList { 855 | if ref == nil { 856 | return nil 857 | } 858 | obj := new(RectangleList) 859 | obj.ref149ca897 = (*C.cairo_rectangle_list_t)(unsafe.Pointer(ref)) 860 | return obj 861 | } 862 | 863 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 864 | // from this wrapping struct, counting allocations into an allocation map. 865 | func (x *RectangleList) PassRef() (*C.cairo_rectangle_list_t, *cgoAllocMap) { 866 | if x == nil { 867 | return nil, nil 868 | } else if x.ref149ca897 != nil { 869 | return x.ref149ca897, nil 870 | } 871 | mem149ca897 := allocRectangleListMemory(1) 872 | ref149ca897 := (*C.cairo_rectangle_list_t)(mem149ca897) 873 | allocs149ca897 := new(cgoAllocMap) 874 | allocs149ca897.Add(mem149ca897) 875 | 876 | var cstatus_allocs *cgoAllocMap 877 | ref149ca897.status, cstatus_allocs = (C.cairo_status_t)(x.Status), cgoAllocsUnknown 878 | allocs149ca897.Borrow(cstatus_allocs) 879 | 880 | var crectangles_allocs *cgoAllocMap 881 | ref149ca897.rectangles, crectangles_allocs = unpackSRectangle(x.Rectangles) 882 | allocs149ca897.Borrow(crectangles_allocs) 883 | 884 | var cnum_rectangles_allocs *cgoAllocMap 885 | ref149ca897.num_rectangles, cnum_rectangles_allocs = (C.int)(x.NumRectangles), cgoAllocsUnknown 886 | allocs149ca897.Borrow(cnum_rectangles_allocs) 887 | 888 | x.ref149ca897 = ref149ca897 889 | x.allocs149ca897 = allocs149ca897 890 | return ref149ca897, allocs149ca897 891 | 892 | } 893 | 894 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 895 | func (x RectangleList) PassValue() (C.cairo_rectangle_list_t, *cgoAllocMap) { 896 | if x.ref149ca897 != nil { 897 | return *x.ref149ca897, nil 898 | } 899 | ref, allocs := x.PassRef() 900 | return *ref, allocs 901 | } 902 | 903 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 904 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 905 | func (x *RectangleList) Deref() { 906 | if x.ref149ca897 == nil { 907 | return 908 | } 909 | x.Status = (Status)(x.ref149ca897.status) 910 | packSRectangle(x.Rectangles, x.ref149ca897.rectangles) 911 | x.NumRectangles = (int32)(x.ref149ca897.num_rectangles) 912 | } 913 | 914 | // Ref returns a reference to C object as it is. 915 | func (x *ScaledFont) Ref() *C.cairo_scaled_font_t { 916 | if x == nil { 917 | return nil 918 | } 919 | return (*C.cairo_scaled_font_t)(unsafe.Pointer(x)) 920 | } 921 | 922 | // Free cleanups the referenced memory using C free. 923 | func (x *ScaledFont) Free() { 924 | if x != nil { 925 | C.free(unsafe.Pointer(x)) 926 | } 927 | } 928 | 929 | // NewScaledFontRef converts the C object reference into a raw struct reference without wrapping. 930 | func NewScaledFontRef(ref unsafe.Pointer) *ScaledFont { 931 | return (*ScaledFont)(ref) 932 | } 933 | 934 | // NewScaledFont allocates a new C object of this type and converts the reference into 935 | // a raw struct reference without wrapping. 936 | func NewScaledFont() *ScaledFont { 937 | return (*ScaledFont)(allocScaledFontMemory(1)) 938 | } 939 | 940 | // allocScaledFontMemory allocates memory for type C.cairo_scaled_font_t in C. 941 | // The caller is responsible for freeing the this memory via C.free. 942 | func allocScaledFontMemory(n int) unsafe.Pointer { 943 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfScaledFontValue)) 944 | if err != nil { 945 | panic("memory alloc error: " + err.Error()) 946 | } 947 | return mem 948 | } 949 | 950 | const sizeOfScaledFontValue = unsafe.Sizeof([1]C.cairo_scaled_font_t{}) 951 | 952 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 953 | func (x *ScaledFont) PassRef() *C.cairo_scaled_font_t { 954 | if x == nil { 955 | x = (*ScaledFont)(allocScaledFontMemory(1)) 956 | } 957 | return (*C.cairo_scaled_font_t)(unsafe.Pointer(x)) 958 | } 959 | 960 | // Ref returns a reference to C object as it is. 961 | func (x *FontFace) Ref() *C.cairo_font_face_t { 962 | if x == nil { 963 | return nil 964 | } 965 | return (*C.cairo_font_face_t)(unsafe.Pointer(x)) 966 | } 967 | 968 | // Free cleanups the referenced memory using C free. 969 | func (x *FontFace) Free() { 970 | if x != nil { 971 | C.free(unsafe.Pointer(x)) 972 | } 973 | } 974 | 975 | // NewFontFaceRef converts the C object reference into a raw struct reference without wrapping. 976 | func NewFontFaceRef(ref unsafe.Pointer) *FontFace { 977 | return (*FontFace)(ref) 978 | } 979 | 980 | // NewFontFace allocates a new C object of this type and converts the reference into 981 | // a raw struct reference without wrapping. 982 | func NewFontFace() *FontFace { 983 | return (*FontFace)(allocFontFaceMemory(1)) 984 | } 985 | 986 | // allocFontFaceMemory allocates memory for type C.cairo_font_face_t in C. 987 | // The caller is responsible for freeing the this memory via C.free. 988 | func allocFontFaceMemory(n int) unsafe.Pointer { 989 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFontFaceValue)) 990 | if err != nil { 991 | panic("memory alloc error: " + err.Error()) 992 | } 993 | return mem 994 | } 995 | 996 | const sizeOfFontFaceValue = unsafe.Sizeof([1]C.cairo_font_face_t{}) 997 | 998 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 999 | func (x *FontFace) PassRef() *C.cairo_font_face_t { 1000 | if x == nil { 1001 | x = (*FontFace)(allocFontFaceMemory(1)) 1002 | } 1003 | return (*C.cairo_font_face_t)(unsafe.Pointer(x)) 1004 | } 1005 | 1006 | // allocGlyphMemory allocates memory for type C.cairo_glyph_t in C. 1007 | // The caller is responsible for freeing the this memory via C.free. 1008 | func allocGlyphMemory(n int) unsafe.Pointer { 1009 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfGlyphValue)) 1010 | if err != nil { 1011 | panic("memory alloc error: " + err.Error()) 1012 | } 1013 | return mem 1014 | } 1015 | 1016 | const sizeOfGlyphValue = unsafe.Sizeof([1]C.cairo_glyph_t{}) 1017 | 1018 | // Ref returns the underlying reference to C object or nil if struct is nil. 1019 | func (x *Glyph) Ref() *C.cairo_glyph_t { 1020 | if x == nil { 1021 | return nil 1022 | } 1023 | return x.ref5b16733c 1024 | } 1025 | 1026 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 1027 | // Does nothing if struct is nil or has no allocation map. 1028 | func (x *Glyph) Free() { 1029 | if x != nil && x.allocs5b16733c != nil { 1030 | x.allocs5b16733c.(*cgoAllocMap).Free() 1031 | x.ref5b16733c = nil 1032 | } 1033 | } 1034 | 1035 | // NewGlyphRef creates a new wrapper struct with underlying reference set to the original C object. 1036 | // Returns nil if the provided pointer to C object is nil too. 1037 | func NewGlyphRef(ref unsafe.Pointer) *Glyph { 1038 | if ref == nil { 1039 | return nil 1040 | } 1041 | obj := new(Glyph) 1042 | obj.ref5b16733c = (*C.cairo_glyph_t)(unsafe.Pointer(ref)) 1043 | return obj 1044 | } 1045 | 1046 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 1047 | // from this wrapping struct, counting allocations into an allocation map. 1048 | func (x *Glyph) PassRef() (*C.cairo_glyph_t, *cgoAllocMap) { 1049 | if x == nil { 1050 | return nil, nil 1051 | } else if x.ref5b16733c != nil { 1052 | return x.ref5b16733c, nil 1053 | } 1054 | mem5b16733c := allocGlyphMemory(1) 1055 | ref5b16733c := (*C.cairo_glyph_t)(mem5b16733c) 1056 | allocs5b16733c := new(cgoAllocMap) 1057 | allocs5b16733c.Add(mem5b16733c) 1058 | 1059 | var cindex_allocs *cgoAllocMap 1060 | ref5b16733c.index, cindex_allocs = (C.ulong)(x.Index), cgoAllocsUnknown 1061 | allocs5b16733c.Borrow(cindex_allocs) 1062 | 1063 | var cx_allocs *cgoAllocMap 1064 | ref5b16733c.x, cx_allocs = (C.double)(x.X), cgoAllocsUnknown 1065 | allocs5b16733c.Borrow(cx_allocs) 1066 | 1067 | var cy_allocs *cgoAllocMap 1068 | ref5b16733c.y, cy_allocs = (C.double)(x.Y), cgoAllocsUnknown 1069 | allocs5b16733c.Borrow(cy_allocs) 1070 | 1071 | x.ref5b16733c = ref5b16733c 1072 | x.allocs5b16733c = allocs5b16733c 1073 | return ref5b16733c, allocs5b16733c 1074 | 1075 | } 1076 | 1077 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 1078 | func (x Glyph) PassValue() (C.cairo_glyph_t, *cgoAllocMap) { 1079 | if x.ref5b16733c != nil { 1080 | return *x.ref5b16733c, nil 1081 | } 1082 | ref, allocs := x.PassRef() 1083 | return *ref, allocs 1084 | } 1085 | 1086 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 1087 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 1088 | func (x *Glyph) Deref() { 1089 | if x.ref5b16733c == nil { 1090 | return 1091 | } 1092 | x.Index = (uint)(x.ref5b16733c.index) 1093 | x.X = (float64)(x.ref5b16733c.x) 1094 | x.Y = (float64)(x.ref5b16733c.y) 1095 | } 1096 | 1097 | // allocTextClusterMemory allocates memory for type C.cairo_text_cluster_t in C. 1098 | // The caller is responsible for freeing the this memory via C.free. 1099 | func allocTextClusterMemory(n int) unsafe.Pointer { 1100 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfTextClusterValue)) 1101 | if err != nil { 1102 | panic("memory alloc error: " + err.Error()) 1103 | } 1104 | return mem 1105 | } 1106 | 1107 | const sizeOfTextClusterValue = unsafe.Sizeof([1]C.cairo_text_cluster_t{}) 1108 | 1109 | // Ref returns the underlying reference to C object or nil if struct is nil. 1110 | func (x *TextCluster) Ref() *C.cairo_text_cluster_t { 1111 | if x == nil { 1112 | return nil 1113 | } 1114 | return x.refd989a040 1115 | } 1116 | 1117 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 1118 | // Does nothing if struct is nil or has no allocation map. 1119 | func (x *TextCluster) Free() { 1120 | if x != nil && x.allocsd989a040 != nil { 1121 | x.allocsd989a040.(*cgoAllocMap).Free() 1122 | x.refd989a040 = nil 1123 | } 1124 | } 1125 | 1126 | // NewTextClusterRef creates a new wrapper struct with underlying reference set to the original C object. 1127 | // Returns nil if the provided pointer to C object is nil too. 1128 | func NewTextClusterRef(ref unsafe.Pointer) *TextCluster { 1129 | if ref == nil { 1130 | return nil 1131 | } 1132 | obj := new(TextCluster) 1133 | obj.refd989a040 = (*C.cairo_text_cluster_t)(unsafe.Pointer(ref)) 1134 | return obj 1135 | } 1136 | 1137 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 1138 | // from this wrapping struct, counting allocations into an allocation map. 1139 | func (x *TextCluster) PassRef() (*C.cairo_text_cluster_t, *cgoAllocMap) { 1140 | if x == nil { 1141 | return nil, nil 1142 | } else if x.refd989a040 != nil { 1143 | return x.refd989a040, nil 1144 | } 1145 | memd989a040 := allocTextClusterMemory(1) 1146 | refd989a040 := (*C.cairo_text_cluster_t)(memd989a040) 1147 | allocsd989a040 := new(cgoAllocMap) 1148 | allocsd989a040.Add(memd989a040) 1149 | 1150 | var cnum_bytes_allocs *cgoAllocMap 1151 | refd989a040.num_bytes, cnum_bytes_allocs = (C.int)(x.NumBytes), cgoAllocsUnknown 1152 | allocsd989a040.Borrow(cnum_bytes_allocs) 1153 | 1154 | var cnum_glyphs_allocs *cgoAllocMap 1155 | refd989a040.num_glyphs, cnum_glyphs_allocs = (C.int)(x.NumGlyphs), cgoAllocsUnknown 1156 | allocsd989a040.Borrow(cnum_glyphs_allocs) 1157 | 1158 | x.refd989a040 = refd989a040 1159 | x.allocsd989a040 = allocsd989a040 1160 | return refd989a040, allocsd989a040 1161 | 1162 | } 1163 | 1164 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 1165 | func (x TextCluster) PassValue() (C.cairo_text_cluster_t, *cgoAllocMap) { 1166 | if x.refd989a040 != nil { 1167 | return *x.refd989a040, nil 1168 | } 1169 | ref, allocs := x.PassRef() 1170 | return *ref, allocs 1171 | } 1172 | 1173 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 1174 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 1175 | func (x *TextCluster) Deref() { 1176 | if x.refd989a040 == nil { 1177 | return 1178 | } 1179 | x.NumBytes = (int32)(x.refd989a040.num_bytes) 1180 | x.NumGlyphs = (int32)(x.refd989a040.num_glyphs) 1181 | } 1182 | 1183 | // allocTextExtentsMemory allocates memory for type C.cairo_text_extents_t in C. 1184 | // The caller is responsible for freeing the this memory via C.free. 1185 | func allocTextExtentsMemory(n int) unsafe.Pointer { 1186 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfTextExtentsValue)) 1187 | if err != nil { 1188 | panic("memory alloc error: " + err.Error()) 1189 | } 1190 | return mem 1191 | } 1192 | 1193 | const sizeOfTextExtentsValue = unsafe.Sizeof([1]C.cairo_text_extents_t{}) 1194 | 1195 | // Ref returns the underlying reference to C object or nil if struct is nil. 1196 | func (x *TextExtents) Ref() *C.cairo_text_extents_t { 1197 | if x == nil { 1198 | return nil 1199 | } 1200 | return x.refe2add9c7 1201 | } 1202 | 1203 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 1204 | // Does nothing if struct is nil or has no allocation map. 1205 | func (x *TextExtents) Free() { 1206 | if x != nil && x.allocse2add9c7 != nil { 1207 | x.allocse2add9c7.(*cgoAllocMap).Free() 1208 | x.refe2add9c7 = nil 1209 | } 1210 | } 1211 | 1212 | // NewTextExtentsRef creates a new wrapper struct with underlying reference set to the original C object. 1213 | // Returns nil if the provided pointer to C object is nil too. 1214 | func NewTextExtentsRef(ref unsafe.Pointer) *TextExtents { 1215 | if ref == nil { 1216 | return nil 1217 | } 1218 | obj := new(TextExtents) 1219 | obj.refe2add9c7 = (*C.cairo_text_extents_t)(unsafe.Pointer(ref)) 1220 | return obj 1221 | } 1222 | 1223 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 1224 | // from this wrapping struct, counting allocations into an allocation map. 1225 | func (x *TextExtents) PassRef() (*C.cairo_text_extents_t, *cgoAllocMap) { 1226 | if x == nil { 1227 | return nil, nil 1228 | } else if x.refe2add9c7 != nil { 1229 | return x.refe2add9c7, nil 1230 | } 1231 | meme2add9c7 := allocTextExtentsMemory(1) 1232 | refe2add9c7 := (*C.cairo_text_extents_t)(meme2add9c7) 1233 | allocse2add9c7 := new(cgoAllocMap) 1234 | allocse2add9c7.Add(meme2add9c7) 1235 | 1236 | var cx_bearing_allocs *cgoAllocMap 1237 | refe2add9c7.x_bearing, cx_bearing_allocs = (C.double)(x.XBearing), cgoAllocsUnknown 1238 | allocse2add9c7.Borrow(cx_bearing_allocs) 1239 | 1240 | var cy_bearing_allocs *cgoAllocMap 1241 | refe2add9c7.y_bearing, cy_bearing_allocs = (C.double)(x.YBearing), cgoAllocsUnknown 1242 | allocse2add9c7.Borrow(cy_bearing_allocs) 1243 | 1244 | var cwidth_allocs *cgoAllocMap 1245 | refe2add9c7.width, cwidth_allocs = (C.double)(x.Width), cgoAllocsUnknown 1246 | allocse2add9c7.Borrow(cwidth_allocs) 1247 | 1248 | var cheight_allocs *cgoAllocMap 1249 | refe2add9c7.height, cheight_allocs = (C.double)(x.Height), cgoAllocsUnknown 1250 | allocse2add9c7.Borrow(cheight_allocs) 1251 | 1252 | var cx_advance_allocs *cgoAllocMap 1253 | refe2add9c7.x_advance, cx_advance_allocs = (C.double)(x.XAdvance), cgoAllocsUnknown 1254 | allocse2add9c7.Borrow(cx_advance_allocs) 1255 | 1256 | var cy_advance_allocs *cgoAllocMap 1257 | refe2add9c7.y_advance, cy_advance_allocs = (C.double)(x.YAdvance), cgoAllocsUnknown 1258 | allocse2add9c7.Borrow(cy_advance_allocs) 1259 | 1260 | x.refe2add9c7 = refe2add9c7 1261 | x.allocse2add9c7 = allocse2add9c7 1262 | return refe2add9c7, allocse2add9c7 1263 | 1264 | } 1265 | 1266 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 1267 | func (x TextExtents) PassValue() (C.cairo_text_extents_t, *cgoAllocMap) { 1268 | if x.refe2add9c7 != nil { 1269 | return *x.refe2add9c7, nil 1270 | } 1271 | ref, allocs := x.PassRef() 1272 | return *ref, allocs 1273 | } 1274 | 1275 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 1276 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 1277 | func (x *TextExtents) Deref() { 1278 | if x.refe2add9c7 == nil { 1279 | return 1280 | } 1281 | x.XBearing = (float64)(x.refe2add9c7.x_bearing) 1282 | x.YBearing = (float64)(x.refe2add9c7.y_bearing) 1283 | x.Width = (float64)(x.refe2add9c7.width) 1284 | x.Height = (float64)(x.refe2add9c7.height) 1285 | x.XAdvance = (float64)(x.refe2add9c7.x_advance) 1286 | x.YAdvance = (float64)(x.refe2add9c7.y_advance) 1287 | } 1288 | 1289 | // allocFontExtentsMemory allocates memory for type C.cairo_font_extents_t in C. 1290 | // The caller is responsible for freeing the this memory via C.free. 1291 | func allocFontExtentsMemory(n int) unsafe.Pointer { 1292 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFontExtentsValue)) 1293 | if err != nil { 1294 | panic("memory alloc error: " + err.Error()) 1295 | } 1296 | return mem 1297 | } 1298 | 1299 | const sizeOfFontExtentsValue = unsafe.Sizeof([1]C.cairo_font_extents_t{}) 1300 | 1301 | // Ref returns the underlying reference to C object or nil if struct is nil. 1302 | func (x *FontExtents) Ref() *C.cairo_font_extents_t { 1303 | if x == nil { 1304 | return nil 1305 | } 1306 | return x.refbc0b0f3c 1307 | } 1308 | 1309 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 1310 | // Does nothing if struct is nil or has no allocation map. 1311 | func (x *FontExtents) Free() { 1312 | if x != nil && x.allocsbc0b0f3c != nil { 1313 | x.allocsbc0b0f3c.(*cgoAllocMap).Free() 1314 | x.refbc0b0f3c = nil 1315 | } 1316 | } 1317 | 1318 | // NewFontExtentsRef creates a new wrapper struct with underlying reference set to the original C object. 1319 | // Returns nil if the provided pointer to C object is nil too. 1320 | func NewFontExtentsRef(ref unsafe.Pointer) *FontExtents { 1321 | if ref == nil { 1322 | return nil 1323 | } 1324 | obj := new(FontExtents) 1325 | obj.refbc0b0f3c = (*C.cairo_font_extents_t)(unsafe.Pointer(ref)) 1326 | return obj 1327 | } 1328 | 1329 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 1330 | // from this wrapping struct, counting allocations into an allocation map. 1331 | func (x *FontExtents) PassRef() (*C.cairo_font_extents_t, *cgoAllocMap) { 1332 | if x == nil { 1333 | return nil, nil 1334 | } else if x.refbc0b0f3c != nil { 1335 | return x.refbc0b0f3c, nil 1336 | } 1337 | membc0b0f3c := allocFontExtentsMemory(1) 1338 | refbc0b0f3c := (*C.cairo_font_extents_t)(membc0b0f3c) 1339 | allocsbc0b0f3c := new(cgoAllocMap) 1340 | allocsbc0b0f3c.Add(membc0b0f3c) 1341 | 1342 | var cascent_allocs *cgoAllocMap 1343 | refbc0b0f3c.ascent, cascent_allocs = (C.double)(x.Ascent), cgoAllocsUnknown 1344 | allocsbc0b0f3c.Borrow(cascent_allocs) 1345 | 1346 | var cdescent_allocs *cgoAllocMap 1347 | refbc0b0f3c.descent, cdescent_allocs = (C.double)(x.Descent), cgoAllocsUnknown 1348 | allocsbc0b0f3c.Borrow(cdescent_allocs) 1349 | 1350 | var cheight_allocs *cgoAllocMap 1351 | refbc0b0f3c.height, cheight_allocs = (C.double)(x.Height), cgoAllocsUnknown 1352 | allocsbc0b0f3c.Borrow(cheight_allocs) 1353 | 1354 | var cmax_x_advance_allocs *cgoAllocMap 1355 | refbc0b0f3c.max_x_advance, cmax_x_advance_allocs = (C.double)(x.MaxXAdvance), cgoAllocsUnknown 1356 | allocsbc0b0f3c.Borrow(cmax_x_advance_allocs) 1357 | 1358 | var cmax_y_advance_allocs *cgoAllocMap 1359 | refbc0b0f3c.max_y_advance, cmax_y_advance_allocs = (C.double)(x.MaxYAdvance), cgoAllocsUnknown 1360 | allocsbc0b0f3c.Borrow(cmax_y_advance_allocs) 1361 | 1362 | x.refbc0b0f3c = refbc0b0f3c 1363 | x.allocsbc0b0f3c = allocsbc0b0f3c 1364 | return refbc0b0f3c, allocsbc0b0f3c 1365 | 1366 | } 1367 | 1368 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 1369 | func (x FontExtents) PassValue() (C.cairo_font_extents_t, *cgoAllocMap) { 1370 | if x.refbc0b0f3c != nil { 1371 | return *x.refbc0b0f3c, nil 1372 | } 1373 | ref, allocs := x.PassRef() 1374 | return *ref, allocs 1375 | } 1376 | 1377 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 1378 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 1379 | func (x *FontExtents) Deref() { 1380 | if x.refbc0b0f3c == nil { 1381 | return 1382 | } 1383 | x.Ascent = (float64)(x.refbc0b0f3c.ascent) 1384 | x.Descent = (float64)(x.refbc0b0f3c.descent) 1385 | x.Height = (float64)(x.refbc0b0f3c.height) 1386 | x.MaxXAdvance = (float64)(x.refbc0b0f3c.max_x_advance) 1387 | x.MaxYAdvance = (float64)(x.refbc0b0f3c.max_y_advance) 1388 | } 1389 | 1390 | // Ref returns a reference to C object as it is. 1391 | func (x *FontOptions) Ref() *C.cairo_font_options_t { 1392 | if x == nil { 1393 | return nil 1394 | } 1395 | return (*C.cairo_font_options_t)(unsafe.Pointer(x)) 1396 | } 1397 | 1398 | // Free cleanups the referenced memory using C free. 1399 | func (x *FontOptions) Free() { 1400 | if x != nil { 1401 | C.free(unsafe.Pointer(x)) 1402 | } 1403 | } 1404 | 1405 | // NewFontOptionsRef converts the C object reference into a raw struct reference without wrapping. 1406 | func NewFontOptionsRef(ref unsafe.Pointer) *FontOptions { 1407 | return (*FontOptions)(ref) 1408 | } 1409 | 1410 | // NewFontOptions allocates a new C object of this type and converts the reference into 1411 | // a raw struct reference without wrapping. 1412 | func NewFontOptions() *FontOptions { 1413 | return (*FontOptions)(allocFontOptionsMemory(1)) 1414 | } 1415 | 1416 | // allocFontOptionsMemory allocates memory for type C.cairo_font_options_t in C. 1417 | // The caller is responsible for freeing the this memory via C.free. 1418 | func allocFontOptionsMemory(n int) unsafe.Pointer { 1419 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFontOptionsValue)) 1420 | if err != nil { 1421 | panic("memory alloc error: " + err.Error()) 1422 | } 1423 | return mem 1424 | } 1425 | 1426 | const sizeOfFontOptionsValue = unsafe.Sizeof([1]C.cairo_font_options_t{}) 1427 | 1428 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 1429 | func (x *FontOptions) PassRef() *C.cairo_font_options_t { 1430 | if x == nil { 1431 | x = (*FontOptions)(allocFontOptionsMemory(1)) 1432 | } 1433 | return (*C.cairo_font_options_t)(unsafe.Pointer(x)) 1434 | } 1435 | 1436 | func (x UserScaledFontInitFunc) PassRef() (ref *C.cairo_user_scaled_font_init_func_t, allocs *cgoAllocMap) { 1437 | if x == nil { 1438 | return nil, nil 1439 | } 1440 | if userScaledFontInitFunc87C5D9CBFunc == nil { 1441 | userScaledFontInitFunc87C5D9CBFunc = x 1442 | } 1443 | return (*C.cairo_user_scaled_font_init_func_t)(C.cairo_user_scaled_font_init_func_t_87c5d9cb), nil 1444 | } 1445 | 1446 | func (x UserScaledFontInitFunc) PassValue() (ref C.cairo_user_scaled_font_init_func_t, allocs *cgoAllocMap) { 1447 | if x == nil { 1448 | return nil, nil 1449 | } 1450 | if userScaledFontInitFunc87C5D9CBFunc == nil { 1451 | userScaledFontInitFunc87C5D9CBFunc = x 1452 | } 1453 | return (C.cairo_user_scaled_font_init_func_t)(C.cairo_user_scaled_font_init_func_t_87c5d9cb), nil 1454 | } 1455 | 1456 | func NewUserScaledFontInitFuncRef(ref unsafe.Pointer) *UserScaledFontInitFunc { 1457 | return (*UserScaledFontInitFunc)(ref) 1458 | } 1459 | 1460 | //export userScaledFontInitFunc87C5D9CB 1461 | func userScaledFontInitFunc87C5D9CB(cscaledFont *C.cairo_scaled_font_t, ccr *C.cairo_t, cextents *C.cairo_font_extents_t) C.cairo_status_t { 1462 | if userScaledFontInitFunc87C5D9CBFunc != nil { 1463 | scaledFont87c5d9cb := (*ScaledFont)(unsafe.Pointer(cscaledFont)) 1464 | cr87c5d9cb := (*Cairo)(unsafe.Pointer(ccr)) 1465 | extents87c5d9cb := NewFontExtentsRef(unsafe.Pointer(cextents)) 1466 | ret87c5d9cb := userScaledFontInitFunc87C5D9CBFunc(scaledFont87c5d9cb, cr87c5d9cb, extents87c5d9cb) 1467 | ret, _ := (C.cairo_status_t)(ret87c5d9cb), cgoAllocsUnknown 1468 | return ret 1469 | } 1470 | panic("callback func has not been set (race?)") 1471 | } 1472 | 1473 | var userScaledFontInitFunc87C5D9CBFunc UserScaledFontInitFunc 1474 | 1475 | func (x UserScaledFontRenderGlyphFunc) PassRef() (ref *C.cairo_user_scaled_font_render_glyph_func_t, allocs *cgoAllocMap) { 1476 | if x == nil { 1477 | return nil, nil 1478 | } 1479 | if userScaledFontRenderGlyphFunc32C7BE76Func == nil { 1480 | userScaledFontRenderGlyphFunc32C7BE76Func = x 1481 | } 1482 | return (*C.cairo_user_scaled_font_render_glyph_func_t)(C.cairo_user_scaled_font_render_glyph_func_t_32c7be76), nil 1483 | } 1484 | 1485 | func (x UserScaledFontRenderGlyphFunc) PassValue() (ref C.cairo_user_scaled_font_render_glyph_func_t, allocs *cgoAllocMap) { 1486 | if x == nil { 1487 | return nil, nil 1488 | } 1489 | if userScaledFontRenderGlyphFunc32C7BE76Func == nil { 1490 | userScaledFontRenderGlyphFunc32C7BE76Func = x 1491 | } 1492 | return (C.cairo_user_scaled_font_render_glyph_func_t)(C.cairo_user_scaled_font_render_glyph_func_t_32c7be76), nil 1493 | } 1494 | 1495 | func NewUserScaledFontRenderGlyphFuncRef(ref unsafe.Pointer) *UserScaledFontRenderGlyphFunc { 1496 | return (*UserScaledFontRenderGlyphFunc)(ref) 1497 | } 1498 | 1499 | //export userScaledFontRenderGlyphFunc32C7BE76 1500 | func userScaledFontRenderGlyphFunc32C7BE76(cscaledFont *C.cairo_scaled_font_t, cglyph C.ulong, ccr *C.cairo_t, cextents *C.cairo_text_extents_t) C.cairo_status_t { 1501 | if userScaledFontRenderGlyphFunc32C7BE76Func != nil { 1502 | scaledFont32c7be76 := (*ScaledFont)(unsafe.Pointer(cscaledFont)) 1503 | glyph32c7be76 := (uint)(cglyph) 1504 | cr32c7be76 := (*Cairo)(unsafe.Pointer(ccr)) 1505 | extents32c7be76 := NewTextExtentsRef(unsafe.Pointer(cextents)) 1506 | ret32c7be76 := userScaledFontRenderGlyphFunc32C7BE76Func(scaledFont32c7be76, glyph32c7be76, cr32c7be76, extents32c7be76) 1507 | ret, _ := (C.cairo_status_t)(ret32c7be76), cgoAllocsUnknown 1508 | return ret 1509 | } 1510 | panic("callback func has not been set (race?)") 1511 | } 1512 | 1513 | var userScaledFontRenderGlyphFunc32C7BE76Func UserScaledFontRenderGlyphFunc 1514 | 1515 | // packPCharString creates a Go string backed by *C.char and avoids copying. 1516 | func packPCharString(p *C.char) (raw string) { 1517 | if p != nil && *p != 0 { 1518 | h := (*stringHeader)(unsafe.Pointer(&raw)) 1519 | h.Data = uintptr(unsafe.Pointer(p)) 1520 | for *p != 0 { 1521 | p = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + 1)) // p++ 1522 | } 1523 | h.Len = int(uintptr(unsafe.Pointer(p)) - h.Data) 1524 | } 1525 | return 1526 | } 1527 | 1528 | // packSPGlyph reads sliced Go data structure out from plain C format. 1529 | func packSPGlyph(v []*Glyph, ptr0 **C.cairo_glyph_t) { 1530 | const m = 0x7fffffff 1531 | for i0 := range v { 1532 | ptr1 := (*(*[m / sizeOfPtr]*C.cairo_glyph_t)(unsafe.Pointer(ptr0)))[i0] 1533 | v[i0] = NewGlyphRef(unsafe.Pointer(ptr1)) 1534 | } 1535 | } 1536 | 1537 | // packSPTextCluster reads sliced Go data structure out from plain C format. 1538 | func packSPTextCluster(v []*TextCluster, ptr0 **C.cairo_text_cluster_t) { 1539 | const m = 0x7fffffff 1540 | for i0 := range v { 1541 | ptr1 := (*(*[m / sizeOfPtr]*C.cairo_text_cluster_t)(unsafe.Pointer(ptr0)))[i0] 1542 | v[i0] = NewTextClusterRef(unsafe.Pointer(ptr1)) 1543 | } 1544 | } 1545 | 1546 | func (x UserScaledFontTextToGlyphsFunc) PassRef() (ref *C.cairo_user_scaled_font_text_to_glyphs_func_t, allocs *cgoAllocMap) { 1547 | if x == nil { 1548 | return nil, nil 1549 | } 1550 | if userScaledFontTextToGlyphsFunc5FC4FFFDFunc == nil { 1551 | userScaledFontTextToGlyphsFunc5FC4FFFDFunc = x 1552 | } 1553 | return (*C.cairo_user_scaled_font_text_to_glyphs_func_t)(C.cairo_user_scaled_font_text_to_glyphs_func_t_5fc4fffd), nil 1554 | } 1555 | 1556 | func (x UserScaledFontTextToGlyphsFunc) PassValue() (ref C.cairo_user_scaled_font_text_to_glyphs_func_t, allocs *cgoAllocMap) { 1557 | if x == nil { 1558 | return nil, nil 1559 | } 1560 | if userScaledFontTextToGlyphsFunc5FC4FFFDFunc == nil { 1561 | userScaledFontTextToGlyphsFunc5FC4FFFDFunc = x 1562 | } 1563 | return (C.cairo_user_scaled_font_text_to_glyphs_func_t)(C.cairo_user_scaled_font_text_to_glyphs_func_t_5fc4fffd), nil 1564 | } 1565 | 1566 | func NewUserScaledFontTextToGlyphsFuncRef(ref unsafe.Pointer) *UserScaledFontTextToGlyphsFunc { 1567 | return (*UserScaledFontTextToGlyphsFunc)(ref) 1568 | } 1569 | 1570 | //export userScaledFontTextToGlyphsFunc5FC4FFFD 1571 | func userScaledFontTextToGlyphsFunc5FC4FFFD(cscaledFont *C.cairo_scaled_font_t, cutf8 *C.char, cutf8Len C.int, cglyphs **C.cairo_glyph_t, cnumGlyphs *C.int, cclusters **C.cairo_text_cluster_t, cnumClusters *C.int, cclusterFlags *C.cairo_text_cluster_flags_t) C.cairo_status_t { 1572 | if userScaledFontTextToGlyphsFunc5FC4FFFDFunc != nil { 1573 | scaledFont5fc4fffd := (*ScaledFont)(unsafe.Pointer(cscaledFont)) 1574 | utf85fc4fffd := packPCharString(cutf8) 1575 | utf8Len5fc4fffd := (int32)(cutf8Len) 1576 | var glyphs5fc4fffd []*Glyph 1577 | packSPGlyph(glyphs5fc4fffd, cglyphs) 1578 | numGlyphs5fc4fffd := (*int32)(unsafe.Pointer(cnumGlyphs)) 1579 | var clusters5fc4fffd []*TextCluster 1580 | packSPTextCluster(clusters5fc4fffd, cclusters) 1581 | numClusters5fc4fffd := (*int32)(unsafe.Pointer(cnumClusters)) 1582 | var clusterFlags5fc4fffd []TextClusterFlags 1583 | hxfc4425b := (*sliceHeader)(unsafe.Pointer(&clusterFlags5fc4fffd)) 1584 | hxfc4425b.Data = uintptr(unsafe.Pointer(cclusterFlags)) 1585 | hxfc4425b.Cap = 0x7fffffff 1586 | // hxfc4425b.Len = ? 1587 | 1588 | ret5fc4fffd := userScaledFontTextToGlyphsFunc5FC4FFFDFunc(scaledFont5fc4fffd, utf85fc4fffd, utf8Len5fc4fffd, glyphs5fc4fffd, numGlyphs5fc4fffd, clusters5fc4fffd, numClusters5fc4fffd, clusterFlags5fc4fffd) 1589 | ret, _ := (C.cairo_status_t)(ret5fc4fffd), cgoAllocsUnknown 1590 | return ret 1591 | } 1592 | panic("callback func has not been set (race?)") 1593 | } 1594 | 1595 | var userScaledFontTextToGlyphsFunc5FC4FFFDFunc UserScaledFontTextToGlyphsFunc 1596 | 1597 | func (x UserScaledFontUnicodeToGlyphFunc) PassRef() (ref *C.cairo_user_scaled_font_unicode_to_glyph_func_t, allocs *cgoAllocMap) { 1598 | if x == nil { 1599 | return nil, nil 1600 | } 1601 | if userScaledFontUnicodeToGlyphFuncD4A3AAE6Func == nil { 1602 | userScaledFontUnicodeToGlyphFuncD4A3AAE6Func = x 1603 | } 1604 | return (*C.cairo_user_scaled_font_unicode_to_glyph_func_t)(C.cairo_user_scaled_font_unicode_to_glyph_func_t_d4a3aae6), nil 1605 | } 1606 | 1607 | func (x UserScaledFontUnicodeToGlyphFunc) PassValue() (ref C.cairo_user_scaled_font_unicode_to_glyph_func_t, allocs *cgoAllocMap) { 1608 | if x == nil { 1609 | return nil, nil 1610 | } 1611 | if userScaledFontUnicodeToGlyphFuncD4A3AAE6Func == nil { 1612 | userScaledFontUnicodeToGlyphFuncD4A3AAE6Func = x 1613 | } 1614 | return (C.cairo_user_scaled_font_unicode_to_glyph_func_t)(C.cairo_user_scaled_font_unicode_to_glyph_func_t_d4a3aae6), nil 1615 | } 1616 | 1617 | func NewUserScaledFontUnicodeToGlyphFuncRef(ref unsafe.Pointer) *UserScaledFontUnicodeToGlyphFunc { 1618 | return (*UserScaledFontUnicodeToGlyphFunc)(ref) 1619 | } 1620 | 1621 | //export userScaledFontUnicodeToGlyphFuncD4A3AAE6 1622 | func userScaledFontUnicodeToGlyphFuncD4A3AAE6(cscaledFont *C.cairo_scaled_font_t, cunicode C.ulong, cglyphIndex *C.ulong) C.cairo_status_t { 1623 | if userScaledFontUnicodeToGlyphFuncD4A3AAE6Func != nil { 1624 | scaledFontd4a3aae6 := (*ScaledFont)(unsafe.Pointer(cscaledFont)) 1625 | unicoded4a3aae6 := (uint)(cunicode) 1626 | glyphIndexd4a3aae6 := (*uint)(unsafe.Pointer(cglyphIndex)) 1627 | retd4a3aae6 := userScaledFontUnicodeToGlyphFuncD4A3AAE6Func(scaledFontd4a3aae6, unicoded4a3aae6, glyphIndexd4a3aae6) 1628 | ret, _ := (C.cairo_status_t)(retd4a3aae6), cgoAllocsUnknown 1629 | return ret 1630 | } 1631 | panic("callback func has not been set (race?)") 1632 | } 1633 | 1634 | var userScaledFontUnicodeToGlyphFuncD4A3AAE6Func UserScaledFontUnicodeToGlyphFunc 1635 | 1636 | // allocPathMemory allocates memory for type C.cairo_path_t in C. 1637 | // The caller is responsible for freeing the this memory via C.free. 1638 | func allocPathMemory(n int) unsafe.Pointer { 1639 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPathValue)) 1640 | if err != nil { 1641 | panic("memory alloc error: " + err.Error()) 1642 | } 1643 | return mem 1644 | } 1645 | 1646 | const sizeOfPathValue = unsafe.Sizeof([1]C.cairo_path_t{}) 1647 | 1648 | // Ref returns the underlying reference to C object or nil if struct is nil. 1649 | func (x *Path) Ref() *C.cairo_path_t { 1650 | if x == nil { 1651 | return nil 1652 | } 1653 | return x.reffd10d41e 1654 | } 1655 | 1656 | // Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. 1657 | // Does nothing if struct is nil or has no allocation map. 1658 | func (x *Path) Free() { 1659 | if x != nil && x.allocsfd10d41e != nil { 1660 | x.allocsfd10d41e.(*cgoAllocMap).Free() 1661 | x.reffd10d41e = nil 1662 | } 1663 | } 1664 | 1665 | // NewPathRef creates a new wrapper struct with underlying reference set to the original C object. 1666 | // Returns nil if the provided pointer to C object is nil too. 1667 | func NewPathRef(ref unsafe.Pointer) *Path { 1668 | if ref == nil { 1669 | return nil 1670 | } 1671 | obj := new(Path) 1672 | obj.reffd10d41e = (*C.cairo_path_t)(unsafe.Pointer(ref)) 1673 | return obj 1674 | } 1675 | 1676 | // PassRef returns the underlying C object, otherwise it will allocate one and set its values 1677 | // from this wrapping struct, counting allocations into an allocation map. 1678 | func (x *Path) PassRef() (*C.cairo_path_t, *cgoAllocMap) { 1679 | if x == nil { 1680 | return nil, nil 1681 | } else if x.reffd10d41e != nil { 1682 | return x.reffd10d41e, nil 1683 | } 1684 | memfd10d41e := allocPathMemory(1) 1685 | reffd10d41e := (*C.cairo_path_t)(memfd10d41e) 1686 | allocsfd10d41e := new(cgoAllocMap) 1687 | allocsfd10d41e.Add(memfd10d41e) 1688 | 1689 | var cstatus_allocs *cgoAllocMap 1690 | reffd10d41e.status, cstatus_allocs = (C.cairo_status_t)(x.Status), cgoAllocsUnknown 1691 | allocsfd10d41e.Borrow(cstatus_allocs) 1692 | 1693 | var cdata_allocs *cgoAllocMap 1694 | reffd10d41e.data, cdata_allocs = (*C.cairo_path_data_t)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&x.Data)).Data)), cgoAllocsUnknown 1695 | allocsfd10d41e.Borrow(cdata_allocs) 1696 | 1697 | var cnum_data_allocs *cgoAllocMap 1698 | reffd10d41e.num_data, cnum_data_allocs = (C.int)(x.NumData), cgoAllocsUnknown 1699 | allocsfd10d41e.Borrow(cnum_data_allocs) 1700 | 1701 | x.reffd10d41e = reffd10d41e 1702 | x.allocsfd10d41e = allocsfd10d41e 1703 | return reffd10d41e, allocsfd10d41e 1704 | 1705 | } 1706 | 1707 | // PassValue does the same as PassRef except that it will try to dereference the returned pointer. 1708 | func (x Path) PassValue() (C.cairo_path_t, *cgoAllocMap) { 1709 | if x.reffd10d41e != nil { 1710 | return *x.reffd10d41e, nil 1711 | } 1712 | ref, allocs := x.PassRef() 1713 | return *ref, allocs 1714 | } 1715 | 1716 | // Deref uses the underlying reference to C object and fills the wrapping struct with values. 1717 | // Do not forget to call this method whether you get a struct for C object and want to read its values. 1718 | func (x *Path) Deref() { 1719 | if x.reffd10d41e == nil { 1720 | return 1721 | } 1722 | x.Status = (Status)(x.reffd10d41e.status) 1723 | hxf95e7c8 := (*sliceHeader)(unsafe.Pointer(&x.Data)) 1724 | hxf95e7c8.Data = uintptr(unsafe.Pointer(x.reffd10d41e.data)) 1725 | hxf95e7c8.Cap = 0x7fffffff 1726 | // hxf95e7c8.Len = ? 1727 | 1728 | x.NumData = (int32)(x.reffd10d41e.num_data) 1729 | } 1730 | 1731 | func (x SurfaceObserverCallback) PassRef() (ref *C.cairo_surface_observer_callback_t, allocs *cgoAllocMap) { 1732 | if x == nil { 1733 | return nil, nil 1734 | } 1735 | if surfaceObserverCallback9F372381Func == nil { 1736 | surfaceObserverCallback9F372381Func = x 1737 | } 1738 | return (*C.cairo_surface_observer_callback_t)(C.cairo_surface_observer_callback_t_9f372381), nil 1739 | } 1740 | 1741 | func (x SurfaceObserverCallback) PassValue() (ref C.cairo_surface_observer_callback_t, allocs *cgoAllocMap) { 1742 | if x == nil { 1743 | return nil, nil 1744 | } 1745 | if surfaceObserverCallback9F372381Func == nil { 1746 | surfaceObserverCallback9F372381Func = x 1747 | } 1748 | return (C.cairo_surface_observer_callback_t)(C.cairo_surface_observer_callback_t_9f372381), nil 1749 | } 1750 | 1751 | func NewSurfaceObserverCallbackRef(ref unsafe.Pointer) *SurfaceObserverCallback { 1752 | return (*SurfaceObserverCallback)(ref) 1753 | } 1754 | 1755 | //export surfaceObserverCallback9F372381 1756 | func surfaceObserverCallback9F372381(cobserver *C.cairo_surface_t, ctarget *C.cairo_surface_t, cdata unsafe.Pointer) { 1757 | if surfaceObserverCallback9F372381Func != nil { 1758 | observer9f372381 := (*Surface)(unsafe.Pointer(cobserver)) 1759 | target9f372381 := (*Surface)(unsafe.Pointer(ctarget)) 1760 | data9f372381 := (unsafe.Pointer)(unsafe.Pointer(cdata)) 1761 | surfaceObserverCallback9F372381Func(observer9f372381, target9f372381, data9f372381) 1762 | return 1763 | } 1764 | panic("callback func has not been set (race?)") 1765 | } 1766 | 1767 | var surfaceObserverCallback9F372381Func SurfaceObserverCallback 1768 | 1769 | func (x RasterSourceAcquireFunc) PassRef() (ref *C.cairo_raster_source_acquire_func_t, allocs *cgoAllocMap) { 1770 | if x == nil { 1771 | return nil, nil 1772 | } 1773 | if rasterSourceAcquireFuncE7404447Func == nil { 1774 | rasterSourceAcquireFuncE7404447Func = x 1775 | } 1776 | return (*C.cairo_raster_source_acquire_func_t)(C.cairo_raster_source_acquire_func_t_e7404447), nil 1777 | } 1778 | 1779 | func (x RasterSourceAcquireFunc) PassValue() (ref C.cairo_raster_source_acquire_func_t, allocs *cgoAllocMap) { 1780 | if x == nil { 1781 | return nil, nil 1782 | } 1783 | if rasterSourceAcquireFuncE7404447Func == nil { 1784 | rasterSourceAcquireFuncE7404447Func = x 1785 | } 1786 | return (C.cairo_raster_source_acquire_func_t)(C.cairo_raster_source_acquire_func_t_e7404447), nil 1787 | } 1788 | 1789 | func NewRasterSourceAcquireFuncRef(ref unsafe.Pointer) *RasterSourceAcquireFunc { 1790 | return (*RasterSourceAcquireFunc)(ref) 1791 | } 1792 | 1793 | //export rasterSourceAcquireFuncE7404447 1794 | func rasterSourceAcquireFuncE7404447(cpattern *C.cairo_pattern_t, ccallbackData unsafe.Pointer, ctarget *C.cairo_surface_t, cextents *C.cairo_rectangle_int_t) *C.cairo_surface_t { 1795 | if rasterSourceAcquireFuncE7404447Func != nil { 1796 | patterne7404447 := (*Pattern)(unsafe.Pointer(cpattern)) 1797 | callbackDatae7404447 := (unsafe.Pointer)(unsafe.Pointer(ccallbackData)) 1798 | targete7404447 := (*Surface)(unsafe.Pointer(ctarget)) 1799 | extentse7404447 := NewRectangleIntRef(unsafe.Pointer(cextents)) 1800 | rete7404447 := rasterSourceAcquireFuncE7404447Func(patterne7404447, callbackDatae7404447, targete7404447, extentse7404447) 1801 | ret, _ := (*C.cairo_surface_t)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&rete7404447)).Data)), cgoAllocsUnknown 1802 | return ret 1803 | } 1804 | panic("callback func has not been set (race?)") 1805 | } 1806 | 1807 | var rasterSourceAcquireFuncE7404447Func RasterSourceAcquireFunc 1808 | 1809 | func (x RasterSourceReleaseFunc) PassRef() (ref *C.cairo_raster_source_release_func_t, allocs *cgoAllocMap) { 1810 | if x == nil { 1811 | return nil, nil 1812 | } 1813 | if rasterSourceReleaseFunc659BFE43Func == nil { 1814 | rasterSourceReleaseFunc659BFE43Func = x 1815 | } 1816 | return (*C.cairo_raster_source_release_func_t)(C.cairo_raster_source_release_func_t_659bfe43), nil 1817 | } 1818 | 1819 | func (x RasterSourceReleaseFunc) PassValue() (ref C.cairo_raster_source_release_func_t, allocs *cgoAllocMap) { 1820 | if x == nil { 1821 | return nil, nil 1822 | } 1823 | if rasterSourceReleaseFunc659BFE43Func == nil { 1824 | rasterSourceReleaseFunc659BFE43Func = x 1825 | } 1826 | return (C.cairo_raster_source_release_func_t)(C.cairo_raster_source_release_func_t_659bfe43), nil 1827 | } 1828 | 1829 | func NewRasterSourceReleaseFuncRef(ref unsafe.Pointer) *RasterSourceReleaseFunc { 1830 | return (*RasterSourceReleaseFunc)(ref) 1831 | } 1832 | 1833 | //export rasterSourceReleaseFunc659BFE43 1834 | func rasterSourceReleaseFunc659BFE43(cpattern *C.cairo_pattern_t, ccallbackData unsafe.Pointer, csurface *C.cairo_surface_t) { 1835 | if rasterSourceReleaseFunc659BFE43Func != nil { 1836 | pattern659bfe43 := (*Pattern)(unsafe.Pointer(cpattern)) 1837 | callbackData659bfe43 := (unsafe.Pointer)(unsafe.Pointer(ccallbackData)) 1838 | surface659bfe43 := (*Surface)(unsafe.Pointer(csurface)) 1839 | rasterSourceReleaseFunc659BFE43Func(pattern659bfe43, callbackData659bfe43, surface659bfe43) 1840 | return 1841 | } 1842 | panic("callback func has not been set (race?)") 1843 | } 1844 | 1845 | var rasterSourceReleaseFunc659BFE43Func RasterSourceReleaseFunc 1846 | 1847 | func (x RasterSourceSnapshotFunc) PassRef() (ref *C.cairo_raster_source_snapshot_func_t, allocs *cgoAllocMap) { 1848 | if x == nil { 1849 | return nil, nil 1850 | } 1851 | if rasterSourceSnapshotFunc518A3707Func == nil { 1852 | rasterSourceSnapshotFunc518A3707Func = x 1853 | } 1854 | return (*C.cairo_raster_source_snapshot_func_t)(C.cairo_raster_source_snapshot_func_t_518a3707), nil 1855 | } 1856 | 1857 | func (x RasterSourceSnapshotFunc) PassValue() (ref C.cairo_raster_source_snapshot_func_t, allocs *cgoAllocMap) { 1858 | if x == nil { 1859 | return nil, nil 1860 | } 1861 | if rasterSourceSnapshotFunc518A3707Func == nil { 1862 | rasterSourceSnapshotFunc518A3707Func = x 1863 | } 1864 | return (C.cairo_raster_source_snapshot_func_t)(C.cairo_raster_source_snapshot_func_t_518a3707), nil 1865 | } 1866 | 1867 | func NewRasterSourceSnapshotFuncRef(ref unsafe.Pointer) *RasterSourceSnapshotFunc { 1868 | return (*RasterSourceSnapshotFunc)(ref) 1869 | } 1870 | 1871 | //export rasterSourceSnapshotFunc518A3707 1872 | func rasterSourceSnapshotFunc518A3707(cpattern *C.cairo_pattern_t, ccallbackData unsafe.Pointer) C.cairo_status_t { 1873 | if rasterSourceSnapshotFunc518A3707Func != nil { 1874 | pattern518a3707 := (*Pattern)(unsafe.Pointer(cpattern)) 1875 | callbackData518a3707 := (unsafe.Pointer)(unsafe.Pointer(ccallbackData)) 1876 | ret518a3707 := rasterSourceSnapshotFunc518A3707Func(pattern518a3707, callbackData518a3707) 1877 | ret, _ := (C.cairo_status_t)(ret518a3707), cgoAllocsUnknown 1878 | return ret 1879 | } 1880 | panic("callback func has not been set (race?)") 1881 | } 1882 | 1883 | var rasterSourceSnapshotFunc518A3707Func RasterSourceSnapshotFunc 1884 | 1885 | func (x RasterSourceCopyFunc) PassRef() (ref *C.cairo_raster_source_copy_func_t, allocs *cgoAllocMap) { 1886 | if x == nil { 1887 | return nil, nil 1888 | } 1889 | if rasterSourceCopyFunc84D80D8BFunc == nil { 1890 | rasterSourceCopyFunc84D80D8BFunc = x 1891 | } 1892 | return (*C.cairo_raster_source_copy_func_t)(C.cairo_raster_source_copy_func_t_84d80d8b), nil 1893 | } 1894 | 1895 | func (x RasterSourceCopyFunc) PassValue() (ref C.cairo_raster_source_copy_func_t, allocs *cgoAllocMap) { 1896 | if x == nil { 1897 | return nil, nil 1898 | } 1899 | if rasterSourceCopyFunc84D80D8BFunc == nil { 1900 | rasterSourceCopyFunc84D80D8BFunc = x 1901 | } 1902 | return (C.cairo_raster_source_copy_func_t)(C.cairo_raster_source_copy_func_t_84d80d8b), nil 1903 | } 1904 | 1905 | func NewRasterSourceCopyFuncRef(ref unsafe.Pointer) *RasterSourceCopyFunc { 1906 | return (*RasterSourceCopyFunc)(ref) 1907 | } 1908 | 1909 | //export rasterSourceCopyFunc84D80D8B 1910 | func rasterSourceCopyFunc84D80D8B(cpattern *C.cairo_pattern_t, ccallbackData unsafe.Pointer, cother *C.cairo_pattern_t) C.cairo_status_t { 1911 | if rasterSourceCopyFunc84D80D8BFunc != nil { 1912 | pattern84d80d8b := (*Pattern)(unsafe.Pointer(cpattern)) 1913 | callbackData84d80d8b := (unsafe.Pointer)(unsafe.Pointer(ccallbackData)) 1914 | other84d80d8b := (*Pattern)(unsafe.Pointer(cother)) 1915 | ret84d80d8b := rasterSourceCopyFunc84D80D8BFunc(pattern84d80d8b, callbackData84d80d8b, other84d80d8b) 1916 | ret, _ := (C.cairo_status_t)(ret84d80d8b), cgoAllocsUnknown 1917 | return ret 1918 | } 1919 | panic("callback func has not been set (race?)") 1920 | } 1921 | 1922 | var rasterSourceCopyFunc84D80D8BFunc RasterSourceCopyFunc 1923 | 1924 | func (x RasterSourceFinishFunc) PassRef() (ref *C.cairo_raster_source_finish_func_t, allocs *cgoAllocMap) { 1925 | if x == nil { 1926 | return nil, nil 1927 | } 1928 | if rasterSourceFinishFuncECE7E85BFunc == nil { 1929 | rasterSourceFinishFuncECE7E85BFunc = x 1930 | } 1931 | return (*C.cairo_raster_source_finish_func_t)(C.cairo_raster_source_finish_func_t_ece7e85b), nil 1932 | } 1933 | 1934 | func (x RasterSourceFinishFunc) PassValue() (ref C.cairo_raster_source_finish_func_t, allocs *cgoAllocMap) { 1935 | if x == nil { 1936 | return nil, nil 1937 | } 1938 | if rasterSourceFinishFuncECE7E85BFunc == nil { 1939 | rasterSourceFinishFuncECE7E85BFunc = x 1940 | } 1941 | return (C.cairo_raster_source_finish_func_t)(C.cairo_raster_source_finish_func_t_ece7e85b), nil 1942 | } 1943 | 1944 | func NewRasterSourceFinishFuncRef(ref unsafe.Pointer) *RasterSourceFinishFunc { 1945 | return (*RasterSourceFinishFunc)(ref) 1946 | } 1947 | 1948 | //export rasterSourceFinishFuncECE7E85B 1949 | func rasterSourceFinishFuncECE7E85B(cpattern *C.cairo_pattern_t, ccallbackData unsafe.Pointer) { 1950 | if rasterSourceFinishFuncECE7E85BFunc != nil { 1951 | patternece7e85b := (*Pattern)(unsafe.Pointer(cpattern)) 1952 | callbackDataece7e85b := (unsafe.Pointer)(unsafe.Pointer(ccallbackData)) 1953 | rasterSourceFinishFuncECE7E85BFunc(patternece7e85b, callbackDataece7e85b) 1954 | return 1955 | } 1956 | panic("callback func has not been set (race?)") 1957 | } 1958 | 1959 | var rasterSourceFinishFuncECE7E85BFunc RasterSourceFinishFunc 1960 | 1961 | // Ref returns a reference to C object as it is. 1962 | func (x *Region) Ref() *C.cairo_region_t { 1963 | if x == nil { 1964 | return nil 1965 | } 1966 | return (*C.cairo_region_t)(unsafe.Pointer(x)) 1967 | } 1968 | 1969 | // Free cleanups the referenced memory using C free. 1970 | func (x *Region) Free() { 1971 | if x != nil { 1972 | C.free(unsafe.Pointer(x)) 1973 | } 1974 | } 1975 | 1976 | // NewRegionRef converts the C object reference into a raw struct reference without wrapping. 1977 | func NewRegionRef(ref unsafe.Pointer) *Region { 1978 | return (*Region)(ref) 1979 | } 1980 | 1981 | // NewRegion allocates a new C object of this type and converts the reference into 1982 | // a raw struct reference without wrapping. 1983 | func NewRegion() *Region { 1984 | return (*Region)(allocRegionMemory(1)) 1985 | } 1986 | 1987 | // allocRegionMemory allocates memory for type C.cairo_region_t in C. 1988 | // The caller is responsible for freeing the this memory via C.free. 1989 | func allocRegionMemory(n int) unsafe.Pointer { 1990 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfRegionValue)) 1991 | if err != nil { 1992 | panic("memory alloc error: " + err.Error()) 1993 | } 1994 | return mem 1995 | } 1996 | 1997 | const sizeOfRegionValue = unsafe.Sizeof([1]C.cairo_region_t{}) 1998 | 1999 | // PassRef returns a reference to C object as it is or allocates a new C object of this type. 2000 | func (x *Region) PassRef() *C.cairo_region_t { 2001 | if x == nil { 2002 | x = (*Region)(allocRegionMemory(1)) 2003 | } 2004 | return (*C.cairo_region_t)(unsafe.Pointer(x)) 2005 | } 2006 | 2007 | // safeString ensures that the string is NULL-terminated, a NULL-terminated copy is created otherwise. 2008 | func safeString(str string) string { 2009 | if len(str) > 0 && str[len(str)-1] != '\x00' { 2010 | str = str + "\x00" 2011 | } else if len(str) == 0 { 2012 | str = "\x00" 2013 | } 2014 | return str 2015 | } 2016 | 2017 | // unpackPCharString represents the data from Go string as *C.char and avoids copying. 2018 | func unpackPCharString(str string) (*C.char, *cgoAllocMap) { 2019 | str = safeString(str) 2020 | h := (*stringHeader)(unsafe.Pointer(&str)) 2021 | return (*C.char)(unsafe.Pointer(h.Data)), cgoAllocsUnknown 2022 | } 2023 | 2024 | // allocPGlyphMemory allocates memory for type *C.cairo_glyph_t in C. 2025 | // The caller is responsible for freeing the this memory via C.free. 2026 | func allocPGlyphMemory(n int) unsafe.Pointer { 2027 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPGlyphValue)) 2028 | if err != nil { 2029 | panic("memory alloc error: " + err.Error()) 2030 | } 2031 | return mem 2032 | } 2033 | 2034 | const sizeOfPGlyphValue = unsafe.Sizeof([1]*C.cairo_glyph_t{}) 2035 | 2036 | // unpackArgSPGlyph transforms a sliced Go data structure into plain C format. 2037 | func unpackArgSPGlyph(x []*Glyph) (unpacked **C.cairo_glyph_t, allocs *cgoAllocMap) { 2038 | if x == nil { 2039 | return nil, nil 2040 | } 2041 | allocs = new(cgoAllocMap) 2042 | defer runtime.SetFinalizer(&unpacked, func(***C.cairo_glyph_t) { 2043 | go allocs.Free() 2044 | }) 2045 | 2046 | len0 := len(x) 2047 | mem0 := allocPGlyphMemory(len0) 2048 | allocs.Add(mem0) 2049 | h0 := &sliceHeader{ 2050 | Data: uintptr(mem0), 2051 | Cap: len0, 2052 | Len: len0, 2053 | } 2054 | v0 := *(*[]*C.cairo_glyph_t)(unsafe.Pointer(h0)) 2055 | for i0 := range x { 2056 | v0[i0], _ = x[i0].PassRef() 2057 | } 2058 | h := (*sliceHeader)(unsafe.Pointer(&v0)) 2059 | unpacked = (**C.cairo_glyph_t)(unsafe.Pointer(h.Data)) 2060 | return 2061 | } 2062 | 2063 | // allocPTextClusterMemory allocates memory for type *C.cairo_text_cluster_t in C. 2064 | // The caller is responsible for freeing the this memory via C.free. 2065 | func allocPTextClusterMemory(n int) unsafe.Pointer { 2066 | mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPTextClusterValue)) 2067 | if err != nil { 2068 | panic("memory alloc error: " + err.Error()) 2069 | } 2070 | return mem 2071 | } 2072 | 2073 | const sizeOfPTextClusterValue = unsafe.Sizeof([1]*C.cairo_text_cluster_t{}) 2074 | 2075 | // unpackArgSSTextCluster transforms a sliced Go data structure into plain C format. 2076 | func unpackArgSSTextCluster(x [][]TextCluster) (unpacked **C.cairo_text_cluster_t, allocs *cgoAllocMap) { 2077 | if x == nil { 2078 | return nil, nil 2079 | } 2080 | allocs = new(cgoAllocMap) 2081 | defer runtime.SetFinalizer(&unpacked, func(***C.cairo_text_cluster_t) { 2082 | go allocs.Free() 2083 | }) 2084 | 2085 | len0 := len(x) 2086 | mem0 := allocPTextClusterMemory(len0) 2087 | allocs.Add(mem0) 2088 | h0 := &sliceHeader{ 2089 | Data: uintptr(mem0), 2090 | Cap: len0, 2091 | Len: len0, 2092 | } 2093 | v0 := *(*[]*C.cairo_text_cluster_t)(unsafe.Pointer(h0)) 2094 | for i0 := range x { 2095 | len1 := len(x[i0]) 2096 | mem1 := allocTextClusterMemory(len1) 2097 | allocs.Add(mem1) 2098 | h1 := &sliceHeader{ 2099 | Data: uintptr(mem1), 2100 | Cap: len1, 2101 | Len: len1, 2102 | } 2103 | v1 := *(*[]C.cairo_text_cluster_t)(unsafe.Pointer(h1)) 2104 | for i1 := range x[i0] { 2105 | allocs1 := new(cgoAllocMap) 2106 | v1[i1], allocs1 = x[i0][i1].PassValue() 2107 | allocs.Borrow(allocs1) 2108 | } 2109 | h := (*sliceHeader)(unsafe.Pointer(&v1)) 2110 | v0[i0] = (*C.cairo_text_cluster_t)(unsafe.Pointer(h.Data)) 2111 | } 2112 | h := (*sliceHeader)(unsafe.Pointer(&v0)) 2113 | unpacked = (**C.cairo_text_cluster_t)(unsafe.Pointer(h.Data)) 2114 | return 2115 | } 2116 | 2117 | // packSSTextCluster reads sliced Go data structure out from plain C format. 2118 | func packSSTextCluster(v [][]TextCluster, ptr0 **C.cairo_text_cluster_t) { 2119 | const m = 0x7fffffff 2120 | for i0 := range v { 2121 | ptr1 := (*(*[m / sizeOfPtr]*C.cairo_text_cluster_t)(unsafe.Pointer(ptr0)))[i0] 2122 | for i1 := range v[i0] { 2123 | ptr2 := (*(*[m / sizeOfTextClusterValue]C.cairo_text_cluster_t)(unsafe.Pointer(ptr1)))[i1] 2124 | v[i0][i1] = *NewTextClusterRef(unsafe.Pointer(&ptr2)) 2125 | } 2126 | } 2127 | } 2128 | 2129 | // unpackPUcharString represents the data from Go string as *C.uchar and avoids copying. 2130 | func unpackPUcharString(str string) (*C.uchar, *cgoAllocMap) { 2131 | str = safeString(str) 2132 | h := (*stringHeader)(unsafe.Pointer(&str)) 2133 | return (*C.uchar)(unsafe.Pointer(h.Data)), cgoAllocsUnknown 2134 | } 2135 | -------------------------------------------------------------------------------- /cgo_helpers.h: -------------------------------------------------------------------------------- 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. 2 | 3 | // WARNING: This file has automatically been generated on Thu, 11 Jan 2018 16:22:52 MSK. 4 | // By https://git.io/c-for-go. DO NOT EDIT. 5 | 6 | #include "include/cairo.h" 7 | #include 8 | #pragma once 9 | 10 | #define __CGOGEN 1 11 | 12 | // cairo_destroy_func_t_6936ee15 is a proxy for callback cairo_destroy_func_t. 13 | void cairo_destroy_func_t_6936ee15(void* data); 14 | 15 | // cairo_write_func_t_f4dfc69 is a proxy for callback cairo_write_func_t. 16 | cairo_status_t cairo_write_func_t_f4dfc69(void* closure, unsigned char* data, unsigned int length); 17 | 18 | // cairo_read_func_t_69800aa2 is a proxy for callback cairo_read_func_t. 19 | cairo_status_t cairo_read_func_t_69800aa2(void* closure, unsigned char* data, unsigned int length); 20 | 21 | // cairo_user_scaled_font_init_func_t_87c5d9cb is a proxy for callback cairo_user_scaled_font_init_func_t. 22 | cairo_status_t cairo_user_scaled_font_init_func_t_87c5d9cb(cairo_scaled_font_t* scaled_font, cairo_t* cr, cairo_font_extents_t* extents); 23 | 24 | // cairo_user_scaled_font_render_glyph_func_t_32c7be76 is a proxy for callback cairo_user_scaled_font_render_glyph_func_t. 25 | cairo_status_t cairo_user_scaled_font_render_glyph_func_t_32c7be76(cairo_scaled_font_t* scaled_font, unsigned long int glyph, cairo_t* cr, cairo_text_extents_t* extents); 26 | 27 | // cairo_user_scaled_font_text_to_glyphs_func_t_5fc4fffd is a proxy for callback cairo_user_scaled_font_text_to_glyphs_func_t. 28 | cairo_status_t cairo_user_scaled_font_text_to_glyphs_func_t_5fc4fffd(cairo_scaled_font_t* scaled_font, char* utf8, int utf8_len, cairo_glyph_t** glyphs, int* num_glyphs, cairo_text_cluster_t** clusters, int* num_clusters, cairo_text_cluster_flags_t* cluster_flags); 29 | 30 | // cairo_user_scaled_font_unicode_to_glyph_func_t_d4a3aae6 is a proxy for callback cairo_user_scaled_font_unicode_to_glyph_func_t. 31 | cairo_status_t cairo_user_scaled_font_unicode_to_glyph_func_t_d4a3aae6(cairo_scaled_font_t* scaled_font, unsigned long int unicode, unsigned long int* glyph_index); 32 | 33 | // cairo_surface_observer_callback_t_9f372381 is a proxy for callback cairo_surface_observer_callback_t. 34 | void cairo_surface_observer_callback_t_9f372381(cairo_surface_t* observer, cairo_surface_t* target, void* data); 35 | 36 | // cairo_raster_source_acquire_func_t_e7404447 is a proxy for callback cairo_raster_source_acquire_func_t. 37 | cairo_surface_t* cairo_raster_source_acquire_func_t_e7404447(cairo_pattern_t* pattern, void* callback_data, cairo_surface_t* target, cairo_rectangle_int_t* extents); 38 | 39 | // cairo_raster_source_release_func_t_659bfe43 is a proxy for callback cairo_raster_source_release_func_t. 40 | void cairo_raster_source_release_func_t_659bfe43(cairo_pattern_t* pattern, void* callback_data, cairo_surface_t* surface); 41 | 42 | // cairo_raster_source_snapshot_func_t_518a3707 is a proxy for callback cairo_raster_source_snapshot_func_t. 43 | cairo_status_t cairo_raster_source_snapshot_func_t_518a3707(cairo_pattern_t* pattern, void* callback_data); 44 | 45 | // cairo_raster_source_copy_func_t_84d80d8b is a proxy for callback cairo_raster_source_copy_func_t. 46 | cairo_status_t cairo_raster_source_copy_func_t_84d80d8b(cairo_pattern_t* pattern, void* callback_data, cairo_pattern_t* other); 47 | 48 | // cairo_raster_source_finish_func_t_ece7e85b is a proxy for callback cairo_raster_source_finish_func_t. 49 | void cairo_raster_source_finish_func_t_ece7e85b(cairo_pattern_t* pattern, void* callback_data); 50 | 51 | -------------------------------------------------------------------------------- /cmd/cairo-example-glfw/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "runtime" 6 | "sync" 7 | "time" 8 | 9 | "github.com/go-gl/gl/v2.1/gl" 10 | "github.com/go-gl/glfw/v3.2/glfw" 11 | "github.com/golang-ui/cairo" 12 | "github.com/golang-ui/cairo/cairogl" 13 | "github.com/xlab/closer" 14 | ) 15 | 16 | func init() { 17 | runtime.LockOSThread() 18 | } 19 | 20 | func main() { 21 | if err := glfw.Init(); err != nil { 22 | closer.Fatalln(err) 23 | } 24 | glfw.WindowHint(glfw.ContextVersionMajor, 2) 25 | glfw.WindowHint(glfw.ContextVersionMinor, 1) 26 | win, err := glfw.CreateWindow(500, 500, "Cairo Demo", nil, nil) 27 | if err != nil { 28 | closer.Fatalln(err) 29 | } 30 | win.MakeContextCurrent() 31 | 32 | ww, wh := win.GetSize() 33 | width, height := win.GetFramebufferSize() 34 | log.Printf("glfw: created window %dx%d (framebuffer: %dx%d)", ww, wh, width, height) 35 | 36 | if err := gl.Init(); err != nil { 37 | closer.Fatalln("opengl: init failed:", err) 38 | } 39 | gl.Viewport(0, 0, int32(width), int32(height)) 40 | surface := cairogl.NewSurface(width, height) 41 | win.SetFramebufferSizeCallback(func(w *glfw.Window, width int, height int) { 42 | surface.Update(width, height) 43 | }) 44 | 45 | exitC := make(chan struct{}, 1) 46 | doneC := make(chan struct{}, 1) 47 | closer.Bind(func() { 48 | close(exitC) 49 | <-doneC 50 | }) 51 | 52 | fpsTicker := time.NewTicker(time.Second / 30) 53 | for { 54 | select { 55 | case <-exitC: 56 | surface.Destroy() 57 | glfw.Terminate() 58 | fpsTicker.Stop() 59 | close(doneC) 60 | return 61 | case <-fpsTicker.C: 62 | if win.ShouldClose() { 63 | close(exitC) 64 | continue 65 | } 66 | glfw.PollEvents() 67 | gfxMain(surface) 68 | win.SwapBuffers() 69 | } 70 | } 71 | } 72 | 73 | const PI = 3.1415926 74 | 75 | var angle = 45.0 76 | var angleMux sync.RWMutex 77 | 78 | func init() { 79 | go func() { 80 | for { 81 | angleMux.Lock() 82 | angle -= 1 83 | if angle <= 0 { 84 | angle = 360.0 85 | } 86 | angleMux.Unlock() 87 | time.Sleep(10 * time.Millisecond) 88 | } 89 | }() 90 | } 91 | 92 | func gfxMain(surface *cairogl.Surface) { 93 | cr := surface.Context() 94 | cairo.SetSourceRgba(cr, 0, 0, 0, 1) 95 | cairo.Paint(cr) 96 | 97 | offset := 300.0 98 | cairo.SetSourceRgba(cr, 1, 1, 1, 1) 99 | cairo.SetLineWidth(cr, 5) 100 | cairo.MakeRectangle(cr, 10+offset, 10+offset, 300, 300) 101 | cairo.Stroke(cr) 102 | 103 | xc := 160.0 + offset 104 | yc := 150.0 + offset 105 | radius := 100.0 106 | angleMux.RLock() 107 | angle1 := angle * (PI / 180.0) 108 | angleMux.RUnlock() 109 | angle2 := 180.0 * (PI / 180.0) 110 | 111 | cairo.SetLineWidth(cr, 3.0) 112 | cairo.SetSourceRgba(cr, 1, 1, 1, 1) 113 | cairo.Arc(cr, xc, yc, radius, angle1, angle2) 114 | cairo.Stroke(cr) 115 | 116 | cairo.SetSourceRgba(cr, 1, 0.2, 0.2, 0.6) 117 | cairo.SetLineWidth(cr, 6.0) 118 | 119 | cairo.Arc(cr, xc, yc, 10.0, 0, 2*PI) 120 | cairo.Fill(cr) 121 | 122 | cairo.Arc(cr, xc, yc, radius, angle1, angle2) 123 | cairo.LineTo(cr, xc, yc) 124 | cairo.Arc(cr, xc, yc, radius, angle1, angle2) 125 | cairo.LineTo(cr, xc, yc) 126 | cairo.Stroke(cr) 127 | 128 | width, height := surface.Size() 129 | gl.Viewport(0, 0, int32(width), int32(height)) 130 | gl.Clear(gl.COLOR_BUFFER_BIT) 131 | gl.ClearColor(1, 1, 1, 1) 132 | surface.Draw() 133 | } 134 | -------------------------------------------------------------------------------- /cmd/cairo-example-glfw/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/cmd/cairo-example-glfw/screenshot.png -------------------------------------------------------------------------------- /cmd/cairo-example-quartz/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/golang-ui/cairo" 7 | ) 8 | 9 | func main() { 10 | surface := cairo.QuartzSurfaceCreate(cairo.FormatArgb32, 800, 600) 11 | defer cairo.SurfaceDestroy(surface) 12 | cr := cairo.Create(surface) 13 | defer cairo.Destroy(cr) 14 | 15 | cairo.SetSourceRgb(cr, 1.0, 1.0, 1.0) 16 | cairo.Paint(cr) 17 | setScene(cr) 18 | cairo.SurfaceWriteToPng(surface, "out.png") 19 | log.Println(cairo.GetStatus(cr), cairo.StatusToString(cairo.GetStatus(cr))) 20 | } 21 | 22 | const PI = 3.1415926 23 | 24 | func setScene(cr *cairo.Cairo) { 25 | cairo.Save(cr) 26 | defer cairo.Restore(cr) 27 | 28 | cairo.SetLineWidth(cr, 6.0) 29 | cairo.SetSourceRgba(cr, 0, 0, 0, 1) 30 | cairo.NewPath(cr) 31 | cairo.MoveTo(cr, 50, 50) 32 | cairo.CurveTo(cr, 50, 50, 300, 250, 50, 500) 33 | cairo.ClosePath(cr) 34 | cairo.Stroke(cr) 35 | 36 | xc := 500.0 37 | yc := 200.0 38 | radius := 100.0 39 | angle1 := 45.0 * (PI / 180.0) 40 | angle2 := 180.0 * (PI / 180.0) 41 | 42 | cairo.SetLineWidth(cr, 3.0) 43 | cairo.SetSourceRgba(cr, 0, 0, 0, 1) 44 | cairo.Arc(cr, xc, yc, radius, angle1, angle2) 45 | cairo.Stroke(cr) 46 | 47 | cairo.SetSourceRgba(cr, 1, 0.2, 0.2, 0.6) 48 | cairo.SetLineWidth(cr, 6.0) 49 | 50 | cairo.Arc(cr, xc, yc, 10.0, 0, 2*PI) 51 | cairo.Fill(cr) 52 | 53 | cairo.Arc(cr, xc, yc, radius, angle1, angle2) 54 | cairo.LineTo(cr, xc, yc) 55 | cairo.Arc(cr, xc, yc, radius, angle1, angle2) 56 | cairo.LineTo(cr, xc, yc) 57 | cairo.Stroke(cr) 58 | } 59 | -------------------------------------------------------------------------------- /cmd/cairo-example-quartz/out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/cmd/cairo-example-quartz/out.png -------------------------------------------------------------------------------- /const.go: -------------------------------------------------------------------------------- 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. 2 | 3 | // WARNING: This file has automatically been generated on Thu, 11 Jan 2018 16:22:52 MSK. 4 | // By https://git.io/c-for-go. DO NOT EDIT. 5 | 6 | package cairo 7 | 8 | /* 9 | #include "include/cairo.h" 10 | #include 11 | #include "cgo_helpers.h" 12 | */ 13 | import "C" 14 | 15 | const ( 16 | // HasMimeSurface as defined in cairo/:24 17 | HasMimeSurface = 1 18 | // HasFcFont as defined in cairo/:25 19 | HasFcFont = 1 20 | // HasGobjectFunctions as defined in cairo/:26 21 | HasGobjectFunctions = 1 22 | // HasObserverSurface as defined in cairo/:27 23 | HasObserverSurface = 1 24 | // HasRecordingSurface as defined in cairo/:28 25 | HasRecordingSurface = 1 26 | // HasSvgSurface as defined in cairo/:29 27 | HasSvgSurface = 1 28 | // HasUserFont as defined in cairo/:30 29 | HasUserFont = 1 30 | // HasImageSurface as defined in cairo/:31 31 | HasImageSurface = 1 32 | // HasPsSurface as defined in cairo/:32 33 | HasPsSurface = 1 34 | // HasScriptSurface as defined in cairo/:33 35 | HasScriptSurface = 1 36 | // HasFtFont as defined in cairo/:34 37 | HasFtFont = 1 38 | // HasPdfSurface as defined in cairo/:35 39 | HasPdfSurface = 1 40 | // HasPngFunctions as defined in cairo/:36 41 | HasPngFunctions = 1 42 | // HasTeeSurface as defined in cairo/:37 43 | HasTeeSurface = 1 44 | // Version as defined in include/cairo.h:68 45 | Version = 11511 46 | // TagDest as defined in include/cairo.h:1031 47 | TagDest = "cairo.dest" 48 | // TagLink as defined in include/cairo.h:1032 49 | TagLink = "Link" 50 | // MimeTypeJpeg as defined in include/cairo.h:2455 51 | MimeTypeJpeg = "image/jpeg" 52 | // MimeTypePng as defined in include/cairo.h:2456 53 | MimeTypePng = "image/png" 54 | // MimeTypeJp2 as defined in include/cairo.h:2457 55 | MimeTypeJp2 = "image/jp2" 56 | // MimeTypeUri as defined in include/cairo.h:2458 57 | MimeTypeUri = "text/x-uri" 58 | // MimeTypeUniqueId as defined in include/cairo.h:2459 59 | MimeTypeUniqueId = "application/x-cairo.uuid" 60 | // MimeTypeJbig2 as defined in include/cairo.h:2460 61 | MimeTypeJbig2 = "application/x-cairo.jbig2" 62 | // MimeTypeJbig2Global as defined in include/cairo.h:2461 63 | MimeTypeJbig2Global = "application/x-cairo.jbig2-global" 64 | // MimeTypeJbig2GlobalId as defined in include/cairo.h:2462 65 | MimeTypeJbig2GlobalId = "application/x-cairo.jbig2-global-id" 66 | // MimeTypeCcittFax as defined in include/cairo.h:2463 67 | MimeTypeCcittFax = "image/g3fax" 68 | // MimeTypeCcittFaxParams as defined in include/cairo.h:2464 69 | MimeTypeCcittFaxParams = "application/x-cairo.ccitt.params" 70 | // MimeTypeEps as defined in include/cairo.h:2465 71 | MimeTypeEps = "application/postscript" 72 | // MimeTypeEpsParams as defined in include/cairo.h:2466 73 | MimeTypeEpsParams = "application/x-cairo.eps.params" 74 | // VersionMajor as defined in include/cairo-version.h:4 75 | VersionMajor = 1 76 | // VersionMinor as defined in include/cairo-version.h:5 77 | VersionMinor = 15 78 | // VersionMicro as defined in include/cairo-version.h:6 79 | VersionMicro = 11 80 | // HasQuartzFont as defined in include/cairo-features.h:14 81 | HasQuartzFont = 1 82 | // HasQuartzSurface as defined in include/cairo-features.h:15 83 | HasQuartzSurface = 1 84 | // HasXlibSurface as defined in include/cairo-features.h:20 85 | HasXlibSurface = 1 86 | // HasXlibXrenderSurface as defined in include/cairo-features.h:21 87 | HasXlibXrenderSurface = 1 88 | ) 89 | 90 | // Status as declared in include/cairo.h:361 91 | type Status int32 92 | 93 | // Status enumeration from include/cairo.h:361 94 | const ( 95 | StatusSuccess Status = iota 96 | StatusNoMemory Status = 1 97 | StatusInvalidRestore Status = 2 98 | StatusInvalidPopGroup Status = 3 99 | StatusNoCurrentPoint Status = 4 100 | StatusInvalidMatrix Status = 5 101 | StatusInvalidStatus Status = 6 102 | StatusNullPointer Status = 7 103 | StatusInvalidString Status = 8 104 | StatusInvalidPathData Status = 9 105 | StatusReadError Status = 10 106 | StatusWriteError Status = 11 107 | StatusSurfaceFinished Status = 12 108 | StatusSurfaceTypeMismatch Status = 13 109 | StatusPatternTypeMismatch Status = 14 110 | StatusInvalidContent Status = 15 111 | StatusInvalidFormat Status = 16 112 | StatusInvalidVisual Status = 17 113 | StatusFileNotFound Status = 18 114 | StatusInvalidDash Status = 19 115 | StatusInvalidDscComment Status = 20 116 | StatusInvalidIndex Status = 21 117 | StatusClipNotRepresentable Status = 22 118 | StatusTempFileError Status = 23 119 | StatusInvalidStride Status = 24 120 | StatusFontTypeMismatch Status = 25 121 | StatusUserFontImmutable Status = 26 122 | StatusUserFontError Status = 27 123 | StatusNegativeCount Status = 28 124 | StatusInvalidClusters Status = 29 125 | StatusInvalidSlant Status = 30 126 | StatusInvalidWeight Status = 31 127 | StatusInvalidSize Status = 32 128 | StatusUserFontNotImplemented Status = 33 129 | StatusDeviceTypeMismatch Status = 34 130 | StatusDeviceError Status = 35 131 | StatusInvalidMeshConstruction Status = 36 132 | StatusDeviceFinished Status = 37 133 | StatusJbig2GlobalMissing Status = 38 134 | StatusPngError Status = 39 135 | StatusFreetypeError Status = 40 136 | StatusWin32GdiError Status = 41 137 | StatusTagError Status = 42 138 | StatusLastStatus Status = 43 139 | ) 140 | 141 | // Content as declared in include/cairo.h:383 142 | type Content int32 143 | 144 | // Content enumeration from include/cairo.h:383 145 | const ( 146 | ContentColor Content = 4096 147 | ContentAlpha Content = 8192 148 | ContentColorAlpha Content = 12288 149 | ) 150 | 151 | // Format as declared in include/cairo.h:424 152 | type Format int32 153 | 154 | // Format enumeration from include/cairo.h:424 155 | const ( 156 | FormatInvalid Format = -1 157 | FormatArgb32 Format = 0 158 | FormatRgb24 Format = 1 159 | FormatA8 Format = 2 160 | FormatA1 Format = 3 161 | FormatRgb16565 Format = 4 162 | FormatRgb30 Format = 5 163 | ) 164 | 165 | // Operator as declared in include/cairo.h:647 166 | type Operator int32 167 | 168 | // Operator enumeration from include/cairo.h:647 169 | const ( 170 | OperatorClear Operator = iota 171 | OperatorSource Operator = 1 172 | OperatorOver Operator = 2 173 | OperatorIn Operator = 3 174 | OperatorOut Operator = 4 175 | OperatorAtop Operator = 5 176 | OperatorDest Operator = 6 177 | OperatorDestOver Operator = 7 178 | OperatorDestIn Operator = 8 179 | OperatorDestOut Operator = 9 180 | OperatorDestAtop Operator = 10 181 | OperatorXor Operator = 11 182 | OperatorAdd Operator = 12 183 | OperatorSaturate Operator = 13 184 | OperatorMultiply Operator = 14 185 | OperatorScreen Operator = 15 186 | OperatorOverlay Operator = 16 187 | OperatorDarken Operator = 17 188 | OperatorLighten Operator = 18 189 | OperatorColorDodge Operator = 19 190 | OperatorColorBurn Operator = 20 191 | OperatorHardLight Operator = 21 192 | OperatorSoftLight Operator = 22 193 | OperatorDifference Operator = 23 194 | OperatorExclusion Operator = 24 195 | OperatorHslHue Operator = 25 196 | OperatorHslSaturation Operator = 26 197 | OperatorHslColor Operator = 27 198 | OperatorHslLuminosity Operator = 28 199 | ) 200 | 201 | // Antialias as declared in include/cairo.h:721 202 | type Antialias int32 203 | 204 | // Antialias enumeration from include/cairo.h:721 205 | const ( 206 | AntialiasDefault Antialias = iota 207 | AntialiasNone Antialias = 1 208 | AntialiasGray Antialias = 2 209 | AntialiasSubpixel Antialias = 3 210 | AntialiasFast Antialias = 4 211 | AntialiasGood Antialias = 5 212 | AntialiasBest Antialias = 6 213 | ) 214 | 215 | // FillRule as declared in include/cairo.h:756 216 | type FillRule int32 217 | 218 | // FillRule enumeration from include/cairo.h:756 219 | const ( 220 | FillRuleWinding FillRule = iota 221 | FillRuleEvenOdd FillRule = 1 222 | ) 223 | 224 | // LineCap as declared in include/cairo.h:780 225 | type LineCap int32 226 | 227 | // LineCap enumeration from include/cairo.h:780 228 | const ( 229 | LineCapButt LineCap = iota 230 | LineCapRound LineCap = 1 231 | LineCapSquare LineCap = 2 232 | ) 233 | 234 | // LineJoin as declared in include/cairo.h:804 235 | type LineJoin int32 236 | 237 | // LineJoin enumeration from include/cairo.h:804 238 | const ( 239 | LineJoinMiter LineJoin = iota 240 | LineJoinRound LineJoin = 1 241 | LineJoinBevel LineJoin = 2 242 | ) 243 | 244 | // TextClusterFlags as declared in include/cairo.h:1162 245 | type TextClusterFlags int32 246 | 247 | // TextClusterFlags enumeration from include/cairo.h:1162 248 | const ( 249 | TextClusterFlagBackward TextClusterFlags = 1 250 | ) 251 | 252 | // FontSlant as declared in include/cairo.h:1267 253 | type FontSlant int32 254 | 255 | // FontSlant enumeration from include/cairo.h:1267 256 | const ( 257 | FontSlantNormal FontSlant = iota 258 | FontSlantItalic FontSlant = 1 259 | FontSlantOblique FontSlant = 2 260 | ) 261 | 262 | // FontWeight as declared in include/cairo.h:1281 263 | type FontWeight int32 264 | 265 | // FontWeight enumeration from include/cairo.h:1281 266 | const ( 267 | FontWeightNormal FontWeight = iota 268 | FontWeightBold FontWeight = 1 269 | ) 270 | 271 | // SubpixelOrder as declared in include/cairo.h:1308 272 | type SubpixelOrder int32 273 | 274 | // SubpixelOrder enumeration from include/cairo.h:1308 275 | const ( 276 | SubpixelOrderDefault SubpixelOrder = iota 277 | SubpixelOrderRgb SubpixelOrder = 1 278 | SubpixelOrderBgr SubpixelOrder = 2 279 | SubpixelOrderVrgb SubpixelOrder = 3 280 | SubpixelOrderVbgr SubpixelOrder = 4 281 | ) 282 | 283 | // HintStyle as declared in include/cairo.h:1340 284 | type HintStyle int32 285 | 286 | // HintStyle enumeration from include/cairo.h:1340 287 | const ( 288 | HintStyleDefault HintStyle = iota 289 | HintStyleNone HintStyle = 1 290 | HintStyleSlight HintStyle = 2 291 | HintStyleMedium HintStyle = 3 292 | HintStyleFull HintStyle = 4 293 | ) 294 | 295 | // HintMetrics as declared in include/cairo.h:1361 296 | type HintMetrics int32 297 | 298 | // HintMetrics enumeration from include/cairo.h:1361 299 | const ( 300 | HintMetricsDefault HintMetrics = iota 301 | HintMetricsOff HintMetrics = 1 302 | HintMetricsOn HintMetrics = 2 303 | ) 304 | 305 | // FontType as declared in include/cairo.h:1578 306 | type FontType int32 307 | 308 | // FontType enumeration from include/cairo.h:1578 309 | const ( 310 | FontTypeToy FontType = iota 311 | FontTypeFt FontType = 1 312 | FontTypeWin32 FontType = 2 313 | FontTypeQuartz FontType = 3 314 | FontTypeUser FontType = 4 315 | ) 316 | 317 | // PathDataType as declared in include/cairo.h:1998 318 | type PathDataType int32 319 | 320 | // PathDataType enumeration from include/cairo.h:1998 321 | const ( 322 | PathMoveTo PathDataType = iota 323 | PathLineTo PathDataType = 1 324 | PathCurveTo PathDataType = 2 325 | PathClosePath PathDataType = 3 326 | ) 327 | 328 | // DeviceType as declared in include/cairo.h:2174 329 | type DeviceType int32 330 | 331 | // DeviceType enumeration from include/cairo.h:2174 332 | const ( 333 | DeviceTypeDrm DeviceType = iota 334 | DeviceTypeGl DeviceType = 1 335 | DeviceTypeScript DeviceType = 2 336 | DeviceTypeXcb DeviceType = 3 337 | DeviceTypeXlib DeviceType = 4 338 | DeviceTypeXml DeviceType = 5 339 | DeviceTypeCogl DeviceType = 6 340 | DeviceTypeWin32 DeviceType = 7 341 | DeviceTypeInvalid DeviceType = -1 342 | ) 343 | 344 | // SurfaceObserverMode as declared in include/cairo.h:2252 345 | type SurfaceObserverMode int32 346 | 347 | // SurfaceObserverMode enumeration from include/cairo.h:2252 348 | const ( 349 | SurfaceObserverNormal SurfaceObserverMode = iota 350 | SurfaceObserverRecordOperations SurfaceObserverMode = 1 351 | ) 352 | 353 | // SurfaceType as declared in include/cairo.h:2424 354 | type SurfaceType int32 355 | 356 | // SurfaceType enumeration from include/cairo.h:2424 357 | const ( 358 | SurfaceTypeImage SurfaceType = iota 359 | SurfaceTypePdf SurfaceType = 1 360 | SurfaceTypePs SurfaceType = 2 361 | SurfaceTypeXlib SurfaceType = 3 362 | SurfaceTypeXcb SurfaceType = 4 363 | SurfaceTypeGlitz SurfaceType = 5 364 | SurfaceTypeQuartz SurfaceType = 6 365 | SurfaceTypeWin32 SurfaceType = 7 366 | SurfaceTypeBeos SurfaceType = 8 367 | SurfaceTypeDirectfb SurfaceType = 9 368 | SurfaceTypeSvg SurfaceType = 10 369 | SurfaceTypeOs2 SurfaceType = 11 370 | SurfaceTypeWin32Printing SurfaceType = 12 371 | SurfaceTypeQuartzImage SurfaceType = 13 372 | SurfaceTypeScript SurfaceType = 14 373 | SurfaceTypeQt SurfaceType = 15 374 | SurfaceTypeRecording SurfaceType = 16 375 | SurfaceTypeVg SurfaceType = 17 376 | SurfaceTypeGl SurfaceType = 18 377 | SurfaceTypeDrm SurfaceType = 19 378 | SurfaceTypeTee SurfaceType = 20 379 | SurfaceTypeXml SurfaceType = 21 380 | SurfaceTypeSkia SurfaceType = 22 381 | SurfaceTypeSubsurface SurfaceType = 23 382 | SurfaceTypeCogl SurfaceType = 24 383 | ) 384 | 385 | // PatternType as declared in include/cairo.h:2832 386 | type PatternType int32 387 | 388 | // PatternType enumeration from include/cairo.h:2832 389 | const ( 390 | PatternTypeSolid PatternType = iota 391 | PatternTypeSurface PatternType = 1 392 | PatternTypeLinear PatternType = 2 393 | PatternTypeRadial PatternType = 3 394 | PatternTypeMesh PatternType = 4 395 | PatternTypeRasterSource PatternType = 5 396 | ) 397 | 398 | // Extend as declared in include/cairo.h:2922 399 | type Extend int32 400 | 401 | // Extend enumeration from include/cairo.h:2922 402 | const ( 403 | ExtendNone Extend = iota 404 | ExtendRepeat Extend = 1 405 | ExtendReflect Extend = 2 406 | ExtendPad Extend = 3 407 | ) 408 | 409 | // Filter as declared in include/cairo.h:2957 410 | type Filter int32 411 | 412 | // Filter enumeration from include/cairo.h:2957 413 | const ( 414 | FilterFast Filter = iota 415 | FilterGood Filter = 1 416 | FilterBest Filter = 2 417 | FilterNearest Filter = 3 418 | FilterBilinear Filter = 4 419 | FilterGaussian Filter = 5 420 | ) 421 | 422 | // RegionOverlap as declared in include/cairo.h:3096 423 | type RegionOverlap int32 424 | 425 | // RegionOverlap enumeration from include/cairo.h:3096 426 | const ( 427 | RegionOverlapIn RegionOverlap = iota 428 | RegionOverlapOut RegionOverlap = 1 429 | RegionOverlapPart RegionOverlap = 2 430 | ) 431 | -------------------------------------------------------------------------------- /deps/darwin_amd64/libcairo-1.15.11.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/deps/darwin_amd64/libcairo-1.15.11.a -------------------------------------------------------------------------------- /deps/darwin_amd64/libfontconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/deps/darwin_amd64/libfontconfig.a -------------------------------------------------------------------------------- /deps/darwin_amd64/libfreetype.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/deps/darwin_amd64/libfreetype.a -------------------------------------------------------------------------------- /deps/darwin_amd64/libpixman-1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/deps/darwin_amd64/libpixman-1.a -------------------------------------------------------------------------------- /deps/darwin_amd64/libpng16.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/deps/darwin_amd64/libpng16.a -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. 2 | 3 | // WARNING: This file has automatically been generated on Thu, 11 Jan 2018 16:22:52 MSK. 4 | // By https://git.io/c-for-go. DO NOT EDIT. 5 | 6 | /* 7 | Package cairo provides Go bindings for Cairo. 8 | */ 9 | package cairo 10 | -------------------------------------------------------------------------------- /include/cairo-deprecated.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2006 Red Hat, Inc. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is Red Hat, Inc. 31 | * 32 | * Contributor(s): 33 | * Carl D. Worth 34 | */ 35 | 36 | #ifndef CAIRO_DEPRECATED_H 37 | #define CAIRO_DEPRECATED_H 38 | 39 | #define CAIRO_FONT_TYPE_ATSUI CAIRO_FONT_TYPE_QUARTZ 40 | 41 | /* Obsolete functions. These definitions exist to coerce the compiler 42 | * into providing a little bit of guidance with its error 43 | * messages. The idea is to help users port their old code without 44 | * having to dig through lots of documentation. 45 | * 46 | * The first set of REPLACED_BY functions is for functions whose names 47 | * have just been changed. So fixing these up is mechanical, (and 48 | * automated by means of the cairo/util/cairo-api-update script. 49 | * 50 | * The second set of DEPRECATED_BY functions is for functions where 51 | * the replacement is used in a different way, (ie. different 52 | * arguments, multiple functions instead of one, etc). Fixing these up 53 | * will require a bit more work on the user's part, (and hopefully we 54 | * can get cairo-api-update to find these and print some guiding 55 | * information). 56 | */ 57 | #define cairo_current_font_extents cairo_current_font_extents_REPLACED_BY_cairo_font_extents 58 | #define cairo_get_font_extents cairo_get_font_extents_REPLACED_BY_cairo_font_extents 59 | #define cairo_current_operator cairo_current_operator_REPLACED_BY_cairo_get_operator 60 | #define cairo_current_tolerance cairo_current_tolerance_REPLACED_BY_cairo_get_tolerance 61 | #define cairo_current_point cairo_current_point_REPLACED_BY_cairo_get_current_point 62 | #define cairo_current_fill_rule cairo_current_fill_rule_REPLACED_BY_cairo_get_fill_rule 63 | #define cairo_current_line_width cairo_current_line_width_REPLACED_BY_cairo_get_line_width 64 | #define cairo_current_line_cap cairo_current_line_cap_REPLACED_BY_cairo_get_line_cap 65 | #define cairo_current_line_join cairo_current_line_join_REPLACED_BY_cairo_get_line_join 66 | #define cairo_current_miter_limit cairo_current_miter_limit_REPLACED_BY_cairo_get_miter_limit 67 | #define cairo_current_matrix cairo_current_matrix_REPLACED_BY_cairo_get_matrix 68 | #define cairo_current_target_surface cairo_current_target_surface_REPLACED_BY_cairo_get_target 69 | #define cairo_get_status cairo_get_status_REPLACED_BY_cairo_status 70 | #define cairo_concat_matrix cairo_concat_matrix_REPLACED_BY_cairo_transform 71 | #define cairo_scale_font cairo_scale_font_REPLACED_BY_cairo_set_font_size 72 | #define cairo_select_font cairo_select_font_REPLACED_BY_cairo_select_font_face 73 | #define cairo_transform_font cairo_transform_font_REPLACED_BY_cairo_set_font_matrix 74 | #define cairo_transform_point cairo_transform_point_REPLACED_BY_cairo_user_to_device 75 | #define cairo_transform_distance cairo_transform_distance_REPLACED_BY_cairo_user_to_device_distance 76 | #define cairo_inverse_transform_point cairo_inverse_transform_point_REPLACED_BY_cairo_device_to_user 77 | #define cairo_inverse_transform_distance cairo_inverse_transform_distance_REPLACED_BY_cairo_device_to_user_distance 78 | #define cairo_init_clip cairo_init_clip_REPLACED_BY_cairo_reset_clip 79 | #define cairo_surface_create_for_image cairo_surface_create_for_image_REPLACED_BY_cairo_image_surface_create_for_data 80 | #define cairo_default_matrix cairo_default_matrix_REPLACED_BY_cairo_identity_matrix 81 | #define cairo_matrix_set_affine cairo_matrix_set_affine_REPLACED_BY_cairo_matrix_init 82 | #define cairo_matrix_set_identity cairo_matrix_set_identity_REPLACED_BY_cairo_matrix_init_identity 83 | #define cairo_pattern_add_color_stop cairo_pattern_add_color_stop_REPLACED_BY_cairo_pattern_add_color_stop_rgba 84 | #define cairo_set_rgb_color cairo_set_rgb_color_REPLACED_BY_cairo_set_source_rgb 85 | #define cairo_set_pattern cairo_set_pattern_REPLACED_BY_cairo_set_source 86 | #define cairo_xlib_surface_create_for_pixmap_with_visual cairo_xlib_surface_create_for_pixmap_with_visual_REPLACED_BY_cairo_xlib_surface_create 87 | #define cairo_xlib_surface_create_for_window_with_visual cairo_xlib_surface_create_for_window_with_visual_REPLACED_BY_cairo_xlib_surface_create 88 | #define cairo_xcb_surface_create_for_pixmap_with_visual cairo_xcb_surface_create_for_pixmap_with_visual_REPLACED_BY_cairo_xcb_surface_create 89 | #define cairo_xcb_surface_create_for_window_with_visual cairo_xcb_surface_create_for_window_with_visual_REPLACED_BY_cairo_xcb_surface_create 90 | #define cairo_ps_surface_set_dpi cairo_ps_surface_set_dpi_REPLACED_BY_cairo_surface_set_fallback_resolution 91 | #define cairo_pdf_surface_set_dpi cairo_pdf_surface_set_dpi_REPLACED_BY_cairo_surface_set_fallback_resolution 92 | #define cairo_svg_surface_set_dpi cairo_svg_surface_set_dpi_REPLACED_BY_cairo_surface_set_fallback_resolution 93 | #define cairo_atsui_font_face_create_for_atsu_font_id cairo_atsui_font_face_create_for_atsu_font_id_REPLACED_BY_cairo_quartz_font_face_create_for_atsu_font_id 94 | 95 | #define cairo_current_path cairo_current_path_DEPRECATED_BY_cairo_copy_path 96 | #define cairo_current_path_flat cairo_current_path_flat_DEPRECATED_BY_cairo_copy_path_flat 97 | #define cairo_get_path cairo_get_path_DEPRECATED_BY_cairo_copy_path 98 | #define cairo_get_path_flat cairo_get_path_flat_DEPRECATED_BY_cairo_get_path_flat 99 | #define cairo_set_alpha cairo_set_alpha_DEPRECATED_BY_cairo_set_source_rgba_OR_cairo_paint_with_alpha 100 | #define cairo_show_surface cairo_show_surface_DEPRECATED_BY_cairo_set_source_surface_AND_cairo_paint 101 | #define cairo_copy cairo_copy_DEPRECATED_BY_cairo_create_AND_MANY_INDIVIDUAL_FUNCTIONS 102 | #define cairo_surface_set_repeat cairo_surface_set_repeat_DEPRECATED_BY_cairo_pattern_set_extend 103 | #define cairo_surface_set_matrix cairo_surface_set_matrix_DEPRECATED_BY_cairo_pattern_set_matrix 104 | #define cairo_surface_get_matrix cairo_surface_get_matrix_DEPRECATED_BY_cairo_pattern_get_matrix 105 | #define cairo_surface_set_filter cairo_surface_set_filter_DEPRECATED_BY_cairo_pattern_set_filter 106 | #define cairo_surface_get_filter cairo_surface_get_filter_DEPRECATED_BY_cairo_pattern_get_filter 107 | #define cairo_matrix_create cairo_matrix_create_DEPRECATED_BY_cairo_matrix_t 108 | #define cairo_matrix_destroy cairo_matrix_destroy_DEPRECATED_BY_cairo_matrix_t 109 | #define cairo_matrix_copy cairo_matrix_copy_DEPRECATED_BY_cairo_matrix_t 110 | #define cairo_matrix_get_affine cairo_matrix_get_affine_DEPRECATED_BY_cairo_matrix_t 111 | #define cairo_set_target_surface cairo_set_target_surface_DEPRECATED_BY_cairo_create 112 | #define cairo_set_target_image cairo_set_target_image_DEPRECATED_BY_cairo_image_surface_create_for_data 113 | #define cairo_set_target_pdf cairo_set_target_pdf_DEPRECATED_BY_cairo_pdf_surface_create 114 | #define cairo_set_target_png cairo_set_target_png_DEPRECATED_BY_cairo_surface_write_to_png 115 | #define cairo_set_target_ps cairo_set_target_ps_DEPRECATED_BY_cairo_ps_surface_create 116 | #define cairo_set_target_quartz cairo_set_target_quartz_DEPRECATED_BY_cairo_quartz_surface_create 117 | #define cairo_set_target_win32 cairo_set_target_win32_DEPRECATED_BY_cairo_win32_surface_create 118 | #define cairo_set_target_xcb cairo_set_target_xcb_DEPRECATED_BY_cairo_xcb_surface_create 119 | #define cairo_set_target_drawable cairo_set_target_drawable_DEPRECATED_BY_cairo_xlib_surface_create 120 | #define cairo_get_status_string cairo_get_status_string_DEPRECATED_BY_cairo_status_AND_cairo_status_to_string 121 | #define cairo_status_string cairo_status_string_DEPRECATED_BY_cairo_status_AND_cairo_status_to_string 122 | 123 | #endif /* CAIRO_DEPRECATED_H */ 124 | -------------------------------------------------------------------------------- /include/cairo-features.h: -------------------------------------------------------------------------------- 1 | /* Generated by configure. Do not edit. */ 2 | #ifndef CAIRO_FEATURES_H 3 | #define CAIRO_FEATURES_H 4 | 5 | #define CAIRO_HAS_FC_FONT 1 6 | #define CAIRO_HAS_FT_FONT 1 7 | #define CAIRO_HAS_GOBJECT_FUNCTIONS 1 8 | #define CAIRO_HAS_IMAGE_SURFACE 1 9 | #define CAIRO_HAS_MIME_SURFACE 1 10 | #define CAIRO_HAS_OBSERVER_SURFACE 1 11 | #define CAIRO_HAS_PDF_SURFACE 1 12 | #define CAIRO_HAS_PNG_FUNCTIONS 1 13 | #define CAIRO_HAS_PS_SURFACE 1 14 | #define CAIRO_HAS_QUARTZ_FONT 1 15 | #define CAIRO_HAS_QUARTZ_SURFACE 1 16 | #define CAIRO_HAS_RECORDING_SURFACE 1 17 | #define CAIRO_HAS_SCRIPT_SURFACE 1 18 | #define CAIRO_HAS_SVG_SURFACE 1 19 | #define CAIRO_HAS_USER_FONT 1 20 | #define CAIRO_HAS_XLIB_SURFACE 1 21 | #define CAIRO_HAS_XLIB_XRENDER_SURFACE 1 22 | 23 | /*#undef CAIRO_HAS_BEOS_SURFACE */ 24 | /*#undef CAIRO_HAS_COGL_SURFACE */ 25 | /*#undef CAIRO_HAS_DIRECTFB_SURFACE */ 26 | /*#undef CAIRO_HAS_DRM_SURFACE */ 27 | /*#undef CAIRO_HAS_EGL_FUNCTIONS */ 28 | /*#undef CAIRO_HAS_GALLIUM_SURFACE */ 29 | /*#undef CAIRO_HAS_GLESV2_SURFACE */ 30 | /*#undef CAIRO_HAS_GLESV3_SURFACE */ 31 | /*#undef CAIRO_HAS_GLX_FUNCTIONS */ 32 | /*#undef CAIRO_HAS_GL_SURFACE */ 33 | /*#undef CAIRO_HAS_OS2_SURFACE */ 34 | /*#undef CAIRO_HAS_QT_SURFACE */ 35 | /*#undef CAIRO_HAS_QUARTZ_IMAGE_SURFACE */ 36 | /*#undef CAIRO_HAS_SKIA_SURFACE */ 37 | /*#undef CAIRO_HAS_TEE_SURFACE */ 38 | /*#undef CAIRO_HAS_VG_SURFACE */ 39 | /*#undef CAIRO_HAS_WGL_FUNCTIONS */ 40 | /*#undef CAIRO_HAS_WIN32_FONT */ 41 | /*#undef CAIRO_HAS_WIN32_SURFACE */ 42 | /*#undef CAIRO_HAS_XCB_SHM_FUNCTIONS */ 43 | /*#undef CAIRO_HAS_XCB_SURFACE */ 44 | /*#undef CAIRO_HAS_XLIB_XCB_FUNCTIONS */ 45 | /*#undef CAIRO_HAS_XML_SURFACE */ 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/cairo-ft.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2005 Red Hat, Inc 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is Red Hat, Inc. 31 | * 32 | * Contributor(s): 33 | * Graydon Hoare 34 | * Owen Taylor 35 | */ 36 | 37 | #ifndef CAIRO_FT_H 38 | #define CAIRO_FT_H 39 | 40 | #include "cairo.h" 41 | 42 | #if CAIRO_HAS_FT_FONT 43 | 44 | /* Fontconfig/Freetype platform-specific font interface */ 45 | 46 | #include 47 | #include FT_FREETYPE_H 48 | 49 | #if CAIRO_HAS_FC_FONT 50 | #include 51 | #endif 52 | 53 | CAIRO_BEGIN_DECLS 54 | 55 | cairo_public cairo_font_face_t * 56 | cairo_ft_font_face_create_for_ft_face (FT_Face face, 57 | int load_flags); 58 | 59 | /** 60 | * cairo_ft_synthesize_t: 61 | * @CAIRO_FT_SYNTHESIZE_BOLD: Embolden the glyphs (redraw with a pixel offset) 62 | * @CAIRO_FT_SYNTHESIZE_OBLIQUE: Slant the glyph outline by 12 degrees to the 63 | * right. 64 | * 65 | * A set of synthesis options to control how FreeType renders the glyphs 66 | * for a particular font face. 67 | * 68 | * Individual synthesis features of a #cairo_ft_font_face_t can be set 69 | * using cairo_ft_font_face_set_synthesize(), or disabled using 70 | * cairo_ft_font_face_unset_synthesize(). The currently enabled set of 71 | * synthesis options can be queried with cairo_ft_font_face_get_synthesize(). 72 | * 73 | * Note: that when synthesizing glyphs, the font metrics returned will only 74 | * be estimates. 75 | * 76 | * Since: 1.12 77 | **/ 78 | typedef enum { 79 | CAIRO_FT_SYNTHESIZE_BOLD = 1 << 0, 80 | CAIRO_FT_SYNTHESIZE_OBLIQUE = 1 << 1 81 | } cairo_ft_synthesize_t; 82 | 83 | cairo_public void 84 | cairo_ft_font_face_set_synthesize (cairo_font_face_t *font_face, 85 | unsigned int synth_flags); 86 | 87 | cairo_public void 88 | cairo_ft_font_face_unset_synthesize (cairo_font_face_t *font_face, 89 | unsigned int synth_flags); 90 | 91 | cairo_public unsigned int 92 | cairo_ft_font_face_get_synthesize (cairo_font_face_t *font_face); 93 | 94 | 95 | cairo_public FT_Face 96 | cairo_ft_scaled_font_lock_face (cairo_scaled_font_t *scaled_font); 97 | 98 | cairo_public void 99 | cairo_ft_scaled_font_unlock_face (cairo_scaled_font_t *scaled_font); 100 | 101 | #if CAIRO_HAS_FC_FONT 102 | 103 | cairo_public cairo_font_face_t * 104 | cairo_ft_font_face_create_for_pattern (FcPattern *pattern); 105 | 106 | cairo_public void 107 | cairo_ft_font_options_substitute (const cairo_font_options_t *options, 108 | FcPattern *pattern); 109 | 110 | #endif 111 | 112 | CAIRO_END_DECLS 113 | 114 | #else /* CAIRO_HAS_FT_FONT */ 115 | # error Cairo was not compiled with support for the freetype font backend 116 | #endif /* CAIRO_HAS_FT_FONT */ 117 | 118 | #endif /* CAIRO_FT_H */ 119 | -------------------------------------------------------------------------------- /include/cairo-gl.h: -------------------------------------------------------------------------------- 1 | /* Cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2009 Eric Anholt 4 | * Copyright © 2009 Chris Wilson 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it either under the terms of the GNU Lesser General Public 8 | * License version 2.1 as published by the Free Software Foundation 9 | * (the "LGPL") or, at your option, under the terms of the Mozilla 10 | * Public License Version 1.1 (the "MPL"). If you do not alter this 11 | * notice, a recipient may use your version of this file under either 12 | * the MPL or the LGPL. 13 | * 14 | * You should have received a copy of the LGPL along with this library 15 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 17 | * You should have received a copy of the MPL along with this library 18 | * in the file COPYING-MPL-1.1 19 | * 20 | * The contents of this file are subject to the Mozilla Public License 21 | * Version 1.1 (the "License"); you may not use this file except in 22 | * compliance with the License. You may obtain a copy of the License at 23 | * http://www.mozilla.org/MPL/ 24 | * 25 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 26 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 27 | * the specific language governing rights and limitations. 28 | * 29 | * The Original Code is the cairo graphics library. 30 | * 31 | * The Initial Developer of the Original Code is Eric Anholt. 32 | */ 33 | 34 | /* 35 | * cairo-gl.h: 36 | * 37 | * The cairo-gl backend provides an implementation of possibly 38 | * hardware-accelerated cairo rendering by targeting the OpenGL API. 39 | * The goal of the cairo-gl backend is to provide better performance 40 | * with equal functionality to cairo-image where possible. It does 41 | * not directly provide for applying additional OpenGL effects to 42 | * cairo surfaces. 43 | * 44 | * Cairo-gl allows interoperability with other GL rendering through GL 45 | * context sharing. Cairo-gl surfaces are created in reference to a 46 | * #cairo_device_t, which represents a GL context created by the user. 47 | * When that GL context is created with its sharePtr set to another 48 | * context (or vice versa), its objects (textures backing cairo-gl 49 | * surfaces) can be accessed in the other OpenGL context. This allows 50 | * cairo-gl to maintain its drawing state in one context while the 51 | * user's 3D rendering occurs in the user's other context. 52 | * 53 | * However, as only one context can be current to a thread at a time, 54 | * cairo-gl may make its context current to the thread on any cairo 55 | * call which interacts with a cairo-gl surface or the cairo-gl 56 | * device. As a result, the user must make their own context current 57 | * between any cairo calls and their own OpenGL rendering. 58 | **/ 59 | 60 | #ifndef CAIRO_GL_H 61 | #define CAIRO_GL_H 62 | 63 | #include "cairo.h" 64 | 65 | #if CAIRO_HAS_GL_SURFACE || CAIRO_HAS_GLESV2_SURFACE || CAIRO_HAS_GLESV3_SURFACE 66 | 67 | CAIRO_BEGIN_DECLS 68 | 69 | cairo_public cairo_surface_t * 70 | cairo_gl_surface_create (cairo_device_t *device, 71 | cairo_content_t content, 72 | int width, int height); 73 | 74 | cairo_public cairo_surface_t * 75 | cairo_gl_surface_create_for_texture (cairo_device_t *abstract_device, 76 | cairo_content_t content, 77 | unsigned int tex, 78 | int width, int height); 79 | cairo_public void 80 | cairo_gl_surface_set_size (cairo_surface_t *surface, int width, int height); 81 | 82 | cairo_public int 83 | cairo_gl_surface_get_width (cairo_surface_t *abstract_surface); 84 | 85 | cairo_public int 86 | cairo_gl_surface_get_height (cairo_surface_t *abstract_surface); 87 | 88 | cairo_public void 89 | cairo_gl_surface_swapbuffers (cairo_surface_t *surface); 90 | 91 | cairo_public void 92 | cairo_gl_device_set_thread_aware (cairo_device_t *device, 93 | cairo_bool_t thread_aware); 94 | 95 | #if CAIRO_HAS_GLX_FUNCTIONS 96 | #include 97 | 98 | cairo_public cairo_device_t * 99 | cairo_glx_device_create (Display *dpy, GLXContext gl_ctx); 100 | 101 | cairo_public Display * 102 | cairo_glx_device_get_display (cairo_device_t *device); 103 | 104 | cairo_public GLXContext 105 | cairo_glx_device_get_context (cairo_device_t *device); 106 | 107 | cairo_public cairo_surface_t * 108 | cairo_gl_surface_create_for_window (cairo_device_t *device, 109 | Window win, 110 | int width, int height); 111 | #endif 112 | 113 | #if CAIRO_HAS_WGL_FUNCTIONS 114 | #include 115 | 116 | cairo_public cairo_device_t * 117 | cairo_wgl_device_create (HGLRC rc); 118 | 119 | cairo_public HGLRC 120 | cairo_wgl_device_get_context (cairo_device_t *device); 121 | 122 | cairo_public cairo_surface_t * 123 | cairo_gl_surface_create_for_dc (cairo_device_t *device, 124 | HDC dc, 125 | int width, 126 | int height); 127 | #endif 128 | 129 | #if CAIRO_HAS_EGL_FUNCTIONS 130 | #include 131 | 132 | cairo_public cairo_device_t * 133 | cairo_egl_device_create (EGLDisplay dpy, EGLContext egl); 134 | 135 | cairo_public cairo_surface_t * 136 | cairo_gl_surface_create_for_egl (cairo_device_t *device, 137 | EGLSurface egl, 138 | int width, 139 | int height); 140 | 141 | cairo_public EGLDisplay 142 | cairo_egl_device_get_display (cairo_device_t *device); 143 | 144 | cairo_public EGLSurface 145 | cairo_egl_device_get_context (cairo_device_t *device); 146 | 147 | #endif 148 | 149 | CAIRO_END_DECLS 150 | 151 | #else /* CAIRO_HAS_GL_SURFACE */ 152 | # error Cairo was not compiled with support for the GL backend 153 | #endif /* CAIRO_HAS_GL_SURFACE */ 154 | 155 | #endif /* CAIRO_GL_H */ 156 | -------------------------------------------------------------------------------- /include/cairo-gobject.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2010 Red Hat Inc. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is University of Southern 31 | * California. 32 | * 33 | * Contributor(s): 34 | * Benjamin Otte 35 | */ 36 | 37 | #ifndef CAIRO_GOBJECT_H 38 | #define CAIRO_GOBJECT_H 39 | 40 | #include 41 | 42 | #if CAIRO_HAS_GOBJECT_FUNCTIONS 43 | 44 | #include 45 | 46 | CAIRO_BEGIN_DECLS 47 | 48 | /* structs */ 49 | 50 | #define CAIRO_GOBJECT_TYPE_CONTEXT cairo_gobject_context_get_type () 51 | cairo_public GType 52 | cairo_gobject_context_get_type (void); 53 | 54 | #define CAIRO_GOBJECT_TYPE_DEVICE cairo_gobject_device_get_type () 55 | cairo_public GType 56 | cairo_gobject_device_get_type (void); 57 | 58 | #define CAIRO_GOBJECT_TYPE_MATRIX cairo_gobject_matrix_get_type () 59 | cairo_public GType 60 | cairo_gobject_matrix_get_type (void); 61 | 62 | #define CAIRO_GOBJECT_TYPE_PATTERN cairo_gobject_pattern_get_type () 63 | cairo_public GType 64 | cairo_gobject_pattern_get_type (void); 65 | 66 | #define CAIRO_GOBJECT_TYPE_SURFACE cairo_gobject_surface_get_type () 67 | cairo_public GType 68 | cairo_gobject_surface_get_type (void); 69 | 70 | #define CAIRO_GOBJECT_TYPE_RECTANGLE cairo_gobject_rectangle_get_type () 71 | cairo_public GType 72 | cairo_gobject_rectangle_get_type (void); 73 | 74 | #define CAIRO_GOBJECT_TYPE_SCALED_FONT cairo_gobject_scaled_font_get_type () 75 | cairo_public GType 76 | cairo_gobject_scaled_font_get_type (void); 77 | 78 | #define CAIRO_GOBJECT_TYPE_FONT_FACE cairo_gobject_font_face_get_type () 79 | cairo_public GType 80 | cairo_gobject_font_face_get_type (void); 81 | 82 | #define CAIRO_GOBJECT_TYPE_FONT_OPTIONS cairo_gobject_font_options_get_type () 83 | cairo_public GType 84 | cairo_gobject_font_options_get_type (void); 85 | 86 | #define CAIRO_GOBJECT_TYPE_RECTANGLE_INT cairo_gobject_rectangle_int_get_type () 87 | cairo_public GType 88 | cairo_gobject_rectangle_int_get_type (void); 89 | 90 | #define CAIRO_GOBJECT_TYPE_REGION cairo_gobject_region_get_type () 91 | cairo_public GType 92 | cairo_gobject_region_get_type (void); 93 | 94 | /* enums */ 95 | 96 | #define CAIRO_GOBJECT_TYPE_STATUS cairo_gobject_status_get_type () 97 | cairo_public GType 98 | cairo_gobject_status_get_type (void); 99 | 100 | #define CAIRO_GOBJECT_TYPE_CONTENT cairo_gobject_content_get_type () 101 | cairo_public GType 102 | cairo_gobject_content_get_type (void); 103 | 104 | #define CAIRO_GOBJECT_TYPE_OPERATOR cairo_gobject_operator_get_type () 105 | cairo_public GType 106 | cairo_gobject_operator_get_type (void); 107 | 108 | #define CAIRO_GOBJECT_TYPE_ANTIALIAS cairo_gobject_antialias_get_type () 109 | cairo_public GType 110 | cairo_gobject_antialias_get_type (void); 111 | 112 | #define CAIRO_GOBJECT_TYPE_FILL_RULE cairo_gobject_fill_rule_get_type () 113 | cairo_public GType 114 | cairo_gobject_fill_rule_get_type (void); 115 | 116 | #define CAIRO_GOBJECT_TYPE_LINE_CAP cairo_gobject_line_cap_get_type () 117 | cairo_public GType 118 | cairo_gobject_line_cap_get_type (void); 119 | 120 | #define CAIRO_GOBJECT_TYPE_LINE_JOIN cairo_gobject_line_join_get_type () 121 | cairo_public GType 122 | cairo_gobject_line_join_get_type (void); 123 | 124 | #define CAIRO_GOBJECT_TYPE_TEXT_CLUSTER_FLAGS cairo_gobject_text_cluster_flags_get_type () 125 | cairo_public GType 126 | cairo_gobject_text_cluster_flags_get_type (void); 127 | 128 | #define CAIRO_GOBJECT_TYPE_FONT_SLANT cairo_gobject_font_slant_get_type () 129 | cairo_public GType 130 | cairo_gobject_font_slant_get_type (void); 131 | 132 | #define CAIRO_GOBJECT_TYPE_FONT_WEIGHT cairo_gobject_font_weight_get_type () 133 | cairo_public GType 134 | cairo_gobject_font_weight_get_type (void); 135 | 136 | #define CAIRO_GOBJECT_TYPE_SUBPIXEL_ORDER cairo_gobject_subpixel_order_get_type () 137 | cairo_public GType 138 | cairo_gobject_subpixel_order_get_type (void); 139 | 140 | #define CAIRO_GOBJECT_TYPE_HINT_STYLE cairo_gobject_hint_style_get_type () 141 | cairo_public GType 142 | cairo_gobject_hint_style_get_type (void); 143 | 144 | /* historical accident */ 145 | #define CAIRO_GOBJECT_TYPE_HNT_METRICS cairo_gobject_hint_metrics_get_type () 146 | #define CAIRO_GOBJECT_TYPE_HINT_METRICS cairo_gobject_hint_metrics_get_type () 147 | cairo_public GType 148 | cairo_gobject_hint_metrics_get_type (void); 149 | 150 | #define CAIRO_GOBJECT_TYPE_FONT_TYPE cairo_gobject_font_type_get_type () 151 | cairo_public GType 152 | cairo_gobject_font_type_get_type (void); 153 | 154 | #define CAIRO_GOBJECT_TYPE_PATH_DATA_TYPE cairo_gobject_path_data_type_get_type () 155 | cairo_public GType 156 | cairo_gobject_path_data_type_get_type (void); 157 | 158 | #define CAIRO_GOBJECT_TYPE_DEVICE_TYPE cairo_gobject_device_type_get_type () 159 | cairo_public GType 160 | cairo_gobject_device_type_get_type (void); 161 | 162 | #define CAIRO_GOBJECT_TYPE_SURFACE_TYPE cairo_gobject_surface_type_get_type () 163 | cairo_public GType 164 | cairo_gobject_surface_type_get_type (void); 165 | 166 | #define CAIRO_GOBJECT_TYPE_FORMAT cairo_gobject_format_get_type () 167 | cairo_public GType 168 | cairo_gobject_format_get_type (void); 169 | 170 | #define CAIRO_GOBJECT_TYPE_PATTERN_TYPE cairo_gobject_pattern_type_get_type () 171 | cairo_public GType 172 | cairo_gobject_pattern_type_get_type (void); 173 | 174 | #define CAIRO_GOBJECT_TYPE_EXTEND cairo_gobject_extend_get_type () 175 | cairo_public GType 176 | cairo_gobject_extend_get_type (void); 177 | 178 | #define CAIRO_GOBJECT_TYPE_FILTER cairo_gobject_filter_get_type () 179 | cairo_public GType 180 | cairo_gobject_filter_get_type (void); 181 | 182 | #define CAIRO_GOBJECT_TYPE_REGION_OVERLAP cairo_gobject_region_overlap_get_type () 183 | cairo_public GType 184 | cairo_gobject_region_overlap_get_type (void); 185 | 186 | CAIRO_END_DECLS 187 | 188 | #else /* CAIRO_HAS_GOBJECT_FUNCTIONS */ 189 | # error Cairo was not compiled with support for GObject 190 | #endif /* CAIRO_HAS_GOBJECT_FUNCTIONS */ 191 | 192 | #endif /* CAIRO_GOBJECT_H */ 193 | -------------------------------------------------------------------------------- /include/cairo-pdf.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2002 University of Southern California 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is University of Southern 31 | * California. 32 | * 33 | * Contributor(s): 34 | * Carl D. Worth 35 | */ 36 | 37 | #ifndef CAIRO_PDF_H 38 | #define CAIRO_PDF_H 39 | 40 | #include "cairo.h" 41 | 42 | #if CAIRO_HAS_PDF_SURFACE 43 | 44 | CAIRO_BEGIN_DECLS 45 | 46 | /** 47 | * cairo_pdf_version_t: 48 | * @CAIRO_PDF_VERSION_1_4: The version 1.4 of the PDF specification. (Since 1.10) 49 | * @CAIRO_PDF_VERSION_1_5: The version 1.5 of the PDF specification. (Since 1.10) 50 | * 51 | * #cairo_pdf_version_t is used to describe the version number of the PDF 52 | * specification that a generated PDF file will conform to. 53 | * 54 | * Since: 1.10 55 | **/ 56 | typedef enum _cairo_pdf_version { 57 | CAIRO_PDF_VERSION_1_4, 58 | CAIRO_PDF_VERSION_1_5 59 | } cairo_pdf_version_t; 60 | 61 | cairo_public cairo_surface_t * 62 | cairo_pdf_surface_create (const char *filename, 63 | double width_in_points, 64 | double height_in_points); 65 | 66 | cairo_public cairo_surface_t * 67 | cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func, 68 | void *closure, 69 | double width_in_points, 70 | double height_in_points); 71 | 72 | cairo_public void 73 | cairo_pdf_surface_restrict_to_version (cairo_surface_t *surface, 74 | cairo_pdf_version_t version); 75 | 76 | cairo_public void 77 | cairo_pdf_get_versions (cairo_pdf_version_t const **versions, 78 | int *num_versions); 79 | 80 | cairo_public const char * 81 | cairo_pdf_version_to_string (cairo_pdf_version_t version); 82 | 83 | cairo_public void 84 | cairo_pdf_surface_set_size (cairo_surface_t *surface, 85 | double width_in_points, 86 | double height_in_points); 87 | 88 | /** 89 | * cairo_pdf_outline_flags_t: 90 | * @CAIRO_PDF_OUTLINE_FLAG_OPEN: The outline item defaults to open in the PDF viewer (Since 1.16) 91 | * @CAIRO_PDF_OUTLINE_FLAG_BOLD: The outline item is displayed by the viewer in bold text (Since 1.16) 92 | * @CAIRO_PDF_OUTLINE_FLAG_ITALIC: The outline item is displayed by the viewer in italic text (Since 1.16) 93 | * 94 | * #cairo_pdf_outline_flags_t is used by the 95 | * cairo_pdf_surface_add_outline() function specify the attributes of 96 | * an outline item. These flags may be bitwise-or'd to produce any 97 | * combination of flags. 98 | * 99 | * Since: 1.16 100 | **/ 101 | typedef enum _cairo_pdf_outline_flags { 102 | CAIRO_PDF_OUTLINE_FLAG_OPEN = 0x1, 103 | CAIRO_PDF_OUTLINE_FLAG_BOLD = 0x2, 104 | CAIRO_PDF_OUTLINE_FLAG_ITALIC = 0x4, 105 | } cairo_pdf_outline_flags_t; 106 | 107 | #define CAIRO_PDF_OUTLINE_ROOT 0 108 | 109 | cairo_public int 110 | cairo_pdf_surface_add_outline (cairo_surface_t *surface, 111 | int parent_id, 112 | const char *utf8, 113 | const char *link_attribs, 114 | cairo_pdf_outline_flags_t flags); 115 | 116 | /** 117 | * cairo_pdf_metadata_t: 118 | * @CAIRO_PDF_METADATA_TITLE: The document title (Since 1.16) 119 | * @CAIRO_PDF_METADATA_AUTHOR: The document author (Since 1.16) 120 | * @CAIRO_PDF_METADATA_SUBJECT: The document subject (Since 1.16) 121 | * @CAIRO_PDF_METADATA_KEYWORDS: The document keywords (Since 1.16) 122 | * @CAIRO_PDF_METADATA_CREATOR: The document creator (Since 1.16) 123 | * @CAIRO_PDF_METADATA_CREATE_DATE: The document creation date (Since 1.16) 124 | * @CAIRO_PDF_METADATA_MOD_DATE: The document modification date (Since 1.16) 125 | * 126 | * #cairo_pdf_metadata_t is used by the 127 | * cairo_pdf_surface_set_metadata() function specify the metadata to set. 128 | * 129 | * Since: 1.16 130 | **/ 131 | typedef enum _cairo_pdf_metadata { 132 | CAIRO_PDF_METADATA_TITLE, 133 | CAIRO_PDF_METADATA_AUTHOR, 134 | CAIRO_PDF_METADATA_SUBJECT, 135 | CAIRO_PDF_METADATA_KEYWORDS, 136 | CAIRO_PDF_METADATA_CREATOR, 137 | CAIRO_PDF_METADATA_CREATE_DATE, 138 | CAIRO_PDF_METADATA_MOD_DATE, 139 | } cairo_pdf_metadata_t; 140 | 141 | cairo_public void 142 | cairo_pdf_surface_set_metadata (cairo_surface_t *surface, 143 | cairo_pdf_metadata_t metadata, 144 | const char *utf8); 145 | 146 | cairo_public void 147 | cairo_pdf_surface_set_page_label (cairo_surface_t *surface, 148 | const char *utf8); 149 | 150 | cairo_public void 151 | cairo_pdf_surface_set_thumbnail_size (cairo_surface_t *surface, 152 | int width, 153 | int height); 154 | 155 | CAIRO_END_DECLS 156 | 157 | #else /* CAIRO_HAS_PDF_SURFACE */ 158 | # error Cairo was not compiled with support for the pdf backend 159 | #endif /* CAIRO_HAS_PDF_SURFACE */ 160 | 161 | #endif /* CAIRO_PDF_H */ 162 | -------------------------------------------------------------------------------- /include/cairo-ps.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2002 University of Southern California 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is University of Southern 31 | * California. 32 | * 33 | * Contributor(s): 34 | * Carl D. Worth 35 | */ 36 | 37 | #ifndef CAIRO_PS_H 38 | #define CAIRO_PS_H 39 | 40 | #include "cairo.h" 41 | 42 | #if CAIRO_HAS_PS_SURFACE 43 | 44 | #include 45 | 46 | CAIRO_BEGIN_DECLS 47 | 48 | /* PS-surface functions */ 49 | 50 | /** 51 | * cairo_ps_level_t: 52 | * @CAIRO_PS_LEVEL_2: The language level 2 of the PostScript specification. (Since 1.6) 53 | * @CAIRO_PS_LEVEL_3: The language level 3 of the PostScript specification. (Since 1.6) 54 | * 55 | * #cairo_ps_level_t is used to describe the language level of the 56 | * PostScript Language Reference that a generated PostScript file will 57 | * conform to. 58 | * 59 | * Since: 1.6 60 | **/ 61 | typedef enum _cairo_ps_level { 62 | CAIRO_PS_LEVEL_2, 63 | CAIRO_PS_LEVEL_3 64 | } cairo_ps_level_t; 65 | 66 | cairo_public cairo_surface_t * 67 | cairo_ps_surface_create (const char *filename, 68 | double width_in_points, 69 | double height_in_points); 70 | 71 | cairo_public cairo_surface_t * 72 | cairo_ps_surface_create_for_stream (cairo_write_func_t write_func, 73 | void *closure, 74 | double width_in_points, 75 | double height_in_points); 76 | 77 | cairo_public void 78 | cairo_ps_surface_restrict_to_level (cairo_surface_t *surface, 79 | cairo_ps_level_t level); 80 | 81 | cairo_public void 82 | cairo_ps_get_levels (cairo_ps_level_t const **levels, 83 | int *num_levels); 84 | 85 | cairo_public const char * 86 | cairo_ps_level_to_string (cairo_ps_level_t level); 87 | 88 | cairo_public void 89 | cairo_ps_surface_set_eps (cairo_surface_t *surface, 90 | cairo_bool_t eps); 91 | 92 | cairo_public cairo_bool_t 93 | cairo_ps_surface_get_eps (cairo_surface_t *surface); 94 | 95 | cairo_public void 96 | cairo_ps_surface_set_size (cairo_surface_t *surface, 97 | double width_in_points, 98 | double height_in_points); 99 | 100 | cairo_public void 101 | cairo_ps_surface_dsc_comment (cairo_surface_t *surface, 102 | const char *comment); 103 | 104 | cairo_public void 105 | cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface); 106 | 107 | cairo_public void 108 | cairo_ps_surface_dsc_begin_page_setup (cairo_surface_t *surface); 109 | 110 | CAIRO_END_DECLS 111 | 112 | #else /* CAIRO_HAS_PS_SURFACE */ 113 | # error Cairo was not compiled with support for the ps backend 114 | #endif /* CAIRO_HAS_PS_SURFACE */ 115 | 116 | #endif /* CAIRO_PS_H */ 117 | -------------------------------------------------------------------------------- /include/cairo-quartz-image.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/include/cairo-quartz-image.h -------------------------------------------------------------------------------- /include/cairo-quartz.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golang-ui/cairo/4a4e1c0840c79561aa21179b3a4217e3e5213b8f/include/cairo-quartz.h -------------------------------------------------------------------------------- /include/cairo-script-interpreter.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2008 Chris Wilson 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is Chris Wilson 31 | * 32 | * Contributor(s): 33 | * Chris Wilson 34 | */ 35 | 36 | #ifndef CAIRO_SCRIPT_INTERPRETER_H 37 | #define CAIRO_SCRIPT_INTERPRETER_H 38 | 39 | #include 40 | #include 41 | 42 | CAIRO_BEGIN_DECLS 43 | 44 | typedef struct _cairo_script_interpreter cairo_script_interpreter_t; 45 | 46 | /* XXX expose csi_dictionary_t and pass to hooks */ 47 | typedef void 48 | (*csi_destroy_func_t) (void *closure, 49 | void *ptr); 50 | 51 | typedef cairo_surface_t * 52 | (*csi_surface_create_func_t) (void *closure, 53 | cairo_content_t content, 54 | double width, 55 | double height, 56 | long uid); 57 | typedef cairo_t * 58 | (*csi_context_create_func_t) (void *closure, 59 | cairo_surface_t *surface); 60 | typedef void 61 | (*csi_show_page_func_t) (void *closure, 62 | cairo_t *cr); 63 | 64 | typedef void 65 | (*csi_copy_page_func_t) (void *closure, 66 | cairo_t *cr); 67 | 68 | typedef cairo_surface_t * 69 | (*csi_create_source_image_t) (void *closure, 70 | cairo_format_t format, 71 | int width, int height, 72 | long uid); 73 | 74 | typedef struct _cairo_script_interpreter_hooks { 75 | void *closure; 76 | csi_surface_create_func_t surface_create; 77 | csi_destroy_func_t surface_destroy; 78 | csi_context_create_func_t context_create; 79 | csi_destroy_func_t context_destroy; 80 | csi_show_page_func_t show_page; 81 | csi_copy_page_func_t copy_page; 82 | csi_create_source_image_t create_source_image; 83 | } cairo_script_interpreter_hooks_t; 84 | 85 | cairo_public cairo_script_interpreter_t * 86 | cairo_script_interpreter_create (void); 87 | 88 | cairo_public void 89 | cairo_script_interpreter_install_hooks (cairo_script_interpreter_t *ctx, 90 | const cairo_script_interpreter_hooks_t *hooks); 91 | 92 | cairo_public cairo_status_t 93 | cairo_script_interpreter_run (cairo_script_interpreter_t *ctx, 94 | const char *filename); 95 | 96 | cairo_public cairo_status_t 97 | cairo_script_interpreter_feed_stream (cairo_script_interpreter_t *ctx, 98 | FILE *stream); 99 | 100 | cairo_public cairo_status_t 101 | cairo_script_interpreter_feed_string (cairo_script_interpreter_t *ctx, 102 | const char *line, 103 | int len); 104 | 105 | cairo_public unsigned int 106 | cairo_script_interpreter_get_line_number (cairo_script_interpreter_t *ctx); 107 | 108 | cairo_public cairo_script_interpreter_t * 109 | cairo_script_interpreter_reference (cairo_script_interpreter_t *ctx); 110 | 111 | cairo_public cairo_status_t 112 | cairo_script_interpreter_finish (cairo_script_interpreter_t *ctx); 113 | 114 | cairo_public cairo_status_t 115 | cairo_script_interpreter_destroy (cairo_script_interpreter_t *ctx); 116 | 117 | cairo_public cairo_status_t 118 | cairo_script_interpreter_translate_stream (FILE *stream, 119 | cairo_write_func_t write_func, 120 | void *closure); 121 | 122 | CAIRO_END_DECLS 123 | 124 | #endif /*CAIRO_SCRIPT_INTERPRETER_H*/ 125 | -------------------------------------------------------------------------------- /include/cairo-script.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2008 Chris Wilson 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is Chris Wilson 31 | * 32 | * Contributor(s): 33 | * Chris Wilson 34 | */ 35 | 36 | #ifndef CAIRO_SCRIPT_H 37 | #define CAIRO_SCRIPT_H 38 | 39 | #include "cairo.h" 40 | 41 | #if CAIRO_HAS_SCRIPT_SURFACE 42 | 43 | CAIRO_BEGIN_DECLS 44 | 45 | /** 46 | * cairo_script_mode_t: 47 | * @CAIRO_SCRIPT_MODE_ASCII: the output will be in readable text (default). (Since 1.12) 48 | * @CAIRO_SCRIPT_MODE_BINARY: the output will use byte codes. (Since 1.12) 49 | * 50 | * A set of script output variants. 51 | * 52 | * Since: 1.12 53 | **/ 54 | typedef enum { 55 | CAIRO_SCRIPT_MODE_ASCII, 56 | CAIRO_SCRIPT_MODE_BINARY 57 | } cairo_script_mode_t; 58 | 59 | cairo_public cairo_device_t * 60 | cairo_script_create (const char *filename); 61 | 62 | cairo_public cairo_device_t * 63 | cairo_script_create_for_stream (cairo_write_func_t write_func, 64 | void *closure); 65 | 66 | cairo_public void 67 | cairo_script_write_comment (cairo_device_t *script, 68 | const char *comment, 69 | int len); 70 | 71 | cairo_public void 72 | cairo_script_set_mode (cairo_device_t *script, 73 | cairo_script_mode_t mode); 74 | 75 | cairo_public cairo_script_mode_t 76 | cairo_script_get_mode (cairo_device_t *script); 77 | 78 | cairo_public cairo_surface_t * 79 | cairo_script_surface_create (cairo_device_t *script, 80 | cairo_content_t content, 81 | double width, 82 | double height); 83 | 84 | cairo_public cairo_surface_t * 85 | cairo_script_surface_create_for_target (cairo_device_t *script, 86 | cairo_surface_t *target); 87 | 88 | cairo_public cairo_status_t 89 | cairo_script_from_recording_surface (cairo_device_t *script, 90 | cairo_surface_t *recording_surface); 91 | 92 | CAIRO_END_DECLS 93 | 94 | #else /*CAIRO_HAS_SCRIPT_SURFACE*/ 95 | # error Cairo was not compiled with support for the CairoScript backend 96 | #endif /*CAIRO_HAS_SCRIPT_SURFACE*/ 97 | 98 | #endif /*CAIRO_SCRIPT_H*/ 99 | -------------------------------------------------------------------------------- /include/cairo-svg.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * cairo-svg.h 4 | * 5 | * Copyright © 2005 Emmanuel Pacaud 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it either under the terms of the GNU Lesser General Public 9 | * License version 2.1 as published by the Free Software Foundation 10 | * (the "LGPL") or, at your option, under the terms of the Mozilla 11 | * Public License Version 1.1 (the "MPL"). If you do not alter this 12 | * notice, a recipient may use your version of this file under either 13 | * the MPL or the LGPL. 14 | * 15 | * You should have received a copy of the LGPL along with this library 16 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 18 | * You should have received a copy of the MPL along with this library 19 | * in the file COPYING-MPL-1.1 20 | * 21 | * The contents of this file are subject to the Mozilla Public License 22 | * Version 1.1 (the "License"); you may not use this file except in 23 | * compliance with the License. You may obtain a copy of the License at 24 | * http://www.mozilla.org/MPL/ 25 | * 26 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 27 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 28 | * the specific language governing rights and limitations. 29 | * 30 | */ 31 | 32 | #ifndef CAIRO_SVG_H 33 | #define CAIRO_SVG_H 34 | 35 | #include "cairo.h" 36 | 37 | #if CAIRO_HAS_SVG_SURFACE 38 | 39 | CAIRO_BEGIN_DECLS 40 | 41 | /** 42 | * cairo_svg_version_t: 43 | * @CAIRO_SVG_VERSION_1_1: The version 1.1 of the SVG specification. (Since 1.2) 44 | * @CAIRO_SVG_VERSION_1_2: The version 1.2 of the SVG specification. (Since 1.2) 45 | * 46 | * #cairo_svg_version_t is used to describe the version number of the SVG 47 | * specification that a generated SVG file will conform to. 48 | * 49 | * Since: 1.2 50 | **/ 51 | typedef enum _cairo_svg_version { 52 | CAIRO_SVG_VERSION_1_1, 53 | CAIRO_SVG_VERSION_1_2 54 | } cairo_svg_version_t; 55 | 56 | /** 57 | * cairo_svg_unit_t: 58 | * 59 | * @CAIRO_SVG_UNIT_USER: User unit, a value in the current coordinate system. 60 | * If used in the root element for the initial coordinate systems it 61 | * corresponds to pixels. (Since 1.16) 62 | * @CAIRO_SVG_UNIT_EM: The size of the element's font. (Since 1.16) 63 | * @CAIRO_SVG_UNIT_EX: The x-height of the element’s font. (Since 1.16) 64 | * @CAIRO_SVG_UNIT_PX: Pixels (1px = 1/96th of 1in). (Since 1.16) 65 | * @CAIRO_SVG_UNIT_IN: Inches (1in = 2.54cm = 96px). (Since 1.16) 66 | * @CAIRO_SVG_UNIT_CM: Centimeters (1cm = 96px/2.54). (Since 1.16) 67 | * @CAIRO_SVG_UNIT_MM: Millimeters (1mm = 1/10th of 1cm). (Since 1.16) 68 | * @CAIRO_SVG_UNIT_PT: Points (1pt = 1/72th of 1in). (Since 1.16) 69 | * @CAIRO_SVG_UNIT_PC: Picas (1pc = 1/6th of 1in). (Since 1.16) 70 | * @CAIRO_SVG_UNIT_PERCENT: Percent, a value that is some fraction of another 71 | * reference value. (Since 1.16) 72 | * 73 | * #cairo_svg_unit_t is used to describe the units valid for coordinates and 74 | * lengths in the SVG specification. 75 | * 76 | * See also: 77 | * https://www.w3.org/TR/SVG/coords.html#Units 78 | * https://www.w3.org/TR/SVG/types.html#DataTypeLength 79 | * https://www.w3.org/TR/css-values-3/#lengths 80 | * 81 | * Since: 1.16 82 | **/ 83 | typedef enum _cairo_svg_unit { 84 | CAIRO_SVG_UNIT_USER = 0, 85 | CAIRO_SVG_UNIT_EM, 86 | CAIRO_SVG_UNIT_EX, 87 | CAIRO_SVG_UNIT_PX, 88 | CAIRO_SVG_UNIT_IN, 89 | CAIRO_SVG_UNIT_CM, 90 | CAIRO_SVG_UNIT_MM, 91 | CAIRO_SVG_UNIT_PT, 92 | CAIRO_SVG_UNIT_PC, 93 | CAIRO_SVG_UNIT_PERCENT 94 | } cairo_svg_unit_t; 95 | 96 | cairo_public cairo_surface_t * 97 | cairo_svg_surface_create (const char *filename, 98 | double width_in_points, 99 | double height_in_points); 100 | 101 | cairo_public cairo_surface_t * 102 | cairo_svg_surface_create_for_stream (cairo_write_func_t write_func, 103 | void *closure, 104 | double width_in_points, 105 | double height_in_points); 106 | 107 | cairo_public void 108 | cairo_svg_surface_restrict_to_version (cairo_surface_t *surface, 109 | cairo_svg_version_t version); 110 | 111 | cairo_public void 112 | cairo_svg_get_versions (cairo_svg_version_t const **versions, 113 | int *num_versions); 114 | 115 | cairo_public const char * 116 | cairo_svg_version_to_string (cairo_svg_version_t version); 117 | 118 | cairo_public void 119 | cairo_svg_surface_set_document_unit (cairo_surface_t *surface, 120 | cairo_svg_unit_t unit); 121 | 122 | cairo_public cairo_svg_unit_t 123 | cairo_svg_surface_get_document_unit (cairo_surface_t *surface); 124 | 125 | CAIRO_END_DECLS 126 | 127 | #else /* CAIRO_HAS_SVG_SURFACE */ 128 | # error Cairo was not compiled with support for the svg backend 129 | #endif /* CAIRO_HAS_SVG_SURFACE */ 130 | 131 | #endif /* CAIRO_SVG_H */ 132 | -------------------------------------------------------------------------------- /include/cairo-tee.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2009 Chris Wilson 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is Chris Wilson 31 | * 32 | * Contributor(s): 33 | * Chris Wilson 34 | */ 35 | 36 | #ifndef CAIRO_TEE_H 37 | #define CAIRO_TEE_H 38 | 39 | #include "cairo.h" 40 | 41 | #if CAIRO_HAS_TEE_SURFACE 42 | 43 | CAIRO_BEGIN_DECLS 44 | 45 | cairo_public cairo_surface_t * 46 | cairo_tee_surface_create (cairo_surface_t *master); 47 | 48 | cairo_public void 49 | cairo_tee_surface_add (cairo_surface_t *surface, 50 | cairo_surface_t *target); 51 | 52 | cairo_public void 53 | cairo_tee_surface_remove (cairo_surface_t *surface, 54 | cairo_surface_t *target); 55 | 56 | cairo_public cairo_surface_t * 57 | cairo_tee_surface_index (cairo_surface_t *surface, 58 | unsigned int index); 59 | 60 | CAIRO_END_DECLS 61 | 62 | #else /*CAIRO_HAS_TEE_SURFACE*/ 63 | # error Cairo was not compiled with support for the TEE backend 64 | #endif /*CAIRO_HAS_TEE_SURFACE*/ 65 | 66 | #endif /*CAIRO_TEE_H*/ 67 | -------------------------------------------------------------------------------- /include/cairo-version.h: -------------------------------------------------------------------------------- 1 | #ifndef CAIRO_VERSION_H 2 | #define CAIRO_VERSION_H 3 | 4 | #define CAIRO_VERSION_MAJOR 1 5 | #define CAIRO_VERSION_MINOR 15 6 | #define CAIRO_VERSION_MICRO 11 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/cairo-xlib-xrender.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2002 University of Southern California 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is University of Southern 31 | * California. 32 | * 33 | * Contributor(s): 34 | * Carl D. Worth 35 | */ 36 | 37 | #ifndef CAIRO_XLIB_XRENDER_H 38 | #define CAIRO_XLIB_XRENDER_H 39 | 40 | #include "cairo.h" 41 | 42 | #if CAIRO_HAS_XLIB_XRENDER_SURFACE 43 | 44 | #include 45 | #include 46 | 47 | CAIRO_BEGIN_DECLS 48 | 49 | cairo_public cairo_surface_t * 50 | cairo_xlib_surface_create_with_xrender_format (Display *dpy, 51 | Drawable drawable, 52 | Screen *screen, 53 | XRenderPictFormat *format, 54 | int width, 55 | int height); 56 | 57 | cairo_public XRenderPictFormat * 58 | cairo_xlib_surface_get_xrender_format (cairo_surface_t *surface); 59 | 60 | CAIRO_END_DECLS 61 | 62 | #else /* CAIRO_HAS_XLIB_XRENDER_SURFACE */ 63 | # error Cairo was not compiled with support for the xlib XRender backend 64 | #endif /* CAIRO_HAS_XLIB_XRENDER_SURFACE */ 65 | 66 | #endif /* CAIRO_XLIB_XRENDER_H */ 67 | -------------------------------------------------------------------------------- /include/cairo-xlib.h: -------------------------------------------------------------------------------- 1 | /* cairo - a vector graphics library with display and print output 2 | * 3 | * Copyright © 2002 University of Southern California 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it either under the terms of the GNU Lesser General Public 7 | * License version 2.1 as published by the Free Software Foundation 8 | * (the "LGPL") or, at your option, under the terms of the Mozilla 9 | * Public License Version 1.1 (the "MPL"). If you do not alter this 10 | * notice, a recipient may use your version of this file under either 11 | * the MPL or the LGPL. 12 | * 13 | * You should have received a copy of the LGPL along with this library 14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA 16 | * You should have received a copy of the MPL along with this library 17 | * in the file COPYING-MPL-1.1 18 | * 19 | * The contents of this file are subject to the Mozilla Public License 20 | * Version 1.1 (the "License"); you may not use this file except in 21 | * compliance with the License. You may obtain a copy of the License at 22 | * http://www.mozilla.org/MPL/ 23 | * 24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for 26 | * the specific language governing rights and limitations. 27 | * 28 | * The Original Code is the cairo graphics library. 29 | * 30 | * The Initial Developer of the Original Code is University of Southern 31 | * California. 32 | * 33 | * Contributor(s): 34 | * Carl D. Worth 35 | */ 36 | 37 | #ifndef CAIRO_XLIB_H 38 | #define CAIRO_XLIB_H 39 | 40 | #include "cairo.h" 41 | 42 | #if CAIRO_HAS_XLIB_SURFACE 43 | 44 | #include 45 | 46 | CAIRO_BEGIN_DECLS 47 | 48 | cairo_public cairo_surface_t * 49 | cairo_xlib_surface_create (Display *dpy, 50 | Drawable drawable, 51 | Visual *visual, 52 | int width, 53 | int height); 54 | 55 | cairo_public cairo_surface_t * 56 | cairo_xlib_surface_create_for_bitmap (Display *dpy, 57 | Pixmap bitmap, 58 | Screen *screen, 59 | int width, 60 | int height); 61 | 62 | cairo_public void 63 | cairo_xlib_surface_set_size (cairo_surface_t *surface, 64 | int width, 65 | int height); 66 | 67 | cairo_public void 68 | cairo_xlib_surface_set_drawable (cairo_surface_t *surface, 69 | Drawable drawable, 70 | int width, 71 | int height); 72 | 73 | cairo_public Display * 74 | cairo_xlib_surface_get_display (cairo_surface_t *surface); 75 | 76 | cairo_public Drawable 77 | cairo_xlib_surface_get_drawable (cairo_surface_t *surface); 78 | 79 | cairo_public Screen * 80 | cairo_xlib_surface_get_screen (cairo_surface_t *surface); 81 | 82 | cairo_public Visual * 83 | cairo_xlib_surface_get_visual (cairo_surface_t *surface); 84 | 85 | cairo_public int 86 | cairo_xlib_surface_get_depth (cairo_surface_t *surface); 87 | 88 | cairo_public int 89 | cairo_xlib_surface_get_width (cairo_surface_t *surface); 90 | 91 | cairo_public int 92 | cairo_xlib_surface_get_height (cairo_surface_t *surface); 93 | 94 | /* debug interface */ 95 | 96 | cairo_public void 97 | cairo_xlib_device_debug_cap_xrender_version (cairo_device_t *device, 98 | int major_version, 99 | int minor_version); 100 | 101 | /* 102 | * @precision: -1 implies automatically choose based on antialiasing mode, 103 | * any other value overrides and sets the corresponding PolyMode. 104 | */ 105 | cairo_public void 106 | cairo_xlib_device_debug_set_precision (cairo_device_t *device, 107 | int precision); 108 | 109 | cairo_public int 110 | cairo_xlib_device_debug_get_precision (cairo_device_t *device); 111 | 112 | CAIRO_END_DECLS 113 | 114 | #else /* CAIRO_HAS_XLIB_SURFACE */ 115 | # error Cairo was not compiled with support for the xlib backend 116 | #endif /* CAIRO_HAS_XLIB_SURFACE */ 117 | 118 | #endif /* CAIRO_XLIB_H */ 119 | -------------------------------------------------------------------------------- /types.go: -------------------------------------------------------------------------------- 1 | // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. 2 | 3 | // WARNING: This file has automatically been generated on Thu, 11 Jan 2018 16:22:52 MSK. 4 | // By https://git.io/c-for-go. DO NOT EDIT. 5 | 6 | package cairo 7 | 8 | /* 9 | #include "include/cairo.h" 10 | #include 11 | #include "cgo_helpers.h" 12 | */ 13 | import "C" 14 | import "unsafe" 15 | 16 | // Bool type as declared in include/cairo.h:107 17 | type Bool int32 18 | 19 | // Cairo as declared in include/cairo.h:124 20 | type Cairo C.cairo_t 21 | 22 | // Surface as declared in include/cairo.h:153 23 | type Surface C.cairo_surface_t 24 | 25 | // Device as declared in include/cairo.h:171 26 | type Device C.cairo_device_t 27 | 28 | // Matrix as declared in include/cairo.h:196 29 | type Matrix struct { 30 | Xx float64 31 | Yx float64 32 | Xy float64 33 | Yy float64 34 | X0 float64 35 | Y0 float64 36 | ref6fd9c783 *C.cairo_matrix_t 37 | allocs6fd9c783 interface{} 38 | } 39 | 40 | // Pattern as declared in include/cairo.h:220 41 | type Pattern C.cairo_pattern_t 42 | 43 | // DestroyFunc type as declared in include/cairo.h:232 44 | type DestroyFunc func(data unsafe.Pointer) 45 | 46 | // UserDataKey as declared in include/cairo.h:248 47 | type UserDataKey struct { 48 | Unused int32 49 | refb2afcf30 *C.cairo_user_data_key_t 50 | allocsb2afcf30 interface{} 51 | } 52 | 53 | // WriteFunc type as declared in include/cairo.h:445 54 | type WriteFunc func(closure unsafe.Pointer, data string, length uint32) Status 55 | 56 | // ReadFunc type as declared in include/cairo.h:467 57 | type ReadFunc func(closure unsafe.Pointer, data *byte, length uint32) Status 58 | 59 | // RectangleInt as declared in include/cairo.h:486 60 | type RectangleInt struct { 61 | X int32 62 | Y int32 63 | Width int32 64 | Height int32 65 | ref182a0d2b *C.cairo_rectangle_int_t 66 | allocs182a0d2b interface{} 67 | } 68 | 69 | // Rectangle as declared in include/cairo.h:1004 70 | type Rectangle struct { 71 | X float64 72 | Y float64 73 | Width float64 74 | Height float64 75 | ref9b663fb6 *C.cairo_rectangle_t 76 | allocs9b663fb6 interface{} 77 | } 78 | 79 | // RectangleList as declared in include/cairo.h:1021 80 | type RectangleList struct { 81 | Status Status 82 | Rectangles []Rectangle 83 | NumRectangles int32 84 | ref149ca897 *C.cairo_rectangle_list_t 85 | allocs149ca897 interface{} 86 | } 87 | 88 | // ScaledFont as declared in include/cairo.h:1059 89 | type ScaledFont C.cairo_scaled_font_t 90 | 91 | // FontFace as declared in include/cairo.h:1080 92 | type FontFace C.cairo_font_face_t 93 | 94 | // Glyph as declared in include/cairo.h:1112 95 | type Glyph struct { 96 | Index uint 97 | X float64 98 | Y float64 99 | ref5b16733c *C.cairo_glyph_t 100 | allocs5b16733c interface{} 101 | } 102 | 103 | // TextCluster as declared in include/cairo.h:1143 104 | type TextCluster struct { 105 | NumBytes int32 106 | NumGlyphs int32 107 | refd989a040 *C.cairo_text_cluster_t 108 | allocsd989a040 interface{} 109 | } 110 | 111 | // TextExtents as declared in include/cairo.h:1200 112 | type TextExtents struct { 113 | XBearing float64 114 | YBearing float64 115 | Width float64 116 | Height float64 117 | XAdvance float64 118 | YAdvance float64 119 | refe2add9c7 *C.cairo_text_extents_t 120 | allocse2add9c7 interface{} 121 | } 122 | 123 | // FontExtents as declared in include/cairo.h:1251 124 | type FontExtents struct { 125 | Ascent float64 126 | Descent float64 127 | Height float64 128 | MaxXAdvance float64 129 | MaxYAdvance float64 130 | refbc0b0f3c *C.cairo_font_extents_t 131 | allocsbc0b0f3c interface{} 132 | } 133 | 134 | // FontOptions as declared in include/cairo.h:1385 135 | type FontOptions C.cairo_font_options_t 136 | 137 | // UserScaledFontInitFunc type as declared in include/cairo.h:1729 138 | type UserScaledFontInitFunc func(scaledFont *ScaledFont, cr *Cairo, extents *FontExtents) Status 139 | 140 | // UserScaledFontRenderGlyphFunc type as declared in include/cairo.h:1776 141 | type UserScaledFontRenderGlyphFunc func(scaledFont *ScaledFont, glyph uint, cr *Cairo, extents *TextExtents) Status 142 | 143 | // UserScaledFontTextToGlyphsFunc type as declared in include/cairo.h:1846 144 | type UserScaledFontTextToGlyphsFunc func(scaledFont *ScaledFont, utf8 string, utf8Len int32, glyphs []*Glyph, numGlyphs *int32, clusters []*TextCluster, numClusters *int32, clusterFlags []TextClusterFlags) Status 145 | 146 | // UserScaledFontUnicodeToGlyphFunc type as declared in include/cairo.h:1893 147 | type UserScaledFontUnicodeToGlyphFunc func(scaledFont *ScaledFont, unicode uint, glyphIndex *uint) Status 148 | 149 | // PathData as declared in include/cairo.h:2068 150 | const sizeofPathData = unsafe.Sizeof(C.cairo_path_data_t{}) 151 | 152 | type PathData [sizeofPathData]byte 153 | 154 | // Path as declared in include/cairo.h:2104 155 | type Path struct { 156 | Status Status 157 | Data []PathData 158 | NumData int32 159 | reffd10d41e *C.cairo_path_t 160 | allocsfd10d41e interface{} 161 | } 162 | 163 | // SurfaceObserverCallback type as declared in include/cairo.h:2258 164 | type SurfaceObserverCallback func(observer *Surface, target *Surface, data unsafe.Pointer) 165 | 166 | // RasterSourceAcquireFunc type as declared in include/cairo.h:2629 167 | type RasterSourceAcquireFunc func(pattern *Pattern, callbackData unsafe.Pointer, target *Surface, extents *RectangleInt) *Surface 168 | 169 | // RasterSourceReleaseFunc type as declared in include/cairo.h:2649 170 | type RasterSourceReleaseFunc func(pattern *Pattern, callbackData unsafe.Pointer, surface *Surface) 171 | 172 | // RasterSourceSnapshotFunc type as declared in include/cairo.h:2670 173 | type RasterSourceSnapshotFunc func(pattern *Pattern, callbackData unsafe.Pointer) Status 174 | 175 | // RasterSourceCopyFunc type as declared in include/cairo.h:2688 176 | type RasterSourceCopyFunc func(pattern *Pattern, callbackData unsafe.Pointer, other *Pattern) Status 177 | 178 | // RasterSourceFinishFunc type as declared in include/cairo.h:2703 179 | type RasterSourceFinishFunc func(pattern *Pattern, callbackData unsafe.Pointer) 180 | 181 | // Region as declared in include/cairo.h:3079 182 | type Region C.cairo_region_t 183 | --------------------------------------------------------------------------------