devided AA into line and shape AA

This commit is contained in:
vurtun 2016-01-14 14:09:32 +01:00
parent 127124c7b9
commit 0c9b5ba1c7
2 changed files with 38 additions and 16 deletions

View File

@ -1906,14 +1906,15 @@ static void
zr_canvas_setup(struct zr_canvas *list, struct zr_buffer *cmds,
struct zr_buffer *vertexes, struct zr_buffer *elements,
struct zr_draw_null_texture null,
enum zr_anti_aliasing AA)
enum zr_anti_aliasing line_AA, enum zr_anti_aliasing shape_AA)
{
list->null = null;
list->clip_rect = zr_null_rect;
list->vertexes = vertexes;
list->elements = elements;
list->buffer = cmds;
list->AA = AA;
list->line_AA = line_AA;
list->shape_AA = shape_AA;
}
static void
@ -2545,7 +2546,7 @@ zr_canvas_path_fill(struct zr_canvas *list, struct zr_color color)
ZR_ASSERT(list);
if (!list) return;
points = (struct zr_vec2*)zr_buffer_memory(list->buffer);
zr_canvas_add_poly_convex(list, points, list->path_count, color, list->AA);
zr_canvas_add_poly_convex(list, points, list->path_count, color, list->shape_AA);
zr_canvas_path_clear(list);
}
@ -2558,7 +2559,7 @@ zr_canvas_path_stroke(struct zr_canvas *list, struct zr_color color,
if (!list) return;
points = (struct zr_vec2*)zr_buffer_memory(list->buffer);
zr_canvas_add_poly_line(list, points, list->path_count, color,
closed, thickness, list->AA);
closed, thickness, list->line_AA);
zr_canvas_path_clear(list);
}
@ -2795,11 +2796,12 @@ zr_canvas_load(struct zr_canvas *list, struct zr_context *queue,
void
zr_convert(struct zr_context *ctx, struct zr_buffer *cmds,
struct zr_buffer *vertexes, struct zr_buffer *elements,
struct zr_draw_null_texture null, enum zr_anti_aliasing AA,
float line_thickness, unsigned int circle_segment_count)
const struct zr_convert_config *config)
{
zr_canvas_setup(&ctx->canvas, cmds, vertexes, elements, null, AA);
zr_canvas_load(&ctx->canvas, ctx, line_thickness, circle_segment_count);
zr_canvas_setup(&ctx->canvas, cmds, vertexes, elements,
config->null, config->line_AA, config->shape_AA);
zr_canvas_load(&ctx->canvas, ctx, config->line_thickness,
config->circle_segment_count);
}
const struct zr_draw_command*
@ -5817,12 +5819,12 @@ zr_input_is_key_down(const struct zr_input *i, enum zr_keys key)
*
* ===============================================================*/
#define ZR_STYLE_PROPERTY_MAP(PROPERTY)\
PROPERTY(SCROLLBAR_SIZE, 14.0f, 14.0f)\
PROPERTY(PADDING, 15.0f, 10.0f)\
PROPERTY(SIZE, 64.0f, 64.0f)\
PROPERTY(ITEM_SPACING, 4.0f, 4.0f)\
PROPERTY(ITEM_PADDING, 4.0f, 4.0f)\
PROPERTY(SCALER_SIZE, 16.0f, 16.0f)
PROPERTY(PADDING, 15.0f, 10.0f)\
PROPERTY(SCALER_SIZE, 16.0f, 16.0f)\
PROPERTY(SCROLLBAR_SIZE, 14.0f, 14.0f)\
PROPERTY(SIZE, 64.0f, 64.0f)
#define ZR_STYLE_ROUNDING_MAP(ROUNDING)\
ROUNDING(BUTTON, 4.0f)\

View File

@ -812,11 +812,17 @@ enum zr_style_rounding {
enum zr_style_properties {
ZR_PROPERTY_ITEM_SPACING,
/* space between widgets */
ZR_PROPERTY_ITEM_PADDING,
/* padding inside widet between content */
ZR_PROPERTY_PADDING,
/* padding between window and widgets */
ZR_PROPERTY_SCALER_SIZE,
/* width and height of the window scaler */
ZR_PROPERTY_SCROLLBAR_SIZE,
/* width for vertical scrollbar and height for horizontal scrollbar*/
ZR_PROPERTY_SIZE,
/* min size of a window that cannot be undercut */
ZR_PROPERTY_MAX
};
@ -1194,8 +1200,10 @@ struct zr_clipboard {
};
struct zr_canvas {
enum zr_anti_aliasing AA;
/* flag indicating if anti-aliasing should be used to render primtives */
enum zr_anti_aliasing shape_AA;
/* flag indicating if anti-aliasing should be used to render shapes */
enum zr_anti_aliasing line_AA;
/* flag indicating if anti-aliasing should be used to render lines */
struct zr_draw_null_texture null;
/* texture with white pixel for easy primitive drawing */
struct zr_rect clip_rect;
@ -1291,10 +1299,22 @@ const struct zr_command* zr__next(struct zr_context*, const struct zr_command*);
const struct zr_command* zr__begin(struct zr_context*);
/* vertex command drawing */
struct zr_convert_config {
float line_thickness;
/* line thickness should generally default to 1*/
enum zr_anti_aliasing line_AA;
/* line anti-aliasing flag can be turned off if you are thight on memory */
enum zr_anti_aliasing shape_AA;
/* shape anti-aliasing flag can be turned off if you are thight on memory */
unsigned int circle_segment_count;
/* number of segments used for circle and curves: default to 22 */
struct zr_draw_null_texture null;
/* handle to texture with a white pixel to draw text */
};
void zr_convert(struct zr_context*, struct zr_buffer *cmds,
struct zr_buffer *vertexes, struct zr_buffer *elements,
struct zr_draw_null_texture , enum zr_anti_aliasing,
float line_thickness, unsigned int circle_segment_count);
const struct zr_convert_config*);
#define zr_draw_foreach(cmd,ctx, b) for((cmd)=zr__draw_begin(ctx, b); (cmd)!=0; (cmd)=zr__draw_next(cmd, b, ctx))
const struct zr_draw_command* zr__draw_begin(const struct zr_context*, const struct zr_buffer*);
const struct zr_draw_command* zr__draw_next(const struct zr_draw_command*,