mirror of
https://github.com/brl/mutter.git
synced 2024-12-01 12:20:47 -05:00
cogl-path: Export _cogl_path_get_bounds
_cogl_path_get_bounds is no longer static and is exported in cogl-path-private.h so that it can be used in the clip stack code. The old version of the function returned x/y and width/height. However this was mostly used to call cogl_rectangle which takes x1/y1 x2/y2. The function has been changed to just directly return the second form because it is more useful. Anywhere that was previously using the function now just directly looks at path->path_nodes_min and path->path_nodes_max instead.
This commit is contained in:
parent
a9da7d72db
commit
5a71ff4cdd
@ -88,4 +88,11 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
gboolean merge,
|
gboolean merge,
|
||||||
gboolean need_clear);
|
gboolean need_clear);
|
||||||
|
|
||||||
|
void
|
||||||
|
_cogl_path_get_bounds (CoglPath *path,
|
||||||
|
float *min_x,
|
||||||
|
float *min_y,
|
||||||
|
float *max_x,
|
||||||
|
float *max_y);
|
||||||
|
|
||||||
#endif /* __COGL_PATH_PRIVATE_H */
|
#endif /* __COGL_PATH_PRIVATE_H */
|
||||||
|
@ -177,18 +177,29 @@ _cogl_path_stroke_nodes (void)
|
|||||||
cogl_handle_unref (source);
|
cogl_handle_unref (source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
_cogl_path_get_bounds (floatVec2 nodes_min,
|
_cogl_path_get_bounds (CoglPath *path,
|
||||||
floatVec2 nodes_max,
|
float *min_x,
|
||||||
float *bounds_x,
|
float *min_y,
|
||||||
float *bounds_y,
|
float *max_x,
|
||||||
float *bounds_w,
|
float *max_y)
|
||||||
float *bounds_h)
|
|
||||||
{
|
{
|
||||||
*bounds_x = nodes_min.x;
|
CoglPathData *data = path->data;
|
||||||
*bounds_y = nodes_min.y;
|
|
||||||
*bounds_w = nodes_max.x - *bounds_x;
|
if (data->path_nodes->len == 0)
|
||||||
*bounds_h = nodes_max.y - *bounds_y;
|
{
|
||||||
|
*min_x = 0.0f;
|
||||||
|
*min_y = 0.0f;
|
||||||
|
*max_x = 0.0f;
|
||||||
|
*max_y = 0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*min_x = data->path_nodes_min.x;
|
||||||
|
*min_y = data->path_nodes_min.y;
|
||||||
|
*max_x = data->path_nodes_max.x;
|
||||||
|
*max_y = data->path_nodes_max.y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -196,11 +207,8 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
gboolean merge,
|
gboolean merge,
|
||||||
gboolean need_clear)
|
gboolean need_clear)
|
||||||
{
|
{
|
||||||
|
CoglPathData *data = path->data;
|
||||||
unsigned int path_start = 0;
|
unsigned int path_start = 0;
|
||||||
float bounds_x;
|
|
||||||
float bounds_y;
|
|
||||||
float bounds_w;
|
|
||||||
float bounds_h;
|
|
||||||
unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY;
|
unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY;
|
||||||
CoglHandle prev_source;
|
CoglHandle prev_source;
|
||||||
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
||||||
@ -230,9 +238,6 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
_cogl_material_get_cogl_enable_flags (ctx->source_material);
|
_cogl_material_get_cogl_enable_flags (ctx->source_material);
|
||||||
_cogl_enable (enable_flags);
|
_cogl_enable (enable_flags);
|
||||||
|
|
||||||
_cogl_path_get_bounds (path->data->path_nodes_min, path->data->path_nodes_max,
|
|
||||||
&bounds_x, &bounds_y, &bounds_w, &bounds_h);
|
|
||||||
|
|
||||||
GE( glEnable (GL_STENCIL_TEST) );
|
GE( glEnable (GL_STENCIL_TEST) );
|
||||||
|
|
||||||
GE( glColorMask (FALSE, FALSE, FALSE, FALSE) );
|
GE( glColorMask (FALSE, FALSE, FALSE, FALSE) );
|
||||||
@ -255,8 +260,10 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
/* Just clear the bounding box */
|
/* Just clear the bounding box */
|
||||||
GE( glStencilMask (~(GLuint) 0) );
|
GE( glStencilMask (~(GLuint) 0) );
|
||||||
GE( glStencilOp (GL_ZERO, GL_ZERO, GL_ZERO) );
|
GE( glStencilOp (GL_ZERO, GL_ZERO, GL_ZERO) );
|
||||||
cogl_rectangle (bounds_x, bounds_y,
|
cogl_rectangle (data->path_nodes_min.x,
|
||||||
bounds_x + bounds_w, bounds_y + bounds_h);
|
data->path_nodes_min.y,
|
||||||
|
data->path_nodes_max.x,
|
||||||
|
data->path_nodes_max.y);
|
||||||
/* Make sure the rectangle hits the stencil buffer before
|
/* Make sure the rectangle hits the stencil buffer before
|
||||||
* directly changing other GL state. */
|
* directly changing other GL state. */
|
||||||
_cogl_journal_flush ();
|
_cogl_journal_flush ();
|
||||||
@ -276,10 +283,10 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
_cogl_bitmask_clear_all (&ctx->temp_bitmask);
|
_cogl_bitmask_clear_all (&ctx->temp_bitmask);
|
||||||
_cogl_disable_other_texcoord_arrays (&ctx->temp_bitmask);
|
_cogl_disable_other_texcoord_arrays (&ctx->temp_bitmask);
|
||||||
|
|
||||||
while (path_start < path->data->path_nodes->len)
|
while (path_start < data->path_nodes->len)
|
||||||
{
|
{
|
||||||
CoglPathNode *node =
|
CoglPathNode *node =
|
||||||
&g_array_index (path->data->path_nodes, CoglPathNode, path_start);
|
&g_array_index (data->path_nodes, CoglPathNode, path_start);
|
||||||
|
|
||||||
GE (glVertexPointer (2, GL_FLOAT, sizeof (CoglPathNode), &node->x));
|
GE (glVertexPointer (2, GL_FLOAT, sizeof (CoglPathNode), &node->x));
|
||||||
GE (glDrawArrays (GL_TRIANGLE_FAN, 0, node->path_size));
|
GE (glDrawArrays (GL_TRIANGLE_FAN, 0, node->path_size));
|
||||||
@ -533,18 +540,11 @@ static void
|
|||||||
_cogl_path_fill_nodes (void)
|
_cogl_path_fill_nodes (void)
|
||||||
{
|
{
|
||||||
CoglPathData *data;
|
CoglPathData *data;
|
||||||
float bounds_x;
|
|
||||||
float bounds_y;
|
|
||||||
float bounds_w;
|
|
||||||
float bounds_h;
|
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
data = COGL_PATH (ctx->current_path)->data;
|
data = COGL_PATH (ctx->current_path)->data;
|
||||||
|
|
||||||
_cogl_path_get_bounds (data->path_nodes_min, data->path_nodes_max,
|
|
||||||
&bounds_x, &bounds_y, &bounds_w, &bounds_h);
|
|
||||||
|
|
||||||
if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_FORCE_SCANLINE_PATHS)) &&
|
if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_FORCE_SCANLINE_PATHS)) &&
|
||||||
cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
|
cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
|
||||||
{
|
{
|
||||||
@ -560,8 +560,10 @@ _cogl_path_fill_nodes (void)
|
|||||||
clip_state->stencil_used,
|
clip_state->stencil_used,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
cogl_rectangle (bounds_x, bounds_y,
|
cogl_rectangle (data->path_nodes_min.x,
|
||||||
bounds_x + bounds_w, bounds_y + bounds_h);
|
data->path_nodes_min.y,
|
||||||
|
data->path_nodes_max.x,
|
||||||
|
data->path_nodes_max.y);
|
||||||
|
|
||||||
/* The stencil buffer now contains garbage so the clip area needs to
|
/* The stencil buffer now contains garbage so the clip area needs to
|
||||||
* be rebuilt.
|
* be rebuilt.
|
||||||
@ -584,8 +586,12 @@ _cogl_path_fill_nodes (void)
|
|||||||
path_start);
|
path_start);
|
||||||
|
|
||||||
_cogl_path_fill_nodes_scanlines (node, node->path_size,
|
_cogl_path_fill_nodes_scanlines (node, node->path_size,
|
||||||
bounds_x, bounds_y,
|
data->path_nodes_min.x,
|
||||||
bounds_w, bounds_h);
|
data->path_nodes_min.y,
|
||||||
|
data->path_nodes_max.x -
|
||||||
|
data->path_nodes_min.x,
|
||||||
|
data->path_nodes_max.y -
|
||||||
|
data->path_nodes_min.y);
|
||||||
|
|
||||||
path_start += node->path_size;
|
path_start += node->path_size;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user