2 * Copyright © 2009 Intel Corporation
3 * Copyright © 1998 Keith Packard
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * Zhigang Gong <zhigang.gong@linux.intel.com>
29 #include "glamor_priv.h"
30 #include "glamor_transform.h"
32 static const glamor_facet glamor_facet_point
= {
34 .vs_vars
= "in vec2 primitive;\n",
35 .vs_exec
= (GLAMOR_DEFAULT_POINT_SIZE
36 GLAMOR_POS(gl_Position
, primitive
)),
40 glamor_poly_point_gl(DrawablePtr drawable
, GCPtr gc
, int mode
, int npt
, DDXPointPtr ppt
)
42 ScreenPtr screen
= drawable
->pScreen
;
43 glamor_screen_private
*glamor_priv
= glamor_get_screen_private(screen
);
44 PixmapPtr pixmap
= glamor_get_drawable_pixmap(drawable
);
45 glamor_program
*prog
= &glamor_priv
->point_prog
;
46 glamor_pixmap_private
*pixmap_priv
;
53 pixmap_priv
= glamor_get_pixmap_private(pixmap
);
54 if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv
))
57 glamor_make_current(glamor_priv
);
63 if (!glamor_build_program(screen
, prog
,
70 if (!glamor_use_program(drawable
, gc
, prog
, NULL
))
73 vbo_ppt
= glamor_get_vbo_space(screen
, npt
* (2 * sizeof (INT16
)), &vbo_offset
);
74 glEnableVertexAttribArray(GLAMOR_VERTEX_POS
);
75 glVertexAttribPointer(GLAMOR_VERTEX_POS
, 2, GL_SHORT
, GL_FALSE
, 0, vbo_offset
);
76 if (mode
== CoordModePrevious
) {
80 vbo_ppt
[0] = (x
+= ppt
->x
);
81 vbo_ppt
[1] = (y
+= ppt
->y
);
86 memcpy(vbo_ppt
, ppt
, npt
* (2 * sizeof (INT16
)));
87 glamor_put_vbo_space(screen
);
89 glEnable(GL_SCISSOR_TEST
);
91 glamor_pixmap_loop(pixmap_priv
, box_index
) {
92 int nbox
= RegionNumRects(gc
->pCompositeClip
);
93 BoxPtr box
= RegionRects(gc
->pCompositeClip
);
95 if (!glamor_set_destination_drawable(drawable
, box_index
, TRUE
, TRUE
,
96 prog
->matrix_uniform
, &off_x
, &off_y
))
100 glScissor(box
->x1
+ off_x
,
105 glDrawArrays(GL_POINTS
, 0, npt
);
112 glDisable(GL_SCISSOR_TEST
);
113 glDisableVertexAttribArray(GLAMOR_VERTEX_POS
);
119 glamor_poly_point(DrawablePtr drawable
, GCPtr gc
, int mode
, int npt
,
122 if (glamor_poly_point_gl(drawable
, gc
, mode
, npt
, ppt
))
124 miPolyPoint(drawable
, gc
, mode
, npt
, ppt
);