[gnome-games] aisleriot: Fixups for updating to the lastest Clutter master
- From: Neil Roberts <nroberts src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games] aisleriot: Fixups for updating to the lastest Clutter master
- Date: Mon, 15 Jun 2009 17:32:23 -0400 (EDT)
commit a81fc6b082a6982ee2979d44e23770e93e8d2407
Author: Neil Roberts <nroberts src gnome org>
Date: Mon Jun 15 21:34:26 2009 +0100
aisleriot: Fixups for updating to the lastest Clutter master
- We should use floats directly instead of the units API
- cogl_material_set_color expects a pre-multiplied color
- The max_waste and auto_mipmap parameters of
cogl_texture_new_from_data have gone
aisleriot/card.c | 36 +++++++++++----------
aisleriot/slot-renderer.c | 42 +++++++++++++++----------
libgames-support/games-card-textures-cache.c | 4 +-
3 files changed, 46 insertions(+), 36 deletions(-)
---
diff --git a/aisleriot/card.c b/aisleriot/card.c
index 7b17f30..5f9be11 100644
--- a/aisleriot/card.c
+++ b/aisleriot/card.c
@@ -26,14 +26,14 @@
static void aisleriot_card_paint (ClutterActor *actor);
static void aisleriot_card_get_preferred_width (ClutterActor *self,
- ClutterUnits for_height,
- ClutterUnits *min_width_p,
- ClutterUnits *natural_width_p);
+ gfloat for_height,
+ gfloat *min_width_p,
+ gfloat *natural_width_p);
static void aisleriot_card_get_preferred_height
(ClutterActor *self,
- ClutterUnits for_width,
- ClutterUnits *min_height_p,
- ClutterUnits *natural_height_p);
+ gfloat for_width,
+ gfloat *min_height_p,
+ gfloat *natural_height_p);
static void aisleriot_card_dispose (GObject *self);
@@ -156,9 +156,9 @@ aisleriot_card_new (GamesCardTexturesCache *cache,
static void
aisleriot_card_get_preferred_width (ClutterActor *self,
- ClutterUnits for_height,
- ClutterUnits *min_width_p,
- ClutterUnits *natural_width_p)
+ gfloat for_height,
+ gfloat *min_width_p,
+ gfloat *natural_width_p)
{
AisleriotCard *card = AISLERIOT_CARD (self);
AisleriotCardPrivate *priv = card->priv;
@@ -174,17 +174,17 @@ aisleriot_card_get_preferred_width (ClutterActor *self,
width = cogl_texture_get_width (tex);
if (min_width_p)
- clutter_units_pixels (min_width_p, 0);
+ *min_width_p = 0;
if (natural_width_p)
- clutter_units_pixels (natural_width_p, width);
+ *natural_width_p = width;
}
static void
aisleriot_card_get_preferred_height (ClutterActor *self,
- ClutterUnits for_width,
- ClutterUnits *min_height_p,
- ClutterUnits *natural_height_p)
+ gfloat for_width,
+ gfloat *min_height_p,
+ gfloat *natural_height_p)
{
AisleriotCard *card = AISLERIOT_CARD (self);
AisleriotCardPrivate *priv = card->priv;
@@ -200,10 +200,10 @@ aisleriot_card_get_preferred_height (ClutterActor *self,
height = cogl_texture_get_height (tex);
if (min_height_p)
- clutter_units_pixels (min_height_p, 0);
+ *min_height_p = 0;
if (natural_height_p)
- clutter_units_pixels (natural_height_p, height);
+ *natural_height_p = height;
}
static void
@@ -213,6 +213,7 @@ aisleriot_card_paint (ClutterActor *actor)
AisleriotCardPrivate *priv = card->priv;
CoglHandle top_tex, bottom_tex;
ClutterActorBox alloc_box;
+ gboolean backface_culling_was_enabled = cogl_get_backface_culling_enabled ();
cogl_set_backface_culling_enabled (TRUE);
@@ -250,7 +251,8 @@ aisleriot_card_paint (ClutterActor *actor)
alloc_box.y2 - alloc_box.y1);
cogl_pop_matrix ();
- cogl_set_backface_culling_enabled (FALSE);
+ if (!backface_culling_was_enabled)
+ cogl_set_backface_culling_enabled (FALSE);
}
static void
diff --git a/aisleriot/slot-renderer.c b/aisleriot/slot-renderer.c
index cad3e22..6a832f3 100644
--- a/aisleriot/slot-renderer.c
+++ b/aisleriot/slot-renderer.c
@@ -348,24 +348,32 @@ aisleriot_slot_renderer_set_material_for_card (AisleriotSlotRenderer *srend,
priv->material = cogl_material_new ();
if (show_highlight)
- /* The previous code for drawing the highlight rendered the normal
- card texture and then rendered the card again multiplied by the
- highlight color but with 50% transparency. The blend function
- is alpha*src+(1-alpha*dst) where src is effectively the tex
- times the highlight color and the dst is the original
- tex. Therefore the final color is 0.5*tex+0.5*tex*highlight
- which is the same as (0.5+highlight/2)*tex. We can precompute
- that value to avoid having to draw the card twice */
- cogl_material_set_color4ub (priv->material,
- MIN (priv->highlight_color.red
- / 2 + 128, 0xff),
- MIN (priv->highlight_color.green
- / 2 + 128, 0xff),
- MIN (priv->highlight_color.blue
- / 2 + 128, 0xff),
- opacity);
+ {
+ CoglColor color;
+
+ /* The previous code for drawing the highlight rendered the
+ normal card texture and then rendered the card again
+ multiplied by the highlight color but with 50%
+ transparency. The blend function is alpha*src+(1-alpha*dst)
+ where src is effectively the tex times the highlight color
+ and the dst is the original tex. Therefore the final color is
+ 0.5*tex+0.5*tex*highlight which is the same as
+ (0.5+highlight/2)*tex. We can precompute that value to avoid
+ having to draw the card twice */
+ cogl_color_set_from_4ub (&color,
+ MIN (priv->highlight_color.red
+ / 2 + 128, 0xff),
+ MIN (priv->highlight_color.green
+ / 2 + 128, 0xff),
+ MIN (priv->highlight_color.blue
+ / 2 + 128, 0xff),
+ opacity);
+ cogl_color_premultiply (&color);
+ cogl_material_set_color (priv->material, &color);
+ }
else
- cogl_material_set_color4ub (priv->material, 255, 255, 255, opacity);
+ cogl_material_set_color4ub (priv->material,
+ opacity, opacity, opacity, opacity);
cogl_material_set_layer (priv->material, 0, tex);
cogl_set_source (priv->material);
diff --git a/libgames-support/games-card-textures-cache.c b/libgames-support/games-card-textures-cache.c
index 61ba8df..7c53512 100644
--- a/libgames-support/games-card-textures-cache.c
+++ b/libgames-support/games-card-textures-cache.c
@@ -307,13 +307,13 @@ games_card_textures_cache_get_card_texture_by_id (GamesCardTexturesCache *cache,
handle = cogl_texture_new_from_data (gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
+ COGL_TEXTURE_NONE,
gdk_pixbuf_get_has_alpha (pixbuf)
? COGL_PIXEL_FORMAT_RGBA_8888
: COGL_PIXEL_FORMAT_RGB_888,
COGL_PIXEL_FORMAT_ANY,
- COGL_PIXEL_FORMAT_ANY,
gdk_pixbuf_get_rowstride (pixbuf),
- (guchar *) pixbuf);
+ gdk_pixbuf_get_pixels (pixbuf));
g_object_unref (pixbuf);
if (handle == COGL_INVALID_HANDLE) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]