1 /************************************************************************** 2 * 3 * Copyright 2009 VMware, Inc. All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portions 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 * 25 **************************************************************************/ 26 27 #ifndef STROKER_H 28 #define STROKER_H 29 30 #include "VG/openvg.h" 31 #include "api_consts.h" 32 33 struct path; 34 struct vg_state; 35 struct array; 36 37 struct stroker { 38 void (*begin)(struct stroker *stroker); 39 void (*process_subpath)(struct stroker *stroker); 40 void (*end)(struct stroker *stroker); 41 42 struct array *segments; 43 struct array *control_points; 44 struct path *path; 45 46 VGfloat back1_x, back1_y; 47 VGfloat back2_x, back2_y; 48 49 VGfloat stroke_width; 50 VGfloat miter_limit; 51 VGCapStyle cap_style; 52 VGJoinStyle join_style; 53 54 VGPathCommand last_cmd; 55 }; 56 57 struct dash_stroker { 58 struct stroker base; 59 60 struct stroker stroker; 61 62 VGfloat dash_pattern[VEGA_MAX_DASH_COUNT]; 63 VGint dash_pattern_num; 64 VGfloat dash_phase; 65 VGboolean dash_phase_reset; 66 }; 67 68 void stroker_init(struct stroker *stroker, 69 struct vg_state *state); 70 void dash_stroker_init(struct stroker *stroker, 71 struct vg_state *state); 72 void dash_stroker_cleanup(struct dash_stroker *stroker); 73 void stroker_cleanup(struct stroker *stroker); 74 75 void stroker_begin(struct stroker *stroker); 76 void stroker_move_to(struct stroker *stroker, VGfloat x, VGfloat y); 77 void stroker_line_to(struct stroker *stroker, VGfloat x, VGfloat y); 78 void stroker_curve_to(struct stroker *stroker, VGfloat px1, VGfloat py1, 79 VGfloat px2, VGfloat py2, 80 VGfloat x, VGfloat y); 81 void stroker_end(struct stroker *stroker); 82 83 void stroker_emit_move_to(struct stroker *stroker, VGfloat x, VGfloat y); 84 void stroker_emit_line_to(struct stroker *stroker, VGfloat x, VGfloat y); 85 void stroker_emit_curve_to(struct stroker *stroker, VGfloat px1, VGfloat py1, 86 VGfloat px2, VGfloat py2, 87 VGfloat x, VGfloat y); 88 89 #endif 90