• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8syntax = "proto3";
9
10package pvg;
11
12enum ClipVerb {
13    INTERSECT = 0;
14    DIFFERENCE = 1;
15}
16
17message Point {
18    float x = 1;
19    float y = 2;
20}
21
22message Rect {
23    float left = 1;
24    float top = 2;
25    float right = 3;
26    float bottom = 4;
27}
28
29message Color {
30    float r = 1;
31    float g = 2;
32    float b = 3;
33    float a = 4;    // default to 1.0
34}
35
36message Matrix33 {
37    // m11, m22, m33 default to 1.0
38
39    float m11 = 1; float m12 = 2; float m13 = 3;
40    float m21 = 4; float m22 = 5; float m23 = 6;
41    float m31 = 7; float m32 = 8; float m33 = 9;
42}
43
44message ClipArgs {
45    ClipVerb    verb  = 1;
46    bool        is_aliased = 2;
47}
48
49////////////////////////////////////////////////
50
51enum BlendMode {
52    SRC_OVER    = 0;
53    CLEAR       = 1;
54    SRC         = 2;
55    // ...
56}
57
58enum PaintStyle {
59    FILL     = 0;
60    STROKE   = 1;
61    HAIRLINE = 2;
62}
63
64enum FilterQuality {
65    NONE   = 0;
66    LOW    = 1;
67    MEDIUM = 2;
68    HIGH   = 3;
69}
70
71message Paint {
72    PaintStyle      style           = 1;
73    FilterQuality   filter_quality  = 2;
74    BlendMode       blend_mode      = 3;
75    bool            is_aliased      = 4;
76
77    Color  color                    = 5;
78
79    int32  shader                   = 6;
80    int32  color_filter             = 7;
81    int32  mask_filter              = 8;
82    int32  path_filter              = 9;
83    int32  image_filter             = 10;
84}
85
86////////////////////////////////////////////////
87
88enum Hinting {
89    NONE_Hinting    = 0;
90    SLIGHT_Hinting  = 1;
91    NORMAL_Hinting  = 2;
92    FULL_Hinting    = 3;
93}
94
95message Font {
96    int32   typeface = 1;
97    float   size     = 2;
98    float   scale_x  = 3;   // default = 1.0
99    float   skew_x   = 4;
100
101    Hinting Hinting  = 5;
102
103    bool    force_autohinting   = 6;
104    bool    embedded_bitmaps    = 7;
105    bool    subpixel            = 8;
106    bool    linear_metrics      = 9;
107    bool    embolden            = 10;
108}
109
110////////////////////////////////////////////////
111
112enum PathVerb {
113    MOVE  = 0;
114    LINE  = 1;
115    QUAD  = 2;
116    CUBIC = 3;
117    CONIC = 4;
118}
119
120message PathData {
121    repeated PathVerb verbs         = 1;
122    repeated float    points        = 2;    // count must be even, and correspond to verbs
123    repeated float    conic_weights = 3;    // count must be == # conic verbs
124}
125
126message DefinePath {
127    uint32   id   = 1;
128    PathData data = 2;
129}
130
131////////////////////////////////////////////////
132
133message DefineImage {
134    uint32  id           = 1;
135    bytes   encoded_data = 2;
136}
137
138////////////////////////////////////////////////
139
140enum TileMode {
141    CLAMP_TileMode  = 0;
142    REPEAT_TileMode = 1;
143    MIRROR_TileMode = 2;
144    DECAL_TileMode  = 3;
145}
146
147message GradientCommon {
148    repeated Color colors       = 1;
149    repeated float positions    = 2;    // empty or count == colors.count
150    Matrix33       local_matrix = 3;
151    TileMode       tile_mode    = 4;
152}
153
154message LinearGradient {
155    Point          p0     = 1;
156    Point          p1     = 2;
157    GradientCommon common = 3;
158}
159
160message RadialGradient {
161    Point          center = 1;
162    float          radius = 2;
163    GradientCommon common = 3;
164}
165
166message ImageShader {
167    uint32   image_id       = 1;
168    TileMode tile_mode_x    = 2;
169    TileMode tile_mode_y    = 3;
170    Matrix33 local_matrix   = 4;
171}
172
173message DefineShader {
174    uint32  id      = 1;
175    oneof type {
176        Color           color           = 2;
177        LinearGradient  linear_gradient = 3;
178        RadialGradient  radial_gradient = 4;
179        ImageShader     image           = 5;
180    }
181}
182
183////////////////////////////////////////////////
184
185message Save {}
186
187message SaveLayer {
188    Rect    bounds = 1;
189    Paint   paint  = 2;
190    // ...
191}
192
193message Restore {}
194
195message Concat {
196    Matrix33 matrix = 1;
197}
198
199message ClipRect {
200    Rect     rect = 1;
201    ClipArgs args = 2;
202}
203
204message ClipPath {
205    oneof path {
206        uint32   id   = 1;
207        PathData data = 2;
208    }
209    ClipArgs args = 3;
210}
211
212message DrawPaint {
213    Paint   paint = 1;
214}
215
216message DrawRect {
217    Rect    rect    = 1;
218    Paint   paint   = 2;
219}
220
221message DrawOval {
222    Rect    oval    = 1;
223    Paint   paint   = 2;
224}
225
226message DrawPath {
227    oneof path {
228        uint32   id   = 1;
229        PathData data = 2;
230    }
231    Paint paint = 3;
232}
233
234message DrawImage {
235    uint32  id    = 1;
236    Paint   paint = 2;
237}
238
239message DrawText {
240    repeated uint32 glyphs  = 1;    // uint16? bytes?
241    repeated float  pos_x   = 2;    // must match counts with glyphs
242    repeated float  pos_y   = 3;    // must match counts with glyphs OR have 1 entry
243
244    Font            font    = 4;
245    Paint           paint   = 5;
246}
247
248message CanvasMsg {
249    oneof msg {
250        Save      save       = 1;
251        SaveLayer save_layer = 2;
252        Restore   restore    = 3;
253
254        Concat    concat     = 4;
255
256        ClipRect  clip_rect  = 5;
257        ClipPath  clip_path  = 6;
258
259        DrawPaint draw_paint = 7;
260        DrawRect  draw_rect  = 8;
261        DrawOval  draw_oval  = 9;
262        DrawPath  draw_path  = 10;
263        DrawImage draw_image = 11;
264        DrawText  draw_text  = 12;
265
266        DefineImage  def_image    = 13;
267        DefinePath   def_path     = 14;
268        DefineShader def_shader   = 15;
269    }
270}
271