summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-01-18 11:47:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-04-14 11:26:43 +0900
commit2ef8d6f39af839c23551239216cea100254f80df (patch)
tree415581d3cb5245012225777926638827051bc3c2 /src/modules/evas/engines/gl_common
parentfb52c15e8513cc1458341da13e570d231a886551 (diff)
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of trying to get rid of unused or poorly implemented classes in ector. Originally ector was meant to support VG but extend to things like filters as well. At the moment, ector's design makes it quite hard to plug in the filters. For now I think it's easier to implement the GL support for the filters directly in the engine, where I hope to interfere as little as possible. This massive patch keeps only the required minimum to support a versatile gl buffer that can be mapped, drawn or rendered to (FBO). It's extremely inefficient as it relies on glReadPixels and lots of texture uploads, as well as conversions between ARGB and Alpha. Another type of GL buffer is a wrap around an existing GL image, but that one is read-only (map or draw: no write map, no FBO). No, all the filters run fine, and the high-level implementation (evas_filters.c) does not need to know whether the underlying engine is SW or GL. One problem though appears with the blending or blurring of some Alpha buffers, the colors are wrong. This patch removes more lines than it adds so it must be good ;)
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h1
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c61
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c1
3 files changed, 63 insertions, 0 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index ef91f7b9d6..38474bbe35 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -688,6 +688,7 @@ void evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x,
688void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im); 688void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
689void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level); 689void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level);
690void evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth); 690void evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth);
691Evas_GL_Image *evas_gl_common_image_surface_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
691 692
692void *evas_gl_font_texture_new(void *gc, RGBA_Font_Glyph *fg); 693void *evas_gl_font_texture_new(void *gc, RGBA_Font_Glyph *fg);
693void evas_gl_font_texture_free(void *); 694void evas_gl_font_texture_free(void *);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c
index 3b02db1406..de907be540 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -248,6 +248,8 @@ evas_gl_common_image_new_from_rgbaimage(Evas_Engine_GL_Context *gc, RGBA_Image *
248 } 248 }
249 */ 249 */
250 250
251 if (error) *error = EVAS_LOAD_ERROR_NONE;
252
251 // FIXME: keep unreffed shared images around 253 // FIXME: keep unreffed shared images around
252 EINA_LIST_FOREACH(gc->shared->images, l, im) 254 EINA_LIST_FOREACH(gc->shared->images, l, im)
253 { 255 {
@@ -1039,6 +1041,65 @@ evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
1039 } 1041 }
1040} 1042}
1041 1043
1044Evas_GL_Image *
1045evas_gl_common_image_surface_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
1046{
1047 Evas_GL_Image *glim = NULL;
1048 Eina_Bool alpha;
1049 int w, h;
1050
1051 if (!gc || !im || !im->im || !im->im->image.data)
1052 goto fail;
1053
1054 if (im->im->cache_entry.space == EFL_GFX_COLORSPACE_ARGB8888)
1055 alpha = EINA_FALSE;
1056 else if (im->im->cache_entry.space == EFL_GFX_COLORSPACE_GRY8)
1057 alpha = EINA_TRUE;
1058 else goto fail;
1059
1060 w = im->im->cache_entry.w;
1061 h = im->im->cache_entry.h;
1062 glim = evas_gl_common_image_surface_new(gc, w, h, EINA_TRUE, EINA_FALSE);
1063 if (!glim) goto fail;
1064
1065 if (alpha)
1066 {
1067 RGBA_Image *image;
1068 uint32_t *rgba;
1069 uint8_t *gry8;
1070 int k;
1071
1072 image = evas_common_image_new(w, h, EINA_TRUE);
1073 if (!image) goto fail;
1074
1075 rgba = image->image.data;
1076 gry8 = im->im->image.data8;
1077 for (k = 0; k < (w * h); k++)
1078 {
1079 const int c = *gry8++;
1080 *rgba++ = ARGB_JOIN(c, c, c, c);
1081 }
1082
1083 glim->im = image;
1084 }
1085 else
1086 {
1087 evas_cache_image_ref(&im->im->cache_entry);
1088 glim->im = im->im;
1089 }
1090
1091 glim->dirty = EINA_TRUE;
1092 evas_gl_common_image_update(gc, glim);
1093 evas_gl_common_image_free(im);
1094
1095 return glim;
1096
1097fail:
1098 ERR("Failed to update surface pixels!");
1099 if (glim) evas_gl_common_image_free(glim);
1100 return NULL;
1101}
1102
1042void 1103void
1043evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, 1104evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
1044 int npoints, RGBA_Map_Point *p, int smooth, int level EINA_UNUSED) 1105 int npoints, RGBA_Map_Point *p, int smooth, int level EINA_UNUSED)
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 f4d747e331..77c55f593b 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_texture.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c
@@ -82,6 +82,7 @@ static const struct {
82 { MATCH_FALSE, MATCH_FALSE, EVAS_COLORSPACE_ARGB8888, &rgb_ifmt, &rgb_fmt }, 82 { MATCH_FALSE, MATCH_FALSE, EVAS_COLORSPACE_ARGB8888, &rgb_ifmt, &rgb_fmt },
83#endif 83#endif
84 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_GRY8, &lum_fmt, &lum_ifmt }, 84 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_GRY8, &lum_fmt, &lum_ifmt },
85 { MATCH_TRUE, MATCH_ANY, EVAS_COLORSPACE_GRY8, &alpha_fmt, &alpha_ifmt },
85 { MATCH_TRUE, MATCH_ANY, EVAS_COLORSPACE_AGRY88, &lum_alpha_fmt, &lum_alpha_ifmt }, 86 { MATCH_TRUE, MATCH_ANY, EVAS_COLORSPACE_AGRY88, &lum_alpha_fmt, &lum_alpha_ifmt },
86 // ETC1/2 support 87 // ETC1/2 support
87 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_ETC1, &etc1_fmt, &etc1_fmt }, 88 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_ETC1, &etc1_fmt, &etc1_fmt },