Lines Matching refs:stroker
522 static INLINE enum line_join_mode stroker_join_mode(struct stroker *s) in stroker_join_mode()
536 static INLINE enum line_join_mode stroker_cap_mode(struct stroker *s) in stroker_cap_mode()
550 void stroker_emit_move_to(struct stroker *stroker, VGfloat x, VGfloat y) in stroker_emit_move_to() argument
557 stroker->back2_x = stroker->back1_x; in stroker_emit_move_to()
558 stroker->back2_y = stroker->back1_y; in stroker_emit_move_to()
559 stroker->back1_x = x; in stroker_emit_move_to()
560 stroker->back1_y = y; in stroker_emit_move_to()
562 path_append_data(stroker->path, in stroker_emit_move_to()
567 void stroker_emit_line_to(struct stroker *stroker, VGfloat x, VGfloat y) in stroker_emit_line_to() argument
574 stroker->back2_x = stroker->back1_x; in stroker_emit_line_to()
575 stroker->back2_y = stroker->back1_y; in stroker_emit_line_to()
576 stroker->back1_x = x; in stroker_emit_line_to()
577 stroker->back1_y = y; in stroker_emit_line_to()
578 path_append_data(stroker->path, in stroker_emit_line_to()
583 void stroker_emit_curve_to(struct stroker *stroker, VGfloat px1, VGfloat py1, in stroker_emit_curve_to() argument
596 stroker->back2_x = stroker->back1_x; in stroker_emit_curve_to()
597 stroker->back2_y = stroker->back1_y; in stroker_emit_curve_to()
599 stroker->back2_x = px1; in stroker_emit_curve_to()
600 stroker->back2_y = py1; in stroker_emit_curve_to()
603 stroker->back2_x = px2; in stroker_emit_curve_to()
604 stroker->back2_y = py2; in stroker_emit_curve_to()
606 stroker->back1_x = x; in stroker_emit_curve_to()
607 stroker->back1_y = y; in stroker_emit_curve_to()
609 path_append_data(stroker->path, in stroker_emit_curve_to()
614 static INLINE void create_round_join(struct stroker *stroker, in create_round_join() argument
628 arc_stroker_emit(&arc, stroker, &matrix); in create_round_join()
632 static void create_joins(struct stroker *stroker, in create_joins() argument
642 if (floatsEqual(stroker->back1_x, next_line[0]) && in create_joins()
643 floatsEqual(stroker->back1_y, next_line[1])) in create_joins()
647 stroker_emit_line_to(stroker, next_line[0], next_line[1]); in create_joins()
649 VGfloat prev_line[] = {stroker->back2_x, stroker->back2_y, in create_joins()
650 stroker->back1_x, stroker->back1_y}; in create_joins()
656 VGfloat offset = stroker->stroke_width / 2; in create_joins()
672 stroker_emit_line_to(stroker, l1[2], l1[3]); in create_joins()
673 stroker_emit_line_to(stroker, l2[2], l2[3]); in create_joins()
674 stroker_emit_line_to(stroker, l2[0], l2[1]); in create_joins()
676 VGfloat offset = stroker->stroke_width / 2; in create_joins()
683 stroker_emit_line_to(stroker, next_line[0], next_line[1]); in create_joins()
686 create_round_join(stroker, prev_line[2], prev_line[3], in create_joins()
690 stroker_emit_line_to(stroker, next_line[0], next_line[1]); in create_joins()
692 VGfloat offset = stroker->stroke_width / 2; in create_joins()
705 stroker_emit_curve_to(stroker, l1[2], l1[3], in create_joins()
716 stroker_emit_curve_to(stroker, in create_joins()
721 VGfloat miter_line[4] = {stroker->back1_x, stroker->back1_y, in create_joins()
723 VGfloat sl = (stroker->stroke_width * stroker->miter_limit); in create_joins()
734 stroker_emit_line_to(stroker, next_line[0], next_line[1]); in create_joins()
739 stroker_emit_line_to(stroker, next_line[0], next_line[1]); in create_joins()
741 stroker_emit_line_to(stroker, isect[0], isect[1]); in create_joins()
742 stroker_emit_line_to(stroker, next_line[0], next_line[1]); in create_joins()
750 static void stroker_add_segment(struct stroker *stroker, in stroker_add_segment() argument
756 if (stroker->segments->num_elements && in stroker_add_segment()
757 stroker->last_cmd == cmd) { in stroker_add_segment()
758 VGfloat *data = stroker->control_points->data; in stroker_add_segment()
759 data += stroker->control_points->num_elements; in stroker_add_segment()
784 } else if (stroker->last_cmd == VG_CUBIC_TO_ABS && in stroker_add_segment()
786 VGfloat *data = stroker->control_points->data; in stroker_add_segment()
787 data += stroker->control_points->num_elements; in stroker_add_segment()
793 stroker->last_cmd = cmd; in stroker_add_segment()
794 array_append_data(stroker->segments, &cmd, 1); in stroker_add_segment()
795 array_append_data(stroker->control_points, coords, num_coords); in stroker_add_segment()
798 void stroker_move_to(struct stroker *stroker, VGfloat x, VGfloat y) in stroker_move_to() argument
805 if (stroker->segments->num_elements > 0) in stroker_move_to()
806 stroker->process_subpath(stroker); in stroker_move_to()
808 array_reset(stroker->segments); in stroker_move_to()
809 array_reset(stroker->control_points); in stroker_move_to()
811 stroker_add_segment(stroker, VG_MOVE_TO_ABS, coords, 2); in stroker_move_to()
814 void stroker_line_to(struct stroker *stroker, VGfloat x, VGfloat y) in stroker_line_to() argument
821 if (!stroker->segments->num_elements) in stroker_line_to()
822 stroker_add_segment(stroker, VG_MOVE_TO_ABS, zero_coords, 2); in stroker_line_to()
824 stroker_add_segment(stroker, VG_LINE_TO_ABS, coords, 2); in stroker_line_to()
827 void stroker_curve_to(struct stroker *stroker, VGfloat px1, VGfloat py1, in stroker_curve_to() argument
838 if (!stroker->segments->num_elements) in stroker_curve_to()
839 stroker_add_segment(stroker, VG_MOVE_TO_ABS, zero_coords, 2); in stroker_curve_to()
841 stroker_add_segment(stroker, VG_CUBIC_TO_ABS, coords, 6); in stroker_curve_to()
869 struct stroker *stroker, in vg_stroke_outline() argument
882 stroker_emit_move_to(stroker, 0.f, 0.f); in vg_stroke_outline()
896 offset = stroker->stroke_width / 2; in vg_stroke_outline()
926 create_joins(stroker, prev[0], prev[1], line, in vg_stroke_outline()
927 stroker_cap_mode(stroker)); in vg_stroke_outline()
929 stroker_emit_move_to(stroker, line[0], line[1]); in vg_stroke_outline()
934 create_joins(stroker, prev[0], prev[1], line, in vg_stroke_outline()
935 stroker_join_mode(stroker)); in vg_stroke_outline()
939 stroker_emit_line_to(stroker, line[2], line[3]); in vg_stroke_outline()
975 create_joins(stroker, prev[0], prev[1], tangent, in vg_stroke_outline()
976 stroker_cap_mode(stroker)); in vg_stroke_outline()
978 stroker_emit_move_to(stroker, pt[0], pt[1]); in vg_stroke_outline()
986 create_joins(stroker, prev[0], prev[1], tangent, in vg_stroke_outline()
987 stroker_join_mode(stroker)); in vg_stroke_outline()
993 stroker_emit_curve_to(stroker, in vg_stroke_outline()
1011 create_joins(stroker, prev[0], prev[1], start_tangent, in vg_stroke_outline()
1012 stroker_join_mode(stroker)); in vg_stroke_outline()
1023 static void stroker_process_subpath(struct stroker *stroker) in stroker_process_subpath() argument
1029 debug_assert(stroker->segments->num_elements > 0); in stroker_process_subpath()
1036 stroke_forward_iterator(&fwit, stroker->segments, in stroker_process_subpath()
1037 stroker->control_points); in stroker_process_subpath()
1038 stroke_backward_iterator(&bwit, stroker->segments, in stroker_process_subpath()
1039 stroker->control_points); in stroker_process_subpath()
1043 fwclosed = vg_stroke_outline(&fwit, stroker, VG_FALSE, fw_start_tangent); in stroker_process_subpath()
1044 bwclosed = vg_stroke_outline(&bwit, stroker, !fwclosed, bw_start_tangent); in stroker_process_subpath()
1047 create_joins(stroker, in stroker_process_subpath()
1049 stroker_cap_mode(stroker)); in stroker_process_subpath()
1054 if (stroker->segments->num_elements <= 3) { in stroker_process_subpath()
1059 stroke_forward_iterator(it, stroker->segments, in stroker_process_subpath()
1060 stroker->control_points); in stroker_process_subpath()
1079 if (stroker->cap_style == VG_CAP_SQUARE) { in stroker_process_subpath()
1080 VGfloat offset = stroker->stroke_width / 2; in stroker_process_subpath()
1081 stroker_emit_move_to(stroker, data[0] - offset, in stroker_process_subpath()
1083 stroker_emit_line_to(stroker, data[0] + offset, in stroker_process_subpath()
1085 stroker_emit_line_to(stroker, data[0] + offset, in stroker_process_subpath()
1087 stroker_emit_line_to(stroker, data[0] - offset, in stroker_process_subpath()
1089 stroker_emit_line_to(stroker, data[0] - offset, in stroker_process_subpath()
1091 } else if (stroker->cap_style == VG_CAP_ROUND) { in stroker_process_subpath()
1092 VGfloat offset = stroker->stroke_width / 2; in stroker_process_subpath()
1099 stroker_emit_move_to(stroker, cx + offset, cy); in stroker_process_subpath()
1104 arc_stroker_emit(&arc, stroker, &matrix); in stroker_process_subpath()
1109 arc_stroker_emit(&arc, stroker, &matrix); in stroker_process_subpath()
1116 static INLINE VGfloat dash_pattern(struct dash_stroker *stroker, in dash_pattern() argument
1119 if (stroker->dash_pattern[idx] < 0) in dash_pattern()
1121 return stroker->dash_pattern[idx]; in dash_pattern()
1124 static void dash_stroker_process_subpath(struct stroker *str) in dash_stroker_process_subpath()
1126 struct dash_stroker *stroker = (struct dash_stroker *)str; in dash_stroker_process_subpath() local
1132 VGfloat doffset = stroker->dash_phase; in dash_stroker_process_subpath()
1143 stroke_flat_iterator(&it, stroker->base.segments, in dash_stroker_process_subpath()
1144 stroker->base.control_points); in dash_stroker_process_subpath()
1150 debug_assert(stroker->dash_pattern_num > 0); in dash_stroker_process_subpath()
1152 for (i = 0; i < stroker->dash_pattern_num; ++i) { in dash_stroker_process_subpath()
1153 sum_length += dash_pattern(stroker, i); in dash_stroker_process_subpath()
1162 while (!floatIsZero(doffset) && doffset >= dash_pattern(stroker, idash)) { in dash_stroker_process_subpath()
1163 doffset -= dash_pattern(stroker, idash); in dash_stroker_process_subpath()
1164 idash = (idash + 1) % stroker->dash_pattern_num; in dash_stroker_process_subpath()
1192 VGfloat dpos = pos + dash_pattern(stroker, idash) - doffset - estart; in dash_stroker_process_subpath()
1197 doffset = dash_pattern(stroker, idash) - (dpos - elen); in dash_stroker_process_subpath()
1215 stroker_move_to(&stroker->stroker, move_to_pos[0], move_to_pos[1]); in dash_stroker_process_subpath()
1218 stroker_line_to(&stroker->stroker, line_to_pos[0], line_to_pos[1]); in dash_stroker_process_subpath()
1224 idash = (idash + idash_incr) % stroker->dash_pattern_num; in dash_stroker_process_subpath()
1237 stroker->base.path = stroker->stroker.path; in dash_stroker_process_subpath()
1240 static void default_begin(struct stroker *stroker) in default_begin() argument
1242 array_reset(stroker->segments); in default_begin()
1243 array_reset(stroker->control_points); in default_begin()
1246 static void default_end(struct stroker *stroker) in default_end() argument
1248 if (stroker->segments->num_elements > 0) in default_end()
1249 stroker->process_subpath(stroker); in default_end()
1253 static void dash_stroker_begin(struct stroker *stroker) in dash_stroker_begin() argument
1256 (struct dash_stroker *)stroker; in dash_stroker_begin()
1258 default_begin(&dasher->stroker); in dash_stroker_begin()
1259 default_begin(stroker); in dash_stroker_begin()
1262 static void dash_stroker_end(struct stroker *stroker) in dash_stroker_end() argument
1265 (struct dash_stroker *)stroker; in dash_stroker_end()
1267 default_end(stroker); in dash_stroker_end()
1268 default_end(&dasher->stroker); in dash_stroker_end()
1271 void stroker_init(struct stroker *stroker, in stroker_init() argument
1274 stroker->stroke_width = state->stroke.line_width.f; in stroker_init()
1275 stroker->miter_limit = state->stroke.miter_limit.f; in stroker_init()
1276 stroker->cap_style = state->stroke.cap_style; in stroker_init()
1277 stroker->join_style = state->stroke.join_style; in stroker_init()
1279 stroker->begin = default_begin; in stroker_init()
1280 stroker->process_subpath = stroker_process_subpath; in stroker_init()
1281 stroker->end = default_end; in stroker_init()
1283 stroker->segments = array_create(sizeof(VGubyte)); in stroker_init()
1284 stroker->control_points = array_create(sizeof(VGfloat)); in stroker_init()
1286 stroker->back1_x = 0; in stroker_init()
1287 stroker->back1_y = 0; in stroker_init()
1288 stroker->back2_x = 0; in stroker_init()
1289 stroker->back2_y = 0; in stroker_init()
1291 stroker->path = path_create(VG_PATH_DATATYPE_F, 1.0f, 0.0f, in stroker_init()
1295 stroker->last_cmd = (VGPathCommand)0; in stroker_init()
1298 void dash_stroker_init(struct stroker *str, in dash_stroker_init()
1301 struct dash_stroker *stroker = (struct dash_stroker *)str; in dash_stroker_init() local
1305 stroker_init(&stroker->stroker, state); in dash_stroker_init()
1312 stroker->dash_pattern[i] = state->stroke.dash_pattern[i].f; in dash_stroker_init()
1313 stroker->dash_pattern_num = real_num; in dash_stroker_init()
1316 stroker->dash_phase = state->stroke.dash_phase.f; in dash_stroker_init()
1317 stroker->dash_phase_reset = state->stroke.dash_phase_reset; in dash_stroker_init()
1319 stroker->base.begin = dash_stroker_begin; in dash_stroker_init()
1320 stroker->base.process_subpath = dash_stroker_process_subpath; in dash_stroker_init()
1321 stroker->base.end = dash_stroker_end; in dash_stroker_init()
1322 path_destroy(stroker->base.path); in dash_stroker_init()
1323 stroker->base.path = NULL; in dash_stroker_init()
1326 void stroker_begin(struct stroker *stroker) in stroker_begin() argument
1328 stroker->begin(stroker); in stroker_begin()
1331 void stroker_end(struct stroker *stroker) in stroker_end() argument
1333 stroker->end(stroker); in stroker_end()
1336 void stroker_cleanup(struct stroker *stroker) in stroker_cleanup() argument
1338 array_destroy(stroker->segments); in stroker_cleanup()
1339 array_destroy(stroker->control_points); in stroker_cleanup()
1342 void dash_stroker_cleanup(struct dash_stroker *stroker) in dash_stroker_cleanup() argument
1347 if (!stroker->base.path) in dash_stroker_cleanup()
1348 path_destroy(stroker->stroker.path); in dash_stroker_cleanup()
1349 stroker_cleanup(&stroker->stroker); in dash_stroker_cleanup()
1350 stroker_cleanup((struct stroker*)stroker); in dash_stroker_cleanup()