gl renderer: Cache current scale in RenderOpBuilder

We call ops_get_scale a lot, so this should be better. It will also make
a later x/y split for the scaling easier.
This commit is contained in:
Timm Bäder 2019-11-29 14:40:20 +01:00
parent a75523da68
commit 1854f3f49c
2 changed files with 10 additions and 6 deletions

View File

@ -30,6 +30,8 @@ ops_finish (RenderOpBuilder *builder)
builder->dx = 0;
builder->dy = 0;
builder->scale_x = 1;
builder->scale_y = 1;
builder->current_modelview = NULL;
builder->current_clip = NULL;
builder->current_render_target = 0;
@ -84,16 +86,11 @@ ops_pop_debug_group (RenderOpBuilder *builder)
float
ops_get_scale (const RenderOpBuilder *builder)
{
const MatrixStackEntry *head;
g_assert (builder->mv_stack != NULL);
g_assert (builder->mv_stack->len >= 1);
head = &g_array_index (builder->mv_stack, MatrixStackEntry, builder->mv_stack->len - 1);
/* TODO: Use two separate values */
return MAX (head->metadata.scale_x,
head->metadata.scale_y);
return MAX (builder->scale_x, builder->scale_y);
}
static void
@ -400,6 +397,8 @@ ops_set_modelview (RenderOpBuilder *builder,
builder->dx = 0;
builder->dy = 0;
builder->current_modelview = entry->transform;
builder->scale_x = entry->metadata.scale_x;
builder->scale_y = entry->metadata.scale_y;
ops_set_modelview_internal (builder, entry->transform);
}
@ -443,6 +442,8 @@ ops_push_modelview (RenderOpBuilder *builder,
builder->dx = 0;
builder->dy = 0;
builder->scale_x = entry->metadata.scale_x;
builder->scale_y = entry->metadata.scale_y;
builder->current_modelview = entry->transform;
ops_set_modelview_internal (builder, entry->transform);
}
@ -465,6 +466,8 @@ ops_pop_modelview (RenderOpBuilder *builder)
if (builder->mv_stack->len >= 1)
{
builder->scale_x = head->metadata.scale_x;
builder->scale_y = head->metadata.scale_y;
builder->current_modelview = head->transform;
ops_set_modelview_internal (builder, head->transform);
}

View File

@ -152,6 +152,7 @@ typedef struct
graphene_rect_t current_viewport;
float current_opacity;
float dx, dy;
float scale_x, scale_y;
OpBuffer render_ops;
GArray *vertices;