Commit 455051a0 authored by Olivier Fourdan's avatar Olivier Fourdan Committed by Adam Jackson

glamor: Check glamor_set_destination_drawable() return value

Check the value returned by glamor_set_destination_drawable() and use
the fallback code path where possible.

Bugzilla: https://bugzilla.redhat.com/1417575Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
parent 04b4bad7
......@@ -344,6 +344,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
glamor_program *prog;
const glamor_facet *copy_facet;
int n;
Bool ret = FALSE;
glamor_make_current(glamor_priv);
......@@ -410,9 +411,10 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
goto bail_ctx;
glamor_pixmap_loop(dst_priv, dst_box_index) {
glamor_set_destination_drawable(dst, dst_box_index, FALSE, FALSE,
prog->matrix_uniform,
&dst_off_x, &dst_off_y);
if (!glamor_set_destination_drawable(dst, dst_box_index, FALSE, FALSE,
prog->matrix_uniform,
&dst_off_x, &dst_off_y))
goto bail_ctx;
glScissor(dst_off_x - args.dx,
dst_off_y - args.dy,
......@@ -422,13 +424,14 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
glamor_glDrawArrays_GL_QUADS(glamor_priv, nbox);
}
}
glDisable(GL_SCISSOR_TEST);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return TRUE;
ret = TRUE;
bail_ctx:
return FALSE;
glDisable(GL_SCISSOR_TEST);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return ret;
}
/**
......
......@@ -49,6 +49,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
glamor_program *prog;
RegionPtr clip = gc->pCompositeClip;
int box_index;
Bool ret = FALSE;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
......@@ -75,8 +76,9 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
int off_x, off_y;
char *vbo_offset;
glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
prog->matrix_uniform, &off_x, &off_y);
if (!glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
prog->matrix_uniform, &off_x, &off_y))
goto bail;
max_points = 500;
num_points = 0;
......@@ -138,11 +140,12 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
}
}
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
ret = TRUE;
return TRUE;
bail:
return FALSE;
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return ret;
}
void
......@@ -174,6 +177,7 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
int num_points;
INT16 *points = NULL;
char *vbo_offset;
Bool ret = FALSE;
if (w * h > MAXINT / (2 * sizeof(float)))
goto bail;
......@@ -221,17 +225,19 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
glamor_put_vbo_space(screen);
glamor_pixmap_loop(pixmap_priv, box_index) {
glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
prog->matrix_uniform, NULL, NULL);
if (!glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
prog->matrix_uniform, NULL, NULL))
goto bail;
glDrawArrays(GL_POINTS, 0, num_points);
}
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return TRUE;
ret = TRUE;
bail:
return FALSE;
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return ret;
}
void
......
......@@ -46,6 +46,7 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
char *vbo_offset;
int box_index;
int add_last;
Bool ret = FALSE;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
......@@ -103,8 +104,9 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
int nbox = RegionNumRects(gc->pCompositeClip);
BoxPtr box = RegionRects(gc->pCompositeClip);
glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
prog->matrix_uniform, &off_x, &off_y);
if (!glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
prog->matrix_uniform, &off_x, &off_y))
goto bail;
while (nbox--) {
glScissor(box->x1 + off_x,
......@@ -116,12 +118,13 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
}
}
ret = TRUE;
bail:
glDisable(GL_SCISSOR_TEST);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return TRUE;
bail:
return FALSE;
return ret;
}
static Bool
......
......@@ -47,6 +47,7 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
GLshort *vbo_ppt;
char *vbo_offset;
int box_index;
Bool ret = FALSE;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
......@@ -90,8 +91,9 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
int nbox = RegionNumRects(gc->pCompositeClip);
BoxPtr box = RegionRects(gc->pCompositeClip);
glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
prog->matrix_uniform, &off_x, &off_y);
if (!glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
prog->matrix_uniform, &off_x, &off_y))
goto bail;
while (nbox--) {
glScissor(box->x1 + off_x,
......@@ -103,13 +105,13 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
}
}
ret = TRUE;
bail:
glDisable(GL_SCISSOR_TEST);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return TRUE;
bail:
return FALSE;
return ret;
}
void
......
......@@ -52,6 +52,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
GLshort *v;
char *vbo_offset;
int box_index;
Bool ret = FALSE;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
......@@ -115,8 +116,9 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
int nbox = RegionNumRects(gc->pCompositeClip);
BoxPtr box = RegionRects(gc->pCompositeClip);
glamor_set_destination_drawable(drawable, box_index, TRUE, FALSE,
prog->matrix_uniform, &off_x, &off_y);
if (!glamor_set_destination_drawable(drawable, box_index, TRUE, FALSE,
prog->matrix_uniform, &off_x, &off_y))
goto bail;
while (nbox--) {
glScissor(box->x1 + off_x,
......@@ -132,14 +134,15 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
}
}
ret = TRUE;
bail:
glDisable(GL_SCISSOR_TEST);
if (glamor_priv->glsl_version >= 130)
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return TRUE;
bail:
return FALSE;
return ret;
}
static void
......
......@@ -46,6 +46,7 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
char *vbo_offset;
int box_index;
int add_last;
Bool ret = FALSE;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
......@@ -62,7 +63,7 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
&glamor_facet_poly_segment);
if (!prog)
goto bail_ctx;
goto bail;
/* Set up the vertex buffers for the points */
......@@ -95,8 +96,9 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
int nbox = RegionNumRects(gc->pCompositeClip);
BoxPtr box = RegionRects(gc->pCompositeClip);
glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
prog->matrix_uniform, &off_x, &off_y);
if (!glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
prog->matrix_uniform, &off_x, &off_y))
goto bail;
while (nbox--) {
glScissor(box->x1 + off_x,
......@@ -108,13 +110,13 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
}
}
ret = TRUE;
glDisable(GL_SCISSOR_TEST);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return TRUE;
bail_ctx:
bail:
return FALSE;
return ret;
}
static Bool
......
......@@ -56,6 +56,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
char *vbo_offset;
int c;
int box_index;
Bool ret = FALSE;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
......@@ -123,8 +124,9 @@ glamor_fill_spans_gl(DrawablePtr drawable,
int nbox = RegionNumRects(gc->pCompositeClip);
BoxPtr box = RegionRects(gc->pCompositeClip);
glamor_set_destination_drawable(drawable, box_index, FALSE, FALSE,
prog->matrix_uniform, &off_x, &off_y);
if (!glamor_set_destination_drawable(drawable, box_index, FALSE, FALSE,
prog->matrix_uniform, &off_x, &off_y))
goto bail;
while (nbox--) {
glScissor(box->x1 + off_x,
......@@ -140,14 +142,15 @@ glamor_fill_spans_gl(DrawablePtr drawable,
}
}
ret = TRUE;
bail:
glDisable(GL_SCISSOR_TEST);
if (glamor_priv->glsl_version >= 130)
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
return TRUE;
bail:
return FALSE;
return ret;
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment