Lines Matching refs:atlas
836 _mesa_delete_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas)
838 if (atlas->texObj) {
839 _mesa_delete_texture_object(ctx, atlas->texObj);
841 free(atlas->glyphs);
842 free(atlas);
852 struct gl_bitmap_atlas *atlas;
855 atlas = _mesa_HashLookup(ctx->Shared->BitmapAtlas, listBase);
856 return atlas;
861 * Create new bitmap atlas and insert into hash table.
866 struct gl_bitmap_atlas *atlas;
871 atlas = calloc(1, sizeof(*atlas));
872 if (atlas) {
873 _mesa_HashInsert(ctx->Shared->BitmapAtlas, listBase, atlas, isGenName);
874 atlas->Id = listBase;
877 return atlas;
882 * Try to build a bitmap atlas. This involves examining a sequence of
884 * images into a texture map (the atlas).
889 build_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas,
896 assert(atlas);
897 assert(!atlas->complete);
898 assert(atlas->numBitmaps > 0);
900 /* We use a rectangle texture (non-normalized coords) for the atlas */
904 atlas->texWidth = 1024;
905 atlas->texHeight = 0; /* determined below */
907 atlas->glyphs = malloc(atlas->numBitmaps * sizeof(atlas->glyphs[0]));
908 if (!atlas->glyphs) {
910 atlas->incomplete = true;
916 * bitmap in the atlas to determine the texture atlas size.
918 for (i = 0; i < atlas->numBitmaps; i++) {
921 struct gl_bitmap_glyph *g = &atlas->glyphs[i];
927 atlas->numBitmaps = i;
933 atlas->incomplete = true;
947 if (xpos + bitmap_width > atlas->texWidth) {
954 /* save the bitmap's position in the atlas */
971 atlas->texHeight = ypos + row_height;
973 if (atlas->texHeight == 0) {
977 else if (atlas->texHeight > ctx->Const.MaxTextureRectSize) {
982 /* Create atlas texture (texture ID is irrelevant) */
983 atlas->texObj = _mesa_new_texture_object(ctx, 999, GL_TEXTURE_RECTANGLE);
984 if (!atlas->texObj) {
988 atlas->texObj->Sampler.Attrib.MinFilter = GL_NEAREST;
989 atlas->texObj->Sampler.Attrib.MagFilter = GL_NEAREST;
990 atlas->texObj->Sampler.Attrib.state.min_img_filter = PIPE_TEX_FILTER_NEAREST;
991 atlas->texObj->Sampler.Attrib.state.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
992 atlas->texObj->Sampler.Attrib.state.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
993 atlas->texObj->Attrib.MaxLevel = 0;
994 atlas->texObj->Immutable = GL_TRUE;
996 atlas->texImage = _mesa_get_tex_image(ctx, atlas->texObj,
998 if (!atlas->texImage) {
1003 _mesa_init_teximage_fields(ctx, atlas->texImage,
1004 atlas->texWidth, atlas->texHeight, 1, 0,
1007 _mesa_init_teximage_fields(ctx, atlas->texImage,
1008 atlas->texWidth, atlas->texHeight, 1, 0,
1012 if (!st_AllocTextureImageBuffer(ctx, atlas->texImage)) {
1017 st_MapTextureImage(ctx, atlas->texImage, 0,
1018 0, 0, atlas->texWidth, atlas->texHeight,
1025 memset(map, 0xff, map_stride * atlas->texHeight);
1027 for (i = 0; i < atlas->numBitmaps; i++) {
1037 unsigned xpos = atlas->glyphs[i].x;
1038 unsigned ypos = atlas->glyphs[i].y;
1041 assert(atlas->glyphs[i].w == bitmap_width);
1042 assert(atlas->glyphs[i].h == bitmap_height);
1052 st_UnmapTextureImage(ctx, atlas->texImage, 0);
1054 atlas->complete = true;
1059 _mesa_error(ctx, GL_OUT_OF_MEMORY, "Display list bitmap atlas");
1061 if (atlas->texObj) {
1062 _mesa_delete_texture_object(ctx, atlas->texObj);
1064 free(atlas->glyphs);
1065 atlas->glyphs = NULL;
1066 atlas->incomplete = true;
1359 * deleted belongs to a bitmap texture atlas.
1364 struct gl_bitmap_atlas *atlas = (struct gl_bitmap_atlas *) data;
1366 const GLuint atlas_id = atlas->Id;
1368 /* See if the list_id falls in the range contained in this texture atlas */
1369 if (atlas->complete &&
1371 list_id < atlas_id + atlas->numBitmaps) {
1372 /* Mark the atlas as incomplete so it doesn't get used. But don't
1376 atlas->complete = false;
1377 atlas->incomplete = true;
1401 * atlas. Examine all atlases to see if that's the case. There's
13393 * bitmap atlas to free.
13395 struct gl_bitmap_atlas *atlas = lookup_bitmap_atlas(ctx, list);
13396 if (atlas) {
13397 _mesa_delete_bitmap_atlas(ctx, atlas);
13449 * Create the empty atlas now.
13451 struct gl_bitmap_atlas *atlas = lookup_bitmap_atlas(ctx, base);
13452 if (!atlas) {
13453 atlas = alloc_bitmap_atlas(ctx, base, true);
13455 if (atlas) {
13457 assert(atlas->numBitmaps == 0);
13458 atlas->numBitmaps = range;
13779 * glBitmap commands with a texture atlas.
13786 struct gl_bitmap_atlas *atlas;
13797 atlas = lookup_bitmap_atlas(ctx, ctx->List.ListBase);
13799 if (!atlas) {
13801 * the atlas now.
13803 atlas = alloc_bitmap_atlas(ctx, ctx->List.ListBase, false);
13806 if (atlas && !atlas->complete && !atlas->incomplete) {
13807 /* Try to build the bitmap atlas now.
13808 * If the atlas was created in glGenLists, we'll have recorded the
13811 if (atlas->numBitmaps == 0)
13812 atlas->numBitmaps = 256;
13813 build_bitmap_atlas(ctx, atlas, ctx->List.ListBase);
13816 if (!atlas || !atlas->complete) {
13820 /* check that all display list IDs are in the atlas */
13824 if (ids[i] >= atlas->numBitmaps) {
13829 st_DrawAtlasBitmaps(ctx, atlas, n, (const GLubyte *) lists);