diff options
Diffstat (limited to 'src/gallium/state_trackers/vega/api_params.c')
-rw-r--r-- | src/gallium/state_trackers/vega/api_params.c | 178 |
1 files changed, 90 insertions, 88 deletions
diff --git a/src/gallium/state_trackers/vega/api_params.c b/src/gallium/state_trackers/vega/api_params.c index a73b6c3eff..aa1e5dd280 100644 --- a/src/gallium/state_trackers/vega/api_params.c +++ b/src/gallium/state_trackers/vega/api_params.c @@ -29,6 +29,7 @@ #include "vg_context.h" #include "paint.h" #include "path.h" +#include "handle.h" #include "image.h" #include "text.h" #include "matrix.h" @@ -60,7 +61,7 @@ static INLINE VGboolean count_in_bounds(VGParamType type, VGint count) else if (type == VG_STROKE_DASH_PATTERN) { return count <= VEGA_MAX_DASH_COUNT; } else { - VGint real_count = vgGetVectorSize(type); + VGint real_count = vegaGetVectorSize(type); return count == real_count; } } @@ -103,7 +104,7 @@ void vegaSetf (VGParamType type, VGfloat value) case VG_MAX_IMAGE_BYTES: case VG_MAX_GAUSSIAN_STD_DEVIATION: case VG_MAX_FLOAT: - vgSeti(type, floor(value)); + vegaSeti(type, floor(value)); return; break; case VG_STROKE_LINE_WIDTH: @@ -289,7 +290,7 @@ void vegaSetfv(VGParamType type, VGint count, case VG_FILTER_FORMAT_LINEAR: case VG_FILTER_FORMAT_PREMULTIPLIED: case VG_FILTER_CHANNEL_MASK: - vgSeti(type, floor(values[0])); + vegaSeti(type, floor(values[0])); return; break; case VG_SCISSOR_RECTS: { @@ -416,7 +417,7 @@ void vegaSetiv(VGParamType type, VGint count, case VG_FILTER_FORMAT_LINEAR: case VG_FILTER_FORMAT_PREMULTIPLIED: case VG_FILTER_CHANNEL_MASK: - vgSeti(type, values[0]); + vegaSeti(type, values[0]); return; break; case VG_SCISSOR_RECTS: { @@ -536,7 +537,7 @@ VGfloat vegaGetf(VGParamType type) case VG_FILTER_FORMAT_LINEAR: case VG_FILTER_FORMAT_PREMULTIPLIED: case VG_FILTER_CHANNEL_MASK: - return vgGeti(type); + return vegaGeti(type); break; case VG_STROKE_LINE_WIDTH: value = state->stroke.line_width.f; @@ -558,7 +559,7 @@ VGfloat vegaGetf(VGParamType type) case VG_MAX_IMAGE_PIXELS: case VG_MAX_IMAGE_BYTES: case VG_MAX_GAUSSIAN_STD_DEVIATION: - return vgGeti(type); + return vegaGeti(type); break; case VG_MAX_FLOAT: value = 1e+10;/*must be at least 1e+10*/ @@ -674,7 +675,7 @@ VGint vegaGeti(VGParamType type) break; case VG_MAX_FLOAT: { - VGfloat val = vgGetf(type); + VGfloat val = vegaGetf(type); value = float_to_int_floor(*((VGuint*)&val)); } break; @@ -765,7 +766,7 @@ void vegaGetfv(VGParamType type, VGint count, { const struct vg_state *state = current_state(); struct vg_context *ctx = vg_current_context(); - VGint real_count = vgGetVectorSize(type); + VGint real_count = vegaGetVectorSize(type); if (!values || count <= 0 || count > real_count || !is_aligned(values)) { vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); @@ -802,10 +803,10 @@ void vegaGetfv(VGParamType type, VGint count, case VG_MAX_IMAGE_PIXELS: case VG_MAX_IMAGE_BYTES: case VG_MAX_GAUSSIAN_STD_DEVIATION: - values[0] = vgGeti(type); + values[0] = vegaGeti(type); break; case VG_MAX_FLOAT: - values[0] = vgGetf(type); + values[0] = vegaGetf(type); break; case VG_SCISSOR_RECTS: { VGint i; @@ -866,7 +867,7 @@ void vegaGetiv(VGParamType type, VGint count, { const struct vg_state *state = current_state(); struct vg_context *ctx = vg_current_context(); - VGint real_count = vgGetVectorSize(type); + VGint real_count = vegaGetVectorSize(type); if (!values || count <= 0 || count > real_count || !is_aligned(values)) { vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); @@ -903,10 +904,10 @@ void vegaGetiv(VGParamType type, VGint count, case VG_MAX_IMAGE_PIXELS: case VG_MAX_IMAGE_BYTES: case VG_MAX_GAUSSIAN_STD_DEVIATION: - values[0] = vgGeti(type); + values[0] = vegaGeti(type); break; case VG_MAX_FLOAT: { - VGfloat val = vgGetf(type); + VGfloat val = vegaGetf(type); values[0] = float_to_int_floor(*((VGuint*)&val)); } break; @@ -972,9 +973,9 @@ void vegaSetParameterf(VGHandle object, VGfloat value) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; + void *ptr = handle_to_pointer(object); - if (!object || object == VG_INVALID_HANDLE || !is_aligned(ptr)) { + if (object == VG_INVALID_HANDLE || !is_aligned(ptr)) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return; } @@ -983,7 +984,7 @@ void vegaSetParameterf(VGHandle object, case VG_PAINT_TYPE: case VG_PAINT_COLOR_RAMP_SPREAD_MODE: case VG_PAINT_PATTERN_TILING_MODE: - vgSetParameteri(object, paramType, floor(value)); + vegaSetParameteri(object, paramType, floor(value)); return; break; case VG_PAINT_COLOR: @@ -994,7 +995,7 @@ void vegaSetParameterf(VGHandle object, vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); break; case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); paint_set_color_ramp_premultiplied(p, value); } break; @@ -1026,9 +1027,9 @@ void vegaSetParameteri(VGHandle object, VGint value) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; + void *ptr = handle_to_pointer(object); - if (!object || object == VG_INVALID_HANDLE || !is_aligned(ptr)) { + if (object == VG_INVALID_HANDLE || !is_aligned(ptr)) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return; } @@ -1039,7 +1040,7 @@ void vegaSetParameteri(VGHandle object, value > VG_PAINT_TYPE_PATTERN) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)ptr; + struct vg_paint *paint = handle_to_paint(object); paint_set_type(paint, value); } break; @@ -1055,12 +1056,12 @@ void vegaSetParameteri(VGHandle object, value > VG_COLOR_RAMP_SPREAD_REFLECT) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)ptr; + struct vg_paint *paint = handle_to_paint(object); paint_set_spread_mode(paint, value); } break; case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); paint_set_color_ramp_premultiplied(p, value); } break; @@ -1069,7 +1070,7 @@ void vegaSetParameteri(VGHandle object, value > VG_TILE_REFLECT) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)ptr; + struct vg_paint *paint = handle_to_paint(object); paint_set_pattern_tiling(paint, value); } break; @@ -1102,10 +1103,10 @@ void vegaSetParameterfv(VGHandle object, const VGfloat * values) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; - VGint real_count = vgGetParameterVectorSize(object, paramType); + void *ptr = handle_to_pointer(object); + VGint real_count = vegaGetParameterVectorSize(object, paramType); - if (!object || object == VG_INVALID_HANDLE || !is_aligned(ptr)) { + if (object == VG_INVALID_HANDLE || !is_aligned(ptr)) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return; } @@ -1125,15 +1126,18 @@ void vegaSetParameterfv(VGHandle object, if (count != 1) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else - vgSetParameterf(object, paramType, values[0]); + vegaSetParameterf(object, paramType, values[0]); return; break; case VG_PAINT_COLOR: { if (count != 4) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_set_color(paint, values); + if (ctx->state.vg.fill_paint == paint || + ctx->state.vg.stroke_paint == paint) + ctx->state.dirty |= PAINT_DIRTY; } } break; @@ -1141,7 +1145,7 @@ void vegaSetParameterfv(VGHandle object, if (count && count < 4) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); count = MIN2(count, VEGA_MAX_COLOR_RAMP_STOPS); paint_set_ramp_stops(paint, values, count); { @@ -1159,7 +1163,7 @@ void vegaSetParameterfv(VGHandle object, if (count != 4) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_set_linear_gradient(paint, values); { VGint vals[4]; @@ -1176,7 +1180,7 @@ void vegaSetParameterfv(VGHandle object, if (count != 5) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_set_radial_gradient(paint, values); { VGint vals[5]; @@ -1215,10 +1219,10 @@ void vegaSetParameteriv(VGHandle object, const VGint * values) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; - VGint real_count = vgGetParameterVectorSize(object, paramType); + void *ptr = handle_to_pointer(object); + VGint real_count = vegaGetParameterVectorSize(object, paramType); - if (!object || object == VG_INVALID_HANDLE || !is_aligned(ptr)) { + if (object == VG_INVALID_HANDLE || !is_aligned(ptr)) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return; } @@ -1238,15 +1242,18 @@ void vegaSetParameteriv(VGHandle object, if (count != 1) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else - vgSetParameteri(object, paramType, values[0]); + vegaSetParameteri(object, paramType, values[0]); return; break; case VG_PAINT_COLOR: { if (count != 4) vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_set_coloriv(paint, values); + if (ctx->state.vg.fill_paint == paint || + ctx->state.vg.stroke_paint == paint) + ctx->state.dirty |= PAINT_DIRTY; } } break; @@ -1256,7 +1263,7 @@ void vegaSetParameteriv(VGHandle object, else { VGfloat *vals = 0; int i; - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); if (count) { vals = malloc(sizeof(VGfloat)*count); for (i = 0; i < count; ++i) @@ -1274,7 +1281,7 @@ void vegaSetParameteriv(VGHandle object, vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { VGfloat vals[4]; - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); vals[0] = values[0]; vals[1] = values[1]; vals[2] = values[2]; @@ -1289,7 +1296,7 @@ void vegaSetParameteriv(VGHandle object, vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); else { VGfloat vals[5]; - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); vals[0] = values[0]; vals[1] = values[1]; vals[2] = values[2]; @@ -1318,9 +1325,8 @@ VGint vegaGetParameterVectorSize(VGHandle object, VGint paramType) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; - if (!ptr || object == VG_INVALID_HANDLE) { + if (object == VG_INVALID_HANDLE) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return 0; } @@ -1334,7 +1340,7 @@ VGint vegaGetParameterVectorSize(VGHandle object, case VG_PAINT_COLOR: return 4; case VG_PAINT_COLOR_RAMP_STOPS: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); return paint_num_ramp_stops(p); } break; @@ -1374,9 +1380,8 @@ VGfloat vegaGetParameterf(VGHandle object, VGint paramType) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; - if (!ptr || object == VG_INVALID_HANDLE) { + if (object == VG_INVALID_HANDLE) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return 0; } @@ -1386,7 +1391,7 @@ VGfloat vegaGetParameterf(VGHandle object, case VG_PAINT_COLOR_RAMP_SPREAD_MODE: case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: case VG_PAINT_PATTERN_TILING_MODE: - return vgGetParameteri(object, paramType); + return vegaGetParameteri(object, paramType); break; case VG_PAINT_COLOR: case VG_PAINT_COLOR_RAMP_STOPS: @@ -1398,17 +1403,17 @@ VGfloat vegaGetParameterf(VGHandle object, case VG_PATH_FORMAT: return VG_PATH_FORMAT_STANDARD; case VG_PATH_SCALE: { - struct path *p = (struct path*)object; + struct path *p = handle_to_path(object); return path_scale(p); } case VG_PATH_BIAS: { - struct path *p = (struct path*)object; + struct path *p = handle_to_path(object); return path_bias(p); } case VG_PATH_DATATYPE: case VG_PATH_NUM_SEGMENTS: case VG_PATH_NUM_COORDS: - return vgGetParameteri(object, paramType); + return vegaGetParameteri(object, paramType); break; case VG_IMAGE_FORMAT: @@ -1416,7 +1421,7 @@ VGfloat vegaGetParameterf(VGHandle object, case VG_IMAGE_HEIGHT: #ifdef OPENVG_VERSION_1_1 case VG_FONT_NUM_GLYPHS: - return vgGetParameteri(object, paramType); + return vegaGetParameteri(object, paramType); break; #endif @@ -1431,30 +1436,29 @@ VGint vegaGetParameteri(VGHandle object, VGint paramType) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; - if (!ptr || object == VG_INVALID_HANDLE) { + if (object == VG_INVALID_HANDLE) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return 0; } switch(paramType) { case VG_PAINT_TYPE: { - struct vg_paint *paint = (struct vg_paint *)ptr; + struct vg_paint *paint = handle_to_paint(object); return paint_type(paint); } break; case VG_PAINT_COLOR_RAMP_SPREAD_MODE: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); return paint_spread_mode(p); } case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); return paint_color_ramp_premultiplied(p); } break; case VG_PAINT_PATTERN_TILING_MODE: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); return paint_pattern_tiling(p); } break; @@ -1469,40 +1473,40 @@ VGint vegaGetParameteri(VGHandle object, return VG_PATH_FORMAT_STANDARD; case VG_PATH_SCALE: case VG_PATH_BIAS: - return vgGetParameterf(object, paramType); + return vegaGetParameterf(object, paramType); case VG_PATH_DATATYPE: { - struct path *p = (struct path*)object; + struct path *p = handle_to_path(object); return path_datatype(p); } case VG_PATH_NUM_SEGMENTS: { - struct path *p = (struct path*)object; + struct path *p = handle_to_path(object); return path_num_segments(p); } case VG_PATH_NUM_COORDS: { - struct path *p = (struct path*)object; + struct path *p = handle_to_path(object); return path_num_coords(p); } break; case VG_IMAGE_FORMAT: { - struct vg_image *img = (struct vg_image*)object; + struct vg_image *img = handle_to_image(object); return img->format; } break; case VG_IMAGE_WIDTH: { - struct vg_image *img = (struct vg_image*)object; + struct vg_image *img = handle_to_image(object); return img->width; } break; case VG_IMAGE_HEIGHT: { - struct vg_image *img = (struct vg_image*)object; + struct vg_image *img = handle_to_image(object); return img->height; } break; #ifdef OPENVG_VERSION_1_1 case VG_FONT_NUM_GLYPHS: { - struct vg_font *font = (struct vg_font*)object; + struct vg_font *font = handle_to_font(object); return font_num_glyphs(font); } break; @@ -1521,10 +1525,9 @@ void vegaGetParameterfv(VGHandle object, VGfloat * values) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; - VGint real_count = vgGetParameterVectorSize(object, paramType); + VGint real_count = vegaGetParameterVectorSize(object, paramType); - if (!ptr || object == VG_INVALID_HANDLE) { + if (object == VG_INVALID_HANDLE) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return; } @@ -1537,41 +1540,41 @@ void vegaGetParameterfv(VGHandle object, switch(paramType) { case VG_PAINT_TYPE: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); values[0] = paint_type(p); } break; case VG_PAINT_COLOR_RAMP_SPREAD_MODE: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); values[0] = paint_spread_mode(p); } break; case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: { - struct vg_paint *p = (struct vg_paint *)object; + struct vg_paint *p = handle_to_paint(object); values[0] = paint_color_ramp_premultiplied(p); } break; case VG_PAINT_PATTERN_TILING_MODE: { - values[0] = vgGetParameterf(object, paramType); + values[0] = vegaGetParameterf(object, paramType); } break; case VG_PAINT_COLOR: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_get_color(paint, values); } break; case VG_PAINT_COLOR_RAMP_STOPS: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_ramp_stops(paint, values, count); } break; case VG_PAINT_LINEAR_GRADIENT: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_linear_gradient(paint, values); } break; case VG_PAINT_RADIAL_GRADIENT: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_radial_gradient(paint, values); } break; @@ -1580,11 +1583,11 @@ void vegaGetParameterfv(VGHandle object, case VG_PATH_DATATYPE: case VG_PATH_NUM_SEGMENTS: case VG_PATH_NUM_COORDS: - values[0] = vgGetParameteri(object, paramType); + values[0] = vegaGetParameteri(object, paramType); break; case VG_PATH_SCALE: case VG_PATH_BIAS: - values[0] = vgGetParameterf(object, paramType); + values[0] = vegaGetParameterf(object, paramType); break; case VG_IMAGE_FORMAT: @@ -1592,7 +1595,7 @@ void vegaGetParameterfv(VGHandle object, case VG_IMAGE_HEIGHT: #ifdef OPENVG_VERSION_1_1 case VG_FONT_NUM_GLYPHS: - values[0] = vgGetParameteri(object, paramType); + values[0] = vegaGetParameteri(object, paramType); break; #endif @@ -1608,10 +1611,9 @@ void vegaGetParameteriv(VGHandle object, VGint * values) { struct vg_context *ctx = vg_current_context(); - void *ptr = (void*)object; - VGint real_count = vgGetParameterVectorSize(object, paramType); + VGint real_count = vegaGetParameterVectorSize(object, paramType); - if (!ptr || object == VG_INVALID_HANDLE) { + if (object || object == VG_INVALID_HANDLE) { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); return; } @@ -1629,45 +1631,45 @@ void vegaGetParameteriv(VGHandle object, case VG_PAINT_PATTERN_TILING_MODE: #ifdef OPENVG_VERSION_1_1 case VG_FONT_NUM_GLYPHS: - values[0] = vgGetParameteri(object, paramType); + values[0] = vegaGetParameteri(object, paramType); break; #endif case VG_PAINT_COLOR: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_get_coloriv(paint, values); } break; case VG_PAINT_COLOR_RAMP_STOPS: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_ramp_stopsi(paint, values, count); } break; case VG_PAINT_LINEAR_GRADIENT: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_linear_gradienti(paint, values); } break; case VG_PAINT_RADIAL_GRADIENT: { - struct vg_paint *paint = (struct vg_paint *)object; + struct vg_paint *paint = handle_to_paint(object); paint_radial_gradienti(paint, values); } break; case VG_PATH_SCALE: case VG_PATH_BIAS: - values[0] = vgGetParameterf(object, paramType); + values[0] = vegaGetParameterf(object, paramType); break; case VG_PATH_FORMAT: case VG_PATH_DATATYPE: case VG_PATH_NUM_SEGMENTS: case VG_PATH_NUM_COORDS: - values[0] = vgGetParameteri(object, paramType); + values[0] = vegaGetParameteri(object, paramType); break; case VG_IMAGE_FORMAT: case VG_IMAGE_WIDTH: case VG_IMAGE_HEIGHT: - values[0] = vgGetParameteri(object, paramType); + values[0] = vegaGetParameteri(object, paramType); break; default: |