#define BITMAP_CACHE_WIDTH 512
#define BITMAP_CACHE_HEIGHT 32
-struct bitmap_cache
-{
- /** Window pos to render the cached image */
- GLint xpos, ypos;
- /** Bounds of region used in window coords */
- GLint xmin, ymin, xmax, ymax;
-
- GLfloat color[4];
-
- /** Bitmap's Z position */
- GLfloat zpos;
-
- struct pipe_resource *texture;
- struct pipe_transfer *trans;
-
- GLboolean empty;
-
- /** An I8 texture image: */
- ubyte *buffer;
-};
-
/** Epsilon for Z comparisons */
#define Z_EPSILON 1e-06
static void
reset_cache(struct st_context *st)
{
- struct bitmap_cache *cache = st->bitmap.cache;
+ struct st_bitmap_cache *cache = &st->bitmap.cache;
/*memset(cache->buffer, 0xff, sizeof(cache->buffer));*/
cache->empty = GL_TRUE;
/** Print bitmap image to stdout (debug) */
static void
-print_cache(const struct bitmap_cache *cache)
+print_cache(const struct st_bitmap_cache *cache)
{
int i, j, k;
create_cache_trans(struct st_context *st)
{
struct pipe_context *pipe = st->pipe;
- struct bitmap_cache *cache = st->bitmap.cache;
+ struct st_bitmap_cache *cache = &st->bitmap.cache;
if (cache->trans)
return;
void
st_flush_bitmap_cache(struct st_context *st)
{
- struct bitmap_cache *cache = st->bitmap.cache;
+ struct st_bitmap_cache *cache = &st->bitmap.cache;
- if (cache && !cache->empty) {
+ if (!cache->empty) {
struct pipe_context *pipe = st->pipe;
struct pipe_sampler_view *sv;
const GLubyte *bitmap )
{
struct st_context *st = ctx->st;
- struct bitmap_cache *cache = st->bitmap.cache;
+ struct st_bitmap_cache *cache = &st->bitmap.cache;
int px = -999, py = -999;
const GLfloat z = ctx->Current.RasterPos[2];
struct pipe_screen *screen = pipe->screen;
/* This function should only be called once */
- assert(st->bitmap.cache == NULL);
+ assert(st->bitmap.vs == NULL);
assert(st->internal_target == PIPE_TEXTURE_2D ||
st->internal_target == PIPE_TEXTURE_RECT);
- /* alloc bitmap cache object */
- st->bitmap.cache = ST_CALLOC_STRUCT(bitmap_cache);
-
/* init sampler state once */
memset(&st->bitmap.sampler, 0, sizeof(st->bitmap.sampler));
st->bitmap.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP;
st_invalidate_readpix_cache(st);
- if (!st->bitmap.cache) {
+ if (!st->bitmap.vs) {
init_bitmap_state(st);
}
struct pipe_vertex_buffer vb = {0};
unsigned i;
- if (!st->bitmap.cache) {
+ if (!st->bitmap.vs) {
init_bitmap_state(st);
}
st_destroy_bitmap(struct st_context *st)
{
struct pipe_context *pipe = st->pipe;
- struct bitmap_cache *cache = st->bitmap.cache;
+ struct st_bitmap_cache *cache = &st->bitmap.cache;
if (st->bitmap.vs) {
cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
st->bitmap.vs = NULL;
}
- if (cache) {
- if (cache->trans && cache->buffer) {
- pipe_transfer_unmap(pipe, cache->trans);
- }
- pipe_resource_reference(&st->bitmap.cache->texture, NULL);
- free(st->bitmap.cache);
- st->bitmap.cache = NULL;
+ if (cache->trans && cache->buffer) {
+ pipe_transfer_unmap(pipe, cache->trans);
}
+ pipe_resource_reference(&st->bitmap.cache.texture, NULL);
}
#endif
-struct bitmap_cache;
struct dd_function_table;
struct draw_context;
struct draw_stage;
float s, t;
};
+struct st_bitmap_cache
+{
+ /** Window pos to render the cached image */
+ GLint xpos, ypos;
+ /** Bounds of region used in window coords */
+ GLint xmin, ymin, xmax, ymax;
+
+ GLfloat color[4];
+
+ /** Bitmap's Z position */
+ GLfloat zpos;
+
+ struct pipe_resource *texture;
+ struct pipe_transfer *trans;
+
+ GLboolean empty;
+
+ /** An I8 texture image: */
+ ubyte *buffer;
+};
struct st_context
{
struct pipe_sampler_state atlas_sampler;
enum pipe_format tex_format;
void *vs;
- struct bitmap_cache *cache;
+ struct st_bitmap_cache cache;
} bitmap;
/** for glDraw/CopyPixels */