diff options
Diffstat (limited to 'src/mesa/state_tracker/st_cb_bitmap.c')
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 3a102df67f..9e32ee2eb4 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -90,6 +90,8 @@ struct bitmap_cache /** Bounds of region used in window coords */ GLint xmin, ymin, xmax, ymax; + GLfloat color[4]; + struct pipe_texture *texture; struct pipe_surface *surf; @@ -360,18 +362,18 @@ setup_bitmap_vertex_data(struct st_context *st, { struct pipe_context *pipe = st->pipe; const struct gl_framebuffer *fb = st->ctx->DrawBuffer; - const GLfloat fb_width = fb->Width; - const GLfloat fb_height = fb->Height; - const GLfloat x0 = x; - const GLfloat x1 = x + width; - const GLfloat y0 = y; - const GLfloat y1 = y + height; - const GLfloat sLeft = 0.0F, sRight = 1.0F; - const GLfloat tTop = 0.0, tBot = 1.0 - tTop; - const GLfloat clip_x0 = x0 / fb_width * 2.0 - 1.0; - const GLfloat clip_y0 = y0 / fb_height * 2.0 - 1.0; - const GLfloat clip_x1 = x1 / fb_width * 2.0 - 1.0; - const GLfloat clip_y1 = y1 / fb_height * 2.0 - 1.0; + const GLfloat fb_width = (GLfloat)fb->Width; + const GLfloat fb_height = (GLfloat)fb->Height; + const GLfloat x0 = (GLfloat)x; + const GLfloat x1 = (GLfloat)(x + width); + const GLfloat y0 = (GLfloat)y; + const GLfloat y1 = (GLfloat)(y + height); + const GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0; + const GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop; + const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0); + const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0); + const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0); + const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0); GLuint i; void *buf; @@ -429,7 +431,8 @@ setup_bitmap_vertex_data(struct st_context *st, static void draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, GLsizei width, GLsizei height, - struct pipe_texture *pt) + struct pipe_texture *pt, + const GLfloat *color) { struct st_context *st = ctx->st; struct pipe_context *pipe = ctx->st->pipe; @@ -444,8 +447,8 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, * it up into chunks. */ maxSize = 1 << (pipe->screen->get_param(pipe->screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1); - assert(width <= maxSize); - assert(height <= maxSize); + assert(width <= (GLsizei)maxSize); + assert(height <= (GLsizei)maxSize); cso_save_rasterizer(cso); cso_save_samplers(cso); @@ -488,15 +491,15 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, { const struct gl_framebuffer *fb = st->ctx->DrawBuffer; const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP); - const float width = fb->Width; - const float height = fb->Height; + const GLfloat width = (GLfloat)fb->Width; + const GLfloat height = (GLfloat)fb->Height; struct pipe_viewport_state vp; vp.scale[0] = 0.5 * width; - vp.scale[1] = height * (invert ? -0.5 : 0.5); + vp.scale[1] = (GLfloat)(height * (invert ? -0.5 : 0.5)); vp.scale[2] = 1.0; vp.scale[3] = 1.0; - vp.translate[0] = 0.5 * width; - vp.translate[1] = 0.5 * height; + vp.translate[0] = (GLfloat)(0.5 * width); + vp.translate[1] = (GLfloat)(0.5 * height); vp.translate[2] = 0.0; vp.translate[3] = 0.0; cso_set_viewport(cso, &vp); @@ -505,7 +508,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* draw textured quad */ setup_bitmap_vertex_data(st, x, y, width, height, ctx->Current.RasterPos[2], - ctx->Current.RasterColor); + color); util_draw_vertex_buffer(pipe, st->bitmap.vbuf, PIPE_PRIM_TRIANGLE_FAN, @@ -567,8 +570,9 @@ void st_flush_bitmap_cache(struct st_context *st) { if (!st->bitmap.cache->empty) { + struct bitmap_cache *cache = st->bitmap.cache; + if (st->ctx->DrawBuffer) { - struct bitmap_cache *cache = st->bitmap.cache; struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; @@ -591,11 +595,13 @@ st_flush_bitmap_cache(struct st_context *st) cache->ypos, st->ctx->Current.RasterPos[2], BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, - cache->texture); - - /* release/free the texture */ - pipe_texture_reference(&cache->texture, NULL); + cache->texture, + cache->color); } + + /* release/free the texture */ + pipe_texture_reference(&cache->texture, NULL); + reset_cache(st); } } @@ -622,8 +628,10 @@ accum_bitmap(struct st_context *st, px = x - cache->xpos; /* pos in buffer */ py = y - cache->ypos; if (px < 0 || px + width > BITMAP_CACHE_WIDTH || - py < 0 || py + height > BITMAP_CACHE_HEIGHT) { - /* This bitmap would extend beyond cache bounds, + py < 0 || py + height > BITMAP_CACHE_HEIGHT || + !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color)) { + /* This bitmap would extend beyond cache bounds, or the bitmap + * color is changing * so flush and continue. */ st_flush_bitmap_cache(st); @@ -637,6 +645,7 @@ accum_bitmap(struct st_context *st, cache->xpos = x; cache->ypos = y - py; cache->empty = GL_FALSE; + COPY_4FV(cache->color, st->ctx->Current.RasterColor); } assert(px != -999); @@ -692,7 +701,8 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, if (pt) { assert(pt->target == PIPE_TEXTURE_2D); draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], - width, height, pt); + width, height, pt, + st->ctx->Current.RasterColor); /* release/free the texture */ pipe_texture_reference(&pt, NULL); } |