[PATCH 04/13] glamor: Use glamor_program and GL_LINES for 0-width lines
Eric Anholt
eric at anholt.net
Tue May 6 11:17:43 PDT 2014
Keith Packard <keithp at keithp.com> writes:
> GL lines are nearly X compliant; you just need to fill in the last
> pixel when the client hasn't requested CapNotLast.
>
> v2: switch to glamor_make_current
>
> Signed-off-by: Keith Packard <keithp at keithp.com>
> diff --git a/glamor/glamor_lines.c b/glamor/glamor_lines.c
> new file mode 100644
> index 0000000..3f021a6
> --- /dev/null
> +++ b/glamor/glamor_lines.c
> +static Bool
> +glamor_poly_lines_gl(DrawablePtr drawable, GCPtr gc,
> + int mode, int n, DDXPointPtr points)
> +{
> + prog = glamor_use_program_fill(pixmap, gc,
> + &glamor_priv->poly_line_program,
> + &glamor_facet_poly_lines);
> +
> + if (!prog)
> + goto bail_ctx;
> +
> + /* Set up the vertex buffers for the points */
> +
> + v = glamor_get_vbo_space(drawable->pScreen, (n + add_last) * sizeof (DDXPointRec), &vbo_offset);
line wrapping
> + glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
> + int nbox = RegionNumRects(gc->pCompositeClip);
> + BoxPtr box = RegionRects(gc->pCompositeClip);
> +
> + glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, TRUE, prog->matrix_uniform, &off_x, &off_y);
wrapping
> +static void
> +glamor_poly_lines_bail(DrawablePtr drawable, GCPtr gc,
> + int mode, int n, DDXPointPtr points)
> +{
> + glamor_fallback("to %p (%c)\n", drawable,
> + glamor_get_drawable_location(drawable));
> +
> + if (gc->lineWidth == 0) {
> + if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
> + glamor_prepare_access_gc(gc)) {
> + fbPolyLine(drawable, gc, mode, n, points);
> + }
> + glamor_finish_access_gc(gc);
> + glamor_finish_access(drawable);
> + } else {
> + if (gc->lineStyle != LineSolid)
> + miWideDash(drawable, gc, mode, n, points);
> + else
> + miWideLine(drawable, gc, mode, n, points);
> + }
> +}
We should have a nice miPolylines fallback that calls the right mi
functions, instead of baking it into xwin, glamor and apparently even
fb.
But that can be done separately.
> +Bool
> +glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
> + int mode, int n, DDXPointPtr points)
> +{
> + if (glamor_poly_lines_gl(drawable, gc, mode, n, points))
> + return TRUE;
> +
> + if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
> + return FALSE;
wrapping
> diff --git a/glamor/glamor_segs.c b/glamor/glamor_segs.c
> new file mode 100644
> index 0000000..98ef9a0
> --- /dev/null
> +++ b/glamor/glamor_segs.c
> +static Bool
> +glamor_poly_segment_gl(DrawablePtr drawable, GCPtr gc,
> + int nseg, xSegment *segs)
> +{
> +
> + /* Set up the vertex buffers for the points */
> +
> + v = glamor_get_vbo_space(drawable->pScreen, (nseg<<add_last) * sizeof (xSegment), &vbo_offset);
line wrapping, spaces around <<
> +
> + glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
> + glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
> + sizeof(DDXPointRec), vbo_offset);
> +
> + if (add_last) {
> + int i, j;
> + for (i = 0, j=0; i < nseg; i++) {
spaces around '='
> + v[j++] = segs[i];
> + v[j].x1 = segs[i].x2;
> + v[j].y1 = segs[i].y2;
> + v[j].x2 = segs[i].x2+1;
> + v[j].y2 = segs[i].y2;
> + j++;
> + }
> + } else
> + memcpy(v, segs, nseg * sizeof (xSegment));
> +
> + glamor_put_vbo_space(screen);
> +
> + glEnable(GL_SCISSOR_TEST);
> +
> + glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
> + int nbox = RegionNumRects(gc->pCompositeClip);
> + BoxPtr box = RegionRects(gc->pCompositeClip);
> +
> + glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, TRUE, prog->matrix_uniform, &off_x, &off_y);
wrapping
Other than the style bits,
Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140506/22037654/attachment.sig>
More information about the xorg-devel
mailing list