From 309e04e44a2cba1f1bab20ff8b4dc2ba374cac4c Mon Sep 17 00:00:00 2001 From: Savio Sena Date: Mon, 20 Oct 2014 19:43:08 -0200 Subject: [PATCH] expedite-cxx: Add missing C++ tests. --- src/bin/Makefile.am | 6 +- src/bin/cxx/font_effect_blur_color.cc | 71 +++++++++++ src/bin/cxx/font_effect_blur_color_capi.h | 31 +++++ src/bin/cxx/poly_blend.cc | 137 ++++++++++++++++++++++ src/bin/cxx/poly_blend_capi.h | 30 +++++ src/bin/tests.h | 4 +- 6 files changed, 276 insertions(+), 3 deletions(-) create mode 100644 src/bin/cxx/font_effect_blur_color.cc create mode 100644 src/bin/cxx/font_effect_blur_color_capi.h create mode 100644 src/bin/cxx/poly_blend.cc create mode 100644 src/bin/cxx/poly_blend_capi.h diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index feb4d93..a00b8ee 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -134,6 +134,8 @@ cxx/image_map_solid_rotate.cc \ cxx/image_map_solid_rotate_capi.h \ cxx/image_quality_scale.cc \ cxx/image_quality_scale_capi.h \ +cxx/poly_blend.cc \ +cxx/poly_blend_capi.h \ cxx/line_blend.cc \ cxx/line_blend_capi.h \ cxx/proxy_image.cc \ @@ -203,7 +205,9 @@ cxx/widgets_list_4_capi.h \ cxx/widgets_list_4_grouped.cc \ cxx/widgets_list_4_grouped_capi.h \ cxx/font_effect_blur_alpha.cc \ -cxx/font_effect_blur_alpha_capi.h +cxx/font_effect_blur_alpha_capi.h \ +cxx/font_effect_blur_color.cc \ +cxx/font_effect_blur_color_capi.h expedite_SOURCES = \ main.c main.h \ diff --git a/src/bin/cxx/font_effect_blur_color.cc b/src/bin/cxx/font_effect_blur_color.cc new file mode 100644 index 0000000..18329d4 --- /dev/null +++ b/src/bin/cxx/font_effect_blur_color.cc @@ -0,0 +1,71 @@ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "Eo.h" +#include "Evas.h" + +#include "Eo.hh" +#include "Eina.hh" +#include "Evas.hh" + +#include "main.h" + +#define EXPEDITE_CXX_TEST_IMPL +#include "font_effect_blur_color_capi.h" + +/* standard var */ +static int done = 0; +extern int win_w, win_h; +/* private data */ +static evas::text text; +static const int MAX_BLUR = 100; + +/* setup */ +static void _setup(void) +{ + evas::canvas canvas(::eo_ref(G_evas)); + int w, h; + + evas::text o(efl::eo::parent = canvas); + o.evas::object::color_set(0, 0, 0, 255); + o.font_set("Vera-Bold", 80); + o.text_set("Font Effect"); + o.visibility_set(true); + o.evas::object::size_get(&w, &h); + o.evas::object::position_set((win_w / 2) - (w / 2) - MAX_BLUR, (win_h / 2) - (h / 2) - MAX_BLUR); + text = o; + done = 0; +} + +/* cleanup */ +static void _cleanup(void) +{ + ::eo_del(text._release()); +} + +/* loop - do things */ +static void _loop(double t, int f) +{ + if (text) + { + char buf[256]; + const char *str = "buffer:a(rgba);padding_set(%d);blend(dst=a,color=darkblue);blur(%d,src=a);"; + sprintf(buf, str, MAX_BLUR, ((f % MAX_BLUR) + 1)); + text.filter_program_set(buf); + } + FPS_STD(NAME); +} + +/* prepend special key handlers if interactive (before STD) */ +static void _key(char *key) +{ + KEY_STD; +} + +extern "C" void FNAME(void) +{ + ui_func_set(_key, _loop); + _setup(); +} diff --git a/src/bin/cxx/font_effect_blur_color_capi.h b/src/bin/cxx/font_effect_blur_color_capi.h new file mode 100644 index 0000000..875e240 --- /dev/null +++ b/src/bin/cxx/font_effect_blur_color_capi.h @@ -0,0 +1,31 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#undef FNAME +#undef NAME +#undef ICON + +/* metadata */ +#define FNAME font_effect_blur_color_cxx_start +#define NAME "(C++) Font Effect Blur (Color)" +#define ICON "text.png" + +#ifdef UI +_ui_menu_item_add(ICON, NAME, FNAME); +#endif + +#ifdef PROTO +void FNAME(void); +#endif + +#ifndef EXPEDITE_CXX_TEST_IMPL +#undef FNAME +#undef NAME +#undef ICON +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/src/bin/cxx/poly_blend.cc b/src/bin/cxx/poly_blend.cc new file mode 100644 index 0000000..06823c4 --- /dev/null +++ b/src/bin/cxx/poly_blend.cc @@ -0,0 +1,137 @@ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "Eo.h" +#include "Evas.h" + +#include "Eo.hh" +#include "Eina.hh" +#include "Evas.hh" + +#include "main.h" + +#define EXPEDITE_CXX_TEST_IMPL +#include "poly_blend_capi.h" + +/* standard var */ +static int done = 0; +/* private data */ +static efl::eina::list images; + +static void +poly(evas::polygon& o, int type, Evas_Coord x, Evas_Coord y) +{ + if (o) + { + o.points_clear(); + } + switch (type % 4) + { + case 0: /* triangle */ + if (o) + { + o.point_add(x + 50 , y + 0); + o.point_add(x + 100, y + 100); + o.point_add(x + 0 , y + 100); + } + break; + case 1: /* square */ + if (o) + { + o.point_add(x + 0 , y + 0); + o.point_add(x + 100, y + 0); + o.point_add(x + 100, y + 100); + o.point_add(x + 0 , y + 100); + } + break; + case 2: /* hex */ + if (o) + { + o.point_add(x + 50 , y + 0); + o.point_add(x + 100, y + 30); + o.point_add(x + 100, y + 70); + o.point_add(x + 50 , y + 100); + o.point_add(x + 0 , y + 70); + o.point_add(x + 0 , y + 30); + } + break; + case 3: /* star */ + if (o) + { + o.point_add(x + 50 , y + 0); + o.point_add(x + 60 , y + 40); + o.point_add(x + 90 , y + 30); + o.point_add(x + 70 , y + 60); + o.point_add(x + 90 , y + 100); + o.point_add(x + 50 , y + 70); + o.point_add(x + 10 , y + 100); + o.point_add(x + 30 , y + 60); + o.point_add(x + 10 , y + 30); + o.point_add(x + 40 , y + 40); + } + break; + default: + break; + } +} + +/* setup */ +static void _setup(void) +{ + evas::canvas canvas(::eo_ref(G_evas)); + srnd(); + for (int i = 0; i < OBNUM; i++) + { + int r, g, b, a; + evas::polygon o(efl::eo::parent = canvas); + images.push_back(o); + a = (rnd()&0xff) / 2; + r = ((rnd()&0xff) * a) / 255; + g = ((rnd()&0xff) * a) / 255; + b = ((rnd()&0xff) * a) / 255; + o.evas::object::color_set(r, g, b, a); + o.evas::object::visibility_set(true); + poly(o, i, 0, 0); + } + done = 0; +} + +/* cleanup */ +static void _cleanup(void) +{ + for (evas::polygon& p : images) + p.parent_set(efl::eo::base(nullptr)); + images.clear(); +} + +/* loop - do things */ +static void _loop(double t, int f) +{ + int i = 0; + Evas_Coord x, y, w, h; + for (evas::polygon& o : images) + { + o.evas::object::size_get(&w, &h); + x = (win_w / 2) - (w / 2); + x += ::sin((double)(f + (i * 13)) / (36.7 * SLOW)) * (win_w / 4); + y = (win_h / 2) - (h / 2); + y += ::cos((double)(f + (i * 28)) / (43.8 * SLOW)) * (win_h / 4); + o.evas::object::position_set(x, y); + ++i; + } + FPS_STD(NAME); +} + +/* prepend special key handlers if interactive (before STD) */ +static void _key(char *key) +{ + KEY_STD; +} + +extern "C" void FNAME(void) +{ + ui_func_set(_key, _loop); + _setup(); +} diff --git a/src/bin/cxx/poly_blend_capi.h b/src/bin/cxx/poly_blend_capi.h new file mode 100644 index 0000000..901dd92 --- /dev/null +++ b/src/bin/cxx/poly_blend_capi.h @@ -0,0 +1,30 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#undef FNAME +#undef NAME +#undef ICON + +/* metadata */ +#define FNAME poly_blend_cxx_start +#define NAME "(C++) Polygon Blend" +#define ICON "rect.png" + +#ifdef UI +_ui_menu_item_add(ICON, NAME, FNAME); +#endif + +#ifdef PROTO +void FNAME(void); +#endif + +#ifndef EXPEDITE_CXX_TEST_IMPL +#undef FNAME +#undef NAME +#undef ICON +#endif + +#ifdef __cplusplus +} +#endif diff --git a/src/bin/tests.h b/src/bin/tests.h index 0a54a13..d530f6f 100644 --- a/src/bin/tests.h +++ b/src/bin/tests.h @@ -265,7 +265,7 @@ extern "C" { #include "cxx/image_blend_occlude3_very_many_capi.h" #include "poly_blend.c" -//#include "cxx/poly_blend_capi.h" +#include "cxx/poly_blend_capi.h" #include "proxy_image.c" #include "cxx/proxy_image_capi.h" @@ -289,7 +289,7 @@ extern "C" { #include "cxx/font_effect_blur_alpha_capi.h" #include "font_effect_blur_color.c" -//#include "cxx/font_effect_blur_color.h" +#include "cxx/font_effect_blur_color_capi.h" #if 0 // test disabled - evas having code disabled #include "image_mask.c"