summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-03-04 16:37:20 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-03-04 17:31:07 +0900
commit53d3cb4fec32d7876aba1c878501fe7ca9e06c46 (patch)
tree1e43d0673ba7d15616ddc3f611ad57f7048e3f57
parentb19d3599a58d310c65a465ba7cddab75c2b16f80 (diff)
downloadefl-53d3cb4fec32d7876aba1c878501fe7ca9e06c46.tar.gz
Evas GL common: Improve quality of miniature image
Sample in the middle of the "macro pixels" and fool around with the borders (usually used to limit linear sampling artifacts) to improve image quality on the edges. Those miniatures are still 16x16 but MAAAYYYYYBE they will look a bit less awful. NOTE: The first row still doesn't scale properly (interpolates with garbage above y=0).
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c51
1 files changed, 43 insertions, 8 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_texture.c b/src/modules/evas/engines/gl_common/evas_gl_texture.c
index 2f3852f7cd..6c3b0343a6 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_texture.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c
@@ -1283,26 +1283,61 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
out = alloca(bytes_count * EVAS_GL_TILE_SIZE * EVAS_GL_TILE_SIZE);
xstep = (float)tex->w / (EVAS_GL_TILE_SIZE - 2);
- ystep = (float)tex->h / (EVAS_GL_TILE_SIZE - 1);
+ ystep = (float)tex->h / (EVAS_GL_TILE_SIZE - 2);
in = im->image.data8;
- for (y = 0, j = 0; j < EVAS_GL_TILE_SIZE - 1; y += ystep, j++)
+ // top-left
+ memcpy(&out[0],
+ &in[0],
+ bytes_count);
+
+ // top
+ for (x = xstep * 0.5f, i = 1; i < EVAS_GL_TILE_SIZE - 1; x += xstep, i++)
+ {
+ memcpy(&out[i * bytes_count],
+ &in[(int)x * bytes_count],
+ bytes_count);
+ }
+
+ // top-right
+ memcpy(&out[((EVAS_GL_TILE_SIZE - 1) * bytes_count)],
+ &in[(im->cache_entry.w - 1) * bytes_count],
+ bytes_count);
+
+ for (y = ystep * 0.5f, j = 1; j < EVAS_GL_TILE_SIZE - 1; y += ystep, j++)
{
+ // left
memcpy(&out[j * EVAS_GL_TILE_SIZE * bytes_count],
- &in[(int)y * im->cache_entry.w * bytes_count],
+ &in[((int)y * im->cache_entry.w) * bytes_count],
bytes_count);
- for (x = 0, i = 1; i < EVAS_GL_TILE_SIZE - 1; x += xstep, i++)
+ // middle
+ for (x = xstep * 0.5f, i = 1; i < EVAS_GL_TILE_SIZE - 1; x += xstep, i++)
memcpy(&out[(j * EVAS_GL_TILE_SIZE + i) * bytes_count],
- &in[((int)y * im->cache_entry.w + (int)x) * bytes_count],
+ &in[(((int)y * im->cache_entry.w) + (int)x) * bytes_count],
bytes_count);
+ // right
memcpy(&out[(j * EVAS_GL_TILE_SIZE + i) * bytes_count],
- &in[((int)y * im->cache_entry.w + (int)(x - xstep)) * bytes_count],
+ &in[(((int)y * im->cache_entry.w) + (im->cache_entry.w - 1)) * bytes_count],
bytes_count);
}
+ // bottom-left
memcpy(&out[(j * EVAS_GL_TILE_SIZE) * bytes_count],
- &out[((j - 1) * EVAS_GL_TILE_SIZE) * bytes_count],
- EVAS_GL_TILE_SIZE * bytes_count);
+ &in[((im->cache_entry.w * (im->cache_entry.h - 1)) + 1) * bytes_count],
+ bytes_count);
+
+ // bottom
+ for (x = xstep * 0.5f, i = 1; i < EVAS_GL_TILE_SIZE - 1; x += xstep, i++)
+ {
+ memcpy(&out[((EVAS_GL_TILE_SIZE * j) + i) * bytes_count],
+ &in[((int)x + im->cache_entry.w * (im->cache_entry.h - 1)) * bytes_count],
+ bytes_count);
+ }
+
+ // bottom-right
+ memcpy(&out[((EVAS_GL_TILE_SIZE * EVAS_GL_TILE_SIZE) - 1) * bytes_count],
+ &in[((im->cache_entry.w * im->cache_entry.h) - 1) * bytes_count],
+ bytes_count);
// out is a miniature of the texture, upload that now and schedule the data for later.