vega: replace casts with pointer/handle conversion functions
Per the spec, all OpenVG handles are 32-bit. We can't just cast them to/from integers on 64-bit systems. Start fixing that mess by introducing a set of handle/pointer conversion functions in handle.h. The next step is to implement a handle/pointer hash table...
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "vg_context.h"
|
||||
#include "image.h"
|
||||
#include "api.h"
|
||||
#include "handle.h"
|
||||
#include "renderer.h"
|
||||
#include "shaders_cache.h"
|
||||
|
||||
@@ -251,8 +252,8 @@ void vegaColorMatrix(VGImage dst, VGImage src,
|
||||
return;
|
||||
}
|
||||
|
||||
d = (struct vg_image*)dst;
|
||||
s = (struct vg_image*)src;
|
||||
d = handle_to_image(dst);
|
||||
s = handle_to_image(src);
|
||||
|
||||
if (vg_image_overlaps(d, s)) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
@@ -317,8 +318,8 @@ void vegaConvolve(VGImage dst, VGImage src,
|
||||
return;
|
||||
}
|
||||
|
||||
d = (struct vg_image*)dst;
|
||||
s = (struct vg_image*)src;
|
||||
d = handle_to_image(dst);
|
||||
s = handle_to_image(src);
|
||||
|
||||
if (vg_image_overlaps(d, s)) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
@@ -502,8 +503,8 @@ void vegaGaussianBlur(VGImage dst, VGImage src,
|
||||
return;
|
||||
}
|
||||
|
||||
d = (struct vg_image*)dst;
|
||||
s = (struct vg_image*)src;
|
||||
d = handle_to_image(dst);
|
||||
s = handle_to_image(src);
|
||||
|
||||
if (vg_image_overlaps(d, s)) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
@@ -599,8 +600,8 @@ void vegaLookup(VGImage dst, VGImage src,
|
||||
return;
|
||||
}
|
||||
|
||||
d = (struct vg_image*)dst;
|
||||
s = (struct vg_image*)src;
|
||||
d = handle_to_image(dst);
|
||||
s = handle_to_image(src);
|
||||
|
||||
if (vg_image_overlaps(d, s)) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
@@ -662,8 +663,8 @@ void vegaLookupSingle(VGImage dst, VGImage src,
|
||||
return;
|
||||
}
|
||||
|
||||
d = (struct vg_image*)dst;
|
||||
s = (struct vg_image*)src;
|
||||
d = handle_to_image(dst);
|
||||
s = handle_to_image(src);
|
||||
|
||||
if (vg_image_overlaps(d, s)) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "vg_translate.h"
|
||||
#include "api_consts.h"
|
||||
#include "api.h"
|
||||
#include "handle.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_screen.h"
|
||||
@@ -122,19 +123,19 @@ VGImage vegaCreateImage(VGImageFormat format,
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (VGImage)image_create(format, width, height);
|
||||
return image_to_handle(image_create(format, width, height));
|
||||
}
|
||||
|
||||
void vegaDestroyImage(VGImage image)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
struct vg_image *img = (struct vg_image *)image;
|
||||
struct vg_image *img = handle_to_image(image);
|
||||
|
||||
if (image == VG_INVALID_HANDLE) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
if (!vg_object_is_valid((void*)image, VG_OBJECT_IMAGE)) {
|
||||
if (!vg_object_is_valid(image, VG_OBJECT_IMAGE)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -157,7 +158,7 @@ void vegaClearImage(VGImage image,
|
||||
return;
|
||||
}
|
||||
|
||||
img = (struct vg_image*)image;
|
||||
img = handle_to_image(image);
|
||||
|
||||
if (x + width < 0 || y + height < 0)
|
||||
return;
|
||||
@@ -189,7 +190,7 @@ void vegaImageSubData(VGImage image,
|
||||
return;
|
||||
}
|
||||
|
||||
img = (struct vg_image*)(image);
|
||||
img = handle_to_image(image);
|
||||
image_sub_data(img, data, dataStride, dataFormat,
|
||||
x, y, width, height);
|
||||
}
|
||||
@@ -216,7 +217,7 @@ void vegaGetImageSubData(VGImage image,
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return;
|
||||
}
|
||||
img = (struct vg_image*)image;
|
||||
img = handle_to_image(image);
|
||||
image_get_sub_data(img, data, dataStride, dataFormat,
|
||||
x, y, width, height);
|
||||
}
|
||||
@@ -229,8 +230,8 @@ VGImage vegaChildImage(VGImage parent,
|
||||
struct vg_image *p;
|
||||
|
||||
if (parent == VG_INVALID_HANDLE ||
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_IMAGE, (void*)parent) ||
|
||||
!vg_object_is_valid((void*)parent, VG_OBJECT_IMAGE)) {
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_IMAGE, parent) ||
|
||||
!vg_object_is_valid(parent, VG_OBJECT_IMAGE)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
@@ -238,7 +239,7 @@ VGImage vegaChildImage(VGImage parent,
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
p = (struct vg_image *)parent;
|
||||
p = handle_to_image(parent);
|
||||
if (x > p->width || y > p->height) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return VG_INVALID_HANDLE;
|
||||
@@ -248,7 +249,7 @@ VGImage vegaChildImage(VGImage parent,
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (VGImage)image_child_image(p, x, y, width, height);
|
||||
return image_to_handle(image_child_image(p, x, y, width, height));
|
||||
}
|
||||
|
||||
VGImage vegaGetParent(VGImage image)
|
||||
@@ -261,9 +262,9 @@ VGImage vegaGetParent(VGImage image)
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
img = (struct vg_image*)image;
|
||||
img = handle_to_image(image);
|
||||
if (img->parent)
|
||||
return (VGImage)img->parent;
|
||||
return image_to_handle(img->parent);
|
||||
else
|
||||
return image;
|
||||
}
|
||||
@@ -285,8 +286,8 @@ void vegaCopyImage(VGImage dst, VGint dx, VGint dy,
|
||||
return;
|
||||
}
|
||||
vg_validate_state(ctx);
|
||||
image_copy((struct vg_image*)dst, dx, dy,
|
||||
(struct vg_image*)src, sx, sy,
|
||||
image_copy(handle_to_image(dst), dx, dy,
|
||||
handle_to_image(src), sx, sy,
|
||||
width, height, dither);
|
||||
}
|
||||
|
||||
@@ -303,7 +304,7 @@ void vegaDrawImage(VGImage image)
|
||||
}
|
||||
|
||||
vg_validate_state(ctx);
|
||||
image_draw((struct vg_image*)image,
|
||||
image_draw(handle_to_image(image),
|
||||
&ctx->state.vg.image_user_to_surface_matrix);
|
||||
}
|
||||
|
||||
@@ -323,7 +324,7 @@ void vegaSetPixels(VGint dx, VGint dy,
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return;
|
||||
}
|
||||
image_set_pixels(dx, dy, (struct vg_image*)src, sx, sy, width,
|
||||
image_set_pixels(dx, dy, handle_to_image(src), sx, sy, width,
|
||||
height);
|
||||
}
|
||||
|
||||
@@ -343,7 +344,7 @@ void vegaGetPixels(VGImage dst, VGint dx, VGint dy,
|
||||
return;
|
||||
}
|
||||
|
||||
img = (struct vg_image*)dst;
|
||||
img = handle_to_image(dst);
|
||||
|
||||
image_get_pixels(img, dx, dy,
|
||||
sx, sy, width, height);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "mask.h"
|
||||
#include "api.h"
|
||||
#include "handle.h"
|
||||
#include "renderer.h"
|
||||
|
||||
#include "vg_context.h"
|
||||
@@ -56,11 +57,11 @@ void vegaMask(VGHandle mask, VGMaskOperation operation,
|
||||
mask_fill(x, y, width, height, 0.f);
|
||||
} else if (operation == VG_FILL_MASK) {
|
||||
mask_fill(x, y, width, height, 1.f);
|
||||
} else if (vg_object_is_valid((void*)mask, VG_OBJECT_IMAGE)) {
|
||||
struct vg_image *image = (struct vg_image *)mask;
|
||||
} else if (vg_object_is_valid(mask, VG_OBJECT_IMAGE)) {
|
||||
struct vg_image *image = handle_to_image(mask);
|
||||
mask_using_image(image, operation, x, y, width, height);
|
||||
} else if (vg_object_is_valid((void*)mask, VG_OBJECT_MASK)) {
|
||||
struct vg_mask_layer *layer = (struct vg_mask_layer *)mask;
|
||||
} else if (vg_object_is_valid(mask, VG_OBJECT_MASK)) {
|
||||
struct vg_mask_layer *layer = handle_to_masklayer(mask);
|
||||
mask_using_layer(layer, operation, x, y, width, height);
|
||||
} else {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
@@ -123,14 +124,14 @@ void vegaRenderToMask(VGPath path,
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return;
|
||||
}
|
||||
if (!vg_object_is_valid((void*)path, VG_OBJECT_PATH)) {
|
||||
if (!vg_object_is_valid(path, VG_OBJECT_PATH)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
vg_validate_state(ctx);
|
||||
|
||||
mask_render_to((struct path *)path, paintModes, operation);
|
||||
mask_render_to(handle_to_path(path), paintModes, operation);
|
||||
}
|
||||
|
||||
VGMaskLayer vegaCreateMaskLayer(VGint width, VGint height)
|
||||
@@ -144,7 +145,7 @@ VGMaskLayer vegaCreateMaskLayer(VGint width, VGint height)
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (VGMaskLayer)mask_layer_create(width, height);
|
||||
return masklayer_to_handle(mask_layer_create(width, height));
|
||||
}
|
||||
|
||||
void vegaDestroyMaskLayer(VGMaskLayer maskLayer)
|
||||
@@ -156,12 +157,12 @@ void vegaDestroyMaskLayer(VGMaskLayer maskLayer)
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
if (!vg_object_is_valid((void*)maskLayer, VG_OBJECT_MASK)) {
|
||||
if (!vg_object_is_valid(maskLayer, VG_OBJECT_MASK)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
mask = (struct vg_mask_layer *)maskLayer;
|
||||
mask = handle_to_masklayer(maskLayer);
|
||||
mask_layer_destroy(mask);
|
||||
}
|
||||
|
||||
@@ -192,12 +193,12 @@ void vegaFillMaskLayer(VGMaskLayer maskLayer,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vg_object_is_valid((void*)maskLayer, VG_OBJECT_MASK)) {
|
||||
if (!vg_object_is_valid(maskLayer, VG_OBJECT_MASK)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
mask = (struct vg_mask_layer*)maskLayer;
|
||||
mask = handle_to_masklayer(maskLayer);
|
||||
|
||||
if (x + width > mask_layer_width(mask) ||
|
||||
y + height > mask_layer_height(mask)) {
|
||||
@@ -226,14 +227,14 @@ void vegaCopyMask(VGMaskLayer maskLayer,
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return;
|
||||
}
|
||||
if (!vg_object_is_valid((void*)maskLayer, VG_OBJECT_MASK)) {
|
||||
if (!vg_object_is_valid(maskLayer, VG_OBJECT_MASK)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
vg_validate_state(ctx);
|
||||
|
||||
mask = (struct vg_mask_layer*)maskLayer;
|
||||
mask = handle_to_masklayer(maskLayer);
|
||||
mask_copy(mask, sx, sy, dx, dy, width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,24 +29,24 @@
|
||||
#include "vg_context.h"
|
||||
#include "paint.h"
|
||||
#include "api.h"
|
||||
#include "handle.h"
|
||||
|
||||
|
||||
VGPaint vegaCreatePaint(void)
|
||||
{
|
||||
return (VGPaint) paint_create(vg_current_context());
|
||||
return paint_to_handle(paint_create(vg_current_context()));
|
||||
}
|
||||
|
||||
void vegaDestroyPaint(VGPaint p)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
struct vg_paint *paint;
|
||||
|
||||
if (p == VG_INVALID_HANDLE) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
paint = (struct vg_paint *)p;
|
||||
paint_destroy(paint);
|
||||
paint_destroy(handle_to_paint(p));
|
||||
}
|
||||
|
||||
void vegaSetPaint(VGPaint paint, VGbitfield paintModes)
|
||||
@@ -55,8 +55,8 @@ void vegaSetPaint(VGPaint paint, VGbitfield paintModes)
|
||||
|
||||
if (paint == VG_INVALID_HANDLE) {
|
||||
/* restore the default */
|
||||
paint = (VGPaint)ctx->default_paint;
|
||||
} else if (!vg_object_is_valid((void*)paint, VG_OBJECT_PAINT)) {
|
||||
paint = paint_to_handle(ctx->default_paint);
|
||||
} else if (!vg_object_is_valid(paint, VG_OBJECT_PAINT)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -67,10 +67,10 @@ void vegaSetPaint(VGPaint paint, VGbitfield paintModes)
|
||||
}
|
||||
|
||||
if (paintModes & VG_FILL_PATH) {
|
||||
ctx->state.vg.fill_paint = (struct vg_paint *)paint;
|
||||
ctx->state.vg.fill_paint = handle_to_paint(paint);
|
||||
}
|
||||
if (paintModes & VG_STROKE_PATH) {
|
||||
ctx->state.vg.stroke_paint = (struct vg_paint *)paint;
|
||||
ctx->state.vg.stroke_paint = handle_to_paint(paint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ VGPaint vegaGetPaint(VGPaintMode paintMode)
|
||||
}
|
||||
|
||||
if (paintMode == VG_FILL_PATH)
|
||||
paint = (VGPaint)ctx->state.vg.fill_paint;
|
||||
paint = paint_to_handle(ctx->state.vg.fill_paint);
|
||||
else if (paintMode == VG_STROKE_PATH)
|
||||
paint = (VGPaint)ctx->state.vg.stroke_paint;
|
||||
paint = paint_to_handle(ctx->state.vg.stroke_paint);
|
||||
|
||||
if (paint == (VGPaint)ctx->default_paint)
|
||||
if (paint == paint_to_handle(ctx->default_paint))
|
||||
paint = VG_INVALID_HANDLE;
|
||||
|
||||
return paint;
|
||||
@@ -104,14 +104,12 @@ void vegaSetColor(VGPaint paint, VGuint rgba)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vg_object_is_valid((void*)paint, VG_OBJECT_PAINT)) {
|
||||
if (!vg_object_is_valid(paint, VG_OBJECT_PAINT)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
{
|
||||
struct vg_paint *p = (struct vg_paint *)paint;
|
||||
paint_set_colori(p, rgba);
|
||||
}
|
||||
|
||||
paint_set_colori(handle_to_paint(paint), rgba);
|
||||
}
|
||||
|
||||
VGuint vegaGetColor(VGPaint paint)
|
||||
@@ -125,11 +123,11 @@ VGuint vegaGetColor(VGPaint paint)
|
||||
return rgba;
|
||||
}
|
||||
|
||||
if (!vg_object_is_valid((void*)paint, VG_OBJECT_PAINT)) {
|
||||
if (!vg_object_is_valid(paint, VG_OBJECT_PAINT)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return rgba;
|
||||
}
|
||||
p = (struct vg_paint *)paint;
|
||||
p = handle_to_paint(paint);
|
||||
|
||||
return paint_colori(p);
|
||||
}
|
||||
@@ -139,28 +137,28 @@ void vegaPaintPattern(VGPaint paint, VGImage pattern)
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
|
||||
if (paint == VG_INVALID_HANDLE ||
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_PAINT, (void *)paint)) {
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_PAINT, paint)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pattern == VG_INVALID_HANDLE) {
|
||||
paint_set_type((struct vg_paint*)paint, VG_PAINT_TYPE_COLOR);
|
||||
paint_set_type(handle_to_paint(paint), VG_PAINT_TYPE_COLOR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vg_context_is_object_valid(ctx, VG_OBJECT_IMAGE, (void *)pattern)) {
|
||||
if (!vg_context_is_object_valid(ctx, VG_OBJECT_IMAGE, pattern)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!vg_object_is_valid((void*)paint, VG_OBJECT_PAINT) ||
|
||||
!vg_object_is_valid((void*)pattern, VG_OBJECT_IMAGE)) {
|
||||
if (!vg_object_is_valid(paint, VG_OBJECT_PAINT) ||
|
||||
!vg_object_is_valid(pattern, VG_OBJECT_IMAGE)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
paint_set_pattern((struct vg_paint*)paint,
|
||||
(struct vg_image*)pattern);
|
||||
paint_set_pattern(handle_to_paint(paint),
|
||||
handle_to_image(pattern));
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
void *ptr = handle_to_pointer(object);
|
||||
VGint real_count = vgGetParameterVectorSize(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;
|
||||
}
|
||||
@@ -1132,7 +1133,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_color(paint, values);
|
||||
}
|
||||
}
|
||||
@@ -1141,7 +1142,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 +1160,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 +1177,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 +1216,10 @@ void vegaSetParameteriv(VGHandle object,
|
||||
const VGint * values)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
void *ptr = (void*)object;
|
||||
void *ptr = handle_to_pointer(object);
|
||||
VGint real_count = vgGetParameterVectorSize(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;
|
||||
}
|
||||
@@ -1245,7 +1246,7 @@ void vegaSetParameteriv(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_coloriv(paint, values);
|
||||
}
|
||||
}
|
||||
@@ -1256,7 +1257,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 +1275,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 +1290,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 +1319,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 +1334,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 +1374,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;
|
||||
}
|
||||
@@ -1398,11 +1397,11 @@ 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:
|
||||
@@ -1431,30 +1430,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;
|
||||
@@ -1471,38 +1469,38 @@ VGint vegaGetParameteri(VGHandle object,
|
||||
case VG_PATH_BIAS:
|
||||
return vgGetParameterf(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 +1519,9 @@ void vegaGetParameterfv(VGHandle object,
|
||||
VGfloat * values)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
void *ptr = (void*)object;
|
||||
VGint real_count = vgGetParameterVectorSize(object, paramType);
|
||||
|
||||
if (!ptr || object == VG_INVALID_HANDLE) {
|
||||
if (object == VG_INVALID_HANDLE) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -1537,17 +1534,17 @@ 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;
|
||||
@@ -1556,22 +1553,22 @@ void vegaGetParameterfv(VGHandle object,
|
||||
}
|
||||
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;
|
||||
@@ -1608,10 +1605,9 @@ void vegaGetParameteriv(VGHandle object,
|
||||
VGint * values)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
void *ptr = (void*)object;
|
||||
VGint real_count = vgGetParameterVectorSize(object, paramType);
|
||||
|
||||
if (!ptr || object == VG_INVALID_HANDLE) {
|
||||
if (object || object == VG_INVALID_HANDLE) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -1633,22 +1629,22 @@ void vegaGetParameteriv(VGHandle object,
|
||||
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;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "VG/openvg.h"
|
||||
|
||||
#include "vg_context.h"
|
||||
#include "handle.h"
|
||||
#include "path.h"
|
||||
#include "api.h"
|
||||
|
||||
@@ -55,9 +56,9 @@ VGPath vegaCreatePath(VGint pathFormat,
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (VGPath)path_create(datatype, scale, bias,
|
||||
segmentCapacityHint, coordCapacityHint,
|
||||
capabilities);
|
||||
return path_to_handle(path_create(datatype, scale, bias,
|
||||
segmentCapacityHint, coordCapacityHint,
|
||||
capabilities));
|
||||
}
|
||||
|
||||
void vegaClearPath(VGPath path, VGbitfield capabilities)
|
||||
@@ -70,7 +71,7 @@ void vegaClearPath(VGPath path, VGbitfield capabilities)
|
||||
return;
|
||||
}
|
||||
|
||||
p = (struct path *)path;
|
||||
p = handle_to_path(path);
|
||||
path_clear(p, capabilities);
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ void vegaDestroyPath(VGPath p)
|
||||
return;
|
||||
}
|
||||
|
||||
path = (struct path *)p;
|
||||
path = handle_to_path(p);
|
||||
path_destroy(path);
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ void vegaRemovePathCapabilities(VGPath path,
|
||||
return;
|
||||
}
|
||||
|
||||
p = (struct path*)path;
|
||||
p = handle_to_path(path);
|
||||
current = path_capabilities(p);
|
||||
path_set_capabilities(p, (current &
|
||||
(~(capabilities & VG_PATH_CAPABILITY_ALL))));
|
||||
@@ -115,7 +116,7 @@ VGbitfield vegaGetPathCapabilities(VGPath path)
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
p = (struct path*)path;
|
||||
p = handle_to_path(path);
|
||||
return path_capabilities(p);
|
||||
}
|
||||
|
||||
@@ -128,8 +129,8 @@ void vegaAppendPath(VGPath dstPath, VGPath srcPath)
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
src = (struct path *)srcPath;
|
||||
dst = (struct path *)dstPath;
|
||||
src = handle_to_path(srcPath);
|
||||
dst = handle_to_path(dstPath);
|
||||
|
||||
if (!(path_capabilities(src) & VG_PATH_CAPABILITY_APPEND_FROM) ||
|
||||
!(path_capabilities(dst) & VG_PATH_CAPABILITY_APPEND_TO)) {
|
||||
@@ -167,7 +168,7 @@ void vegaAppendPathData(VGPath dstPath,
|
||||
}
|
||||
}
|
||||
|
||||
p = (struct path*)dstPath;
|
||||
p = handle_to_path(dstPath);
|
||||
|
||||
if (!pathData || !is_aligned_to(pathData, path_datatype_size(p))) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
@@ -199,7 +200,7 @@ void vegaModifyPathCoords(VGPath dstPath,
|
||||
return;
|
||||
}
|
||||
|
||||
p = (struct path *)dstPath;
|
||||
p = handle_to_path(dstPath);
|
||||
|
||||
if (!pathData || !is_aligned_to(pathData, path_datatype_size(p))) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
@@ -226,8 +227,8 @@ void vegaTransformPath(VGPath dstPath, VGPath srcPath)
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
src = (struct path *)srcPath;
|
||||
dst = (struct path *)dstPath;
|
||||
src = handle_to_path(srcPath);
|
||||
dst = handle_to_path(dstPath);
|
||||
|
||||
if (!(path_capabilities(src) & VG_PATH_CAPABILITY_TRANSFORM_FROM) ||
|
||||
!(path_capabilities(dst) & VG_PATH_CAPABILITY_TRANSFORM_TO)) {
|
||||
@@ -251,9 +252,9 @@ VGboolean vegaInterpolatePath(VGPath dstPath,
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return VG_FALSE;
|
||||
}
|
||||
dst = (struct path *)dstPath;
|
||||
start = (struct path *)startPath;
|
||||
end = (struct path *)endPath;
|
||||
dst = handle_to_path(dstPath);
|
||||
start = handle_to_path(startPath);
|
||||
end = handle_to_path(endPath);
|
||||
|
||||
if (!(path_capabilities(dst) & VG_PATH_CAPABILITY_INTERPOLATE_TO) ||
|
||||
!(path_capabilities(start) & VG_PATH_CAPABILITY_INTERPOLATE_FROM) ||
|
||||
@@ -285,7 +286,7 @@ VGfloat vegaPathLength(VGPath path,
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return -1;
|
||||
}
|
||||
p = (struct path*)path;
|
||||
p = handle_to_path(path);
|
||||
|
||||
if (!(path_capabilities(p) & VG_PATH_CAPABILITY_PATH_LENGTH)) {
|
||||
vg_set_error(ctx, VG_PATH_CAPABILITY_ERROR);
|
||||
@@ -330,7 +331,7 @@ void vegaPointAlongPath(VGPath path,
|
||||
return;
|
||||
}
|
||||
|
||||
p = (struct path*)path;
|
||||
p = handle_to_path(path);
|
||||
|
||||
caps = path_capabilities(p);
|
||||
if (!(caps & VG_PATH_CAPABILITY_POINT_ALONG_PATH) ||
|
||||
@@ -385,7 +386,7 @@ void vegaPathBounds(VGPath path,
|
||||
return;
|
||||
}
|
||||
|
||||
p = (struct path*)path;
|
||||
p = handle_to_path(path);
|
||||
|
||||
caps = path_capabilities(p);
|
||||
if (!(caps & VG_PATH_CAPABILITY_PATH_BOUNDS)) {
|
||||
@@ -422,7 +423,7 @@ void vegaPathTransformedBounds(VGPath path,
|
||||
return;
|
||||
}
|
||||
|
||||
p = (struct path*)path;
|
||||
p = handle_to_path(path);
|
||||
|
||||
caps = path_capabilities(p);
|
||||
if (!(caps & VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS)) {
|
||||
@@ -466,6 +467,7 @@ void vegaPathTransformedBounds(VGPath path,
|
||||
void vegaDrawPath(VGPath path, VGbitfield paintModes)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
struct path *p = handle_to_path(path);
|
||||
|
||||
if (path == VG_INVALID_HANDLE) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
@@ -477,9 +479,9 @@ void vegaDrawPath(VGPath path, VGbitfield paintModes)
|
||||
return;
|
||||
}
|
||||
|
||||
if (path_is_empty((struct path*)path))
|
||||
if (path_is_empty(p))
|
||||
return;
|
||||
path_render((struct path*)path, paintModes,
|
||||
path_render(p, paintModes,
|
||||
&ctx->state.vg.path_user_to_surface_matrix);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "vg_context.h"
|
||||
#include "text.h"
|
||||
#include "api.h"
|
||||
#include "handle.h"
|
||||
|
||||
#include "util/u_memory.h"
|
||||
|
||||
@@ -43,19 +44,19 @@ VGFont vegaCreateFont(VGint glyphCapacityHint)
|
||||
return VG_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (VGFont) font_create(glyphCapacityHint);
|
||||
return font_to_handle(font_create(glyphCapacityHint));
|
||||
}
|
||||
|
||||
void vegaDestroyFont(VGFont f)
|
||||
{
|
||||
struct vg_font *font = (struct vg_font *)f;
|
||||
struct vg_font *font = handle_to_font(f);
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
|
||||
if (f == VG_INVALID_HANDLE) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
if (!vg_object_is_valid((void *) font, VG_OBJECT_FONT)) {
|
||||
if (!vg_object_is_valid(f, VG_OBJECT_FONT)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +76,7 @@ void vegaSetGlyphToPath(VGFont font,
|
||||
struct vg_font *f;
|
||||
|
||||
if (font == VG_INVALID_HANDLE ||
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_FONT, (void *)font)) {
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_FONT, font)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -85,13 +86,13 @@ void vegaSetGlyphToPath(VGFont font,
|
||||
return;
|
||||
}
|
||||
if (path != VG_INVALID_HANDLE &&
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_PATH, (void *)path)) {
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_PATH, path)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
pathObj = (struct path*) path;
|
||||
f = (struct vg_font*) font;
|
||||
pathObj = handle_to_path(path);
|
||||
f = handle_to_font(font);
|
||||
|
||||
font_set_glyph_to_path(f, glyphIndex, pathObj,
|
||||
isHinted, glyphOrigin, escapement);
|
||||
@@ -108,7 +109,7 @@ void vegaSetGlyphToImage(VGFont font,
|
||||
struct vg_font *f;
|
||||
|
||||
if (font == VG_INVALID_HANDLE ||
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_FONT, (void *)font)) {
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_FONT, font)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -118,13 +119,13 @@ void vegaSetGlyphToImage(VGFont font,
|
||||
return;
|
||||
}
|
||||
if (image != VG_INVALID_HANDLE &&
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_IMAGE, (void *)image)) {
|
||||
!vg_context_is_object_valid(ctx, VG_OBJECT_IMAGE, image)) {
|
||||
vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
img_obj = (struct vg_image*)image;
|
||||
f = (struct vg_font*)font;
|
||||
img_obj = handle_to_image(image);
|
||||
f = handle_to_font(font);
|
||||
|
||||
font_set_glyph_to_image(f, glyphIndex, img_obj, glyphOrigin, escapement);
|
||||
}
|
||||
@@ -140,7 +141,7 @@ void vegaClearGlyph(VGFont font,
|
||||
return;
|
||||
}
|
||||
|
||||
f = (struct vg_font*) font;
|
||||
f = handle_to_font(font);
|
||||
|
||||
font_clear_glyph(f, glyphIndex);
|
||||
}
|
||||
@@ -161,7 +162,7 @@ void vegaDrawGlyph(VGFont font,
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
return;
|
||||
}
|
||||
f = (struct vg_font*)font;
|
||||
f = handle_to_font(font);
|
||||
|
||||
font_draw_glyph(f, glyphIndex, paintModes, allowAutoHinting);
|
||||
}
|
||||
@@ -199,7 +200,7 @@ void vegaDrawGlyphs(VGFont font,
|
||||
return;
|
||||
}
|
||||
|
||||
f = (struct vg_font*)font;
|
||||
f = handle_to_font(font);
|
||||
|
||||
font_draw_glyphs(f, glyphCount, glyphIndices,
|
||||
adjustments_x, adjustments_y, paintModes, allowAutoHinting);
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 VMware, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Convert opaque VG object handles into pointers and vice versa.
|
||||
* XXX This is not yet 64-bit safe! All VG handles are 32 bits in size.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HANDLE_H
|
||||
#define HANDLE_H
|
||||
|
||||
#include "VG/openvg.h"
|
||||
#include "pipe/p_compiler.h"
|
||||
|
||||
|
||||
struct vg_mask_layer;
|
||||
struct vg_font;
|
||||
struct vg_image;
|
||||
struct vg_paint;
|
||||
struct path;
|
||||
|
||||
|
||||
static INLINE VGHandle
|
||||
image_to_handle(struct vg_image *img)
|
||||
{
|
||||
return (VGHandle) img;
|
||||
}
|
||||
|
||||
|
||||
static INLINE VGHandle
|
||||
masklayer_to_handle(struct vg_mask_layer *mask)
|
||||
{
|
||||
return (VGHandle) mask;
|
||||
}
|
||||
|
||||
|
||||
static INLINE VGHandle
|
||||
font_to_handle(struct vg_font *font)
|
||||
{
|
||||
return (VGHandle) font;
|
||||
}
|
||||
|
||||
static INLINE VGHandle
|
||||
paint_to_handle(struct vg_paint *paint)
|
||||
{
|
||||
return (VGHandle) paint;
|
||||
}
|
||||
|
||||
static INLINE VGHandle
|
||||
path_to_handle(struct path *path)
|
||||
{
|
||||
return (VGHandle) path;
|
||||
}
|
||||
|
||||
|
||||
static INLINE void *
|
||||
handle_to_pointer(VGHandle h)
|
||||
{
|
||||
return (void *) h;
|
||||
}
|
||||
|
||||
|
||||
static INLINE struct vg_font *
|
||||
handle_to_font(VGHandle h)
|
||||
{
|
||||
return (struct vg_font *) handle_to_pointer(h);
|
||||
}
|
||||
|
||||
|
||||
static INLINE struct vg_image *
|
||||
handle_to_image(VGHandle h)
|
||||
{
|
||||
return (struct vg_image *) handle_to_pointer(h);
|
||||
}
|
||||
|
||||
|
||||
static INLINE struct vg_mask_layer *
|
||||
handle_to_masklayer(VGHandle h)
|
||||
{
|
||||
return (struct vg_mask_layer *) handle_to_pointer(h);
|
||||
}
|
||||
|
||||
|
||||
static INLINE struct vg_object *
|
||||
handle_to_object(VGHandle h)
|
||||
{
|
||||
return (struct vg_object *) handle_to_pointer(h);
|
||||
}
|
||||
|
||||
|
||||
static INLINE struct vg_paint *
|
||||
handle_to_paint(VGHandle h)
|
||||
{
|
||||
return (struct vg_paint *) handle_to_pointer(h);
|
||||
}
|
||||
|
||||
|
||||
static INLINE struct path *
|
||||
handle_to_path(VGHandle h)
|
||||
{
|
||||
return (struct path *) handle_to_pointer(h);
|
||||
}
|
||||
|
||||
|
||||
#endif /* HANDLE_H */
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "vg_manager.h"
|
||||
#include "api.h"
|
||||
#include "mask.h"
|
||||
#include "handle.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "util/u_inlines.h"
|
||||
@@ -186,13 +187,13 @@ void vg_init_object(struct vg_object *obj, struct vg_context *ctx, enum vg_objec
|
||||
|
||||
VGboolean vg_context_is_object_valid(struct vg_context *ctx,
|
||||
enum vg_object_type type,
|
||||
void *ptr)
|
||||
VGHandle object)
|
||||
{
|
||||
if (ctx) {
|
||||
struct cso_hash *hash = ctx->owned_objects[type];
|
||||
if (!hash)
|
||||
return VG_FALSE;
|
||||
return cso_hash_contains(hash, (unsigned)(long)ptr);
|
||||
return cso_hash_contains(hash, (unsigned)(long)object);
|
||||
}
|
||||
return VG_FALSE;
|
||||
}
|
||||
@@ -412,10 +413,10 @@ void vg_validate_state(struct vg_context *ctx)
|
||||
shader_set_color_transform(ctx->shader, ctx->state.vg.color_transform);
|
||||
}
|
||||
|
||||
VGboolean vg_object_is_valid(void *ptr, enum vg_object_type type)
|
||||
VGboolean vg_object_is_valid(VGHandle object, enum vg_object_type type)
|
||||
{
|
||||
struct vg_object *obj = ptr;
|
||||
if (ptr && is_aligned(obj) && obj->type == type)
|
||||
struct vg_object *obj = handle_to_object(object);
|
||||
if (object && is_aligned(obj) && obj->type == type)
|
||||
return VG_TRUE;
|
||||
else
|
||||
return VG_FALSE;
|
||||
|
||||
@@ -134,7 +134,7 @@ struct vg_object {
|
||||
struct vg_context *ctx;
|
||||
};
|
||||
void vg_init_object(struct vg_object *obj, struct vg_context *ctx, enum vg_object_type type);
|
||||
VGboolean vg_object_is_valid(void *ptr, enum vg_object_type type);
|
||||
VGboolean vg_object_is_valid(VGHandle object, enum vg_object_type type);
|
||||
|
||||
struct vg_context *vg_create_context(struct pipe_context *pipe,
|
||||
const void *visual,
|
||||
@@ -145,7 +145,7 @@ void vg_set_current_context(struct vg_context *ctx);
|
||||
|
||||
VGboolean vg_context_is_object_valid(struct vg_context *ctx,
|
||||
enum vg_object_type type,
|
||||
void *ptr);
|
||||
VGHandle object);
|
||||
void vg_context_add_object(struct vg_context *ctx,
|
||||
enum vg_object_type type,
|
||||
void *ptr);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "matrix.h"
|
||||
#include "path.h"
|
||||
#include "handle.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_pointer.h"
|
||||
@@ -54,7 +55,7 @@ static void vgu_append_float_coords(VGPath path,
|
||||
VGint num_coords)
|
||||
{
|
||||
VGubyte common_data[40 * sizeof(VGfloat)];
|
||||
struct path *p = (struct path *)path;
|
||||
struct path *p = handle_to_path(path);
|
||||
|
||||
vg_float_to_datatype(path_datatype(p), common_data, coords, num_coords);
|
||||
vgAppendPathData(path, num_cmds, cmds, common_data);
|
||||
|
||||
Reference in New Issue
Block a user