1 /**************************************************************************
3 * Copyright 2009 VMware, Inc. All Rights Reserved.
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:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
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.
25 **************************************************************************/
27 #include "VG/openvg.h"
29 #include "vg_context.h"
34 #include "api_consts.h"
37 #include "pipe/p_compiler.h"
38 #include "util/u_pointer.h"
39 #include "util/u_math.h"
43 static INLINE
struct vg_state
*current_state()
45 struct vg_context
*ctx
= vg_current_context();
49 return &ctx
->state
.vg
;
52 static INLINE VGboolean
count_in_bounds(VGParamType type
, VGint count
)
57 if (type
== VG_SCISSOR_RECTS
)
58 return (!(count
% 4) && (count
>= 0 || count
<= VEGA_MAX_SCISSOR_RECTS
* 4));
59 else if (type
== VG_STROKE_DASH_PATTERN
) {
60 return count
<= VEGA_MAX_DASH_COUNT
;
62 VGint real_count
= vgGetVectorSize(type
);
63 return count
== real_count
;
67 void vegaSetf (VGParamType type
, VGfloat value
)
69 struct vg_context
*ctx
= vg_current_context();
70 struct vg_state
*state
= current_state();
71 VGErrorCode error
= VG_NO_ERROR
;
76 case VG_IMAGE_QUALITY
:
77 case VG_RENDERING_QUALITY
:
80 #ifdef OPENVG_VERSION_1_1
81 case VG_COLOR_TRANSFORM
:
83 case VG_STROKE_CAP_STYLE
:
84 case VG_STROKE_JOIN_STYLE
:
85 case VG_STROKE_DASH_PHASE_RESET
:
89 case VG_SCREEN_LAYOUT
:
90 case VG_FILTER_FORMAT_LINEAR
:
91 case VG_FILTER_FORMAT_PREMULTIPLIED
:
92 case VG_FILTER_CHANNEL_MASK
:
94 case VG_MAX_SCISSOR_RECTS
:
95 case VG_MAX_DASH_COUNT
:
96 case VG_MAX_KERNEL_SIZE
:
97 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
98 case VG_MAX_COLOR_RAMP_STOPS
:
99 case VG_MAX_IMAGE_WIDTH
:
100 case VG_MAX_IMAGE_HEIGHT
:
101 case VG_MAX_IMAGE_PIXELS
:
102 case VG_MAX_IMAGE_BYTES
:
103 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
105 vgSeti(type
, floor(value
));
108 case VG_STROKE_LINE_WIDTH
:
109 state
->stroke
.line_width
.f
= value
;
110 state
->stroke
.line_width
.i
= float_to_int_floor(*((VGuint
*)(&value
)));
112 case VG_STROKE_MITER_LIMIT
:
113 state
->stroke
.miter_limit
.f
= value
;
114 state
->stroke
.miter_limit
.i
= float_to_int_floor(*((VGuint
*)(&value
)));
116 case VG_STROKE_DASH_PHASE
:
117 state
->stroke
.dash_phase
.f
= value
;
118 state
->stroke
.dash_phase
.i
= float_to_int_floor(*((VGuint
*)(&value
)));
121 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
124 vg_set_error(ctx
, error
);
127 void vegaSeti (VGParamType type
, VGint value
)
129 struct vg_context
*ctx
= vg_current_context();
130 struct vg_state
*state
= current_state();
131 VGErrorCode error
= VG_NO_ERROR
;
135 if (value
< VG_MATRIX_PATH_USER_TO_SURFACE
||
136 #ifdef OPENVG_VERSION_1_1
137 value
> VG_MATRIX_GLYPH_USER_TO_SURFACE
)
139 value
> VG_MATRIX_STROKE_PAINT_TO_USER
)
141 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
143 state
->matrix_mode
= value
;
146 if (value
< VG_EVEN_ODD
||
148 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
150 state
->fill_rule
= value
;
152 case VG_IMAGE_QUALITY
:
153 state
->image_quality
= value
;
155 case VG_RENDERING_QUALITY
:
156 if (value
< VG_RENDERING_QUALITY_NONANTIALIASED
||
157 value
> VG_RENDERING_QUALITY_BETTER
)
158 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
160 state
->rendering_quality
= value
;
163 if (value
< VG_BLEND_SRC
||
164 value
> VG_BLEND_ADDITIVE
)
165 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
167 ctx
->state
.dirty
|= BLEND_DIRTY
;
168 state
->blend_mode
= value
;
172 if (value
< VG_DRAW_IMAGE_NORMAL
||
173 value
> VG_DRAW_IMAGE_STENCIL
)
174 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
176 state
->image_mode
= value
;
177 #ifdef OPENVG_VERSION_1_1
178 case VG_COLOR_TRANSFORM
:
179 state
->color_transform
= value
;
182 case VG_STROKE_LINE_WIDTH
:
183 state
->stroke
.line_width
.f
= value
;
184 state
->stroke
.line_width
.i
= value
;
186 case VG_STROKE_CAP_STYLE
:
187 if (value
< VG_CAP_BUTT
||
188 value
> VG_CAP_SQUARE
)
189 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
191 state
->stroke
.cap_style
= value
;
193 case VG_STROKE_JOIN_STYLE
:
194 if (value
< VG_JOIN_MITER
||
195 value
> VG_JOIN_BEVEL
)
196 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
198 state
->stroke
.join_style
= value
;
200 case VG_STROKE_MITER_LIMIT
:
201 state
->stroke
.miter_limit
.f
= value
;
202 state
->stroke
.miter_limit
.i
= value
;
204 case VG_STROKE_DASH_PHASE
:
205 state
->stroke
.dash_phase
.f
= value
;
206 state
->stroke
.dash_phase
.i
= value
;
208 case VG_STROKE_DASH_PHASE_RESET
:
209 state
->stroke
.dash_phase_reset
= value
;
212 state
->masking
= value
;
215 state
->scissoring
= value
;
216 ctx
->state
.dirty
|= DEPTH_STENCIL_DIRTY
;
218 case VG_PIXEL_LAYOUT
:
219 if (value
< VG_PIXEL_LAYOUT_UNKNOWN
||
220 value
> VG_PIXEL_LAYOUT_BGR_HORIZONTAL
)
221 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
223 state
->pixel_layout
= value
;
225 case VG_SCREEN_LAYOUT
:
226 /* read only ignore */
228 case VG_FILTER_FORMAT_LINEAR
:
229 state
->filter_format_linear
= value
;
231 case VG_FILTER_FORMAT_PREMULTIPLIED
:
232 state
->filter_format_premultiplied
= value
;
234 case VG_FILTER_CHANNEL_MASK
:
235 state
->filter_channel_mask
= value
;
238 case VG_MAX_SCISSOR_RECTS
:
239 case VG_MAX_DASH_COUNT
:
240 case VG_MAX_KERNEL_SIZE
:
241 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
242 case VG_MAX_COLOR_RAMP_STOPS
:
243 case VG_MAX_IMAGE_WIDTH
:
244 case VG_MAX_IMAGE_HEIGHT
:
245 case VG_MAX_IMAGE_PIXELS
:
246 case VG_MAX_IMAGE_BYTES
:
247 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
249 /* read only ignore */
252 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
255 vg_set_error(ctx
, error
);
258 void vegaSetfv(VGParamType type
, VGint count
,
259 const VGfloat
* values
)
261 struct vg_context
*ctx
= vg_current_context();
262 struct vg_state
*state
= current_state();
263 VGErrorCode error
= VG_NO_ERROR
;
265 if ((count
&& !values
) || !count_in_bounds(type
, count
) || !is_aligned(values
)) {
266 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
273 case VG_IMAGE_QUALITY
:
274 case VG_RENDERING_QUALITY
:
277 #ifdef OPENVG_VERSION_1_1
278 case VG_COLOR_TRANSFORM
:
280 case VG_STROKE_CAP_STYLE
:
281 case VG_STROKE_JOIN_STYLE
:
282 case VG_STROKE_DASH_PHASE_RESET
:
285 case VG_PIXEL_LAYOUT
:
286 case VG_SCREEN_LAYOUT
:
287 case VG_FILTER_FORMAT_LINEAR
:
288 case VG_FILTER_FORMAT_PREMULTIPLIED
:
289 case VG_FILTER_CHANNEL_MASK
:
290 vgSeti(type
, floor(values
[0]));
293 case VG_SCISSOR_RECTS
: {
295 VGuint
*x
= (VGuint
*)values
;
296 for (i
= 0; i
< count
; ++i
) {
297 state
->scissor_rects
[i
].f
= values
[i
];
298 state
->scissor_rects
[i
].i
= float_to_int_floor(x
[i
]);
300 state
->scissor_rects_num
= count
/ 4;
301 ctx
->state
.dirty
|= DEPTH_STENCIL_DIRTY
;
304 #ifdef OPENVG_VERSION_1_1
305 case VG_COLOR_TRANSFORM_VALUES
: {
307 for (i
= 0; i
< count
; ++i
) {
308 state
->color_transform_values
[i
] = values
[i
];
313 case VG_STROKE_LINE_WIDTH
:
314 state
->stroke
.line_width
.f
= values
[0];
315 state
->stroke
.line_width
.i
= float_to_int_floor(*((VGuint
*)(values
)));
317 case VG_STROKE_MITER_LIMIT
:
318 state
->stroke
.miter_limit
.f
= values
[0];
319 state
->stroke
.miter_limit
.i
= float_to_int_floor(*((VGuint
*)(values
)));
321 case VG_STROKE_DASH_PATTERN
: {
323 for (i
= 0; i
< count
; ++i
) {
324 state
->stroke
.dash_pattern
[i
].f
= values
[i
];
325 state
->stroke
.dash_pattern
[i
].i
=
326 float_to_int_floor(*((VGuint
*)(values
+ i
)));
328 state
->stroke
.dash_pattern_num
= count
;
331 case VG_STROKE_DASH_PHASE
:
332 state
->stroke
.dash_phase
.f
= values
[0];
333 state
->stroke
.dash_phase
.i
= float_to_int_floor(*((VGuint
*)(values
)));
335 case VG_TILE_FILL_COLOR
:
336 state
->tile_fill_color
[0] = values
[0];
337 state
->tile_fill_color
[1] = values
[1];
338 state
->tile_fill_color
[2] = values
[2];
339 state
->tile_fill_color
[3] = values
[3];
341 state
->tile_fill_colori
[0] = float_to_int_floor(*((VGuint
*)(values
+ 0)));
342 state
->tile_fill_colori
[1] = float_to_int_floor(*((VGuint
*)(values
+ 1)));
343 state
->tile_fill_colori
[2] = float_to_int_floor(*((VGuint
*)(values
+ 2)));
344 state
->tile_fill_colori
[3] = float_to_int_floor(*((VGuint
*)(values
+ 3)));
347 state
->clear_color
[0] = values
[0];
348 state
->clear_color
[1] = values
[1];
349 state
->clear_color
[2] = values
[2];
350 state
->clear_color
[3] = values
[3];
352 state
->clear_colori
[0] = float_to_int_floor(*((VGuint
*)(values
+ 0)));
353 state
->clear_colori
[1] = float_to_int_floor(*((VGuint
*)(values
+ 1)));
354 state
->clear_colori
[2] = float_to_int_floor(*((VGuint
*)(values
+ 2)));
355 state
->clear_colori
[3] = float_to_int_floor(*((VGuint
*)(values
+ 3)));
357 #ifdef OPENVG_VERSION_1_1
358 case VG_GLYPH_ORIGIN
:
359 state
->glyph_origin
[0].f
= values
[0];
360 state
->glyph_origin
[1].f
= values
[1];
362 state
->glyph_origin
[0].i
= float_to_int_floor(*((VGuint
*)(values
+ 0)));
363 state
->glyph_origin
[1].i
= float_to_int_floor(*((VGuint
*)(values
+ 1)));
367 case VG_MAX_SCISSOR_RECTS
:
368 case VG_MAX_DASH_COUNT
:
369 case VG_MAX_KERNEL_SIZE
:
370 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
371 case VG_MAX_COLOR_RAMP_STOPS
:
372 case VG_MAX_IMAGE_WIDTH
:
373 case VG_MAX_IMAGE_HEIGHT
:
374 case VG_MAX_IMAGE_PIXELS
:
375 case VG_MAX_IMAGE_BYTES
:
376 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
380 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
383 vg_set_error(ctx
, error
);
386 void vegaSetiv(VGParamType type
, VGint count
,
387 const VGint
* values
)
389 struct vg_context
*ctx
= vg_current_context();
390 struct vg_state
*state
= current_state();
392 if ((count
&& !values
) || !count_in_bounds(type
, count
) || !is_aligned(values
)) {
393 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
400 case VG_IMAGE_QUALITY
:
401 case VG_RENDERING_QUALITY
:
404 #ifdef OPENVG_VERSION_1_1
405 case VG_COLOR_TRANSFORM
:
407 case VG_STROKE_CAP_STYLE
:
408 case VG_STROKE_JOIN_STYLE
:
409 case VG_STROKE_DASH_PHASE_RESET
:
412 case VG_PIXEL_LAYOUT
:
413 case VG_SCREEN_LAYOUT
:
414 case VG_FILTER_FORMAT_LINEAR
:
415 case VG_FILTER_FORMAT_PREMULTIPLIED
:
416 case VG_FILTER_CHANNEL_MASK
:
417 vgSeti(type
, values
[0]);
420 case VG_SCISSOR_RECTS
: {
422 for (i
= 0; i
< count
; ++i
) {
423 state
->scissor_rects
[i
].i
= values
[i
];
424 state
->scissor_rects
[i
].f
= values
[i
];
426 state
->scissor_rects_num
= count
/ 4;
427 ctx
->state
.dirty
|= DEPTH_STENCIL_DIRTY
;
430 #ifdef OPENVG_VERSION_1_1
431 case VG_COLOR_TRANSFORM_VALUES
: {
433 for (i
= 0; i
< count
; ++i
) {
434 state
->color_transform_values
[i
] = values
[i
];
439 case VG_STROKE_LINE_WIDTH
:
440 state
->stroke
.line_width
.f
= values
[0];
441 state
->stroke
.line_width
.i
= values
[0];
443 case VG_STROKE_MITER_LIMIT
:
444 state
->stroke
.miter_limit
.f
= values
[0];
445 state
->stroke
.miter_limit
.i
= values
[0];
447 case VG_STROKE_DASH_PATTERN
: {
449 for (i
= 0; i
< count
; ++i
) {
450 state
->stroke
.dash_pattern
[i
].f
= values
[i
];
451 state
->stroke
.dash_pattern
[i
].i
= values
[i
];
453 state
->stroke
.dash_pattern_num
= count
;
456 case VG_STROKE_DASH_PHASE
:
457 state
->stroke
.dash_phase
.f
= values
[0];
458 state
->stroke
.dash_phase
.i
= values
[0];
460 case VG_TILE_FILL_COLOR
:
461 state
->tile_fill_color
[0] = values
[0];
462 state
->tile_fill_color
[1] = values
[1];
463 state
->tile_fill_color
[2] = values
[2];
464 state
->tile_fill_color
[3] = values
[3];
466 state
->tile_fill_colori
[0] = values
[0];
467 state
->tile_fill_colori
[1] = values
[1];
468 state
->tile_fill_colori
[2] = values
[2];
469 state
->tile_fill_colori
[3] = values
[3];
472 state
->clear_color
[0] = values
[0];
473 state
->clear_color
[1] = values
[1];
474 state
->clear_color
[2] = values
[2];
475 state
->clear_color
[3] = values
[3];
477 state
->clear_colori
[0] = values
[0];
478 state
->clear_colori
[1] = values
[1];
479 state
->clear_colori
[2] = values
[2];
480 state
->clear_colori
[3] = values
[3];
482 #ifdef OPENVG_VERSION_1_1
483 case VG_GLYPH_ORIGIN
:
484 state
->glyph_origin
[0].f
= values
[0];
485 state
->glyph_origin
[1].f
= values
[1];
486 state
->glyph_origin
[0].i
= values
[0];
487 state
->glyph_origin
[1].i
= values
[1];
491 case VG_MAX_SCISSOR_RECTS
:
492 case VG_MAX_DASH_COUNT
:
493 case VG_MAX_KERNEL_SIZE
:
494 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
495 case VG_MAX_COLOR_RAMP_STOPS
:
496 case VG_MAX_IMAGE_WIDTH
:
497 case VG_MAX_IMAGE_HEIGHT
:
498 case VG_MAX_IMAGE_PIXELS
:
499 case VG_MAX_IMAGE_BYTES
:
500 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
505 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
510 VGfloat
vegaGetf(VGParamType type
)
512 struct vg_context
*ctx
= vg_current_context();
513 const struct vg_state
*state
= current_state();
514 VGErrorCode error
= VG_NO_ERROR
;
515 VGfloat value
= 0.0f
;
520 case VG_IMAGE_QUALITY
:
521 case VG_RENDERING_QUALITY
:
524 #ifdef OPENVG_VERSION_1_1
525 case VG_COLOR_TRANSFORM
:
527 case VG_STROKE_CAP_STYLE
:
528 case VG_STROKE_JOIN_STYLE
:
529 case VG_STROKE_DASH_PHASE_RESET
:
532 case VG_PIXEL_LAYOUT
:
533 case VG_SCREEN_LAYOUT
:
534 case VG_FILTER_FORMAT_LINEAR
:
535 case VG_FILTER_FORMAT_PREMULTIPLIED
:
536 case VG_FILTER_CHANNEL_MASK
:
539 case VG_STROKE_LINE_WIDTH
:
540 value
= state
->stroke
.line_width
.f
;
542 case VG_STROKE_MITER_LIMIT
:
543 value
= state
->stroke
.miter_limit
.f
;
545 case VG_STROKE_DASH_PHASE
:
546 value
= state
->stroke
.dash_phase
.f
;
549 case VG_MAX_SCISSOR_RECTS
:
550 case VG_MAX_DASH_COUNT
:
551 case VG_MAX_KERNEL_SIZE
:
552 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
553 case VG_MAX_COLOR_RAMP_STOPS
:
554 case VG_MAX_IMAGE_WIDTH
:
555 case VG_MAX_IMAGE_HEIGHT
:
556 case VG_MAX_IMAGE_PIXELS
:
557 case VG_MAX_IMAGE_BYTES
:
558 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
562 value
= 1e+10;/*must be at least 1e+10*/
565 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
568 vg_set_error(ctx
, error
);
572 VGint
vegaGeti(VGParamType type
)
574 const struct vg_state
*state
= current_state();
575 struct vg_context
*ctx
= vg_current_context();
576 VGErrorCode error
= VG_NO_ERROR
;
581 value
= state
->matrix_mode
;
584 value
= state
->fill_rule
;
586 case VG_IMAGE_QUALITY
:
587 value
= state
->image_quality
;
589 case VG_RENDERING_QUALITY
:
590 value
= state
->rendering_quality
;
593 value
= state
->blend_mode
;
596 value
= state
->image_mode
;
598 #ifdef OPENVG_VERSION_1_1
599 case VG_COLOR_TRANSFORM
:
600 value
= state
->color_transform
;
603 case VG_STROKE_LINE_WIDTH
:
604 value
= state
->stroke
.line_width
.i
;
606 case VG_STROKE_CAP_STYLE
:
607 value
= state
->stroke
.cap_style
;
609 case VG_STROKE_JOIN_STYLE
:
610 value
= state
->stroke
.join_style
;
612 case VG_STROKE_MITER_LIMIT
:
613 value
= state
->stroke
.miter_limit
.i
;
615 case VG_STROKE_DASH_PHASE
:
616 value
= state
->stroke
.dash_phase
.i
;
618 case VG_STROKE_DASH_PHASE_RESET
:
619 value
= state
->stroke
.dash_phase_reset
;
622 value
= state
->masking
;
625 value
= state
->scissoring
;
627 case VG_PIXEL_LAYOUT
:
628 value
= state
->pixel_layout
;
630 case VG_SCREEN_LAYOUT
:
631 value
= state
->screen_layout
;
633 case VG_FILTER_FORMAT_LINEAR
:
634 value
= state
->filter_format_linear
;
636 case VG_FILTER_FORMAT_PREMULTIPLIED
:
637 value
= state
->filter_format_premultiplied
;
639 case VG_FILTER_CHANNEL_MASK
:
640 value
= state
->filter_channel_mask
;
643 case VG_MAX_SCISSOR_RECTS
:
644 value
= 32; /*must be at least 32*/
646 case VG_MAX_DASH_COUNT
:
647 value
= 16; /*must be at least 16*/
649 case VG_MAX_KERNEL_SIZE
:
650 value
= 7; /*must be at least 7*/
652 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
653 value
= 15; /*must be at least 15*/
655 case VG_MAX_COLOR_RAMP_STOPS
:
656 value
= 256; /*must be at least 32*/
658 case VG_MAX_IMAGE_WIDTH
:
661 case VG_MAX_IMAGE_HEIGHT
:
664 case VG_MAX_IMAGE_PIXELS
:
667 case VG_MAX_IMAGE_BYTES
:
668 value
= 2048*2048 * 4;
670 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
671 value
= 128; /*must be at least 128*/
675 VGfloat val
= vgGetf(type
);
676 value
= float_to_int_floor(*((VGuint
*)&val
));
680 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
683 vg_set_error(ctx
, error
);
687 VGint
vegaGetVectorSize(VGParamType type
)
689 struct vg_context
*ctx
= vg_current_context();
690 const struct vg_state
*state
= current_state();
694 case VG_IMAGE_QUALITY
:
695 case VG_RENDERING_QUALITY
:
699 case VG_SCISSOR_RECTS
:
700 return state
->scissor_rects_num
* 4;
701 #ifdef OPENVG_VERSION_1_1
702 case VG_COLOR_TRANSFORM
:
704 case VG_COLOR_TRANSFORM_VALUES
:
707 case VG_STROKE_LINE_WIDTH
:
708 case VG_STROKE_CAP_STYLE
:
709 case VG_STROKE_JOIN_STYLE
:
710 case VG_STROKE_MITER_LIMIT
:
712 case VG_STROKE_DASH_PATTERN
:
713 return state
->stroke
.dash_pattern_num
;
714 case VG_STROKE_DASH_PHASE
:
716 case VG_STROKE_DASH_PHASE_RESET
:
718 case VG_TILE_FILL_COLOR
:
722 #ifdef OPENVG_VERSION_1_1
723 case VG_GLYPH_ORIGIN
:
730 case VG_PIXEL_LAYOUT
:
732 case VG_SCREEN_LAYOUT
:
734 case VG_FILTER_FORMAT_LINEAR
:
736 case VG_FILTER_FORMAT_PREMULTIPLIED
:
738 case VG_FILTER_CHANNEL_MASK
:
741 case VG_MAX_COLOR_RAMP_STOPS
:
743 case VG_MAX_SCISSOR_RECTS
:
744 case VG_MAX_DASH_COUNT
:
745 case VG_MAX_KERNEL_SIZE
:
746 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
747 case VG_MAX_IMAGE_WIDTH
:
748 case VG_MAX_IMAGE_HEIGHT
:
749 case VG_MAX_IMAGE_PIXELS
:
750 case VG_MAX_IMAGE_BYTES
:
752 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
756 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
761 void vegaGetfv(VGParamType type
, VGint count
,
764 const struct vg_state
*state
= current_state();
765 struct vg_context
*ctx
= vg_current_context();
766 VGint real_count
= vgGetVectorSize(type
);
768 if (!values
|| count
<= 0 || count
> real_count
|| !is_aligned(values
)) {
769 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
776 case VG_IMAGE_QUALITY
:
777 case VG_RENDERING_QUALITY
:
780 #ifdef OPENVG_VERSION_1_1
781 case VG_COLOR_TRANSFORM
:
783 case VG_STROKE_CAP_STYLE
:
784 case VG_STROKE_JOIN_STYLE
:
785 case VG_STROKE_DASH_PHASE_RESET
:
788 case VG_PIXEL_LAYOUT
:
789 case VG_SCREEN_LAYOUT
:
790 case VG_FILTER_FORMAT_LINEAR
:
791 case VG_FILTER_FORMAT_PREMULTIPLIED
:
792 case VG_FILTER_CHANNEL_MASK
:
793 case VG_MAX_SCISSOR_RECTS
:
794 case VG_MAX_DASH_COUNT
:
795 case VG_MAX_KERNEL_SIZE
:
796 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
797 case VG_MAX_COLOR_RAMP_STOPS
:
798 case VG_MAX_IMAGE_WIDTH
:
799 case VG_MAX_IMAGE_HEIGHT
:
800 case VG_MAX_IMAGE_PIXELS
:
801 case VG_MAX_IMAGE_BYTES
:
802 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
803 values
[0] = vgGeti(type
);
806 values
[0] = vgGetf(type
);
808 case VG_SCISSOR_RECTS
: {
810 for (i
= 0; i
< count
; ++i
) {
811 values
[i
] = state
->scissor_rects
[i
].f
;
815 #ifdef OPENVG_VERSION_1_1
816 case VG_COLOR_TRANSFORM_VALUES
: {
817 memcpy(values
, state
->color_transform_values
,
818 sizeof(VGfloat
) * count
);
822 case VG_STROKE_LINE_WIDTH
:
823 values
[0] = state
->stroke
.line_width
.f
;
825 case VG_STROKE_MITER_LIMIT
:
826 values
[0] = state
->stroke
.miter_limit
.f
;
828 case VG_STROKE_DASH_PATTERN
: {
830 for (i
= 0; i
< count
; ++i
) {
831 values
[i
] = state
->stroke
.dash_pattern
[i
].f
;
835 case VG_STROKE_DASH_PHASE
:
836 values
[0] = state
->stroke
.dash_phase
.f
;
838 case VG_TILE_FILL_COLOR
:
839 values
[0] = state
->tile_fill_color
[0];
840 values
[1] = state
->tile_fill_color
[1];
841 values
[2] = state
->tile_fill_color
[2];
842 values
[3] = state
->tile_fill_color
[3];
845 values
[0] = state
->clear_color
[0];
846 values
[1] = state
->clear_color
[1];
847 values
[2] = state
->clear_color
[2];
848 values
[3] = state
->clear_color
[3];
850 #ifdef OPENVG_VERSION_1_1
851 case VG_GLYPH_ORIGIN
:
852 values
[0] = state
->glyph_origin
[0].f
;
853 values
[1] = state
->glyph_origin
[1].f
;
857 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
862 void vegaGetiv(VGParamType type
, VGint count
,
865 const struct vg_state
*state
= current_state();
866 struct vg_context
*ctx
= vg_current_context();
867 VGint real_count
= vgGetVectorSize(type
);
869 if (!values
|| count
<= 0 || count
> real_count
|| !is_aligned(values
)) {
870 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
877 case VG_IMAGE_QUALITY
:
878 case VG_RENDERING_QUALITY
:
881 #ifdef OPENVG_VERSION_1_1
882 case VG_COLOR_TRANSFORM
:
884 case VG_STROKE_CAP_STYLE
:
885 case VG_STROKE_JOIN_STYLE
:
886 case VG_STROKE_DASH_PHASE_RESET
:
889 case VG_PIXEL_LAYOUT
:
890 case VG_SCREEN_LAYOUT
:
891 case VG_FILTER_FORMAT_LINEAR
:
892 case VG_FILTER_FORMAT_PREMULTIPLIED
:
893 case VG_FILTER_CHANNEL_MASK
:
894 case VG_MAX_SCISSOR_RECTS
:
895 case VG_MAX_DASH_COUNT
:
896 case VG_MAX_KERNEL_SIZE
:
897 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
898 case VG_MAX_COLOR_RAMP_STOPS
:
899 case VG_MAX_IMAGE_WIDTH
:
900 case VG_MAX_IMAGE_HEIGHT
:
901 case VG_MAX_IMAGE_PIXELS
:
902 case VG_MAX_IMAGE_BYTES
:
903 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
904 values
[0] = vgGeti(type
);
907 VGfloat val
= vgGetf(type
);
908 values
[0] = float_to_int_floor(*((VGuint
*)&val
));
911 case VG_SCISSOR_RECTS
: {
913 for (i
= 0; i
< count
; ++i
) {
914 values
[i
] = state
->scissor_rects
[i
].i
;
918 #ifdef OPENVG_VERSION_1_1
919 case VG_COLOR_TRANSFORM_VALUES
: {
921 VGuint
*x
= (VGuint
*)state
->color_transform_values
;
922 for (i
= 0; i
< count
; ++i
) {
923 values
[i
] = float_to_int_floor(x
[i
]);
928 case VG_STROKE_LINE_WIDTH
:
929 values
[0] = state
->stroke
.line_width
.i
;
931 case VG_STROKE_MITER_LIMIT
:
932 values
[0] = state
->stroke
.miter_limit
.i
;
934 case VG_STROKE_DASH_PATTERN
: {
936 for (i
= 0; i
< count
; ++i
) {
937 values
[i
] = state
->stroke
.dash_pattern
[i
].i
;
941 case VG_STROKE_DASH_PHASE
:
942 values
[0] = state
->stroke
.dash_phase
.i
;
944 case VG_TILE_FILL_COLOR
:
945 values
[0] = state
->tile_fill_colori
[0];
946 values
[1] = state
->tile_fill_colori
[1];
947 values
[2] = state
->tile_fill_colori
[2];
948 values
[3] = state
->tile_fill_colori
[3];
951 values
[0] = state
->clear_colori
[0];
952 values
[1] = state
->clear_colori
[1];
953 values
[2] = state
->clear_colori
[2];
954 values
[3] = state
->clear_colori
[3];
956 #ifdef OPENVG_VERSION_1_1
957 case VG_GLYPH_ORIGIN
:
958 values
[0] = state
->glyph_origin
[0].i
;
959 values
[1] = state
->glyph_origin
[1].i
;
963 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
968 void vegaSetParameterf(VGHandle object
,
972 struct vg_context
*ctx
= vg_current_context();
973 void *ptr
= (void*)object
;
975 if (!object
|| object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
976 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
982 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
983 case VG_PAINT_PATTERN_TILING_MODE
:
984 vgSetParameteri(object
, paramType
, floor(value
));
988 case VG_PAINT_COLOR_RAMP_STOPS
:
989 case VG_PAINT_LINEAR_GRADIENT
:
990 case VG_PAINT_RADIAL_GRADIENT
:
991 /* it's an error if paramType refers to a vector parameter */
992 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
994 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
995 struct vg_paint
*p
= (struct vg_paint
*)object
;
996 paint_set_color_ramp_premultiplied(p
, value
);
1000 case VG_PATH_DATATYPE
:
1001 case VG_PATH_FORMAT
:
1004 case VG_PATH_NUM_SEGMENTS
:
1005 case VG_PATH_NUM_COORDS
:
1007 case VG_IMAGE_FORMAT
:
1008 case VG_IMAGE_WIDTH
:
1009 case VG_IMAGE_HEIGHT
:
1011 #ifdef OPENVG_VERSION_1_1
1012 case VG_FONT_NUM_GLYPHS
:
1013 /* read only don't produce an error */
1017 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1022 void vegaSetParameteri(VGHandle object
,
1026 struct vg_context
*ctx
= vg_current_context();
1027 void *ptr
= (void*)object
;
1029 if (!object
|| object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
1030 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1036 if (value
< VG_PAINT_TYPE_COLOR
||
1037 value
> VG_PAINT_TYPE_PATTERN
)
1038 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1040 struct vg_paint
*paint
= (struct vg_paint
*)ptr
;
1041 paint_set_type(paint
, value
);
1044 case VG_PAINT_COLOR
:
1045 case VG_PAINT_COLOR_RAMP_STOPS
:
1046 case VG_PAINT_LINEAR_GRADIENT
:
1047 case VG_PAINT_RADIAL_GRADIENT
:
1048 /* it's an error if paramType refers to a vector parameter */
1049 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1051 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1052 if (value
< VG_COLOR_RAMP_SPREAD_PAD
||
1053 value
> VG_COLOR_RAMP_SPREAD_REFLECT
)
1054 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1056 struct vg_paint
*paint
= (struct vg_paint
*)ptr
;
1057 paint_set_spread_mode(paint
, value
);
1060 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
1061 struct vg_paint
*p
= (struct vg_paint
*)object
;
1062 paint_set_color_ramp_premultiplied(p
, value
);
1065 case VG_PAINT_PATTERN_TILING_MODE
:
1066 if (value
< VG_TILE_FILL
||
1067 value
> VG_TILE_REFLECT
)
1068 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1070 struct vg_paint
*paint
= (struct vg_paint
*)ptr
;
1071 paint_set_pattern_tiling(paint
, value
);
1075 case VG_PATH_DATATYPE
:
1076 case VG_PATH_FORMAT
:
1079 case VG_PATH_NUM_SEGMENTS
:
1080 case VG_PATH_NUM_COORDS
:
1082 case VG_IMAGE_FORMAT
:
1083 case VG_IMAGE_WIDTH
:
1084 case VG_IMAGE_HEIGHT
:
1086 #ifdef OPENVG_VERSION_1_1
1087 case VG_FONT_NUM_GLYPHS
:
1088 /* read only don't produce an error */
1092 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1097 void vegaSetParameterfv(VGHandle object
,
1100 const VGfloat
* values
)
1102 struct vg_context
*ctx
= vg_current_context();
1103 void *ptr
= (void*)object
;
1104 VGint real_count
= vgGetParameterVectorSize(object
, paramType
);
1106 if (!object
|| object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
1107 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1111 if (count
< 0 || count
< real_count
||
1112 (values
== NULL
&& count
!= 0) ||
1113 !is_aligned(values
)) {
1114 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1120 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1121 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1122 case VG_PAINT_PATTERN_TILING_MODE
:
1124 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1126 vgSetParameterf(object
, paramType
, values
[0]);
1129 case VG_PAINT_COLOR
: {
1131 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1133 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1134 paint_set_color(paint
, values
);
1138 case VG_PAINT_COLOR_RAMP_STOPS
: {
1139 if (count
&& count
< 4)
1140 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1142 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1143 count
= MIN2(count
, VEGA_MAX_COLOR_RAMP_STOPS
);
1144 paint_set_ramp_stops(paint
, values
, count
);
1146 VGint stopsi
[VEGA_MAX_COLOR_RAMP_STOPS
];
1148 for (i
= 0; i
< count
; ++i
) {
1149 stopsi
[i
] = float_to_int_floor(*((VGuint
*)(values
+ i
)));
1151 paint_set_ramp_stopsi(paint
, stopsi
, count
);
1156 case VG_PAINT_LINEAR_GRADIENT
: {
1158 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1160 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1161 paint_set_linear_gradient(paint
, values
);
1164 vals
[0] = FLT_TO_INT(values
[0]);
1165 vals
[1] = FLT_TO_INT(values
[1]);
1166 vals
[2] = FLT_TO_INT(values
[2]);
1167 vals
[3] = FLT_TO_INT(values
[3]);
1168 paint_set_linear_gradienti(paint
, vals
);
1173 case VG_PAINT_RADIAL_GRADIENT
: {
1175 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1177 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1178 paint_set_radial_gradient(paint
, values
);
1181 vals
[0] = FLT_TO_INT(values
[0]);
1182 vals
[1] = FLT_TO_INT(values
[1]);
1183 vals
[2] = FLT_TO_INT(values
[2]);
1184 vals
[3] = FLT_TO_INT(values
[3]);
1185 vals
[4] = FLT_TO_INT(values
[4]);
1186 paint_set_radial_gradienti(paint
, vals
);
1192 case VG_PATH_DATATYPE
:
1193 case VG_PATH_FORMAT
:
1196 case VG_PATH_NUM_SEGMENTS
:
1197 case VG_PATH_NUM_COORDS
:
1199 #ifdef OPENVG_VERSION_1_1
1200 case VG_FONT_NUM_GLYPHS
:
1201 /* read only don't produce an error */
1205 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1210 void vegaSetParameteriv(VGHandle object
,
1213 const VGint
* values
)
1215 struct vg_context
*ctx
= vg_current_context();
1216 void *ptr
= (void*)object
;
1217 VGint real_count
= vgGetParameterVectorSize(object
, paramType
);
1219 if (!object
|| object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
1220 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1224 if (count
< 0 || count
< real_count
||
1225 (values
== NULL
&& count
!= 0) ||
1226 !is_aligned(values
)) {
1227 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1233 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1234 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1235 case VG_PAINT_PATTERN_TILING_MODE
:
1237 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1239 vgSetParameteri(object
, paramType
, values
[0]);
1242 case VG_PAINT_COLOR
: {
1244 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1246 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1247 paint_set_coloriv(paint
, values
);
1251 case VG_PAINT_COLOR_RAMP_STOPS
: {
1253 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1257 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1259 vals
= malloc(sizeof(VGfloat
)*count
);
1260 for (i
= 0; i
< count
; ++i
)
1261 vals
[i
] = values
[i
];
1264 paint_set_ramp_stopsi(paint
, values
, count
);
1265 paint_set_ramp_stops(paint
, vals
, count
);
1270 case VG_PAINT_LINEAR_GRADIENT
: {
1272 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1275 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1276 vals
[0] = values
[0];
1277 vals
[1] = values
[1];
1278 vals
[2] = values
[2];
1279 vals
[3] = values
[3];
1280 paint_set_linear_gradient(paint
, vals
);
1281 paint_set_linear_gradienti(paint
, values
);
1285 case VG_PAINT_RADIAL_GRADIENT
: {
1287 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1290 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1291 vals
[0] = values
[0];
1292 vals
[1] = values
[1];
1293 vals
[2] = values
[2];
1294 vals
[3] = values
[3];
1295 vals
[4] = values
[4];
1296 paint_set_radial_gradient(paint
, vals
);
1297 paint_set_radial_gradienti(paint
, values
);
1301 case VG_PATH_DATATYPE
:
1302 case VG_PATH_FORMAT
:
1305 case VG_PATH_NUM_SEGMENTS
:
1306 case VG_PATH_NUM_COORDS
:
1307 /* read only don't produce an error */
1310 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1315 VGint
vegaGetParameterVectorSize(VGHandle object
,
1318 struct vg_context
*ctx
= vg_current_context();
1319 void *ptr
= (void*)object
;
1321 if (!ptr
|| object
== VG_INVALID_HANDLE
) {
1322 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1328 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1329 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1330 case VG_PAINT_PATTERN_TILING_MODE
:
1332 case VG_PAINT_COLOR
:
1334 case VG_PAINT_COLOR_RAMP_STOPS
: {
1335 struct vg_paint
*p
= (struct vg_paint
*)object
;
1336 return paint_num_ramp_stops(p
);
1339 case VG_PAINT_LINEAR_GRADIENT
:
1341 case VG_PAINT_RADIAL_GRADIENT
:
1345 case VG_PATH_FORMAT
:
1346 case VG_PATH_DATATYPE
:
1349 case VG_PATH_NUM_SEGMENTS
:
1350 case VG_PATH_NUM_COORDS
:
1353 case VG_IMAGE_FORMAT
:
1354 case VG_IMAGE_WIDTH
:
1355 case VG_IMAGE_HEIGHT
:
1358 #ifdef OPENVG_VERSION_1_1
1359 case VG_FONT_NUM_GLYPHS
:
1364 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1371 VGfloat
vegaGetParameterf(VGHandle object
,
1374 struct vg_context
*ctx
= vg_current_context();
1375 void *ptr
= (void*)object
;
1377 if (!ptr
|| object
== VG_INVALID_HANDLE
) {
1378 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1384 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1385 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1386 case VG_PAINT_PATTERN_TILING_MODE
:
1387 return vgGetParameteri(object
, paramType
);
1389 case VG_PAINT_COLOR
:
1390 case VG_PAINT_COLOR_RAMP_STOPS
:
1391 case VG_PAINT_LINEAR_GRADIENT
:
1392 case VG_PAINT_RADIAL_GRADIENT
:
1393 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1396 case VG_PATH_FORMAT
:
1397 return VG_PATH_FORMAT_STANDARD
;
1398 case VG_PATH_SCALE
: {
1399 struct path
*p
= (struct path
*)object
;
1400 return path_scale(p
);
1402 case VG_PATH_BIAS
: {
1403 struct path
*p
= (struct path
*)object
;
1404 return path_bias(p
);
1406 case VG_PATH_DATATYPE
:
1407 case VG_PATH_NUM_SEGMENTS
:
1408 case VG_PATH_NUM_COORDS
:
1409 return vgGetParameteri(object
, paramType
);
1412 case VG_IMAGE_FORMAT
:
1413 case VG_IMAGE_WIDTH
:
1414 case VG_IMAGE_HEIGHT
:
1415 #ifdef OPENVG_VERSION_1_1
1416 case VG_FONT_NUM_GLYPHS
:
1417 return vgGetParameteri(object
, paramType
);
1422 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1428 VGint
vegaGetParameteri(VGHandle object
,
1431 struct vg_context
*ctx
= vg_current_context();
1432 void *ptr
= (void*)object
;
1434 if (!ptr
|| object
== VG_INVALID_HANDLE
) {
1435 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1440 case VG_PAINT_TYPE
: {
1441 struct vg_paint
*paint
= (struct vg_paint
*)ptr
;
1442 return paint_type(paint
);
1445 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
: {
1446 struct vg_paint
*p
= (struct vg_paint
*)object
;
1447 return paint_spread_mode(p
);
1449 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
1450 struct vg_paint
*p
= (struct vg_paint
*)object
;
1451 return paint_color_ramp_premultiplied(p
);
1454 case VG_PAINT_PATTERN_TILING_MODE
: {
1455 struct vg_paint
*p
= (struct vg_paint
*)object
;
1456 return paint_pattern_tiling(p
);
1459 case VG_PAINT_COLOR
:
1460 case VG_PAINT_COLOR_RAMP_STOPS
:
1461 case VG_PAINT_LINEAR_GRADIENT
:
1462 case VG_PAINT_RADIAL_GRADIENT
:
1463 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1466 case VG_PATH_FORMAT
:
1467 return VG_PATH_FORMAT_STANDARD
;
1470 return vgGetParameterf(object
, paramType
);
1471 case VG_PATH_DATATYPE
: {
1472 struct path
*p
= (struct path
*)object
;
1473 return path_datatype(p
);
1475 case VG_PATH_NUM_SEGMENTS
: {
1476 struct path
*p
= (struct path
*)object
;
1477 return path_num_segments(p
);
1479 case VG_PATH_NUM_COORDS
: {
1480 struct path
*p
= (struct path
*)object
;
1481 return path_num_coords(p
);
1485 case VG_IMAGE_FORMAT
: {
1486 struct vg_image
*img
= (struct vg_image
*)object
;
1490 case VG_IMAGE_WIDTH
: {
1491 struct vg_image
*img
= (struct vg_image
*)object
;
1495 case VG_IMAGE_HEIGHT
: {
1496 struct vg_image
*img
= (struct vg_image
*)object
;
1501 #ifdef OPENVG_VERSION_1_1
1502 case VG_FONT_NUM_GLYPHS
: {
1509 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1515 void vegaGetParameterfv(VGHandle object
,
1520 struct vg_context
*ctx
= vg_current_context();
1521 void *ptr
= (void*)object
;
1522 VGint real_count
= vgGetParameterVectorSize(object
, paramType
);
1524 if (!ptr
|| object
== VG_INVALID_HANDLE
) {
1525 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1529 if (!values
|| count
<= 0 || count
> real_count
||
1530 !is_aligned(values
)) {
1531 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1536 case VG_PAINT_TYPE
: {
1537 struct vg_paint
*p
= (struct vg_paint
*)object
;
1538 values
[0] = paint_type(p
);
1541 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
: {
1542 struct vg_paint
*p
= (struct vg_paint
*)object
;
1543 values
[0] = paint_spread_mode(p
);
1546 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
1547 struct vg_paint
*p
= (struct vg_paint
*)object
;
1548 values
[0] = paint_color_ramp_premultiplied(p
);
1551 case VG_PAINT_PATTERN_TILING_MODE
: {
1552 values
[0] = vgGetParameterf(object
, paramType
);
1555 case VG_PAINT_COLOR
: {
1556 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1557 paint_get_color(paint
, values
);
1560 case VG_PAINT_COLOR_RAMP_STOPS
: {
1561 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1562 paint_ramp_stops(paint
, values
, count
);
1565 case VG_PAINT_LINEAR_GRADIENT
: {
1566 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1567 paint_linear_gradient(paint
, values
);
1570 case VG_PAINT_RADIAL_GRADIENT
: {
1571 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1572 paint_radial_gradient(paint
, values
);
1576 case VG_PATH_FORMAT
:
1577 case VG_PATH_DATATYPE
:
1578 case VG_PATH_NUM_SEGMENTS
:
1579 case VG_PATH_NUM_COORDS
:
1580 values
[0] = vgGetParameteri(object
, paramType
);
1584 values
[0] = vgGetParameterf(object
, paramType
);
1587 case VG_IMAGE_FORMAT
:
1588 case VG_IMAGE_WIDTH
:
1589 case VG_IMAGE_HEIGHT
:
1590 #ifdef OPENVG_VERSION_1_1
1591 case VG_FONT_NUM_GLYPHS
:
1592 values
[0] = vgGetParameteri(object
, paramType
);
1597 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1602 void vegaGetParameteriv(VGHandle object
,
1607 struct vg_context
*ctx
= vg_current_context();
1608 void *ptr
= (void*)object
;
1609 VGint real_count
= vgGetParameterVectorSize(object
, paramType
);
1611 if (!ptr
|| object
== VG_INVALID_HANDLE
) {
1612 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1616 if (!values
|| count
<= 0 || count
> real_count
||
1617 !is_aligned(values
)) {
1618 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1624 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1625 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1626 case VG_PAINT_PATTERN_TILING_MODE
:
1627 #ifdef OPENVG_VERSION_1_1
1628 case VG_FONT_NUM_GLYPHS
:
1629 values
[0] = vgGetParameteri(object
, paramType
);
1632 case VG_PAINT_COLOR
: {
1633 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1634 paint_get_coloriv(paint
, values
);
1637 case VG_PAINT_COLOR_RAMP_STOPS
: {
1638 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1639 paint_ramp_stopsi(paint
, values
, count
);
1642 case VG_PAINT_LINEAR_GRADIENT
: {
1643 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1644 paint_linear_gradienti(paint
, values
);
1647 case VG_PAINT_RADIAL_GRADIENT
: {
1648 struct vg_paint
*paint
= (struct vg_paint
*)object
;
1649 paint_radial_gradienti(paint
, values
);
1655 values
[0] = vgGetParameterf(object
, paramType
);
1657 case VG_PATH_FORMAT
:
1658 case VG_PATH_DATATYPE
:
1659 case VG_PATH_NUM_SEGMENTS
:
1660 case VG_PATH_NUM_COORDS
:
1661 values
[0] = vgGetParameteri(object
, paramType
);
1664 case VG_IMAGE_FORMAT
:
1665 case VG_IMAGE_WIDTH
:
1666 case VG_IMAGE_HEIGHT
:
1667 values
[0] = vgGetParameteri(object
, paramType
);
1671 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);