* Matrix computations in vkvg are taken from the cairo library.
* @{ */
#define VKVG_IDENTITY_MATRIX {1,0,0,1,0,0}/*!< The identity matrix*/
-/**
- * @xx: xx component of the affine transformation
- * @yx: yx component of the affine transformation
- * @xy: xy component of the affine transformation
- * @yy: yy component of the affine transformation
- * @x0: X translation component of the affine transformation
- * @y0: Y translation component of the affine transformation
- *
/**
* @brief vkvg matrix structure
*
* x_new = xx * x + xy * y + x0;
* y_new = yx * x + yy * y + y0;
* @endcode
+ * @xx: xx component of the affine transformation
+ * @yx: yx component of the affine transformation
+ * @xy: xy component of the affine transformation
+ * @yy: yy component of the affine transformation
+ * @x0: X translation component of the affine transformation
+ * @y0: Y translation component of the affine transformation
*/
typedef struct {
float xx; float yx;
*/
vkvg_public
void vkvg_path_extents (VkvgContext ctx, float *x1, float *y1, float *x2, float *y2);
+/**
+ * @brief Get the current point of the context, return 0,0 if no point is defined.
+ * @param ctx
+ * @param x
+ * @param y
+ */
+vkvg_public
+void vkvg_get_current_point (VkvgContext ctx, float* x, float* y);
/**
* @brief Add a line to the current path from the current point to the coordinate given in arguments.
*
vkvg_public
void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
/**
+ * @brief Adds a cubic Bézier spline to the current path relative to the current point.
+ *
+ * Adds a cubic Bézier spline to the path from the current point to position (x3, y3) in relative coordinate to the current point,
+ * using (x1, y1) and (x2, y2) as the control points relative to the current point.
+ * After this call the current point will be (x3, y3).
+ *
+ * If there is no current point before the call to vkvg_rel_curve_to() => error:VKVG_STATUS_NO_CURRENT_POINT.
+ * @param ctx The vkvg context pointer.
+ * @param x1 The X coordinate of the first control point.
+ * @param y1 The Y coordinate of the first control point.
+ * @param x2 The X coordinate of the second control point.
+ * @param y2 The Y coordinate of the second control point.
+ * @param x3 The X coordinate of the end of the curve.
+ * @param y3 The Y coordinate of the end of the curve.
+ */
+vkvg_public
+void vkvg_rel_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
+/**
+ * @brief Add a quadratic Bezizer curve to the current path
+ *
+ * If there is no current point before the call to vkvg_quadratic_to() this function will behave as if preceded by a call to vkvg_move_to(ctx, x1, y1).
+ * @param ctx The vkvg context pointer.
+ * @param x1 The X coordinate of the control point.
+ * @param y1 The Y coordinate of the control point.
+ * @param x2 The X coordinate of the end point of the curve.
+ * @param y2 The Y coordinate of the end point of the curve.
+ */
+vkvg_public
+void vkvg_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float y2);
+/**
+ * @brief Add a quadratic Bezizer curve to the current path relative to the current point
+ *
+ * @param ctx The vkvg context pointer.
+ * @param x1 The X coordinate of the control point relative to the current point.
+ * @param y1 The Y coordinate of the control point relative to the current point.
+ * @param x2 The X coordinate of the end point of the curve relative to the current point.
+ * @param y2 The Y coordinate of the end point of the curve relative to the current point.
+ */
+vkvg_public
+void vkvg_rel_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float y2);/**
* @brief Add an axis aligned rectangle subpath to the current path.
*
* Adds a closed sub-path rectangle of the given size to the current path at position (x, y).
*/
vkvg_public
void vkvg_clip_preserve (VkvgContext ctx);
-
+/**
+ * @brief Set current source for drawing to the solid color defined by the supplied 32bit integer.
+ * @param ctx a valid vkvg @ref context
+ * @param rgba color coded in 32bit integer.
+ */
+vkvg_public
+void vkvg_set_source_color (VkvgContext ctx, uint32_t c);
/**
* @brief set color with alpha.
*
void vkvg_rel_line_to (VkvgContext ctx, float dx, float dy){
if (ctx->status)
return;
- if (_current_path_is_empty(ctx)){
- ctx->status = VKVG_STATUS_NO_CURRENT_POINT;
- return;
- }
+ if (_current_path_is_empty(ctx))
+ _add_point(ctx, 0, 0);
vec2 cp = _get_current_position(ctx);
vkvg_line_to(ctx, cp.x + dx, cp.y + dy);
}
{
if (ctx->status)
return;
- if (_current_path_is_empty(ctx)){
- ctx->status = VKVG_STATUS_NO_CURRENT_POINT;
- return;
- }
+ if (_current_path_is_empty(ctx))
+ _add_point(ctx, 0, 0);
vec2 cp = _get_current_position(ctx);
vkvg_move_to(ctx, cp.x + x, cp.y + y);
}
_finish_path(ctx);
_add_point (ctx, x, y);
}
-
+void vkvg_get_current_point (VkvgContext ctx, float* x, float* y) {
+ if (_current_path_is_empty(ctx)) {
+ *x = *y = 0;
+ return;
+ }
+ vec2 cp = _get_current_position(ctx);
+ *x = cp.x;
+ *y = cp.y;
+}
+void vkvg_rel_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float y2) {
+ if (ctx->status)
+ return;
+ vec2 cp = _get_current_position(ctx);
+ vkvg_quadratic_to (ctx, cp.x + x1, cp.y + y1, cp.x + x2, cp.y + y2);
+}
+void vkvg_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float y2) {
+ if (ctx->status)
+ return;
+ _set_curve_start (ctx);
+ if (_current_path_is_empty(ctx))
+ _add_point(ctx, x1, y1);
+ float x0, y0;
+ vkvg_get_current_point (ctx, &x0, &y0);
+ vkvg_curve_to (ctx,
+ 2.0 / 3.0 * x1 + 1.0 / 3.0 * x0,
+ 2.0 / 3.0 * y1 + 1.0 / 3.0 * y0,
+ 2.0 / 3.0 * x1 + 1.0 / 3.0 * x2,
+ 2.0 / 3.0 * y1 + 1.0 / 3.0 * y2,
+ y1, y2);
+ _set_curve_end (ctx);
+}
void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) {
if (ctx->status)
return;
void vkvg_rel_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) {
if (ctx->status)
return;
- if (_current_path_is_empty(ctx)){
- ctx->status = VKVG_STATUS_NO_CURRENT_POINT;
- return;
- }
vec2 cp = _get_current_position(ctx);
vkvg_curve_to (ctx, cp.x + x1, cp.y + y1, cp.x + x2, cp.y + y2, cp.x + x3, cp.y + y3);
}
_ensure_renderpass_is_started (ctx);
_draw_full_screen_quad (ctx, true);
}
+void vkvg_set_source_color (VkvgContext ctx, uint32_t c) {
+ if (ctx->status)
+ return;
+ ctx->curColor = c;
+ _update_cur_pattern (ctx, NULL);
+}
void vkvg_set_source_rgb (VkvgContext ctx, float r, float g, float b) {
vkvg_set_source_rgba (ctx, r, g, b, 1);
}
VkvgDevice dev = (vkvg_device*)calloc(1,sizeof(vkvg_device));
dev->instance = inst;
- dev->hdpi = 96;
- dev->vdpi = 96;
+ dev->hdpi = 72;
+ dev->vdpi = 72;
dev->samples= samples;
dev->deferredResolve = deferredResolve;
dev->vkDev = vkdev;
bool deferredResolve = false;
device = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, samples, deferredResolve);
-
- vkvg_device_set_dpy(device, 96, 96);
-
surf = vkvg_surface_create(device, width, height);
vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height);
device = vkvg_device_create_multisample(vkh_app_get_inst(app), dev->phy, dev->dev, pi->gQueue, 0, samples, deferredResolve);
- vkvg_device_set_dpy(device, 96, 96);
+ //vkvg_device_set_dpy(device, 96, 96);
vkh_app_free_phyinfos (phyCount, phys);
-Subproject commit 97cdc0fb23b33356cc1d4c1be8973891d7661ac5
+Subproject commit 7dfff1a2e601e142583c122c9f716578d8e85039