summaryrefslogtreecommitdiff
path: root/src/tests/evas
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2019-12-12 16:22:12 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2019-12-12 16:22:12 +0900
commit2d7622491884843ce15e2717675b128af1bdbefc (patch)
treebadc8961affe622f541c3347e3b1b6d620bff898 /src/tests/evas
parentc62a7dae6316df60c6c47577743b62185ca56951 (diff)
evas_object_textblock: add support for variation sequences
Summary: update font processing to handle variation sequences unicodes to select proper glypg in respect to variation seqences Test Plan: ``` #define EFL_EO_API_SUPPORT 1 #define EFL_BETA_API_SUPPORT 1 #include <Eina.h> #include <Efl.h> #include <Elementary.h> EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win, *textblock; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("Main", ""); elm_win_autodel_set(win, EINA_TRUE); textblock = evas_object_textblock_add(win); efl_canvas_text_style_set(textblock,NULL,"DEFAULT='font=DejaVuSans font_fallbacks=SamsungColorEmoji color=#000 font_size=20'"); evas_object_textblock_text_markup_set(textblock, "8&#xfe0f;&#x20E3;&#x262a;&#xfe0f;AAA&#x262a;&#xfe0E;1234567&#xfe0f;&#x20E3;"); evas_object_size_hint_weight_set(textblock, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(textblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(textblock); evas_object_move(textblock, 0, 0); evas_object_resize(textblock, 320, 320); evas_object_resize(win, 320, 320); evas_object_show(win); elm_run(); return 0; } ELM_MAIN() ``` Reviewers: woohyun, bowonryu, segfaultxavi, cedric, bu5hm4n Reviewed By: woohyun, cedric Subscribers: raster, bu5hm4n, subodh6129, herdsman, segfaultxavi, zmike, cedric, #committers, #reviewers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9053
Diffstat (limited to 'src/tests/evas')
-rw-r--r--src/tests/evas/evas_buffer_helper.c199
-rw-r--r--src/tests/evas/evas_buffer_helper.h32
-rw-r--r--src/tests/evas/evas_test_object_smart.c2
-rw-r--r--src/tests/evas/evas_test_textblock.c3
-rw-r--r--src/tests/evas/meson.build1
5 files changed, 235 insertions, 2 deletions
diff --git a/src/tests/evas/evas_buffer_helper.c b/src/tests/evas/evas_buffer_helper.c
new file mode 100644
index 0000000000..db705df75e
--- /dev/null
+++ b/src/tests/evas/evas_buffer_helper.c
@@ -0,0 +1,199 @@
1
2#include <Evas.h>
3#include <Evas_Engine_Buffer.h>
4#include <stdio.h>
5#include <errno.h>
6
7/* Convenience routine to allocate and initialize the canvas.
8 * In a real application we'd be using ecore_evas_buffer_new() instead.
9 */
10Evas *canvas_create(int width, int height)
11{
12 Evas *canvas;
13 Evas_Engine_Info_Buffer *einfo;
14 int method;
15 void *pixels;
16
17 /* Request a handle for the 'buffer' type of rendering engine. */
18 method = evas_render_method_lookup("buffer");
19 if (method <= 0)
20 {
21 fputs("ERROR: evas was not compiled with 'buffer' engine!\n", stderr);
22 return NULL;
23 }
24
25 /* Create a general canvas object.
26 * Note that we are responsible for freeing the canvas when we're done. */
27 canvas = evas_new();
28 if (!canvas)
29 {
30 fputs("ERROR: could not instantiate new evas canvas.\n", stderr);
31 return NULL;
32 }
33
34 /* Specify that the canvas will be rendering using the buffer engine method.
35 * We also size the canvas and viewport to the same width and height, with
36 * the viewport set to the origin of the canvas.
37 */
38 evas_output_method_set(canvas, method);
39 evas_output_size_set(canvas, width, height);
40 evas_output_viewport_set(canvas, 0, 0, width, height);
41
42 /* Before we can use the engine, we *must* set its configuration
43 * parameters. The available parameters are kept in a struct
44 * named Evas_Engine_Info which is internal to Evas. Thus to set
45 * parameters we must first request the current info object from
46 * our canvas:
47 */
48 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(canvas);
49 if (!einfo)
50 {
51 fputs("ERROR: could not get evas engine info!\n", stderr);
52 evas_free(canvas);
53 return NULL;
54 }
55
56 /* Create the underlying data buffer that our canvas will use. This
57 * is a simple array of ARGB32 pixels. Each color component
58 * (including alpha) is one byte, resulting in 4 bytes per pixel (or
59 * 32 bits). We can thus store each pixel in an integer data type,
60 * thus calculating our data buffer as W x H x sizeof(int) bytes in
61 * length.
62 */
63 pixels = malloc(width * height * sizeof(int));
64 if (!pixels)
65 {
66 fputs("ERROR: could not allocate canvas pixels!\n", stderr);
67 evas_free(canvas);
68 return NULL;
69 }
70
71 /* Next set the various configuration parameters. We
72 * register the pixel buffer that the canvas will use,
73 * indicate the pixel format as ARGB32, and the size of
74 * each row of data. */
75 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
76 einfo->info.dest_buffer = pixels;
77 einfo->info.dest_buffer_row_bytes = width * sizeof(int);
78 einfo->info.use_color_key = 0;
79 einfo->info.alpha_threshold = 0;
80 einfo->info.func.new_update_region = NULL;
81 einfo->info.func.free_update_region = NULL;
82
83 /* Finally, we configure the canvas with our chosen parameters. */
84 evas_engine_info_set(canvas, (Evas_Engine_Info *)einfo);
85
86 return canvas;
87}
88
89/* Convenience routine to shut down the canvas.
90 * In a real application we'd be using ecore_evas_free() instead
91 */
92void canvas_destroy(Evas *canvas)
93{
94 Evas_Engine_Info_Buffer *einfo;
95
96 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(canvas);
97 if (!einfo)
98 {
99 fputs("ERROR: could not get evas engine info!\n", stderr);
100 evas_free(canvas);
101 return;
102 }
103
104 /* Free the data buffer we allocated in create_buffer() */
105 free(einfo->info.dest_buffer);
106
107 /* Finally, free the canvas itself. */
108 evas_free(canvas);
109}
110
111/*
112 * return internal buffer address
113*/
114void* canvas_buffer(Evas *canvas)
115{
116 Evas_Engine_Info_Buffer *einfo;
117 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(canvas);
118 if (!einfo)
119 {
120 fputs("ERROR: could not get evas engine info!\n", stderr);
121 return NULL;
122 }
123 return einfo->info.dest_buffer;
124}
125
126/* Convenience routine to update the scene.
127 * In a real application Ecore Evas would be doing this for us.
128 */
129void canvas_draw(Evas *canvas)
130{
131 Eina_List *updates, *n;
132 Eina_Rectangle *update;
133
134 /* Render the canvas, and get a list of the updated rectangles. */
135 updates = evas_render_updates(canvas);
136
137 /* Just for informative purposes, print out the areas being updated: */
138 EINA_LIST_FOREACH(updates, n, update)
139 printf("UPDATED REGION: pos: %3d, %3d size: %3dx%3d\n",
140 update->x, update->y, update->w, update->h);
141
142 /* Free the list of update rectangles */
143 evas_render_updates_free(updates);
144}
145
146/* Output the canvas buffer to a Portable Pixel Map (PPM) file */
147void canvas_save(Evas *canvas, const char *dest)
148{
149 Evas_Engine_Info_Buffer *einfo;
150 const unsigned int *pixels, *pixels_end;
151 int width, height;
152 FILE *f;
153
154 /* Retrieve the current data buffer. */
155 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(canvas);
156 if (!einfo)
157 {
158 fputs("ERROR: could not get evas engine info!\n", stderr);
159 return;
160 }
161
162 /* Retrieve the canvas dimensions */
163 evas_output_size_get(canvas, &width, &height);
164
165 /* Open our output PPM file for writing */
166 f = fopen(dest, "wb+");
167 if (!f)
168 {
169 fprintf(stderr, "ERROR: could not open for writing '%s': %s\n",
170 dest, strerror(errno));
171 return;
172 }
173
174 /* Write out the pixel data to the PPM file */
175 pixels = einfo->info.dest_buffer;
176 pixels_end = pixels + (width * height);
177
178 /* PPM P6 format is dead simple to write. First we output a magic
179 * number 'P6' to designate the file as PPM, then the width and
180 * height on their own line in ASCII decimal, followed by the maximum
181 * color value (255) on its own line in ASCII decimal, and finally a
182 * the pixel data in RGB order with each color component written as
183 * a char (byte). No alpha information is stored.
184 */
185 fprintf(f, "P6\n%d %d\n255\n", width, height);
186 for (; pixels < pixels_end; pixels++)
187 {
188 int r, g, b;
189
190 r = ((*pixels) & 0xff0000) >> 16;
191 g = ((*pixels) & 0x00ff00) >> 8;
192 b = (*pixels) & 0x0000ff;
193
194 fprintf(f, "%c%c%c", r, g, b);
195 }
196
197 fclose(f);
198 printf("saved scene as '%s'\n", dest);
199} \ No newline at end of file
diff --git a/src/tests/evas/evas_buffer_helper.h b/src/tests/evas/evas_buffer_helper.h
new file mode 100644
index 0000000000..9b55c17ca3
--- /dev/null
+++ b/src/tests/evas/evas_buffer_helper.h
@@ -0,0 +1,32 @@
1#ifndef _EVAS_BUFFER_HELPER_H_
2#define _EVAS_BUFFER_HELPER_H_
3
4#include <Evas.h>
5
6/*
7 * Create canvas with buffer and create its internal buffer
8*/
9Evas* canvas_create(int width, int height);
10
11/*
12 * return internal buffer
13*/
14void* canvas_buffer(Evas *evas);
15
16/*
17 * Destroy canvas and internal buffer
18*/
19void canvas_destroy(Evas *canvas);
20
21/*
22 * Save canvas into image with PPM P6 format (*.ppm)
23*/
24void canvas_save(Evas *canvas, const char *dest);
25
26/*
27 * Draw canvas (this should be called after making changes into evas)
28*/
29void canvas_draw(Evas *canvas);
30
31
32#endif // !_EVAS_BUFFER_HELPER_H_
diff --git a/src/tests/evas/evas_test_object_smart.c b/src/tests/evas/evas_test_object_smart.c
index 188e9c244b..e209100de6 100644
--- a/src/tests/evas/evas_test_object_smart.c
+++ b/src/tests/evas/evas_test_object_smart.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * TODO: 2 * TODO:
3 * * Test different font lodaing mechanisms. 3 * * Test different font loading mechanisms.
4 */ 4 */
5 5
6#ifdef HAVE_CONFIG_H 6#ifdef HAVE_CONFIG_H
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index a450ebc608..1a75153dd9 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * TODO: 2 * TODO:
3 * * Test different font lodaing mechanisms. 3 * * Test different font loading mechanisms.
4 */ 4 */
5 5
6#ifdef HAVE_CONFIG_H 6#ifdef HAVE_CONFIG_H
@@ -15,6 +15,7 @@
15 15
16#include "evas_suite.h" 16#include "evas_suite.h"
17#include "evas_tests_helpers.h" 17#include "evas_tests_helpers.h"
18#include "evas_buffer_helper.h"
18 19
19#define TESTS_DIC_DIR TESTS_SRC_DIR"/dicts" 20#define TESTS_DIC_DIR TESTS_SRC_DIR"/dicts"
20 21
diff --git a/src/tests/evas/meson.build b/src/tests/evas/meson.build
index 0e92eba83e..d89d602507 100644
--- a/src/tests/evas/meson.build
+++ b/src/tests/evas/meson.build
@@ -5,6 +5,7 @@ evas_suite_src = [
5 'evas_test_object.c', 5 'evas_test_object.c',
6 'evas_test_object_smart.c', 6 'evas_test_object_smart.c',
7 'evas_test_textblock.c', 7 'evas_test_textblock.c',
8 'evas_buffer_helper.c',
8 'evas_test_text.c', 9 'evas_test_text.c',
9 'evas_test_callbacks.c', 10 'evas_test_callbacks.c',
10 'evas_test_render_engines.c', 11 'evas_test_render_engines.c',