glamor: Replace the immediate mode in glamor_fill() with glDrawArrays().
This commit is contained in:
parent
60775e21e3
commit
003dee4c82
|
@ -92,29 +92,15 @@ glamor_init_solid_shader(ScreenPtr screen)
|
||||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
const char *solid_vs_only =
|
const char *solid_vs_only =
|
||||||
"uniform vec4 color;\n"
|
"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"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
|
" gl_Position = gl_Vertex;\n"
|
||||||
" (gl_Vertex.y + y_bias) * y_scale,\n"
|
|
||||||
" 0,\n"
|
|
||||||
" 1);\n"
|
|
||||||
" gl_Color = color;\n"
|
" gl_Color = color;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char *solid_vs =
|
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"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
|
" gl_Position = gl_Vertex;\n"
|
||||||
" (gl_Vertex.y + y_bias) * y_scale,\n"
|
|
||||||
" 0,\n"
|
|
||||||
" 1);\n"
|
|
||||||
"}\n";
|
"}\n";
|
||||||
const char *solid_fs =
|
const char *solid_fs =
|
||||||
"uniform vec4 color;\n"
|
"uniform vec4 color;\n"
|
||||||
|
@ -138,8 +124,6 @@ glamor_init_solid_shader(ScreenPtr screen)
|
||||||
|
|
||||||
glamor_priv->solid_color_uniform_location =
|
glamor_priv->solid_color_uniform_location =
|
||||||
glGetUniformLocationARB(glamor_priv->solid_prog, "color");
|
glGetUniformLocationARB(glamor_priv->solid_prog, "color");
|
||||||
glamor_get_transform_uniform_locations(glamor_priv->solid_prog,
|
|
||||||
&glamor_priv->solid_transform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -153,6 +137,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||||
int y1 = y;
|
int y1 = y;
|
||||||
int y2 = y + height;
|
int y2 = y + height;
|
||||||
GLfloat color[4];
|
GLfloat color[4];
|
||||||
|
float vertices[4][2];
|
||||||
|
|
||||||
if (!glamor_set_destination_pixmap(pixmap))
|
if (!glamor_set_destination_pixmap(pixmap))
|
||||||
return;
|
return;
|
||||||
|
@ -163,15 +148,22 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||||
glUseProgramObjectARB(glamor_priv->solid_prog);
|
glUseProgramObjectARB(glamor_priv->solid_prog);
|
||||||
glamor_get_color_4f_from_pixel(pixmap, fg_pixel, color);
|
glamor_get_color_4f_from_pixel(pixmap, fg_pixel, color);
|
||||||
glUniform4fvARB(glamor_priv->solid_color_uniform_location, 1, color);
|
glUniform4fvARB(glamor_priv->solid_color_uniform_location, 1, color);
|
||||||
glamor_set_transform_for_pixmap(pixmap, &glamor_priv->solid_transform);
|
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
|
||||||
glVertex2f(x1, y1);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertex2f(x1, y2);
|
|
||||||
glVertex2f(x2, y2);
|
|
||||||
glVertex2f(x2, y1);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
|
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);
|
glUseProgramObjectARB(0);
|
||||||
fail:
|
fail:
|
||||||
glamor_set_alu(GXcopy);
|
glamor_set_alu(GXcopy);
|
||||||
|
|
|
@ -150,7 +150,6 @@ typedef struct glamor_screen_private {
|
||||||
/* glamor_solid */
|
/* glamor_solid */
|
||||||
GLint solid_prog;
|
GLint solid_prog;
|
||||||
GLint solid_color_uniform_location;
|
GLint solid_color_uniform_location;
|
||||||
glamor_transform_uniforms solid_transform;
|
|
||||||
|
|
||||||
/* glamor_tile */
|
/* glamor_tile */
|
||||||
GLint tile_prog;
|
GLint tile_prog;
|
||||||
|
|
|
@ -124,12 +124,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
||||||
RegionPtr clip;
|
RegionPtr clip;
|
||||||
BoxPtr box;
|
BoxPtr box;
|
||||||
int nbox;
|
int nbox;
|
||||||
float dest_coords[8] = {
|
float dest_coords[4][2];
|
||||||
x, y,
|
|
||||||
x + w, y,
|
|
||||||
x + w, y + h,
|
|
||||||
x, y + h,
|
|
||||||
};
|
|
||||||
const float bitmap_coords[8] = {
|
const float bitmap_coords[8] = {
|
||||||
0.0, 0.0,
|
0.0, 0.0,
|
||||||
1.0, 0.0,
|
1.0, 0.0,
|
||||||
|
@ -137,6 +132,15 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
||||||
0.0, 1.0,
|
0.0, 1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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");
|
glamor_fallback("glamor_put_image_xybitmap: disabled\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -158,8 +162,6 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
||||||
glUniform4fvARB(glamor_priv->put_image_xybitmap_bg_uniform_location,
|
glUniform4fvARB(glamor_priv->put_image_xybitmap_bg_uniform_location,
|
||||||
1, bg);
|
1, bg);
|
||||||
|
|
||||||
glamor_set_transform_for_pixmap(pixmap, &glamor_priv->solid_transform);
|
|
||||||
|
|
||||||
glGenTextures(1, &tex);
|
glGenTextures(1, &tex);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
Loading…
Reference in New Issue