Deprecate clutter_util_next_p2()

The next_p2() function should have never been publicly exposed by
Clutter.
This commit is contained in:
Emmanuele Bassi 2010-02-05 16:22:09 +00:00
parent bbaf6b233d
commit e55966d675
3 changed files with 31 additions and 12 deletions

View File

@ -25,12 +25,11 @@
/** /**
* SECTION:clutter-util * SECTION:clutter-util
* @short_description: Misc utility functions. * @short_description: Utility functions
* *
* Various misc utilility functions. * Various miscellaneous utilility functions.
*/ */
#include "clutter-util.h" #include "clutter-util.h"
#include "clutter-main.h" #include "clutter-main.h"
@ -41,9 +40,11 @@
* Calculates the nearest power of two, greater than or equal to @a. * Calculates the nearest power of two, greater than or equal to @a.
* *
* Return value: The nearest power of two, greater or equal to @a. * Return value: The nearest power of two, greater or equal to @a.
*
* Deprecated: 1.2
*/ */
int gint
clutter_util_next_p2 (int a) clutter_util_next_p2 (gint a)
{ {
int rval = 1; int rval = 1;

View File

@ -32,9 +32,12 @@
G_BEGIN_DECLS G_BEGIN_DECLS
int #ifndef CLUTTER_DISABLE_DEPRECATED
clutter_util_next_p2 (int a);
gint clutter_util_next_p2 (gint a) G_GNUC_DEPRECATED;
#endif /* CLUTTER_DISABLE_DEPRECATED */
G_END_DECLS G_END_DECLS
#endif #endif /* __CLUTTER_UTIL_H__ */

View File

@ -203,6 +203,17 @@ static ShaderSource shaders[]=
static gint shader_no = 0; static gint shader_no = 0;
static int
next_p2 (gint a)
{
int rval = 1;
while (rval < a)
rval <<= 1;
return rval;
}
static void static void
set_shader_num (ClutterActor *actor, gint new_no) set_shader_num (ClutterActor *actor, gint new_no)
{ {
@ -251,10 +262,14 @@ set_shader_num (ClutterActor *actor, gint new_no)
if (CLUTTER_IS_TEXTURE (actor)) 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 = clutter_actor_get_width (actor);
tex_width = clutter_util_next_p2 (tex_width); tex_width = next_p2 (tex_width);
tex_height = clutter_actor_get_height (actor); tex_height = clutter_actor_get_height (actor);
tex_height = clutter_util_next_p2 (tex_height); tex_height = next_p2 (tex_height);
clutter_actor_set_shader_param_float (actor, "x_step", clutter_actor_set_shader_param_float (actor, "x_step",
1.0f / tex_width); 1.0f / tex_width);