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"
36 #include "api_consts.h"
39 #include "pipe/p_compiler.h"
40 #include "util/u_pointer.h"
41 #include "util/u_math.h"
45 static INLINE
struct vg_state
*current_state()
47 struct vg_context
*ctx
= vg_current_context();
51 return &ctx
->state
.vg
;
54 static INLINE VGboolean
count_in_bounds(VGParamType type
, VGint count
)
59 if (type
== VG_SCISSOR_RECTS
)
60 return (!(count
% 4) && (count
>= 0 || count
<= VEGA_MAX_SCISSOR_RECTS
* 4));
61 else if (type
== VG_STROKE_DASH_PATTERN
) {
62 return count
<= VEGA_MAX_DASH_COUNT
;
64 VGint real_count
= vegaGetVectorSize(type
);
65 return count
== real_count
;
69 void vegaSetf (VGParamType type
, VGfloat value
)
71 struct vg_context
*ctx
= vg_current_context();
72 struct vg_state
*state
= current_state();
73 VGErrorCode error
= VG_NO_ERROR
;
78 case VG_IMAGE_QUALITY
:
79 case VG_RENDERING_QUALITY
:
82 #ifdef OPENVG_VERSION_1_1
83 case VG_COLOR_TRANSFORM
:
85 case VG_STROKE_CAP_STYLE
:
86 case VG_STROKE_JOIN_STYLE
:
87 case VG_STROKE_DASH_PHASE_RESET
:
91 case VG_SCREEN_LAYOUT
:
92 case VG_FILTER_FORMAT_LINEAR
:
93 case VG_FILTER_FORMAT_PREMULTIPLIED
:
94 case VG_FILTER_CHANNEL_MASK
:
96 case VG_MAX_SCISSOR_RECTS
:
97 case VG_MAX_DASH_COUNT
:
98 case VG_MAX_KERNEL_SIZE
:
99 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
100 case VG_MAX_COLOR_RAMP_STOPS
:
101 case VG_MAX_IMAGE_WIDTH
:
102 case VG_MAX_IMAGE_HEIGHT
:
103 case VG_MAX_IMAGE_PIXELS
:
104 case VG_MAX_IMAGE_BYTES
:
105 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
107 vegaSeti(type
, floor(value
));
110 case VG_STROKE_LINE_WIDTH
:
111 state
->stroke
.line_width
.f
= value
;
112 state
->stroke
.line_width
.i
= float_to_int_floor(*((VGuint
*)(&value
)));
114 case VG_STROKE_MITER_LIMIT
:
115 state
->stroke
.miter_limit
.f
= value
;
116 state
->stroke
.miter_limit
.i
= float_to_int_floor(*((VGuint
*)(&value
)));
118 case VG_STROKE_DASH_PHASE
:
119 state
->stroke
.dash_phase
.f
= value
;
120 state
->stroke
.dash_phase
.i
= float_to_int_floor(*((VGuint
*)(&value
)));
123 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
126 vg_set_error(ctx
, error
);
129 void vegaSeti (VGParamType type
, VGint value
)
131 struct vg_context
*ctx
= vg_current_context();
132 struct vg_state
*state
= current_state();
133 VGErrorCode error
= VG_NO_ERROR
;
137 if (value
< VG_MATRIX_PATH_USER_TO_SURFACE
||
138 #ifdef OPENVG_VERSION_1_1
139 value
> VG_MATRIX_GLYPH_USER_TO_SURFACE
)
141 value
> VG_MATRIX_STROKE_PAINT_TO_USER
)
143 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
145 state
->matrix_mode
= value
;
148 if (value
< VG_EVEN_ODD
||
150 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
152 state
->fill_rule
= value
;
154 case VG_IMAGE_QUALITY
:
155 state
->image_quality
= value
;
157 case VG_RENDERING_QUALITY
:
158 if (value
< VG_RENDERING_QUALITY_NONANTIALIASED
||
159 value
> VG_RENDERING_QUALITY_BETTER
)
160 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
162 state
->rendering_quality
= value
;
165 if (value
< VG_BLEND_SRC
||
166 value
> VG_BLEND_ADDITIVE
)
167 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
169 ctx
->state
.dirty
|= BLEND_DIRTY
;
170 state
->blend_mode
= value
;
174 if (value
< VG_DRAW_IMAGE_NORMAL
||
175 value
> VG_DRAW_IMAGE_STENCIL
)
176 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
178 state
->image_mode
= value
;
180 #ifdef OPENVG_VERSION_1_1
181 case VG_COLOR_TRANSFORM
:
182 state
->color_transform
= value
;
185 case VG_STROKE_LINE_WIDTH
:
186 state
->stroke
.line_width
.f
= value
;
187 state
->stroke
.line_width
.i
= value
;
189 case VG_STROKE_CAP_STYLE
:
190 if (value
< VG_CAP_BUTT
||
191 value
> VG_CAP_SQUARE
)
192 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
194 state
->stroke
.cap_style
= value
;
196 case VG_STROKE_JOIN_STYLE
:
197 if (value
< VG_JOIN_MITER
||
198 value
> VG_JOIN_BEVEL
)
199 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
201 state
->stroke
.join_style
= value
;
203 case VG_STROKE_MITER_LIMIT
:
204 state
->stroke
.miter_limit
.f
= value
;
205 state
->stroke
.miter_limit
.i
= value
;
207 case VG_STROKE_DASH_PHASE
:
208 state
->stroke
.dash_phase
.f
= value
;
209 state
->stroke
.dash_phase
.i
= value
;
211 case VG_STROKE_DASH_PHASE_RESET
:
212 state
->stroke
.dash_phase_reset
= value
;
215 state
->masking
= value
;
218 state
->scissoring
= value
;
219 ctx
->state
.dirty
|= DEPTH_STENCIL_DIRTY
;
221 case VG_PIXEL_LAYOUT
:
222 if (value
< VG_PIXEL_LAYOUT_UNKNOWN
||
223 value
> VG_PIXEL_LAYOUT_BGR_HORIZONTAL
)
224 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
226 state
->pixel_layout
= value
;
228 case VG_SCREEN_LAYOUT
:
229 /* read only ignore */
231 case VG_FILTER_FORMAT_LINEAR
:
232 state
->filter_format_linear
= value
;
234 case VG_FILTER_FORMAT_PREMULTIPLIED
:
235 state
->filter_format_premultiplied
= value
;
237 case VG_FILTER_CHANNEL_MASK
:
238 state
->filter_channel_mask
= value
;
241 case VG_MAX_SCISSOR_RECTS
:
242 case VG_MAX_DASH_COUNT
:
243 case VG_MAX_KERNEL_SIZE
:
244 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
245 case VG_MAX_COLOR_RAMP_STOPS
:
246 case VG_MAX_IMAGE_WIDTH
:
247 case VG_MAX_IMAGE_HEIGHT
:
248 case VG_MAX_IMAGE_PIXELS
:
249 case VG_MAX_IMAGE_BYTES
:
250 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
252 /* read only ignore */
255 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
258 vg_set_error(ctx
, error
);
261 void vegaSetfv(VGParamType type
, VGint count
,
262 const VGfloat
* values
)
264 struct vg_context
*ctx
= vg_current_context();
265 struct vg_state
*state
= current_state();
266 VGErrorCode error
= VG_NO_ERROR
;
268 if ((count
&& !values
) || !count_in_bounds(type
, count
) || !is_aligned(values
)) {
269 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
276 case VG_IMAGE_QUALITY
:
277 case VG_RENDERING_QUALITY
:
280 #ifdef OPENVG_VERSION_1_1
281 case VG_COLOR_TRANSFORM
:
283 case VG_STROKE_CAP_STYLE
:
284 case VG_STROKE_JOIN_STYLE
:
285 case VG_STROKE_DASH_PHASE_RESET
:
288 case VG_PIXEL_LAYOUT
:
289 case VG_SCREEN_LAYOUT
:
290 case VG_FILTER_FORMAT_LINEAR
:
291 case VG_FILTER_FORMAT_PREMULTIPLIED
:
292 case VG_FILTER_CHANNEL_MASK
:
293 vegaSeti(type
, floor(values
[0]));
296 case VG_SCISSOR_RECTS
: {
298 VGuint
*x
= (VGuint
*)values
;
299 for (i
= 0; i
< count
; ++i
) {
300 state
->scissor_rects
[i
].f
= values
[i
];
301 state
->scissor_rects
[i
].i
= float_to_int_floor(x
[i
]);
303 state
->scissor_rects_num
= count
/ 4;
304 ctx
->state
.dirty
|= DEPTH_STENCIL_DIRTY
;
307 #ifdef OPENVG_VERSION_1_1
308 case VG_COLOR_TRANSFORM_VALUES
: {
310 for (i
= 0; i
< count
; ++i
) {
311 state
->color_transform_values
[i
] = values
[i
];
316 case VG_STROKE_LINE_WIDTH
:
317 state
->stroke
.line_width
.f
= values
[0];
318 state
->stroke
.line_width
.i
= float_to_int_floor(*((VGuint
*)(values
)));
320 case VG_STROKE_MITER_LIMIT
:
321 state
->stroke
.miter_limit
.f
= values
[0];
322 state
->stroke
.miter_limit
.i
= float_to_int_floor(*((VGuint
*)(values
)));
324 case VG_STROKE_DASH_PATTERN
: {
326 for (i
= 0; i
< count
; ++i
) {
327 state
->stroke
.dash_pattern
[i
].f
= values
[i
];
328 state
->stroke
.dash_pattern
[i
].i
=
329 float_to_int_floor(*((VGuint
*)(values
+ i
)));
331 state
->stroke
.dash_pattern_num
= count
;
334 case VG_STROKE_DASH_PHASE
:
335 state
->stroke
.dash_phase
.f
= values
[0];
336 state
->stroke
.dash_phase
.i
= float_to_int_floor(*((VGuint
*)(values
)));
338 case VG_TILE_FILL_COLOR
:
339 state
->tile_fill_color
[0] = values
[0];
340 state
->tile_fill_color
[1] = values
[1];
341 state
->tile_fill_color
[2] = values
[2];
342 state
->tile_fill_color
[3] = values
[3];
344 state
->tile_fill_colori
[0] = float_to_int_floor(*((VGuint
*)(values
+ 0)));
345 state
->tile_fill_colori
[1] = float_to_int_floor(*((VGuint
*)(values
+ 1)));
346 state
->tile_fill_colori
[2] = float_to_int_floor(*((VGuint
*)(values
+ 2)));
347 state
->tile_fill_colori
[3] = float_to_int_floor(*((VGuint
*)(values
+ 3)));
350 state
->clear_color
[0] = values
[0];
351 state
->clear_color
[1] = values
[1];
352 state
->clear_color
[2] = values
[2];
353 state
->clear_color
[3] = values
[3];
355 state
->clear_colori
[0] = float_to_int_floor(*((VGuint
*)(values
+ 0)));
356 state
->clear_colori
[1] = float_to_int_floor(*((VGuint
*)(values
+ 1)));
357 state
->clear_colori
[2] = float_to_int_floor(*((VGuint
*)(values
+ 2)));
358 state
->clear_colori
[3] = float_to_int_floor(*((VGuint
*)(values
+ 3)));
360 #ifdef OPENVG_VERSION_1_1
361 case VG_GLYPH_ORIGIN
:
362 state
->glyph_origin
[0].f
= values
[0];
363 state
->glyph_origin
[1].f
= values
[1];
365 state
->glyph_origin
[0].i
= float_to_int_floor(*((VGuint
*)(values
+ 0)));
366 state
->glyph_origin
[1].i
= float_to_int_floor(*((VGuint
*)(values
+ 1)));
370 case VG_MAX_SCISSOR_RECTS
:
371 case VG_MAX_DASH_COUNT
:
372 case VG_MAX_KERNEL_SIZE
:
373 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
374 case VG_MAX_COLOR_RAMP_STOPS
:
375 case VG_MAX_IMAGE_WIDTH
:
376 case VG_MAX_IMAGE_HEIGHT
:
377 case VG_MAX_IMAGE_PIXELS
:
378 case VG_MAX_IMAGE_BYTES
:
379 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
383 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
386 vg_set_error(ctx
, error
);
389 void vegaSetiv(VGParamType type
, VGint count
,
390 const VGint
* values
)
392 struct vg_context
*ctx
= vg_current_context();
393 struct vg_state
*state
= current_state();
395 if ((count
&& !values
) || !count_in_bounds(type
, count
) || !is_aligned(values
)) {
396 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
403 case VG_IMAGE_QUALITY
:
404 case VG_RENDERING_QUALITY
:
407 #ifdef OPENVG_VERSION_1_1
408 case VG_COLOR_TRANSFORM
:
410 case VG_STROKE_CAP_STYLE
:
411 case VG_STROKE_JOIN_STYLE
:
412 case VG_STROKE_DASH_PHASE_RESET
:
415 case VG_PIXEL_LAYOUT
:
416 case VG_SCREEN_LAYOUT
:
417 case VG_FILTER_FORMAT_LINEAR
:
418 case VG_FILTER_FORMAT_PREMULTIPLIED
:
419 case VG_FILTER_CHANNEL_MASK
:
420 vegaSeti(type
, values
[0]);
423 case VG_SCISSOR_RECTS
: {
425 for (i
= 0; i
< count
; ++i
) {
426 state
->scissor_rects
[i
].i
= values
[i
];
427 state
->scissor_rects
[i
].f
= values
[i
];
429 state
->scissor_rects_num
= count
/ 4;
430 ctx
->state
.dirty
|= DEPTH_STENCIL_DIRTY
;
433 #ifdef OPENVG_VERSION_1_1
434 case VG_COLOR_TRANSFORM_VALUES
: {
436 for (i
= 0; i
< count
; ++i
) {
437 state
->color_transform_values
[i
] = values
[i
];
442 case VG_STROKE_LINE_WIDTH
:
443 state
->stroke
.line_width
.f
= values
[0];
444 state
->stroke
.line_width
.i
= values
[0];
446 case VG_STROKE_MITER_LIMIT
:
447 state
->stroke
.miter_limit
.f
= values
[0];
448 state
->stroke
.miter_limit
.i
= values
[0];
450 case VG_STROKE_DASH_PATTERN
: {
452 for (i
= 0; i
< count
; ++i
) {
453 state
->stroke
.dash_pattern
[i
].f
= values
[i
];
454 state
->stroke
.dash_pattern
[i
].i
= values
[i
];
456 state
->stroke
.dash_pattern_num
= count
;
459 case VG_STROKE_DASH_PHASE
:
460 state
->stroke
.dash_phase
.f
= values
[0];
461 state
->stroke
.dash_phase
.i
= values
[0];
463 case VG_TILE_FILL_COLOR
:
464 state
->tile_fill_color
[0] = values
[0];
465 state
->tile_fill_color
[1] = values
[1];
466 state
->tile_fill_color
[2] = values
[2];
467 state
->tile_fill_color
[3] = values
[3];
469 state
->tile_fill_colori
[0] = values
[0];
470 state
->tile_fill_colori
[1] = values
[1];
471 state
->tile_fill_colori
[2] = values
[2];
472 state
->tile_fill_colori
[3] = values
[3];
475 state
->clear_color
[0] = values
[0];
476 state
->clear_color
[1] = values
[1];
477 state
->clear_color
[2] = values
[2];
478 state
->clear_color
[3] = values
[3];
480 state
->clear_colori
[0] = values
[0];
481 state
->clear_colori
[1] = values
[1];
482 state
->clear_colori
[2] = values
[2];
483 state
->clear_colori
[3] = values
[3];
485 #ifdef OPENVG_VERSION_1_1
486 case VG_GLYPH_ORIGIN
:
487 state
->glyph_origin
[0].f
= values
[0];
488 state
->glyph_origin
[1].f
= values
[1];
489 state
->glyph_origin
[0].i
= values
[0];
490 state
->glyph_origin
[1].i
= values
[1];
494 case VG_MAX_SCISSOR_RECTS
:
495 case VG_MAX_DASH_COUNT
:
496 case VG_MAX_KERNEL_SIZE
:
497 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
498 case VG_MAX_COLOR_RAMP_STOPS
:
499 case VG_MAX_IMAGE_WIDTH
:
500 case VG_MAX_IMAGE_HEIGHT
:
501 case VG_MAX_IMAGE_PIXELS
:
502 case VG_MAX_IMAGE_BYTES
:
503 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
508 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
513 VGfloat
vegaGetf(VGParamType type
)
515 struct vg_context
*ctx
= vg_current_context();
516 const struct vg_state
*state
= current_state();
517 VGErrorCode error
= VG_NO_ERROR
;
518 VGfloat value
= 0.0f
;
523 case VG_IMAGE_QUALITY
:
524 case VG_RENDERING_QUALITY
:
527 #ifdef OPENVG_VERSION_1_1
528 case VG_COLOR_TRANSFORM
:
530 case VG_STROKE_CAP_STYLE
:
531 case VG_STROKE_JOIN_STYLE
:
532 case VG_STROKE_DASH_PHASE_RESET
:
535 case VG_PIXEL_LAYOUT
:
536 case VG_SCREEN_LAYOUT
:
537 case VG_FILTER_FORMAT_LINEAR
:
538 case VG_FILTER_FORMAT_PREMULTIPLIED
:
539 case VG_FILTER_CHANNEL_MASK
:
540 return vegaGeti(type
);
542 case VG_STROKE_LINE_WIDTH
:
543 value
= state
->stroke
.line_width
.f
;
545 case VG_STROKE_MITER_LIMIT
:
546 value
= state
->stroke
.miter_limit
.f
;
548 case VG_STROKE_DASH_PHASE
:
549 value
= state
->stroke
.dash_phase
.f
;
552 case VG_MAX_SCISSOR_RECTS
:
553 case VG_MAX_DASH_COUNT
:
554 case VG_MAX_KERNEL_SIZE
:
555 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
556 case VG_MAX_COLOR_RAMP_STOPS
:
557 case VG_MAX_IMAGE_WIDTH
:
558 case VG_MAX_IMAGE_HEIGHT
:
559 case VG_MAX_IMAGE_PIXELS
:
560 case VG_MAX_IMAGE_BYTES
:
561 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
562 return vegaGeti(type
);
565 value
= 1e+10;/*must be at least 1e+10*/
568 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
571 vg_set_error(ctx
, error
);
575 VGint
vegaGeti(VGParamType type
)
577 const struct vg_state
*state
= current_state();
578 struct vg_context
*ctx
= vg_current_context();
579 VGErrorCode error
= VG_NO_ERROR
;
584 value
= state
->matrix_mode
;
587 value
= state
->fill_rule
;
589 case VG_IMAGE_QUALITY
:
590 value
= state
->image_quality
;
592 case VG_RENDERING_QUALITY
:
593 value
= state
->rendering_quality
;
596 value
= state
->blend_mode
;
599 value
= state
->image_mode
;
601 #ifdef OPENVG_VERSION_1_1
602 case VG_COLOR_TRANSFORM
:
603 value
= state
->color_transform
;
606 case VG_STROKE_LINE_WIDTH
:
607 value
= state
->stroke
.line_width
.i
;
609 case VG_STROKE_CAP_STYLE
:
610 value
= state
->stroke
.cap_style
;
612 case VG_STROKE_JOIN_STYLE
:
613 value
= state
->stroke
.join_style
;
615 case VG_STROKE_MITER_LIMIT
:
616 value
= state
->stroke
.miter_limit
.i
;
618 case VG_STROKE_DASH_PHASE
:
619 value
= state
->stroke
.dash_phase
.i
;
621 case VG_STROKE_DASH_PHASE_RESET
:
622 value
= state
->stroke
.dash_phase_reset
;
625 value
= state
->masking
;
628 value
= state
->scissoring
;
630 case VG_PIXEL_LAYOUT
:
631 value
= state
->pixel_layout
;
633 case VG_SCREEN_LAYOUT
:
634 value
= state
->screen_layout
;
636 case VG_FILTER_FORMAT_LINEAR
:
637 value
= state
->filter_format_linear
;
639 case VG_FILTER_FORMAT_PREMULTIPLIED
:
640 value
= state
->filter_format_premultiplied
;
642 case VG_FILTER_CHANNEL_MASK
:
643 value
= state
->filter_channel_mask
;
646 case VG_MAX_SCISSOR_RECTS
:
647 value
= 32; /*must be at least 32*/
649 case VG_MAX_DASH_COUNT
:
650 value
= 16; /*must be at least 16*/
652 case VG_MAX_KERNEL_SIZE
:
653 value
= 7; /*must be at least 7*/
655 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
656 value
= 15; /*must be at least 15*/
658 case VG_MAX_COLOR_RAMP_STOPS
:
659 value
= 256; /*must be at least 32*/
661 case VG_MAX_IMAGE_WIDTH
:
664 case VG_MAX_IMAGE_HEIGHT
:
667 case VG_MAX_IMAGE_PIXELS
:
670 case VG_MAX_IMAGE_BYTES
:
671 value
= 2048*2048 * 4;
673 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
674 value
= 128; /*must be at least 128*/
678 VGfloat val
= vegaGetf(type
);
679 value
= float_to_int_floor(*((VGuint
*)&val
));
683 error
= VG_ILLEGAL_ARGUMENT_ERROR
;
686 vg_set_error(ctx
, error
);
690 VGint
vegaGetVectorSize(VGParamType type
)
692 struct vg_context
*ctx
= vg_current_context();
693 const struct vg_state
*state
= current_state();
697 case VG_IMAGE_QUALITY
:
698 case VG_RENDERING_QUALITY
:
702 case VG_SCISSOR_RECTS
:
703 return state
->scissor_rects_num
* 4;
704 #ifdef OPENVG_VERSION_1_1
705 case VG_COLOR_TRANSFORM
:
707 case VG_COLOR_TRANSFORM_VALUES
:
710 case VG_STROKE_LINE_WIDTH
:
711 case VG_STROKE_CAP_STYLE
:
712 case VG_STROKE_JOIN_STYLE
:
713 case VG_STROKE_MITER_LIMIT
:
715 case VG_STROKE_DASH_PATTERN
:
716 return state
->stroke
.dash_pattern_num
;
717 case VG_STROKE_DASH_PHASE
:
719 case VG_STROKE_DASH_PHASE_RESET
:
721 case VG_TILE_FILL_COLOR
:
725 #ifdef OPENVG_VERSION_1_1
726 case VG_GLYPH_ORIGIN
:
733 case VG_PIXEL_LAYOUT
:
735 case VG_SCREEN_LAYOUT
:
737 case VG_FILTER_FORMAT_LINEAR
:
739 case VG_FILTER_FORMAT_PREMULTIPLIED
:
741 case VG_FILTER_CHANNEL_MASK
:
744 case VG_MAX_COLOR_RAMP_STOPS
:
746 case VG_MAX_SCISSOR_RECTS
:
747 case VG_MAX_DASH_COUNT
:
748 case VG_MAX_KERNEL_SIZE
:
749 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
750 case VG_MAX_IMAGE_WIDTH
:
751 case VG_MAX_IMAGE_HEIGHT
:
752 case VG_MAX_IMAGE_PIXELS
:
753 case VG_MAX_IMAGE_BYTES
:
755 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
759 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
764 void vegaGetfv(VGParamType type
, VGint count
,
767 const struct vg_state
*state
= current_state();
768 struct vg_context
*ctx
= vg_current_context();
769 VGint real_count
= vegaGetVectorSize(type
);
771 if (!values
|| count
<= 0 || count
> real_count
|| !is_aligned(values
)) {
772 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
779 case VG_IMAGE_QUALITY
:
780 case VG_RENDERING_QUALITY
:
783 #ifdef OPENVG_VERSION_1_1
784 case VG_COLOR_TRANSFORM
:
786 case VG_STROKE_CAP_STYLE
:
787 case VG_STROKE_JOIN_STYLE
:
788 case VG_STROKE_DASH_PHASE_RESET
:
791 case VG_PIXEL_LAYOUT
:
792 case VG_SCREEN_LAYOUT
:
793 case VG_FILTER_FORMAT_LINEAR
:
794 case VG_FILTER_FORMAT_PREMULTIPLIED
:
795 case VG_FILTER_CHANNEL_MASK
:
796 case VG_MAX_SCISSOR_RECTS
:
797 case VG_MAX_DASH_COUNT
:
798 case VG_MAX_KERNEL_SIZE
:
799 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
800 case VG_MAX_COLOR_RAMP_STOPS
:
801 case VG_MAX_IMAGE_WIDTH
:
802 case VG_MAX_IMAGE_HEIGHT
:
803 case VG_MAX_IMAGE_PIXELS
:
804 case VG_MAX_IMAGE_BYTES
:
805 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
806 values
[0] = vegaGeti(type
);
809 values
[0] = vegaGetf(type
);
811 case VG_SCISSOR_RECTS
: {
813 for (i
= 0; i
< count
; ++i
) {
814 values
[i
] = state
->scissor_rects
[i
].f
;
818 #ifdef OPENVG_VERSION_1_1
819 case VG_COLOR_TRANSFORM_VALUES
: {
820 memcpy(values
, state
->color_transform_values
,
821 sizeof(VGfloat
) * count
);
825 case VG_STROKE_LINE_WIDTH
:
826 values
[0] = state
->stroke
.line_width
.f
;
828 case VG_STROKE_MITER_LIMIT
:
829 values
[0] = state
->stroke
.miter_limit
.f
;
831 case VG_STROKE_DASH_PATTERN
: {
833 for (i
= 0; i
< count
; ++i
) {
834 values
[i
] = state
->stroke
.dash_pattern
[i
].f
;
838 case VG_STROKE_DASH_PHASE
:
839 values
[0] = state
->stroke
.dash_phase
.f
;
841 case VG_TILE_FILL_COLOR
:
842 values
[0] = state
->tile_fill_color
[0];
843 values
[1] = state
->tile_fill_color
[1];
844 values
[2] = state
->tile_fill_color
[2];
845 values
[3] = state
->tile_fill_color
[3];
848 values
[0] = state
->clear_color
[0];
849 values
[1] = state
->clear_color
[1];
850 values
[2] = state
->clear_color
[2];
851 values
[3] = state
->clear_color
[3];
853 #ifdef OPENVG_VERSION_1_1
854 case VG_GLYPH_ORIGIN
:
855 values
[0] = state
->glyph_origin
[0].f
;
856 values
[1] = state
->glyph_origin
[1].f
;
860 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
865 void vegaGetiv(VGParamType type
, VGint count
,
868 const struct vg_state
*state
= current_state();
869 struct vg_context
*ctx
= vg_current_context();
870 VGint real_count
= vegaGetVectorSize(type
);
872 if (!values
|| count
<= 0 || count
> real_count
|| !is_aligned(values
)) {
873 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
880 case VG_IMAGE_QUALITY
:
881 case VG_RENDERING_QUALITY
:
884 #ifdef OPENVG_VERSION_1_1
885 case VG_COLOR_TRANSFORM
:
887 case VG_STROKE_CAP_STYLE
:
888 case VG_STROKE_JOIN_STYLE
:
889 case VG_STROKE_DASH_PHASE_RESET
:
892 case VG_PIXEL_LAYOUT
:
893 case VG_SCREEN_LAYOUT
:
894 case VG_FILTER_FORMAT_LINEAR
:
895 case VG_FILTER_FORMAT_PREMULTIPLIED
:
896 case VG_FILTER_CHANNEL_MASK
:
897 case VG_MAX_SCISSOR_RECTS
:
898 case VG_MAX_DASH_COUNT
:
899 case VG_MAX_KERNEL_SIZE
:
900 case VG_MAX_SEPARABLE_KERNEL_SIZE
:
901 case VG_MAX_COLOR_RAMP_STOPS
:
902 case VG_MAX_IMAGE_WIDTH
:
903 case VG_MAX_IMAGE_HEIGHT
:
904 case VG_MAX_IMAGE_PIXELS
:
905 case VG_MAX_IMAGE_BYTES
:
906 case VG_MAX_GAUSSIAN_STD_DEVIATION
:
907 values
[0] = vegaGeti(type
);
910 VGfloat val
= vegaGetf(type
);
911 values
[0] = float_to_int_floor(*((VGuint
*)&val
));
914 case VG_SCISSOR_RECTS
: {
916 for (i
= 0; i
< count
; ++i
) {
917 values
[i
] = state
->scissor_rects
[i
].i
;
921 #ifdef OPENVG_VERSION_1_1
922 case VG_COLOR_TRANSFORM_VALUES
: {
924 VGuint
*x
= (VGuint
*)state
->color_transform_values
;
925 for (i
= 0; i
< count
; ++i
) {
926 values
[i
] = float_to_int_floor(x
[i
]);
931 case VG_STROKE_LINE_WIDTH
:
932 values
[0] = state
->stroke
.line_width
.i
;
934 case VG_STROKE_MITER_LIMIT
:
935 values
[0] = state
->stroke
.miter_limit
.i
;
937 case VG_STROKE_DASH_PATTERN
: {
939 for (i
= 0; i
< count
; ++i
) {
940 values
[i
] = state
->stroke
.dash_pattern
[i
].i
;
944 case VG_STROKE_DASH_PHASE
:
945 values
[0] = state
->stroke
.dash_phase
.i
;
947 case VG_TILE_FILL_COLOR
:
948 values
[0] = state
->tile_fill_colori
[0];
949 values
[1] = state
->tile_fill_colori
[1];
950 values
[2] = state
->tile_fill_colori
[2];
951 values
[3] = state
->tile_fill_colori
[3];
954 values
[0] = state
->clear_colori
[0];
955 values
[1] = state
->clear_colori
[1];
956 values
[2] = state
->clear_colori
[2];
957 values
[3] = state
->clear_colori
[3];
959 #ifdef OPENVG_VERSION_1_1
960 case VG_GLYPH_ORIGIN
:
961 values
[0] = state
->glyph_origin
[0].i
;
962 values
[1] = state
->glyph_origin
[1].i
;
966 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
971 void vegaSetParameterf(VGHandle object
,
975 struct vg_context
*ctx
= vg_current_context();
976 void *ptr
= handle_to_pointer(object
);
978 if (object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
979 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
985 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
986 case VG_PAINT_PATTERN_TILING_MODE
:
987 vegaSetParameteri(object
, paramType
, floor(value
));
991 case VG_PAINT_COLOR_RAMP_STOPS
:
992 case VG_PAINT_LINEAR_GRADIENT
:
993 case VG_PAINT_RADIAL_GRADIENT
:
994 /* it's an error if paramType refers to a vector parameter */
995 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
997 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
998 struct vg_paint
*p
= handle_to_paint(object
);
999 paint_set_color_ramp_premultiplied(p
, value
);
1003 case VG_PATH_DATATYPE
:
1004 case VG_PATH_FORMAT
:
1007 case VG_PATH_NUM_SEGMENTS
:
1008 case VG_PATH_NUM_COORDS
:
1010 case VG_IMAGE_FORMAT
:
1011 case VG_IMAGE_WIDTH
:
1012 case VG_IMAGE_HEIGHT
:
1014 #ifdef OPENVG_VERSION_1_1
1015 case VG_FONT_NUM_GLYPHS
:
1016 /* read only don't produce an error */
1020 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1025 void vegaSetParameteri(VGHandle object
,
1029 struct vg_context
*ctx
= vg_current_context();
1030 void *ptr
= handle_to_pointer(object
);
1032 if (object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
1033 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1039 if (value
< VG_PAINT_TYPE_COLOR
||
1040 value
> VG_PAINT_TYPE_PATTERN
)
1041 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1043 struct vg_paint
*paint
= handle_to_paint(object
);
1044 paint_set_type(paint
, value
);
1047 case VG_PAINT_COLOR
:
1048 case VG_PAINT_COLOR_RAMP_STOPS
:
1049 case VG_PAINT_LINEAR_GRADIENT
:
1050 case VG_PAINT_RADIAL_GRADIENT
:
1051 /* it's an error if paramType refers to a vector parameter */
1052 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1054 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1055 if (value
< VG_COLOR_RAMP_SPREAD_PAD
||
1056 value
> VG_COLOR_RAMP_SPREAD_REFLECT
)
1057 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1059 struct vg_paint
*paint
= handle_to_paint(object
);
1060 paint_set_spread_mode(paint
, value
);
1063 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
1064 struct vg_paint
*p
= handle_to_paint(object
);
1065 paint_set_color_ramp_premultiplied(p
, value
);
1068 case VG_PAINT_PATTERN_TILING_MODE
:
1069 if (value
< VG_TILE_FILL
||
1070 value
> VG_TILE_REFLECT
)
1071 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1073 struct vg_paint
*paint
= handle_to_paint(object
);
1074 paint_set_pattern_tiling(paint
, value
);
1078 case VG_PATH_DATATYPE
:
1079 case VG_PATH_FORMAT
:
1082 case VG_PATH_NUM_SEGMENTS
:
1083 case VG_PATH_NUM_COORDS
:
1085 case VG_IMAGE_FORMAT
:
1086 case VG_IMAGE_WIDTH
:
1087 case VG_IMAGE_HEIGHT
:
1089 #ifdef OPENVG_VERSION_1_1
1090 case VG_FONT_NUM_GLYPHS
:
1091 /* read only don't produce an error */
1095 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1100 void vegaSetParameterfv(VGHandle object
,
1103 const VGfloat
* values
)
1105 struct vg_context
*ctx
= vg_current_context();
1106 void *ptr
= handle_to_pointer(object
);
1107 VGint real_count
= vegaGetParameterVectorSize(object
, paramType
);
1109 if (object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
1110 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1114 if (count
< 0 || count
< real_count
||
1115 (values
== NULL
&& count
!= 0) ||
1116 !is_aligned(values
)) {
1117 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1123 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1124 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1125 case VG_PAINT_PATTERN_TILING_MODE
:
1127 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1129 vegaSetParameterf(object
, paramType
, values
[0]);
1132 case VG_PAINT_COLOR
: {
1134 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1136 struct vg_paint
*paint
= handle_to_paint(object
);
1137 paint_set_color(paint
, values
);
1138 if (ctx
->state
.vg
.fill_paint
== paint
||
1139 ctx
->state
.vg
.stroke_paint
== paint
)
1140 ctx
->state
.dirty
|= PAINT_DIRTY
;
1144 case VG_PAINT_COLOR_RAMP_STOPS
: {
1145 if (count
&& count
< 4)
1146 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1148 struct vg_paint
*paint
= handle_to_paint(object
);
1149 count
= MIN2(count
, VEGA_MAX_COLOR_RAMP_STOPS
);
1150 paint_set_ramp_stops(paint
, values
, count
);
1152 VGint stopsi
[VEGA_MAX_COLOR_RAMP_STOPS
];
1154 for (i
= 0; i
< count
; ++i
) {
1155 stopsi
[i
] = float_to_int_floor(*((VGuint
*)(values
+ i
)));
1157 paint_set_ramp_stopsi(paint
, stopsi
, count
);
1162 case VG_PAINT_LINEAR_GRADIENT
: {
1164 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1166 struct vg_paint
*paint
= handle_to_paint(object
);
1167 paint_set_linear_gradient(paint
, values
);
1170 vals
[0] = FLT_TO_INT(values
[0]);
1171 vals
[1] = FLT_TO_INT(values
[1]);
1172 vals
[2] = FLT_TO_INT(values
[2]);
1173 vals
[3] = FLT_TO_INT(values
[3]);
1174 paint_set_linear_gradienti(paint
, vals
);
1179 case VG_PAINT_RADIAL_GRADIENT
: {
1181 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1183 struct vg_paint
*paint
= handle_to_paint(object
);
1184 paint_set_radial_gradient(paint
, values
);
1187 vals
[0] = FLT_TO_INT(values
[0]);
1188 vals
[1] = FLT_TO_INT(values
[1]);
1189 vals
[2] = FLT_TO_INT(values
[2]);
1190 vals
[3] = FLT_TO_INT(values
[3]);
1191 vals
[4] = FLT_TO_INT(values
[4]);
1192 paint_set_radial_gradienti(paint
, vals
);
1198 case VG_PATH_DATATYPE
:
1199 case VG_PATH_FORMAT
:
1202 case VG_PATH_NUM_SEGMENTS
:
1203 case VG_PATH_NUM_COORDS
:
1205 #ifdef OPENVG_VERSION_1_1
1206 case VG_FONT_NUM_GLYPHS
:
1207 /* read only don't produce an error */
1211 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1216 void vegaSetParameteriv(VGHandle object
,
1219 const VGint
* values
)
1221 struct vg_context
*ctx
= vg_current_context();
1222 void *ptr
= handle_to_pointer(object
);
1223 VGint real_count
= vegaGetParameterVectorSize(object
, paramType
);
1225 if (object
== VG_INVALID_HANDLE
|| !is_aligned(ptr
)) {
1226 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1230 if (count
< 0 || count
< real_count
||
1231 (values
== NULL
&& count
!= 0) ||
1232 !is_aligned(values
)) {
1233 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1239 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1240 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1241 case VG_PAINT_PATTERN_TILING_MODE
:
1243 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1245 vegaSetParameteri(object
, paramType
, values
[0]);
1248 case VG_PAINT_COLOR
: {
1250 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1252 struct vg_paint
*paint
= handle_to_paint(object
);
1253 paint_set_coloriv(paint
, values
);
1254 if (ctx
->state
.vg
.fill_paint
== paint
||
1255 ctx
->state
.vg
.stroke_paint
== paint
)
1256 ctx
->state
.dirty
|= PAINT_DIRTY
;
1260 case VG_PAINT_COLOR_RAMP_STOPS
: {
1262 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1266 struct vg_paint
*paint
= handle_to_paint(object
);
1268 vals
= malloc(sizeof(VGfloat
)*count
);
1269 for (i
= 0; i
< count
; ++i
)
1270 vals
[i
] = values
[i
];
1273 paint_set_ramp_stopsi(paint
, values
, count
);
1274 paint_set_ramp_stops(paint
, vals
, count
);
1279 case VG_PAINT_LINEAR_GRADIENT
: {
1281 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1284 struct vg_paint
*paint
= handle_to_paint(object
);
1285 vals
[0] = values
[0];
1286 vals
[1] = values
[1];
1287 vals
[2] = values
[2];
1288 vals
[3] = values
[3];
1289 paint_set_linear_gradient(paint
, vals
);
1290 paint_set_linear_gradienti(paint
, values
);
1294 case VG_PAINT_RADIAL_GRADIENT
: {
1296 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1299 struct vg_paint
*paint
= handle_to_paint(object
);
1300 vals
[0] = values
[0];
1301 vals
[1] = values
[1];
1302 vals
[2] = values
[2];
1303 vals
[3] = values
[3];
1304 vals
[4] = values
[4];
1305 paint_set_radial_gradient(paint
, vals
);
1306 paint_set_radial_gradienti(paint
, values
);
1310 case VG_PATH_DATATYPE
:
1311 case VG_PATH_FORMAT
:
1314 case VG_PATH_NUM_SEGMENTS
:
1315 case VG_PATH_NUM_COORDS
:
1316 /* read only don't produce an error */
1319 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1324 VGint
vegaGetParameterVectorSize(VGHandle object
,
1327 struct vg_context
*ctx
= vg_current_context();
1329 if (object
== VG_INVALID_HANDLE
) {
1330 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1336 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1337 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1338 case VG_PAINT_PATTERN_TILING_MODE
:
1340 case VG_PAINT_COLOR
:
1342 case VG_PAINT_COLOR_RAMP_STOPS
: {
1343 struct vg_paint
*p
= handle_to_paint(object
);
1344 return paint_num_ramp_stops(p
);
1347 case VG_PAINT_LINEAR_GRADIENT
:
1349 case VG_PAINT_RADIAL_GRADIENT
:
1353 case VG_PATH_FORMAT
:
1354 case VG_PATH_DATATYPE
:
1357 case VG_PATH_NUM_SEGMENTS
:
1358 case VG_PATH_NUM_COORDS
:
1361 case VG_IMAGE_FORMAT
:
1362 case VG_IMAGE_WIDTH
:
1363 case VG_IMAGE_HEIGHT
:
1366 #ifdef OPENVG_VERSION_1_1
1367 case VG_FONT_NUM_GLYPHS
:
1372 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1379 VGfloat
vegaGetParameterf(VGHandle object
,
1382 struct vg_context
*ctx
= vg_current_context();
1384 if (object
== VG_INVALID_HANDLE
) {
1385 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1391 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1392 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1393 case VG_PAINT_PATTERN_TILING_MODE
:
1394 return vegaGetParameteri(object
, paramType
);
1396 case VG_PAINT_COLOR
:
1397 case VG_PAINT_COLOR_RAMP_STOPS
:
1398 case VG_PAINT_LINEAR_GRADIENT
:
1399 case VG_PAINT_RADIAL_GRADIENT
:
1400 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1403 case VG_PATH_FORMAT
:
1404 return VG_PATH_FORMAT_STANDARD
;
1405 case VG_PATH_SCALE
: {
1406 struct path
*p
= handle_to_path(object
);
1407 return path_scale(p
);
1409 case VG_PATH_BIAS
: {
1410 struct path
*p
= handle_to_path(object
);
1411 return path_bias(p
);
1413 case VG_PATH_DATATYPE
:
1414 case VG_PATH_NUM_SEGMENTS
:
1415 case VG_PATH_NUM_COORDS
:
1416 return vegaGetParameteri(object
, paramType
);
1419 case VG_IMAGE_FORMAT
:
1420 case VG_IMAGE_WIDTH
:
1421 case VG_IMAGE_HEIGHT
:
1422 #ifdef OPENVG_VERSION_1_1
1423 case VG_FONT_NUM_GLYPHS
:
1424 return vegaGetParameteri(object
, paramType
);
1429 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1435 VGint
vegaGetParameteri(VGHandle object
,
1438 struct vg_context
*ctx
= vg_current_context();
1440 if (object
== VG_INVALID_HANDLE
) {
1441 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1446 case VG_PAINT_TYPE
: {
1447 struct vg_paint
*paint
= handle_to_paint(object
);
1448 return paint_type(paint
);
1451 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
: {
1452 struct vg_paint
*p
= handle_to_paint(object
);
1453 return paint_spread_mode(p
);
1455 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
1456 struct vg_paint
*p
= handle_to_paint(object
);
1457 return paint_color_ramp_premultiplied(p
);
1460 case VG_PAINT_PATTERN_TILING_MODE
: {
1461 struct vg_paint
*p
= handle_to_paint(object
);
1462 return paint_pattern_tiling(p
);
1465 case VG_PAINT_COLOR
:
1466 case VG_PAINT_COLOR_RAMP_STOPS
:
1467 case VG_PAINT_LINEAR_GRADIENT
:
1468 case VG_PAINT_RADIAL_GRADIENT
:
1469 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1472 case VG_PATH_FORMAT
:
1473 return VG_PATH_FORMAT_STANDARD
;
1476 return vegaGetParameterf(object
, paramType
);
1477 case VG_PATH_DATATYPE
: {
1478 struct path
*p
= handle_to_path(object
);
1479 return path_datatype(p
);
1481 case VG_PATH_NUM_SEGMENTS
: {
1482 struct path
*p
= handle_to_path(object
);
1483 return path_num_segments(p
);
1485 case VG_PATH_NUM_COORDS
: {
1486 struct path
*p
= handle_to_path(object
);
1487 return path_num_coords(p
);
1491 case VG_IMAGE_FORMAT
: {
1492 struct vg_image
*img
= handle_to_image(object
);
1496 case VG_IMAGE_WIDTH
: {
1497 struct vg_image
*img
= handle_to_image(object
);
1501 case VG_IMAGE_HEIGHT
: {
1502 struct vg_image
*img
= handle_to_image(object
);
1507 #ifdef OPENVG_VERSION_1_1
1508 case VG_FONT_NUM_GLYPHS
: {
1509 struct vg_font
*font
= handle_to_font(object
);
1510 return font_num_glyphs(font
);
1516 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1522 void vegaGetParameterfv(VGHandle object
,
1527 struct vg_context
*ctx
= vg_current_context();
1528 VGint real_count
= vegaGetParameterVectorSize(object
, paramType
);
1530 if (object
== VG_INVALID_HANDLE
) {
1531 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1535 if (!values
|| count
<= 0 || count
> real_count
||
1536 !is_aligned(values
)) {
1537 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1542 case VG_PAINT_TYPE
: {
1543 struct vg_paint
*p
= handle_to_paint(object
);
1544 values
[0] = paint_type(p
);
1547 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
: {
1548 struct vg_paint
*p
= handle_to_paint(object
);
1549 values
[0] = paint_spread_mode(p
);
1552 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
: {
1553 struct vg_paint
*p
= handle_to_paint(object
);
1554 values
[0] = paint_color_ramp_premultiplied(p
);
1557 case VG_PAINT_PATTERN_TILING_MODE
: {
1558 values
[0] = vegaGetParameterf(object
, paramType
);
1561 case VG_PAINT_COLOR
: {
1562 struct vg_paint
*paint
= handle_to_paint(object
);
1563 paint_get_color(paint
, values
);
1566 case VG_PAINT_COLOR_RAMP_STOPS
: {
1567 struct vg_paint
*paint
= handle_to_paint(object
);
1568 paint_ramp_stops(paint
, values
, count
);
1571 case VG_PAINT_LINEAR_GRADIENT
: {
1572 struct vg_paint
*paint
= handle_to_paint(object
);
1573 paint_linear_gradient(paint
, values
);
1576 case VG_PAINT_RADIAL_GRADIENT
: {
1577 struct vg_paint
*paint
= handle_to_paint(object
);
1578 paint_radial_gradient(paint
, values
);
1582 case VG_PATH_FORMAT
:
1583 case VG_PATH_DATATYPE
:
1584 case VG_PATH_NUM_SEGMENTS
:
1585 case VG_PATH_NUM_COORDS
:
1586 values
[0] = vegaGetParameteri(object
, paramType
);
1590 values
[0] = vegaGetParameterf(object
, paramType
);
1593 case VG_IMAGE_FORMAT
:
1594 case VG_IMAGE_WIDTH
:
1595 case VG_IMAGE_HEIGHT
:
1596 #ifdef OPENVG_VERSION_1_1
1597 case VG_FONT_NUM_GLYPHS
:
1598 values
[0] = vegaGetParameteri(object
, paramType
);
1603 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1608 void vegaGetParameteriv(VGHandle object
,
1613 struct vg_context
*ctx
= vg_current_context();
1614 VGint real_count
= vegaGetParameterVectorSize(object
, paramType
);
1616 if (object
|| object
== VG_INVALID_HANDLE
) {
1617 vg_set_error(ctx
, VG_BAD_HANDLE_ERROR
);
1621 if (!values
|| count
<= 0 || count
> real_count
||
1622 !is_aligned(values
)) {
1623 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);
1629 case VG_PAINT_COLOR_RAMP_SPREAD_MODE
:
1630 case VG_PAINT_COLOR_RAMP_PREMULTIPLIED
:
1631 case VG_PAINT_PATTERN_TILING_MODE
:
1632 #ifdef OPENVG_VERSION_1_1
1633 case VG_FONT_NUM_GLYPHS
:
1634 values
[0] = vegaGetParameteri(object
, paramType
);
1637 case VG_PAINT_COLOR
: {
1638 struct vg_paint
*paint
= handle_to_paint(object
);
1639 paint_get_coloriv(paint
, values
);
1642 case VG_PAINT_COLOR_RAMP_STOPS
: {
1643 struct vg_paint
*paint
= handle_to_paint(object
);
1644 paint_ramp_stopsi(paint
, values
, count
);
1647 case VG_PAINT_LINEAR_GRADIENT
: {
1648 struct vg_paint
*paint
= handle_to_paint(object
);
1649 paint_linear_gradienti(paint
, values
);
1652 case VG_PAINT_RADIAL_GRADIENT
: {
1653 struct vg_paint
*paint
= handle_to_paint(object
);
1654 paint_radial_gradienti(paint
, values
);
1660 values
[0] = vegaGetParameterf(object
, paramType
);
1662 case VG_PATH_FORMAT
:
1663 case VG_PATH_DATATYPE
:
1664 case VG_PATH_NUM_SEGMENTS
:
1665 case VG_PATH_NUM_COORDS
:
1666 values
[0] = vegaGetParameteri(object
, paramType
);
1669 case VG_IMAGE_FORMAT
:
1670 case VG_IMAGE_WIDTH
:
1671 case VG_IMAGE_HEIGHT
:
1672 values
[0] = vegaGetParameteri(object
, paramType
);
1676 vg_set_error(ctx
, VG_ILLEGAL_ARGUMENT_ERROR
);