path.h revision 165cb19abc4279839b0f5f53eb2feac60c2f415e
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 _PATH_H 28#define _PATH_H 29 30#include "VG/openvg.h" 31 32struct path; 33struct polygon; 34struct matrix; 35 36enum fill_rule { 37 ODD_EVEN_FILL, 38 WINDING_FILL 39}; 40 41 42struct path_for_each_data { 43 VGubyte segment; 44 /* all coords are absolute, even if segment is relative */ 45 const VGfloat *coords; 46 VGfloat sx, sy, ox, oy, px, py; 47 void *user_data; 48}; 49 50typedef VGboolean (*path_for_each_cb)(struct path *p, 51 struct path_for_each_data *data); 52 53 54struct path *path_create(VGPathDatatype dt, VGfloat scale, VGfloat bias, 55 VGint segmentCapacityHint, 56 VGint coordCapacityHint, 57 VGbitfield capabilities); 58void path_destroy(struct path *p); 59 60VGbitfield path_capabilities(struct path *p); 61void path_set_capabilities(struct path *p, VGbitfield bf); 62 63void path_append_data(struct path *p, 64 VGint numSegments, 65 const VGubyte * pathSegments, 66 const void * pathData); 67 68void path_append_path(struct path *dst, 69 struct path *src); 70 71VGint path_num_segments(struct path *p); 72 73void path_bounding_rect(struct path *p, float *x, float *y, 74 float *w, float *h); 75float path_length(struct path *p, int start_segment, int num_segments); 76 77void path_set_fill_rule(enum fill_rule fill); 78enum fill_rule path_fill_rule(enum fill_rule fill); 79 80VGboolean path_is_empty(struct path *p); 81 82VGbyte path_datatype_size(struct path *p); 83 84VGPathDatatype path_datatype(struct path *p); 85VGfloat path_scale(struct path *p); 86VGfloat path_bias(struct path *p); 87VGint path_num_coords(struct path *p); 88 89void path_modify_coords(struct path *p, 90 VGint startIndex, 91 VGint numSegments, 92 const void * pathData); 93 94struct path *path_create_stroke(struct path *p, 95 struct matrix *m); 96 97void path_for_each_segment(struct path *path, 98 path_for_each_cb cb, 99 void *user_data); 100 101void path_transform(struct path *dst, struct path *src); 102VGboolean path_interpolate(struct path *dst, 103 struct path *start, struct path *end, 104 VGfloat amount); 105 106void path_clear(struct path *p, VGbitfield capabilities); 107void path_render(struct path *p, VGbitfield paintModes, struct matrix *mat); 108void path_fill(struct path *p, struct matrix *mat); 109void path_stroke(struct path *p, struct matrix *mat); 110 111void path_move_to(struct path *p, float x, float y); 112void path_line_to(struct path *p, float x, float y); 113void path_cubic_to(struct path *p, float px1, float py1, 114 float px2, float py2, 115 float x, float y); 116 117void path_point(struct path *p, VGint startSegment, VGint numSegments, 118 VGfloat distance, VGfloat *point, VGfloat *normal); 119 120 121 122void vg_float_to_datatype(VGPathDatatype datatype, 123 VGubyte *common_data, 124 const VGfloat *data, 125 VGint num_coords); 126#endif 127