From: Emmanuele Bassi Date: Wed, 29 Feb 2012 09:27:01 +0000 (+0000) Subject: interactive: Remove test-shader X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a22d7ac1b569ea2cfb4ffe30e738db9887c06002;p=profile%2Fivi%2Fclutter.git interactive: Remove test-shader ClutterShader is deprecated, and we already have various tests for the shader API, both for Cogl and for ClutterShaderEffect. --- diff --git a/tests/interactive/Makefile.am b/tests/interactive/Makefile.am index 9613117..9e8adca 100644 --- a/tests/interactive/Makefile.am +++ b/tests/interactive/Makefile.am @@ -12,7 +12,6 @@ UNIT_TESTS = \ test-threads.c \ test-script.c \ test-grab.c \ - test-shader.c \ test-cogl-shader-arbfp.c \ test-cogl-shader-glsl.c \ test-animator.c \ diff --git a/tests/interactive/test-shader.c b/tests/interactive/test-shader.c deleted file mode 100644 index 35a7c47..0000000 --- a/tests/interactive/test-shader.c +++ /dev/null @@ -1,411 +0,0 @@ -#include - -#include -#include -#include -#include - -/* Dynamic branching appeared in "Shader Model 3.0" that low-end IGPs - * don't support. - */ -#define GPU_SUPPORTS_DYNAMIC_BRANCHING 0 - -typedef struct -{ - gchar *name; - gchar *source; -} ShaderSource; - -/* a couple of boilerplate defines that are common amongst all the - * sample shaders - */ - -/* FRAGMENT_SHADER_BEGIN: generate boilerplate with a local vec4 color already - * initialized, from a sampler2D in a variable tex. - */ -#define FRAGMENT_SHADER_VARS \ - "uniform sampler2D tex;" \ - "uniform float x_step, y_step;" \ - -#define FRAGMENT_SHADER_BEGIN \ - "void main (){" \ - " vec4 color = texture2D (tex, vec2(cogl_tex_coord_in[0]));" - -/* FRAGMENT_SHADER_END: apply the changed color to the output buffer correctly - * blended with the gl specified color (makes the opacity of actors work - * correctly). - */ -#define FRAGMENT_SHADER_END \ - " cogl_color_out = color * cogl_color_in;" \ - "}" - -static ShaderSource shaders[]= - { - {"brightness-contrast", - FRAGMENT_SHADER_VARS - "uniform float brightness, contrast;" - FRAGMENT_SHADER_BEGIN - " color.rgb /= color.a;" - " color.rgb = (color.rgb - vec3(0.5, 0.5, 0.5)) * contrast + " - "vec3 (brightness + 0.5, brightness + 0.5, brightness + 0.5);" - " color.rgb *= color.a;" - FRAGMENT_SHADER_END - }, - - {"box-blur", - FRAGMENT_SHADER_VARS - -#if GPU_SUPPORTS_DYNAMIC_BRANCHING - "uniform float radius;" - FRAGMENT_SHADER_BEGIN - "float u, v;" - "int count = 1;" - "for (u=-radius;u= 0 && shaders[new_no].name) - { - ClutterShader *shader; - GError *error; - shader_no = new_no; - - g_print ("setting shaders[%i] named '%s'\n", - shader_no, - shaders[shader_no].name); - - shader = clutter_shader_new (); - - error = NULL; - g_object_set (G_OBJECT (shader), - "fragment-source", shaders[shader_no].source, - NULL); - - /* try to bind the shader, provoking an error we catch if there is issues - * with the shader sources we've provided. At a later stage it should be - * possible to iterate through a set of alternate shader sources (glsl -> - * asm -> cg?) and the one that succesfully compiles is used. - */ - clutter_shader_compile (shader, &error); - if (error) - { - g_print ("unable to set shaders[%i] named '%s': %s", - shader_no, shaders[shader_no].name, - error->message); - g_error_free (error); - clutter_actor_set_shader (actor, NULL); - } - else - { - clutter_actor_set_shader (actor, NULL); - clutter_actor_set_shader (actor, shader); - clutter_actor_set_shader_param_int (actor, "tex", 0); - clutter_actor_set_shader_param_float (actor, "radius", 3.0); - clutter_actor_set_shader_param_float (actor, "brightness", 0.4); - clutter_actor_set_shader_param_float (actor, "contrast", -1.9); - - if (CLUTTER_IS_TEXTURE (actor)) - { - /* XXX - this assumes *a lot* about how things are done - * internally on *some* hardware and driver - */ - tex_width = clutter_actor_get_width (actor); - tex_width = next_p2 (tex_width); - - tex_height = clutter_actor_get_height (actor); - tex_height = next_p2 (tex_height); - - clutter_actor_set_shader_param_float (actor, "x_step", - 1.0f / tex_width); - clutter_actor_set_shader_param_float (actor, "y_step", - 1.0f / tex_height); - } - } - - g_object_unref (shader); - } -} - -static gboolean -button_release_cb (ClutterActor *actor, - ClutterEvent *event, - gpointer data) -{ - gint new_no; - - if (event->button.button == 1) - { - new_no = shader_no - 1; - } - else - { - new_no = shader_no + 1; - } - - set_shader_num (actor, new_no); - - return CLUTTER_EVENT_STOP; -} - -#ifdef COGL_HAS_GLES2 -static gboolean -timeout_cb (gpointer data) -{ - int new_no = shader_no + 1; - - if (shaders[new_no].name == NULL) - new_no = 0; - - set_shader_num (CLUTTER_ACTOR (data), new_no); - - return G_SOURCE_CONTINUE; -} -#endif /* COGL_HAS_GLES2 */ - -G_MODULE_EXPORT gint -test_shader_main (gint argc, gchar *argv[]) -{ - ClutterActor *actor; - ClutterActor *stage; - ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; - ClutterShader *shader; - GError *error; - gchar *file; - - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - - stage = clutter_stage_new (); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Shaders"); - clutter_actor_set_size (stage, 512, 384); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); - - g_print ("applying shaders[%i] named '%s'\n", - shader_no, - shaders[shader_no].name); - - shader = clutter_shader_new (); - - error = NULL; - clutter_shader_set_fragment_source (shader, shaders[shader_no].source, -1); - clutter_shader_compile (shader, &error); - if (error) - { - g_print ("unable to load shaders[%d] named '%s': %s\n", - shader_no, - shaders[shader_no].name, - error->message); - g_error_free (error); - - return EXIT_FAILURE; - } - - clutter_stage_set_title (CLUTTER_STAGE (stage), "Shader Test"); - clutter_actor_set_background_color (stage, &stage_color); - - file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - -#ifndef TEST_GROUP - actor = clutter_texture_new_from_file (file, &error); - if (!actor) - g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); -#else - actor = clutter_group_new (); - - { - ClutterActor *child1, *child2, *child3, *child4; - ClutterColor color = { 0xff, 0x22, 0x66, 0x99 }; - - child1 = clutter_texture_new_from_file (file, &error); - if (!child1) - g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); - - child2 = clutter_texture_new_from_file (file, &error); - if (!child2) - g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); - - child3 = clutter_rectangle_new (); - child4 = clutter_text_new_with_text ("Sans 20px", "Shady stuff"); - - clutter_rectangle_set_color (CLUTTER_RECTANGLE (child3), &color); - clutter_actor_set_size (child3, 50, 50); - - clutter_actor_set_position (child1, 0, 0); - clutter_actor_set_position (child2, 50, 100); - clutter_actor_set_position (child3, 30, -30); - clutter_actor_set_position (child4, -50, 20); - - clutter_container_add (CLUTTER_CONTAINER (actor), - child1, - child2, - child3, - child4, - NULL); - - clutter_actor_show_all (actor); - } -#endif /* !TEST_GROUP */ - - g_free (file); - - clutter_actor_set_shader (actor, shader); - clutter_actor_set_position (actor, 100, 100); - - g_object_unref (shader); - - clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); - - clutter_actor_set_shader_param_int (actor, "tex", 0); - clutter_actor_set_shader_param_float (actor, "brightness", 0.4); - clutter_actor_set_shader_param_float (actor, "contrast", -1.9); - - clutter_actor_set_reactive (actor, TRUE); - g_signal_connect (actor, "button-release-event", - G_CALLBACK (button_release_cb), NULL); - -#ifdef COGL_HAS_GLES2 - /* On an embedded platform it is difficult to right click so we will - cycle through the shaders automatically */ - clutter_threads_add_timeout (3000, timeout_cb, actor); -#endif - - /* Show everying ( and map window ) */ - clutter_actor_show_all (stage); - - clutter_main (); - - return EXIT_SUCCESS; -}