Lines Matching refs:paint

197    struct vg_paint *paint = CALLOC_STRUCT(vg_paint);  in paint_create()  local
201 vg_init_object(&paint->base, ctx, VG_OBJECT_PAINT); in paint_create()
202 vg_context_add_object(ctx, &paint->base); in paint_create()
204 paint->type = VG_PAINT_TYPE_COLOR; in paint_create()
205 memcpy(paint->solid.color, default_color, in paint_create()
207 paint->gradient.spread = VG_COLOR_RAMP_SPREAD_PAD; in paint_create()
208 memcpy(paint->gradient.linear.coords, def_ling, in paint_create()
210 memcpy(paint->gradient.radial.vals, def_radg, in paint_create()
213 paint->gradient.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; in paint_create()
214 paint->gradient.sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; in paint_create()
215 paint->gradient.sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST; in paint_create()
216 paint->gradient.sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST; in paint_create()
217 paint->gradient.sampler.normalized_coords = 1; in paint_create()
219 memcpy(&paint->pattern.sampler, in paint_create()
220 &paint->gradient.sampler, in paint_create()
223 return paint; in paint_create()
226 void paint_destroy(struct vg_paint *paint) in paint_destroy() argument
228 struct vg_context *ctx = paint->base.ctx; in paint_destroy()
229 pipe_sampler_view_reference(&paint->gradient.sampler_view, NULL); in paint_destroy()
230 if (paint->pattern.sampler_view) in paint_destroy()
231 pipe_sampler_view_reference(&paint->pattern.sampler_view, NULL); in paint_destroy()
233 vg_context_remove_object(ctx, &paint->base); in paint_destroy()
235 free(paint->gradient.ramp_stopsi); in paint_destroy()
236 free(paint->gradient.ramp_stops); in paint_destroy()
237 FREE(paint); in paint_destroy()
240 void paint_set_color(struct vg_paint *paint, in paint_set_color() argument
243 paint->solid.color[0] = color[0]; in paint_set_color()
244 paint->solid.color[1] = color[1]; in paint_set_color()
245 paint->solid.color[2] = color[2]; in paint_set_color()
246 paint->solid.color[3] = color[3]; in paint_set_color()
248 paint->solid.colori[0] = FLT_TO_INT(color[0]); in paint_set_color()
249 paint->solid.colori[1] = FLT_TO_INT(color[1]); in paint_set_color()
250 paint->solid.colori[2] = FLT_TO_INT(color[2]); in paint_set_color()
251 paint->solid.colori[3] = FLT_TO_INT(color[3]); in paint_set_color()
254 static INLINE void paint_color_buffer(struct vg_paint *paint, void *buffer) in paint_color_buffer() argument
257 memcpy(buffer, paint->solid.color, 4 * sizeof(VGfloat)); in paint_color_buffer()
264 static INLINE void paint_linear_gradient_buffer(struct vg_paint *paint, in paint_linear_gradient_buffer() argument
271 map[0] = paint->gradient.linear.coords[2] - paint->gradient.linear.coords[0]; in paint_linear_gradient_buffer()
272 map[1] = paint->gradient.linear.coords[3] - paint->gradient.linear.coords[1]; in paint_linear_gradient_buffer()
286 matrix_translate(&mat, -paint->gradient.linear.coords[0], -paint->gradient.linear.coords[1]); in paint_linear_gradient_buffer()
300 static INLINE void paint_radial_gradient_buffer(struct vg_paint *paint, in paint_radial_gradient_buffer() argument
304 const VGfloat *center = &paint->gradient.radial.vals[0]; in paint_radial_gradient_buffer()
305 const VGfloat *focal = &paint->gradient.radial.vals[2]; in paint_radial_gradient_buffer()
306 VGfloat rr = paint->gradient.radial.vals[4]; in paint_radial_gradient_buffer()
356 static INLINE void paint_pattern_buffer(struct vg_paint *paint, in paint_pattern_buffer() argument
361 memcpy(map, paint->solid.color, 4 * sizeof(VGfloat)); in paint_pattern_buffer()
365 map[6] = paint->pattern.sampler_view->texture->width0; in paint_pattern_buffer()
366 map[7] = paint->pattern.sampler_view->texture->height0; in paint_pattern_buffer()
378 void paint_set_type(struct vg_paint *paint, VGPaintType type) in paint_set_type() argument
380 paint->type = type; in paint_set_type()
383 void paint_set_ramp_stops(struct vg_paint *paint, const VGfloat *stops, in paint_set_ramp_stops() argument
392 paint->gradient.num_stops = num; in paint_set_ramp_stops()
394 free(paint->gradient.ramp_stops); in paint_set_ramp_stops()
395 paint->gradient.ramp_stops = malloc(sizeof(VGfloat)*num); in paint_set_ramp_stops()
396 memcpy(paint->gradient.ramp_stops, stops, sizeof(VGfloat)*num); in paint_set_ramp_stops()
418 create_gradient_data(stops, num / 5, paint->gradient.color_data, in paint_set_ramp_stops()
421 if (paint->gradient.sampler_view) { in paint_set_ramp_stops()
422 pipe_sampler_view_reference(&paint->gradient.sampler_view, NULL); in paint_set_ramp_stops()
423 paint->gradient.sampler_view = NULL; in paint_set_ramp_stops()
426 paint->gradient.sampler_view = create_gradient_sampler_view(paint); in paint_set_ramp_stops()
449 void paint_set_linear_gradient(struct vg_paint *paint, in paint_set_linear_gradient() argument
452 memcpy(paint->gradient.linear.coords, coords, sizeof(VGfloat) * 4); in paint_set_linear_gradient()
455 void paint_set_spread_mode(struct vg_paint *paint, in paint_set_spread_mode() argument
458 paint->gradient.spread = mode; in paint_set_spread_mode()
461 paint->gradient.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; in paint_set_spread_mode()
464 paint->gradient.sampler.wrap_s = PIPE_TEX_WRAP_REPEAT; in paint_set_spread_mode()
467 paint->gradient.sampler.wrap_s = PIPE_TEX_WRAP_MIRROR_REPEAT; in paint_set_spread_mode()
472 VGColorRampSpreadMode paint_spread_mode(struct vg_paint *paint) in paint_spread_mode() argument
474 return paint->gradient.spread; in paint_spread_mode()
477 void paint_set_radial_gradient(struct vg_paint *paint, in paint_set_radial_gradient() argument
480 memcpy(paint->gradient.radial.vals, values, sizeof(VGfloat) * 5); in paint_set_radial_gradient()
483 void paint_set_pattern(struct vg_paint *paint, in paint_set_pattern() argument
486 if (paint->pattern.sampler_view) in paint_set_pattern()
487 pipe_sampler_view_reference(&paint->pattern.sampler_view, NULL); in paint_set_pattern()
489 paint->pattern.sampler_view = NULL; in paint_set_pattern()
490 pipe_sampler_view_reference(&paint->pattern.sampler_view, in paint_set_pattern()
494 void paint_set_pattern_tiling(struct vg_paint *paint, in paint_set_pattern_tiling() argument
497 paint->pattern.tiling_mode = mode; in paint_set_pattern_tiling()
501 paint->pattern.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_BORDER; in paint_set_pattern_tiling()
502 paint->pattern.sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_BORDER; in paint_set_pattern_tiling()
505 paint->pattern.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; in paint_set_pattern_tiling()
506 paint->pattern.sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; in paint_set_pattern_tiling()
509 paint->pattern.sampler.wrap_s = PIPE_TEX_WRAP_REPEAT; in paint_set_pattern_tiling()
510 paint->pattern.sampler.wrap_t = PIPE_TEX_WRAP_REPEAT; in paint_set_pattern_tiling()
513 paint->pattern.sampler.wrap_s = PIPE_TEX_WRAP_MIRROR_REPEAT; in paint_set_pattern_tiling()
514 paint->pattern.sampler.wrap_t = PIPE_TEX_WRAP_MIRROR_REPEAT; in paint_set_pattern_tiling()
521 void paint_get_color(struct vg_paint *paint, in paint_get_color() argument
524 color[0] = paint->solid.color[0]; in paint_get_color()
525 color[1] = paint->solid.color[1]; in paint_get_color()
526 color[2] = paint->solid.color[2]; in paint_get_color()
527 color[3] = paint->solid.color[3]; in paint_get_color()
530 void paint_ramp_stops(struct vg_paint *paint, VGfloat *stops, in paint_ramp_stops() argument
533 memcpy(stops, paint->gradient.ramp_stops, sizeof(VGfloat)*num); in paint_ramp_stops()
536 void paint_linear_gradient(struct vg_paint *paint, in paint_linear_gradient() argument
539 memcpy(coords, paint->gradient.linear.coords, sizeof(VGfloat)*4); in paint_linear_gradient()
542 void paint_radial_gradient(struct vg_paint *paint, in paint_radial_gradient() argument
545 memcpy(coords, paint->gradient.radial.vals, sizeof(VGfloat)*5); in paint_radial_gradient()
548 int paint_num_ramp_stops(struct vg_paint *paint) in paint_num_ramp_stops() argument
550 return paint->gradient.num_stops; in paint_num_ramp_stops()
553 VGPaintType paint_type(struct vg_paint *paint) in paint_type() argument
555 return paint->type; in paint_type()
558 void paint_set_coloriv(struct vg_paint *paint, in paint_set_coloriv() argument
561 paint->solid.color[0] = color[0]; in paint_set_coloriv()
562 paint->solid.color[1] = color[1]; in paint_set_coloriv()
563 paint->solid.color[2] = color[2]; in paint_set_coloriv()
564 paint->solid.color[3] = color[3]; in paint_set_coloriv()
566 paint->solid.colori[0] = color[0]; in paint_set_coloriv()
567 paint->solid.colori[1] = color[1]; in paint_set_coloriv()
568 paint->solid.colori[2] = color[2]; in paint_set_coloriv()
569 paint->solid.colori[3] = color[3]; in paint_set_coloriv()
572 void paint_get_coloriv(struct vg_paint *paint, in paint_get_coloriv() argument
575 color[0] = paint->solid.colori[0]; in paint_get_coloriv()
576 color[1] = paint->solid.colori[1]; in paint_get_coloriv()
577 color[2] = paint->solid.colori[2]; in paint_get_coloriv()
578 color[3] = paint->solid.colori[3]; in paint_get_coloriv()
581 void paint_set_color_ramp_premultiplied(struct vg_paint *paint, in paint_set_color_ramp_premultiplied() argument
584 paint->gradient.color_ramps_premultiplied = set; in paint_set_color_ramp_premultiplied()
587 VGboolean paint_color_ramp_premultiplied(struct vg_paint *paint) in paint_color_ramp_premultiplied() argument
589 return paint->gradient.color_ramps_premultiplied; in paint_color_ramp_premultiplied()
592 void paint_set_ramp_stopsi(struct vg_paint *paint, const VGint *stops, in paint_set_ramp_stopsi() argument
596 free(paint->gradient.ramp_stopsi); in paint_set_ramp_stopsi()
597 paint->gradient.ramp_stopsi = malloc(sizeof(VGint)*num); in paint_set_ramp_stopsi()
598 memcpy(paint->gradient.ramp_stopsi, stops, sizeof(VGint)*num); in paint_set_ramp_stopsi()
602 void paint_ramp_stopsi(struct vg_paint *paint, VGint *stops, in paint_ramp_stopsi() argument
605 memcpy(stops, paint->gradient.ramp_stopsi, sizeof(VGint)*num); in paint_ramp_stopsi()
608 void paint_set_linear_gradienti(struct vg_paint *paint, in paint_set_linear_gradienti() argument
611 memcpy(paint->gradient.linear.coordsi, coords, sizeof(VGint) * 4); in paint_set_linear_gradienti()
614 void paint_linear_gradienti(struct vg_paint *paint, in paint_linear_gradienti() argument
617 memcpy(coords, paint->gradient.linear.coordsi, sizeof(VGint)*4); in paint_linear_gradienti()
620 void paint_set_radial_gradienti(struct vg_paint *paint, in paint_set_radial_gradienti() argument
623 memcpy(paint->gradient.radial.valsi, values, sizeof(VGint) * 5); in paint_set_radial_gradienti()
626 void paint_radial_gradienti(struct vg_paint *paint, in paint_radial_gradienti() argument
629 memcpy(coords, paint->gradient.radial.valsi, sizeof(VGint)*5); in paint_radial_gradienti()
632 VGTilingMode paint_pattern_tiling(struct vg_paint *paint) in paint_pattern_tiling() argument
634 return paint->pattern.tiling_mode; in paint_pattern_tiling()
637 VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **samplers, in paint_bind_samplers() argument
642 switch(paint->type) { in paint_bind_samplers()
645 if (paint->gradient.sampler_view) { in paint_bind_samplers()
646 paint->gradient.sampler.min_img_filter = image_sampler_filter(ctx); in paint_bind_samplers()
647 paint->gradient.sampler.mag_img_filter = image_sampler_filter(ctx); in paint_bind_samplers()
648 samplers[0] = &paint->gradient.sampler; in paint_bind_samplers()
649 sampler_views[0] = paint->gradient.sampler_view; in paint_bind_samplers()
655 memcpy(paint->pattern.sampler.border_color.f, in paint_bind_samplers()
658 paint->pattern.sampler.min_img_filter = image_sampler_filter(ctx); in paint_bind_samplers()
659 paint->pattern.sampler.mag_img_filter = image_sampler_filter(ctx); in paint_bind_samplers()
660 samplers[0] = &paint->pattern.sampler; in paint_bind_samplers()
661 sampler_views[0] = paint->pattern.sampler_view; in paint_bind_samplers()
671 void paint_resolve_type(struct vg_paint *paint) in paint_resolve_type() argument
673 if (paint->type == VG_PAINT_TYPE_PATTERN && in paint_resolve_type()
674 !paint->pattern.sampler_view) { in paint_resolve_type()
675 paint->type = VG_PAINT_TYPE_COLOR; in paint_resolve_type()
679 VGboolean paint_is_degenerate(struct vg_paint *paint) in paint_is_degenerate() argument
685 switch (paint->type) { in paint_is_degenerate()
687 vals = paint->gradient.linear.coords; in paint_is_degenerate()
693 vals = paint->gradient.radial.vals; in paint_is_degenerate()
707 VGint paint_constant_buffer_size(struct vg_paint *paint) in paint_constant_buffer_size() argument
709 switch(paint->type) { in paint_constant_buffer_size()
723 debug_printf("Uknown paint type: %d\n", paint->type); in paint_constant_buffer_size()
729 void paint_fill_constant_buffer(struct vg_paint *paint, in paint_fill_constant_buffer() argument
733 switch(paint->type) { in paint_fill_constant_buffer()
735 paint_color_buffer(paint, buffer); in paint_fill_constant_buffer()
738 paint_linear_gradient_buffer(paint, mat, buffer); in paint_fill_constant_buffer()
741 paint_radial_gradient_buffer(paint, mat, buffer); in paint_fill_constant_buffer()
744 paint_pattern_buffer(paint, mat, buffer); in paint_fill_constant_buffer()
752 VGboolean paint_is_opaque(struct vg_paint *paint) in paint_is_opaque() argument
755 return (paint->type == VG_PAINT_TYPE_COLOR && in paint_is_opaque()
756 floatsEqual(paint->solid.color[3], 1.0f)); in paint_is_opaque()