1     typealias Color = u32
2     typealias ReleaseContext = MutPtr
3     
4     typealias FuncPtr = fn Unit -> Unit
5     typealias GetProc = fn (ctx : MutPtr) * (name : Ptr<CChar>) -> FuncPtr
6     typealias RenderTargetReleaseProc = fn ReleaseContext -> Unit
7     
8     type ColorSpace "sk_sp<SkColorSpace>" @cpp
9     type Interface "sk_sp<const GrGLInterface>" @cpp
10    type BackendRenderTarget "GrBackendRenderTarget" @cpp
11    type RecordingContext "GrRecordingContext" @cpp
12    type DirectContext "GrDirectContext" @cpp =
13        inherit RecordingContext
14    
15        def flush
16    
17    type SkSp<T> "sk_sp" =
18        def release : MutPtr<T>
19    
20    type FramebufferInfo "GrGLFramebufferInfo" = struct
21        fbo_id "fFBOID" : uint
22        format "fFormat" : uint = 0
23        protected "fProtected" : Protected = Protected/No
24    
25    type Rect "SkRect" = struct
26        left "fLeft" : f32 = 0
27        top "fTop" : f32 = 0
28        right "fRight" : f32 = 0
29        bottom "fBottom" : f32 = 0
30    
31    type Paint "SkPaint" @cpp =
32        def set_color "setColor" (color : Color)
33        def set_stroke_width "setStrokeWidth" (width : f32)
34        def set_anti_alias "setAntiAlias" (aa : bool)
35        def set_stroke_cap "setStrokeCap" (cap : Cap)
36    
37    type Typeface "sk_sp<SkTypeface>" @cpp
38    
39    type Font "SkFont" @cpp =
40        fun new (typeface : mem Typeface)
41        def get_size "getSize" : f32
42        def set_size "setSize" (text_size : f32)
43        def set_subpixel "setSubpixel" (subpixel : bool)
44        def set_edging "setEdging" (edging : FontEdging)
45        def set_hinting "setHinting" (hinting_level : FontHinting)
46        def is_baseline_snap "isBaselineSnap" : bool
47        def set_baseline_snap "setBaselineSnap" (baseline_snap : bool)
48        def measure_text "measureText" (text : Ptr
49                                        byte_length : usize
50                                        encoding : TextEncoding
51                                        bounds : mut ptr Rect
52                                        paint : ptr mem Paint) : f32
53    
54    type Point "SkPoint" = struct
55        x "fX" : f32
56        y "fY" : f32
57    
58    type Span<T> "SkSpan" @cpp =
59        fun new (ptr : MutPtr<T>) (size : usize)
60    
61    type Path "SkPath" @cpp =
62        def add_poly "addPoly" (pts : mem Span<Point>) (close : bool) : Path
63        def rewind : Path
64    
65    type Canvas "SkCanvas" @cpp =
66        def draw_paint "drawPaint" (paint : Paint)
67        def draw_line "drawLine" (x0 : f32) (y0 : f32) (x1 : f32) (y1 : f32)
68                                 (paint : Paint)
69        def draw_rect "drawRect" (rect : ref Rect) (paint : Paint)
70        def draw_path "drawPath" (path : Path) (paint : Paint)
71        def draw_string "drawString" (str : CString
72                                      x : f32
73                                      y : f32
74                                      font : Font
75                                      paint : Paint)
76    
77        def draw_simple_text "drawSimpleText" (text : Ptr
78                                               byte_length : usize
79                                               encoding : TextEncoding
80                                               x : f32
81                                               y : f32
82                                               font : Font
83                                               paint : Paint)
84    
85        def clip_rect "clipRect" (rect : ref Rect) (op : ClipOp)
86        def translate (dx : f32) (dy : f32)
87        def save
88        def restore
89    
90    type Surface "SkSurface" @cpp =
91        def get_canvas "getCanvas" : Canvas
92    
93    type FontScanner "std::unique_ptr<SkFontScanner>" @cpp
94    type FontMgr "sk_sp<SkFontMgr>" @cpp =
95        def make_from_file "makeFromFile" (path : CString) : mem Typeface
96    
97    type FcConfig @cpp
98    
99    type SurfaceProps "SkSurfaceProps" @cpp =
100       fun new (flags : u32) (geometry : PixelGeometry)
101