[maemo-commits] [maemo-commits] r17380 - projects/haf/trunk/clutter/clutter/cogl/gles
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Feb 9 14:44:12 EET 2009
- Previous message: [maemo-commits] r17379 - projects/haf/tags/osso-app-killer
- Next message: [maemo-commits] r17381 - in projects/haf/trunk/hildon-thumbnail: . thumbs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: gw Date: 2009-02-09 14:44:02 +0200 (Mon, 09 Feb 2009) New Revision: 17380 Modified: projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.c projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.h projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.c projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.h Log: Removing multiply by colour if colour is white Modified: projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.c =================================================================== --- projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.c 2009-02-09 11:53:06 UTC (rev 17379) +++ projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.c 2009-02-09 12:44:02 UTC (rev 17380) @@ -31,7 +31,6 @@ "precision lowp float;\n" "\n" "/* Inputs from the vertex shader */\n" - "varying lowp vec4 frag_color;\n" "varying mediump vec2 tex_coord;\n" "\n" "/* Texturing options */\n" @@ -41,6 +40,9 @@ "uniform lowp float alpha_test_ref;\n" "\n" ; +const char cogl_fixed_fragment_shader_header_color[] = + "varying lowp vec4 frag_color;\n" + ; const char cogl_fixed_fragment_shader_header_fog[] = "\n" "/* Fogging options */\n" @@ -65,13 +67,17 @@ " gl_FragColor.a *= texture2D (texture_unit, tex_coord).a;\n" "\n" ; -const char cogl_fixed_fragment_shader_texture[] = +const char cogl_fixed_fragment_shader_texture_color[] = "\n" " /* This pointless extra variable is needed to work around an\n" " apparent bug in the PowerVR drivers. Without it the alpha\n" " blending seems to stop working */\n" " lowp vec4 frag_color_copy = frag_color;\n" " gl_FragColor = frag_color_copy * texture2D (texture_unit, tex_coord);\n" + " \n" + ; +const char cogl_fixed_fragment_shader_texture[] = + " gl_FragColor = texture2D (texture_unit, tex_coord);\n" "\n" ; const char cogl_fixed_fragment_shader_solid_color[] = Modified: projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl =================================================================== --- projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl 2009-02-09 11:53:06 UTC (rev 17379) +++ projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl 2009-02-09 12:44:02 UTC (rev 17380) @@ -5,7 +5,6 @@ precision lowp float; /* Inputs from the vertex shader */ -varying lowp vec4 frag_color; varying mediump vec2 tex_coord; /* Texturing options */ @@ -14,6 +13,8 @@ /* Alpha test options */ uniform lowp float alpha_test_ref; +/*** cogl_fixed_fragment_shader_header_color ***/ +varying lowp vec4 frag_color; /*** cogl_fixed_fragment_shader_header_fog ***/ /* Fogging options */ @@ -35,13 +36,16 @@ gl_FragColor = frag_color; gl_FragColor.a *= texture2D (texture_unit, tex_coord).a; - /*** cogl_fixed_fragment_shader_texture ***/ + /*** cogl_fixed_fragment_shader_texture_color ***/ /* This pointless extra variable is needed to work around an apparent bug in the PowerVR drivers. Without it the alpha blending seems to stop working */ lowp vec4 frag_color_copy = frag_color; gl_FragColor = frag_color_copy * texture2D (texture_unit, tex_coord); + + /*** cogl_fixed_fragment_shader_texture ***/ + gl_FragColor = texture2D (texture_unit, tex_coord); /*** cogl_fixed_fragment_shader_solid_color ***/ gl_FragColor = frag_color; Modified: projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.h =================================================================== --- projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.h 2009-02-09 11:53:06 UTC (rev 17379) +++ projects/haf/trunk/clutter/clutter/cogl/gles/cogl-fixed-fragment-shader.h 2009-02-09 12:44:02 UTC (rev 17380) @@ -27,9 +27,11 @@ #define __COGL_FIXED_FRAGMENT_SHADER_H extern const char cogl_fixed_fragment_shader_header_start[]; +extern const char cogl_fixed_fragment_shader_header_color[]; extern const char cogl_fixed_fragment_shader_header_fog[]; extern const char cogl_fixed_fragment_shader_start[]; extern const char cogl_fixed_fragment_shader_texture_alpha_only[]; +extern const char cogl_fixed_fragment_shader_texture_color[]; extern const char cogl_fixed_fragment_shader_texture[]; extern const char cogl_fixed_fragment_shader_solid_color[]; extern const char cogl_fixed_fragment_shader_fog[]; Modified: projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.c =================================================================== --- projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.c 2009-02-09 11:53:06 UTC (rev 17379) +++ projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.c 2009-02-09 12:44:02 UTC (rev 17380) @@ -142,6 +142,9 @@ if (a->texture_2d_enabled != b->texture_2d_enabled) return FALSE; + if (a->color_enabled != b->color_enabled) + return FALSE; + if (a->texture_2d_enabled && a->alpha_only != b->alpha_only) return FALSE; @@ -180,6 +183,7 @@ /* Otherwise create a new shader */ shader_source = g_string_new (cogl_fixed_vertex_shader_header_start); + if (settings->fog_enabled) { g_string_append (shader_source, cogl_fixed_vertex_shader_header_fog); @@ -250,6 +254,11 @@ /* Otherwise create a new shader */ shader_source = g_string_new (cogl_fixed_fragment_shader_header_start); + if (settings->color_enabled || + (!settings->texture_2d_enabled) || + settings->alpha_only) + g_string_append (shader_source, cogl_fixed_fragment_shader_header_color); + if (settings->fog_enabled) { g_string_append (shader_source, cogl_fixed_fragment_shader_header_fog); @@ -263,8 +272,14 @@ g_string_append (shader_source, cogl_fixed_fragment_shader_texture_alpha_only); else - g_string_append (shader_source, - cogl_fixed_fragment_shader_texture); + { + if (settings->color_enabled) + g_string_append (shader_source, + cogl_fixed_fragment_shader_texture_color); + else + g_string_append (shader_source, + cogl_fixed_fragment_shader_texture); + } } else g_string_append (shader_source, cogl_fixed_fragment_shader_solid_color); @@ -1075,11 +1090,16 @@ void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a) { + gboolean is_white = (r>=65535) && (g>=65535) & (b>=65535) & (a>=65535); + _COGL_GET_GLES2_WRAPPER (w, NO_RETVAL); + glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, CLUTTER_FIXED_TO_FLOAT (r), CLUTTER_FIXED_TO_FLOAT (g), CLUTTER_FIXED_TO_FLOAT (b), CLUTTER_FIXED_TO_FLOAT (a)); + + _COGL_GLES2_CHANGE_SETTING (w, color_enabled, !is_white); } void Modified: projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.h =================================================================== --- projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.h 2009-02-09 11:53:06 UTC (rev 17379) +++ projects/haf/trunk/clutter/clutter/cogl/gles/cogl-gles2-wrapper.h 2009-02-09 12:44:02 UTC (rev 17380) @@ -81,6 +81,8 @@ gboolean alpha_test_enabled; GLint alpha_test_func; + gboolean color_enabled; + gboolean fog_enabled; GLint fog_mode;
- Previous message: [maemo-commits] r17379 - projects/haf/tags/osso-app-killer
- Next message: [maemo-commits] r17381 - in projects/haf/trunk/hildon-thumbnail: . thumbs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]