summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorOleksandr Shcherbina <o.shcherbina@samsung.com>2015-04-22 15:19:02 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-07 09:53:09 +0200
commitd88ccf06a5f6ebcfc68dcc21e55a241f64ff9aa9 (patch)
treec161bdf705243e99217f689e42458a0de2edb9f9 /src/lib
parent0f6d101ad5ec8327088e448c347e1f4054a5c8d7 (diff)
evas: use Evas_GL_image for generate texture unit for Evas_3D_Texture.
Summary: Used engine function for load image/data and use texture unit through Evas_GL_Image object Used Evas_ColorSpace format instead Evas_3D_Color/Pixel format Added transformation matrix for adjusting texture unit coordinates in shader Added property in Evas_3D_Texture for mark possibility get texture without atlas (see https://phab.enlightenment.org/conpherence/54/, I suppose it will done after this patch) Reviewers: Hermet, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2371 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/evas/Evas_Eo.h38
-rw-r--r--src/lib/evas/canvas/evas_3d_texture.c84
-rw-r--r--src/lib/evas/canvas/evas_3d_texture.eo30
-rw-r--r--src/lib/evas/include/evas_3d_utils.h30
-rw-r--r--src/lib/evas/include/evas_private.h12
5 files changed, 127 insertions, 67 deletions
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 1e1fb5945b..296444268f 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -698,44 +698,6 @@ typedef enum _Evas_3D_Comparison
698} Evas_3D_Comparison; 698} Evas_3D_Comparison;
699 699
700/** 700/**
701 * Color formats of pixel data
702 *
703 * @since 1.10
704 * @ingroup Evas_3D_Types
705 */
706typedef enum _Evas_3D_Color_Format
707{
708 /**< Color contains full components, red, green, blue and alpha */
709 EVAS_3D_COLOR_FORMAT_RGBA = 0,
710 /**< Color contains only red, green and blue components */
711 EVAS_3D_COLOR_FORMAT_RGB,
712 /**< Color contains only alpha component */
713 EVAS_3D_COLOR_FORMAT_ALPHA
714} Evas_3D_Color_Format;
715
716/**
717 * Pixel formats
718 *
719 * @since 1.10
720 * @ingroup Evas_3D_Types
721 */
722typedef enum _Evas_3D_Pixel_Format
723{
724 /**< 8-bit pixel with single component */
725 EVAS_3D_PIXEL_FORMAT_8 = 0,
726 /**< 16-bit pixel with three components (5-6-5 bit) */
727 EVAS_3D_PIXEL_FORMAT_565,
728 /**< 24-bit pixel with three 8-bit components */
729 EVAS_3D_PIXEL_FORMAT_888,
730 /**< 32-bit pixel with four 8-bit components */
731 EVAS_3D_PIXEL_FORMAT_8888,
732 /**< 16-bit pixel with four 4-bit components */
733 EVAS_3D_PIXEL_FORMAT_4444,
734 /**< 16-bit pixel with four components (5-5-5-1 bit) */
735 EVAS_3D_PIXEL_FORMAT_5551
736} Evas_3D_Pixel_Format;
737
738/**
739 * Wrap modes 701 * Wrap modes
740 * 702 *
741 * @since 1.10 703 * @since 1.10
diff --git a/src/lib/evas/canvas/evas_3d_texture.c b/src/lib/evas/canvas/evas_3d_texture.c
index 314450cddf..8b68d818d6 100644
--- a/src/lib/evas/canvas/evas_3d_texture.c
+++ b/src/lib/evas/canvas/evas_3d_texture.c
@@ -234,7 +234,7 @@ _evas_3d_texture_evas_3d_object_update_notify(Eo *obj, Evas_3D_Texture_Data *pd)
234 if (e->engine.func->texture_new) 234 if (e->engine.func->texture_new)
235 { 235 {
236 pd->engine_data = 236 pd->engine_data =
237 e->engine.func->texture_new(e->engine.data.output); 237 e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable);
238 } 238 }
239 239
240 if (pd->engine_data == NULL) 240 if (pd->engine_data == NULL)
@@ -308,7 +308,6 @@ evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *materia
308 eina_hash_set(pd->materials, &material, (const void *)(uintptr_t)(count - 1)); 308 eina_hash_set(pd->materials, &material, (const void *)(uintptr_t)(count - 1));
309} 309}
310 310
311
312EAPI Evas_3D_Texture * 311EAPI Evas_3D_Texture *
313evas_3d_texture_add(Evas *e) 312evas_3d_texture_add(Evas *e)
314{ 313{
@@ -324,6 +323,8 @@ EOLIAN static void
324_evas_3d_texture_eo_base_constructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUSED) 323_evas_3d_texture_eo_base_constructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUSED)
325{ 324{
326 eo_do_super(obj, MY_CLASS, eo_constructor()); 325 eo_do_super(obj, MY_CLASS, eo_constructor());
326 pd->atlas_enable = EINA_TRUE;
327
327 eo_do(obj, evas_3d_object_type_set(EVAS_3D_OBJECT_TYPE_TEXTURE)); 328 eo_do(obj, evas_3d_object_type_set(EVAS_3D_OBJECT_TYPE_TEXTURE));
328} 329}
329 330
@@ -335,37 +336,68 @@ _evas_3d_texture_eo_base_destructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUS
335} 336}
336 337
337EOLIAN static void 338EOLIAN static void
338_evas_3d_texture_data_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Color_Format color_format, 339_evas_3d_texture_data_set(Eo *obj, Evas_3D_Texture_Data *pd,
339 Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data) 340 Evas_Colorspace color_format,
341 int w, int h, const void *data)
340{ 342{
341 Eo *evas = NULL; 343 Eo *evas = NULL;
344 void *image = NULL;
342 eo_do(obj, evas = evas_common_evas_get()); 345 eo_do(obj, evas = evas_common_evas_get());
343 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); 346 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
344 347
345 if (!pd->engine_data && e->engine.func->texture_new) 348 if (!pd->engine_data && e->engine.func->texture_new)
346 pd->engine_data = e->engine.func->texture_new(e->engine.data.output); 349 pd->engine_data = e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable);
350 if (!data)
351 {
352 ERR("Failure, image data is empty");
353 return;
354 }
347 355
348 if (e->engine.func->texture_data_set) 356 image = e->engine.func->image_new_from_data(e->engine.data.output, w, h, (DATA32 *)data, EINA_TRUE, color_format);
349 e->engine.func->texture_data_set(e->engine.data.output, pd->engine_data, 357 if (!image)
350 color_format, pixel_format, w, h, data); 358 {
359 ERR("Can't load image from data");
360 return;
361 }
351 362
363 if (e->engine.func->texture_image_set)
364 e->engine.func->texture_image_set(e->engine.data.output,
365 pd->engine_data,
366 image);
367 e->engine.func->image_free(e->engine.data.output, image);
352 eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); 368 eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL));
353} 369}
354 370
355EOLIAN static void 371EOLIAN static void
356_evas_3d_texture_file_set(Eo *obj, Evas_3D_Texture_Data *pd, const char *file, const char *key) 372_evas_3d_texture_file_set(Eo *obj, Evas_3D_Texture_Data *pd, const char *file, const char *key)
357{ 373{
374
375 Evas_Image_Load_Opts lo;
376 int load_error;
358 Eo *evas = NULL; 377 Eo *evas = NULL;
378 void *image;
379
359 eo_do(obj, evas = evas_common_evas_get()); 380 eo_do(obj, evas = evas_common_evas_get());
360 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); 381 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
361 382
362 if (!pd->engine_data && e->engine.func->texture_new) 383 if (!pd->engine_data && e->engine.func->texture_new)
363 pd->engine_data = e->engine.func->texture_new(e->engine.data.output); 384 pd->engine_data = e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable);
385
386 memset(&lo, 0x0, sizeof(Evas_Image_Load_Opts));
387 image = e->engine.func->image_load(e->engine.data.output,
388 file, key, &load_error, &lo);
389 if (!image)
390 {
391 ERR("Can't load image from file");
392 return;
393 }
364 394
365 if (e->engine.func->texture_file_set) 395 if (e->engine.func->texture_image_set)
366 e->engine.func->texture_file_set(e->engine.data.output, pd->engine_data, 396 e->engine.func->texture_image_set(e->engine.data.output,
367 file, key); 397 pd->engine_data,
398 image);
368 399
400 e->engine.func->image_free(e->engine.data.output, image);
369 eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); 401 eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL));
370} 402}
371 403
@@ -374,6 +406,7 @@ _evas_3d_texture_source_set(Eo *obj , Evas_3D_Texture_Data *pd, Evas_Object *sou
374{ 406{
375 Eo *evas = NULL; 407 Eo *evas = NULL;
376 eo_do(obj, evas = evas_common_evas_get()); 408 eo_do(obj, evas = evas_common_evas_get());
409 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
377 Evas_Object_Protected_Data *src; 410 Evas_Object_Protected_Data *src;
378 411
379 if (source == pd->source) 412 if (source == pd->source)
@@ -403,6 +436,8 @@ _evas_3d_texture_source_set(Eo *obj , Evas_3D_Texture_Data *pd, Evas_Object *sou
403 ERR("No evas surface associated with the source object."); 436 ERR("No evas surface associated with the source object.");
404 return; 437 return;
405 } 438 }
439 if (!pd->engine_data && e->engine.func->texture_new)
440 pd->engine_data = e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable);
406 441
407 _texture_proxy_set(obj, source, src); 442 _texture_proxy_set(obj, source, src);
408 eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); 443 eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL));
@@ -442,19 +477,21 @@ _evas_3d_texture_source_visible_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *p
442 return !src_obj->proxy->src_invisible; 477 return !src_obj->proxy->src_invisible;
443} 478}
444 479
445EOLIAN static Evas_3D_Color_Format 480EOLIAN static Evas_Colorspace
446_evas_3d_texture_color_format_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) 481_evas_3d_texture_color_format_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd)
447{ 482{
448 // FIXME: we need an unknown color format and unify that with Evas color space to 483 Evas_Colorspace format = -1;
449 Evas_3D_Color_Format format = -1;
450 Eo *evas = NULL; 484 Eo *evas = NULL;
451 eo_do(obj, evas = evas_common_evas_get()); 485 eo_do(obj, evas = evas_common_evas_get());
452 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); 486 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
453 487
454 if (e->engine.func->texture_color_format_get) 488 if (e->engine.func->image_colorspace_get &&
489 e->engine.func->texture_image_get)
455 { 490 {
456 e->engine.func->texture_color_format_get(e->engine.data.output, 491 void *image;
457 pd->engine_data, &format); 492
493 image = e->engine.func->texture_image_get(e->engine.data.output, pd->engine_data);
494 format = e->engine.func->image_colorspace_get(e->engine.data.output, image);
458 } 495 }
459 496
460 return format; 497 return format;
@@ -527,4 +564,15 @@ _evas_3d_texture_filter_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_
527 } 564 }
528} 565}
529 566
567EOLIAN static void
568_evas_3d_texture_atlas_enable_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Eina_Bool use_atlas)
569{
570 if (pd->atlas_enable != use_atlas) pd->atlas_enable = use_atlas;
571}
572
573EOLIAN static Eina_Bool
574_evas_3d_texture_atlas_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd)
575{
576 return pd->atlas_enable;
577}
530#include "canvas/evas_3d_texture.eo.c" 578#include "canvas/evas_3d_texture.eo.c"
diff --git a/src/lib/evas/canvas/evas_3d_texture.eo b/src/lib/evas/canvas/evas_3d_texture.eo
index 83ab29a9d6..39efb61e23 100644
--- a/src/lib/evas/canvas/evas_3d_texture.eo
+++ b/src/lib/evas/canvas/evas_3d_texture.eo
@@ -31,6 +31,29 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface)
31 bool visible; /*@ @c EINA_TRUE for visible, @c EINA_FALSE for invisible.*/ 31 bool visible; /*@ @c EINA_TRUE for visible, @c EINA_FALSE for invisible.*/
32 } 32 }
33 } 33 }
34 atlas_enable {
35 set {
36 /*
37 Set enable flag to generation texture unit with support atlas.
38
39 Use this flag only in case not normalize texture coordinates.
40
41 By default, is enabled.
42
43 @ingroup Evas_3D_Texture
44 */
45 }
46 get {
47 /*
48 Get enable flag of generation texture unit with support atlas.
49
50 @ingroup Evas_3D_Texture
51 */
52 }
53 values {
54 bool use_atlas; /*@ @c EINA_TRUE for enable, @c EINA_FALSE for disable.*/
55 }
56 }
34 } 57 }
35 methods { 58 methods {
36 data_set { 59 data_set {
@@ -43,8 +66,7 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface)
43 */ 66 */
44 67
45 params { 68 params {
46 @in Evas_3D_Color_Format color_format; /*@ Color format of the texture. */ 69 @in Evas_Colorspace color_format; /*@ Color format of the texture. */
47 @in Evas_3D_Pixel_Format pixel_format; /*@ Pixel format of the data. */
48 @in int w; /*@ Width of the data. */ 70 @in int w; /*@ Width of the data. */
49 @in int h; /*@ Height of the data. */ 71 @in int h; /*@ Height of the data. */
50 @in const(void)* data; /*@ Pointer to the data. */ 72 @in const(void)* data; /*@ Pointer to the data. */
@@ -55,8 +77,6 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface)
55 /* 77 /*
56 Set the data of the given texture from file. 78 Set the data of the given texture from file.
57 79
58 Only PNG format is supported.
59
60 @ingroup Evas_3D_Texture 80 @ingroup Evas_3D_Texture
61 */ 81 */
62 82
@@ -96,7 +116,7 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface)
96 116
97 @ingroup Evas_3D_Texture 117 @ingroup Evas_3D_Texture
98 */ 118 */
99 return: Evas_3D_Color_Format; 119 return: Evas_Colorspace;
100 } 120 }
101 121
102 size_get @const { 122 size_get @const {
diff --git a/src/lib/evas/include/evas_3d_utils.h b/src/lib/evas/include/evas_3d_utils.h
index d11533ff6e..87bf70867d 100644
--- a/src/lib/evas/include/evas_3d_utils.h
+++ b/src/lib/evas/include/evas_3d_utils.h
@@ -1150,6 +1150,36 @@ evas_mat3_invserse(Evas_Mat3 *out, const Evas_Mat3 *mat)
1150 } 1150 }
1151} 1151}
1152 1152
1153static inline void
1154evas_mat3_set_position_transform(Evas_Mat3 *out, const Evas_Real p_x, const Evas_Real p_y)
1155{
1156 Evas_Real *d = &out->m[0];
1157 memset(d, 0x00, sizeof(Evas_Mat3));
1158 d[0] = 1;
1159 d[2] = p_x;
1160 d[4] = 1;
1161 d[5] = p_y;
1162 d[8] = 1;
1163 if (p_x || p_y)
1164 out->flags = 0;
1165 else
1166 out->flags = EVAS_MATRIX_IS_IDENTITY;
1167}
1168
1169static inline void
1170evas_mat3_set_scale_transform(Evas_Mat3 *out, Evas_Real s_x, Evas_Real s_y)
1171{
1172 Evas_Real *d = &out->m[0];
1173 memset(d, 0x00, sizeof(Evas_Mat3));
1174 d[0] = s_x;
1175 d[4] = s_y;
1176 d[8] = 1;
1177 if (s_x != 1.0 || s_y != 1.0)
1178 out->flags = 0;
1179 else
1180 out->flags = EVAS_MATRIX_IS_IDENTITY;
1181}
1182
1153/* 2x2 matrix */ 1183/* 2x2 matrix */
1154static inline void 1184static inline void
1155evas_mat2_identity_set(Evas_Mat2 *m) 1185evas_mat2_identity_set(Evas_Mat2 *m)
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index af2592bc1a..427a71de0d 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -369,9 +369,11 @@ struct _Evas_3D_Texture
369 Evas_Object *source; 369 Evas_Object *source;
370 Eina_Bool proxy_rendering; 370 Eina_Bool proxy_rendering;
371 void *proxy_surface; 371 void *proxy_surface;
372
373 /* Engine-side object. */ 372 /* Engine-side object. */
374 void *engine_data; 373 void *engine_data;
374
375 /*Use atlases, @EINA_TRUE by default*/
376 Eina_Bool atlas_enable :1;
375}; 377};
376 378
377struct _Evas_3D_Material 379struct _Evas_3D_Material
@@ -389,7 +391,7 @@ struct _Evas_3D_Material
389 391
390struct _Evas_3D_Scene_Public_Data 392struct _Evas_3D_Scene_Public_Data
391{ 393{
392 Evas_Color bg_color; 394 Evas_Color bg_color;
393 Evas_3D_Node *camera_node; 395 Evas_3D_Node *camera_node;
394 Eina_List *light_nodes; 396 Eina_List *light_nodes;
395 Eina_List *mesh_nodes; 397 Eina_List *mesh_nodes;
@@ -1360,17 +1362,15 @@ struct _Evas_Func
1360 int (*drawable_texture_color_pick_id_get) (void *drawable); 1362 int (*drawable_texture_color_pick_id_get) (void *drawable);
1361 double (*drawable_texture_pixel_color_get) (unsigned int tex EINA_UNUSED, int x, int y, void *drawable); 1363 double (*drawable_texture_pixel_color_get) (unsigned int tex EINA_UNUSED, int x, int y, void *drawable);
1362 1364
1363 void *(*texture_new) (void *data); 1365 void *(*texture_new) (void *data, Eina_Bool use_atlas);
1364 void (*texture_free) (void *data, void *texture); 1366 void (*texture_free) (void *data, void *texture);
1365 void (*texture_data_set) (void *data, void *texture, Evas_3D_Color_Format format, Evas_3D_Pixel_Format pixel_format, int w, int h, const void *pixels);
1366 void (*texture_file_set) (void *data, void *texture, const char *file, const char *key);
1367 void (*texture_color_format_get) (void *data, void *texture, Evas_3D_Color_Format *format);
1368 void (*texture_size_get) (void *data, void *texture, int *w, int *h); 1367 void (*texture_size_get) (void *data, void *texture, int *w, int *h);
1369 void (*texture_wrap_set) (void *data, void *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t); 1368 void (*texture_wrap_set) (void *data, void *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t);
1370 void (*texture_wrap_get) (void *data, void *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t); 1369 void (*texture_wrap_get) (void *data, void *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t);
1371 void (*texture_filter_set) (void *data, void *texture, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag); 1370 void (*texture_filter_set) (void *data, void *texture, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag);
1372 void (*texture_filter_get) (void *data, void *texture, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag); 1371 void (*texture_filter_get) (void *data, void *texture, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag);
1373 void (*texture_image_set) (void *data, void *texture, void *image); 1372 void (*texture_image_set) (void *data, void *texture, void *image);
1373 void *(*texture_image_get) (void *data, void *texture);
1374 1374
1375 Ector_Surface *(*ector_get) (void *data); 1375 Ector_Surface *(*ector_get) (void *data);
1376 void (*ector_begin) (void *data, void *context, void *surface, int x, int y, Eina_Bool do_async); 1376 void (*ector_begin) (void *data, void *context, void *surface, int x, int y, Eina_Bool do_async);