was playing with ansiotropic filtering - with mipmap stuff it looks nicer.

stillnot perfect. xrender engine detects "same source data pointer" and
shares nicely now :)


SVN revision: 17224
This commit is contained in:
Carsten Haitzler 2005-10-06 02:38:34 +00:00
parent 58443f1f4a
commit e08ff34ee1
6 changed files with 119 additions and 49 deletions

View File

@ -65,10 +65,6 @@ evas_gl_common_context_use(Evas_GL_Context *gc)
{ {
if (strstr(ext, "GL_SGIS_generate_mipmap")) gc->ext.sgis_generate_mipmap = 1; if (strstr(ext, "GL_SGIS_generate_mipmap")) gc->ext.sgis_generate_mipmap = 1;
if (strstr(ext, "GL_NV_texture_rectangle")) gc->ext.nv_texture_rectangle = 1; if (strstr(ext, "GL_NV_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
/* technically this should work, as its a compatible */
/* implementation of the nvidia texture_rectangle extension */
/* since the #define value is the same as is the description */
/* it was fixed in the latest (3.2.5) fglrx drivers */
if (strstr(ext, "GL_EXT_texture_rectangle")) gc->ext.nv_texture_rectangle = 1; if (strstr(ext, "GL_EXT_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
printf("GL EXT supported: GL_SGIS_generate_mipmap = %x\n", gc->ext.sgis_generate_mipmap); printf("GL EXT supported: GL_SGIS_generate_mipmap = %x\n", gc->ext.sgis_generate_mipmap);
printf("GL EXT supported: GL_NV_texture_rectangle = %x\n", gc->ext.nv_texture_rectangle); printf("GL EXT supported: GL_NV_texture_rectangle = %x\n", gc->ext.nv_texture_rectangle);

View File

@ -172,7 +172,8 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, Evas_GL_Im
oh = (dh * im->tex->th) / sh; oh = (dh * im->tex->th) / sh;
evas_gl_common_context_texture_set(gc, im->tex, smooth, ow, oh); evas_gl_common_context_texture_set(gc, im->tex, smooth, ow, oh);
if ((!im->tex->have_mipmaps) && (smooth) && if ((!im->tex->have_mipmaps) && (smooth) &&
((im->tex->uw < im->tex->tw) || (im->tex->uh < im->tex->th))) ((im->tex->uw < im->tex->tw) || (im->tex->uh < im->tex->th)) &&
(!gc->ext.sgis_generate_mipmap))
evas_gl_common_texture_mipmaps_build(im->tex, im->im, smooth); evas_gl_common_texture_mipmaps_build(im->tex, im->im, smooth);
if (im->tex->not_power_of_two) if (im->tex->not_power_of_two)
@ -204,9 +205,19 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, Evas_GL_Im
evas_gl_common_context_write_buf_set(gc, GL_BACK); evas_gl_common_context_write_buf_set(gc, GL_BACK);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2d(tx1, ty1); glVertex2i(dx , dy ); if (im->tex->not_power_of_two)
glTexCoord2d(tx2, ty1); glVertex2i(dx + dw, dy ); {
glTexCoord2d(tx2, ty2); glVertex2i(dx + dw, dy + dh); glTexCoord2d(tx1, ty1); glVertex2i(dx , dy );
glTexCoord2d(tx1, ty2); glVertex2i(dx , dy + dh); glTexCoord2d(tx2, ty1); glVertex2i(dx + dw, dy );
glTexCoord2d(tx2, ty2); glVertex2i(dx + dw, dy + dh);
glTexCoord2d(tx1, ty2); glVertex2i(dx , dy + dh);
}
else
{
glTexCoord2d(tx1, ty1); glVertex2f(dx , dy );
glTexCoord2d(tx2, ty1); glVertex2f(dx + dw + 0.5, dy );
glTexCoord2d(tx2, ty2); glVertex2f(dx + dw + 0.5, dy + dh + 0.5);
glTexCoord2d(tx1, ty2); glVertex2f(dx , dy + dh + 0.5);
}
glEnd(); glEnd();
} }

View File

@ -68,12 +68,13 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glGenTextures(1, &(tex->texture)); glGenTextures(1, &(tex->texture));
glBindTexture(GL_TEXTURE_2D, tex->texture); glBindTexture(GL_TEXTURE_2D, tex->texture);
if (gc->texture) gc->texture->references--; if (gc->texture) gc->texture->references--;
gc->texture = tex; gc->texture = tex;
gc->change.texture = 1; gc->change.texture = 1;
tex->references++; tex->references++;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

View File

@ -772,14 +772,22 @@ evas_engine_xrender_x11_image_data_put(void *data, void *image, DATA32 *image_da
XR_Image *old_image; XR_Image *old_image;
old_image = (XR_Image *)image; old_image = (XR_Image *)image;
image = _xre_image_new_from_data(old_image->xinf, old_image->w, old_image->h, image_data); image = _xre_image_data_find(image_data);
if (image) if (!image)
{ {
((XR_Image *)image)->alpha = old_image->alpha; image = _xre_image_new_from_data(old_image->xinf, old_image->w, old_image->h, image_data);
_xre_image_free(old_image); if (image)
{
((XR_Image *)image)->alpha = old_image->alpha;
_xre_image_free(old_image);
}
else
image = old_image;
} }
else else
image = old_image; {
_xre_image_free(old_image);
}
} }
return image; return image;
} }

View File

@ -111,6 +111,7 @@ void _xre_image_region_dirty(XR_Image *im, int x, int y, int w, int h);
void _xre_image_dirty(XR_Image *im); void _xre_image_dirty(XR_Image *im);
XR_Image *_xre_image_copy(XR_Image *im); XR_Image *_xre_image_copy(XR_Image *im);
void *_xre_image_data_get(XR_Image *im); void *_xre_image_data_get(XR_Image *im);
XR_Image *_xre_image_data_find(void *data);
void _xre_image_data_put(XR_Image *im, void *data); void _xre_image_data_put(XR_Image *im, void *data);
void _xre_image_alpha_set(XR_Image *im, int alpha); void _xre_image_alpha_set(XR_Image *im, int alpha);
int _xre_image_alpha_get(XR_Image *im); int _xre_image_alpha_get(XR_Image *im);

View File

@ -8,6 +8,36 @@ static Evas_Hash *_xr_image_hash = NULL;
static int _xr_image_cache_size = 0; static int _xr_image_cache_size = 0;
static int _xr_image_cache_usage = 0; static int _xr_image_cache_usage = 0;
static Evas_List *_xr_image_cache = NULL; static Evas_List *_xr_image_cache = NULL;
static Evas_Hash *_xr_image_dirty_hash = NULL;
static void
__xre_image_dirty_hash_add(XR_Image *im)
{
char buf[64];
if (!im->data) return;
snprintf(buf, sizeof(buf), "%p", im->data);
_xr_image_dirty_hash = evas_hash_add(_xr_image_dirty_hash, buf, im);
}
static void
__xre_image_dirty_hash_del(XR_Image *im)
{
char buf[64];
if (!im->data) return;
snprintf(buf, sizeof(buf), "%p", im->data);
_xr_image_dirty_hash = evas_hash_del(_xr_image_dirty_hash, buf, im);
}
static XR_Image *
__xre_image_dirty_hash_find(void *data)
{
char buf[64];
snprintf(buf, sizeof(buf), "%p", data);
return evas_hash_find(_xr_image_dirty_hash, buf);
}
static XR_Image * static XR_Image *
__xre_image_find(char *fkey) __xre_image_find(char *fkey)
@ -91,6 +121,7 @@ _xre_image_new_from_data(Ximage_Info *xinf, int w, int h, void *data)
im->data = data; im->data = data;
im->alpha = 1; im->alpha = 1;
im->dirty = 1; im->dirty = 1;
__xre_image_dirty_hash_add(im);
return im; return im;
} }
@ -99,6 +130,39 @@ _xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data)
{ {
XR_Image *im; XR_Image *im;
im = calloc(1, sizeof(XR_Image));
if (!im) return NULL;
im->data = malloc(w * h * 4);
if (!im->data)
{
free(im);
return NULL;
}
if (data)
{
Gfx_Func_Blend_Src_Dst func;
func = evas_common_draw_func_copy_get(w * h, 0);
if (func) func(data, im->data, w * h);
evas_common_cpu_end_opt();
}
im->w = w;
im->h = h;
im->references = 1;
im->xinf = xinf;
im->xinf->references++;
im->free_data = 1;
im->alpha = 1;
im->dirty = 1;
__xre_image_dirty_hash_add(im);
return im;
}
XR_Image *
_xre_image_new(Ximage_Info *xinf, int w, int h)
{
XR_Image *im;
im = calloc(1, sizeof(XR_Image)); im = calloc(1, sizeof(XR_Image));
if (!im) return NULL; if (!im) return NULL;
im->data = malloc(w * h * 4); im->data = malloc(w * h * 4);
@ -113,42 +177,9 @@ _xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data)
im->xinf = xinf; im->xinf = xinf;
im->xinf->references++; im->xinf->references++;
im->free_data = 1; im->free_data = 1;
if (data)
{
Gfx_Func_Blend_Src_Dst func;
func = evas_common_draw_func_copy_get(w * h, 0);
if (func) func(data, im->data, w * h);
evas_common_cpu_end_opt();
}
im->alpha = 1;
im->dirty = 1;
return im;
}
XR_Image *
_xre_image_new(Ximage_Info *xinf, int w, int h)
{
XR_Image *im;
im = calloc(1, sizeof(XR_Image));
if (!im) return NULL;
im->xinf = xinf;
im->xinf->references++;
im->w = w;
im->h = h;
im->references = 1;
im->data = malloc(w * h * 4);
if (!im->data)
{
im->xinf->references--;
free(im);
}
im->free_data = 1;
im->alpha = 1; im->alpha = 1;
im->dirty = 1; im->dirty = 1;
__xre_image_dirty_hash_add(im);
return im; return im;
} }
@ -159,6 +190,7 @@ __xre_image_real_free(XR_Image *im)
if (im->key) free(im->key); if (im->key) free(im->key);
if (im->fkey) free(im->fkey); if (im->fkey) free(im->fkey);
if (im->im) evas_common_image_unref(im->im); if (im->im) evas_common_image_unref(im->im);
if ((im->data) && (im->dirty)) __xre_image_dirty_hash_del(im);
if ((im->free_data) && (im->data)) free(im->data); if ((im->free_data) && (im->data)) free(im->data);
if (im->surface) _xr_render_surface_free(im->surface); if (im->surface) _xr_render_surface_free(im->surface);
if (im->format) free(im->format); if (im->format) free(im->format);
@ -283,8 +315,10 @@ _xre_image_resize(XR_Image *im, int w, int h)
} }
evas_common_cpu_end_opt(); evas_common_cpu_end_opt();
} }
__xre_image_dirty_hash_del(im);
free(im->data); free(im->data);
im->data = data; im->data = data;
__xre_image_dirty_hash_add(im);
} }
else if (im->im) else if (im->im)
{ {
@ -312,12 +346,19 @@ _xre_image_resize(XR_Image *im, int w, int h)
evas_common_blit_rectangle(im_old, im->im, 0, 0, ww, hh, 0, 0); evas_common_blit_rectangle(im_old, im->im, 0, 0, ww, hh, 0, 0);
evas_common_cpu_end_opt(); evas_common_cpu_end_opt();
} }
im->free_data = 1;
im->data = im->im->image->data;
im->im->image->data = NULL;
evas_common_image_unref(im->im);
im->im = NULL;
evas_common_image_unref(im_old); evas_common_image_unref(im_old);
__xre_image_dirty_hash_add(im);
} }
else else
{ {
im->data = malloc(w * h * 4); im->data = malloc(w * h * 4);
im->free_data = 1; im->free_data = 1;
__xre_image_dirty_hash_add(im);
} }
im->w = w; im->w = w;
im->h = h; im->h = h;
@ -341,6 +382,16 @@ _xre_image_data_get(XR_Image *im)
return data; return data;
} }
XR_Image *
_xre_image_data_find(void *data)
{
XR_Image *im;
im = __xre_image_dirty_hash_find(data);
if (im) im->references++;
return im;
}
void void
_xre_image_data_put(XR_Image *im, void *data) _xre_image_data_put(XR_Image *im, void *data)
{ {
@ -351,6 +402,7 @@ _xre_image_data_put(XR_Image *im, void *data)
{ {
imdata = im->data; imdata = im->data;
if (data == imdata) return; if (data == imdata) return;
__xre_image_dirty_hash_del(im);
if (im->free_data) free(im->data); if (im->free_data) free(im->data);
} }
else else
@ -364,6 +416,7 @@ _xre_image_data_put(XR_Image *im, void *data)
} }
} }
im->data = data; im->data = data;
__xre_image_dirty_hash_add(im);
im->free_data = 0; im->free_data = 0;
if (im->surface) if (im->surface)
{ {