summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-02-19 06:10:11 -0800
committerEric Anholt <eric@anholt.net>2010-02-19 06:13:16 -0800
commit6efafeeeebe4c0a2eee534dfca5ac594a40aca09 (patch)
tree5fa26d6f6302fed3858742e7a624e54738948c1f
parent9dfae480f16525dfa52fdf566b020c1d2abe3fdb (diff)
glamor: Replace the immediate mode in glamor_fill() with glDrawArrays().
-rw-r--r--glamor/glamor_fill.c42
-rw-r--r--glamor/glamor_priv.h1
-rw-r--r--glamor/glamor_putimage.c20
3 files changed, 28 insertions, 35 deletions
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index 8e269e22e..c3e0528bf 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -92,29 +92,15 @@ glamor_init_solid_shader(ScreenPtr screen)
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
const char *solid_vs_only =
"uniform vec4 color;\n"
- "uniform float x_bias;\n"
- "uniform float x_scale;\n"
- "uniform float y_bias;\n"
- "uniform float y_scale;\n"
"void main()\n"
"{\n"
- " gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
- " (gl_Vertex.y + y_bias) * y_scale,\n"
- " 0,\n"
- " 1);\n"
+ " gl_Position = gl_Vertex;\n"
" gl_Color = color;\n"
"}\n";
const char *solid_vs =
- "uniform float x_bias;\n"
- "uniform float x_scale;\n"
- "uniform float y_bias;\n"
- "uniform float y_scale;\n"
"void main()\n"
"{\n"
- " gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
- " (gl_Vertex.y + y_bias) * y_scale,\n"
- " 0,\n"
- " 1);\n"
+ " gl_Position = gl_Vertex;\n"
"}\n";
const char *solid_fs =
"uniform vec4 color;\n"
@@ -138,8 +124,6 @@ glamor_init_solid_shader(ScreenPtr screen)
glamor_priv->solid_color_uniform_location =
glGetUniformLocationARB(glamor_priv->solid_prog, "color");
- glamor_get_transform_uniform_locations(glamor_priv->solid_prog,
- &glamor_priv->solid_transform);
}
void
@@ -153,6 +137,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
int y1 = y;
int y2 = y + height;
GLfloat color[4];
+ float vertices[4][2];
if (!glamor_set_destination_pixmap(pixmap))
return;
@@ -163,15 +148,22 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
glUseProgramObjectARB(glamor_priv->solid_prog);
glamor_get_color_4f_from_pixel(pixmap, fg_pixel, color);
glUniform4fvARB(glamor_priv->solid_color_uniform_location, 1, color);
- glamor_set_transform_for_pixmap(pixmap, &glamor_priv->solid_transform);
- glBegin(GL_TRIANGLE_FAN);
- glVertex2f(x1, y1);
- glVertex2f(x1, y2);
- glVertex2f(x2, y2);
- glVertex2f(x2, y1);
- glEnd();
+ glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ vertices[0][0] = v_from_x_coord_x(pixmap, x1);
+ vertices[0][1] = v_from_x_coord_y(pixmap, y1);
+ vertices[1][0] = v_from_x_coord_x(pixmap, x2);
+ vertices[1][1] = v_from_x_coord_y(pixmap, y1);
+ vertices[2][0] = v_from_x_coord_x(pixmap, x2);
+ vertices[2][1] = v_from_x_coord_y(pixmap, y2);
+ vertices[3][0] = v_from_x_coord_x(pixmap, x1);
+ vertices[3][1] = v_from_x_coord_y(pixmap, y2);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
glUseProgramObjectARB(0);
fail:
glamor_set_alu(GXcopy);
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 0db9b28c4..3dc3a5389 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -150,7 +150,6 @@ typedef struct glamor_screen_private {
/* glamor_solid */
GLint solid_prog;
GLint solid_color_uniform_location;
- glamor_transform_uniforms solid_transform;
/* glamor_tile */
GLint tile_prog;
diff --git a/glamor/glamor_putimage.c b/glamor/glamor_putimage.c
index 74910fa67..ead5b692e 100644
--- a/glamor/glamor_putimage.c
+++ b/glamor/glamor_putimage.c
@@ -124,12 +124,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
RegionPtr clip;
BoxPtr box;
int nbox;
- float dest_coords[8] = {
- x, y,
- x + w, y,
- x + w, y + h,
- x, y + h,
- };
+ float dest_coords[4][2];
const float bitmap_coords[8] = {
0.0, 0.0,
1.0, 0.0,
@@ -137,7 +132,16 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
0.0, 1.0,
};
- glamor_fallback("glamor_put_image_xybitmap: disabled\n");
+ dest_coords[0][0] = v_from_x_coord_x(pixmap, x);
+ dest_coords[0][1] = v_from_x_coord_y(pixmap, y);
+ dest_coords[1][0] = v_from_x_coord_x(pixmap, x + w);
+ dest_coords[1][1] = v_from_x_coord_y(pixmap, y);
+ dest_coords[2][0] = v_from_x_coord_x(pixmap, x + w);
+ dest_coords[2][1] = v_from_x_coord_y(pixmap, y + h);
+ dest_coords[3][0] = v_from_x_coord_x(pixmap, x);
+ dest_coords[3][1] = v_from_x_coord_y(pixmap, y + h);
+
+ glamor_fallback("glamor_put_image_xybitmap: disabled\n");
goto fail;
if (glamor_priv->put_image_xybitmap_prog == 0) {
@@ -158,8 +162,6 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
glUniform4fvARB(glamor_priv->put_image_xybitmap_bg_uniform_location,
1, bg);
- glamor_set_transform_for_pixmap(pixmap, &glamor_priv->solid_transform);
-
glGenTextures(1, &tex);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);