static void test_coglbox_paint(ClutterActor *self) { TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self); ClutterColor cback = {0x66, 0x66, 0xDD, 0xFF}; ClutterColor cwhite = {0xFF, 0xFF, 0xFF, 0xFF}; ClutterFixed texcoords[4] = { CLUTTER_FLOAT_TO_FIXED (0.3f), CLUTTER_FLOAT_TO_FIXED (0.3f), CLUTTER_FLOAT_TO_FIXED (0.7f), CLUTTER_FLOAT_TO_FIXED (0.7f) }; priv = TEST_COGLBOX_GET_PRIVATE (self); cogl_color (&cback); cogl_rectangle (0,0,400,400); cogl_color (&cwhite); cogl_push_matrix (); cogl_translate (100,100,0); cogl_texture_rectangle (priv->cogl_handle, 0, 0, CLUTTER_INT_TO_FIXED (200), CLUTTER_INT_TO_FIXED (200), texcoords[0], texcoords[1], texcoords[2], texcoords[3]); cogl_pop_matrix(); }
static VALUE rb_cogl_color (int argc, VALUE *argv, VALUE self) { /* Accept either a single ClutterColor argument or up to four components */ if (argc == 1 && RTEST (rb_obj_is_kind_of (argv[0], GTYPE2CLASS (CLUTTER_TYPE_COLOR)))) { const ClutterColor *color = (const ClutterColor *) RVAL2BOXED (argv[0], CLUTTER_TYPE_COLOR); cogl_color (color); } else { VALUE r, g, b, a; ClutterColor color; rb_scan_args (argc, argv, "04", &r, &g, &b, &a); color.red = NIL_P (r) ? 0 : rbclt_num_to_guint8 (r); color.green = NIL_P (g) ? 0 : rbclt_num_to_guint8 (g); color.blue = NIL_P (b) ? 0 : rbclt_num_to_guint8 (b); color.alpha = NIL_P (a) ? 255 : rbclt_num_to_guint8 (a); cogl_color (&color); } return Qnil; }
static void test_coglbox_paint(ClutterActor *self) { TestCoglboxPrivate *priv; ClutterColor cfill; ClutterColor cstroke; static GTimer *timer = NULL; static gint paint_index = 0; gint NUM_PAINT_FUNCS; NUM_PAINT_FUNCS = G_N_ELEMENTS (paint_func); priv = TEST_COGLBOX_GET_PRIVATE (self); if (!timer) { timer = g_timer_new (); g_timer_start (timer); } if (g_timer_elapsed (timer, NULL) >= 1) { paint_index += 1; paint_index = paint_index % NUM_PAINT_FUNCS; g_timer_start (timer); } cfill.red = 0; cfill.green = 160; cfill.blue = 0; cfill.alpha = 255; cstroke.red = 200; cstroke.green = 0; cstroke.blue = 0; cstroke.alpha = 255; cogl_push_matrix (); paint_func[paint_index] (); cogl_translate (100,100,0); cogl_color (&cstroke); cogl_path_stroke (); cogl_translate (150,0,0); cogl_color (&cfill); cogl_path_fill (); cogl_pop_matrix(); }
static void clutter_rectangle_paint (ClutterActor *self) { ClutterRectangle *rectangle = CLUTTER_RECTANGLE(self); ClutterRectanglePrivate *priv; ClutterGeometry geom; ClutterColor tmp_col; rectangle = CLUTTER_RECTANGLE(self); priv = rectangle->priv; CLUTTER_NOTE (PAINT, "painting rect '%s'", clutter_actor_get_name (self) ? clutter_actor_get_name (self) : "unknown"); clutter_actor_get_allocation_geometry (self, &geom); CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i " "opacity: %i", geom.x, geom.y, geom.x+geom.width, geom.y+geom.height, clutter_actor_get_opacity (self)); /* parent paint call will have translated us into position so * paint from 0, 0 */ if (priv->has_border) { tmp_col.red = priv->border_color.red; tmp_col.green = priv->border_color.green; tmp_col.blue = priv->border_color.blue; tmp_col.alpha = clutter_actor_get_paint_opacity (self) * priv->border_color.alpha / 255; cogl_color (&tmp_col); /* this sucks, but it's the only way to make a border */ cogl_rectangle (priv->border_width, 0, geom.width - priv->border_width, priv->border_width); cogl_rectangle (geom.width - priv->border_width, priv->border_width, priv->border_width, geom.height - priv->border_width); cogl_rectangle (0, geom.height - priv->border_width, geom.width - priv->border_width, priv->border_width); cogl_rectangle (0, 0, priv->border_width, geom.height - priv->border_width); tmp_col.red = priv->color.red; tmp_col.green = priv->color.green; tmp_col.blue = priv->color.blue; tmp_col.alpha = clutter_actor_get_paint_opacity (self) * priv->color.alpha / 255; cogl_color (&tmp_col); cogl_rectangle (priv->border_width, priv->border_width, geom.width - priv->border_width * 2, geom.height - priv->border_width * 2); } else { tmp_col.red = priv->color.red; tmp_col.green = priv->color.green; tmp_col.blue = priv->color.blue; tmp_col.alpha = clutter_actor_get_paint_opacity (self) * priv->color.alpha / 255; cogl_color (&tmp_col); cogl_rectangle (0, 0, geom.width, geom.height); } }
static void tidy_texture_frame_paint (ClutterActor *self) { TidyTextureFramePrivate *priv; ClutterActor *parent_texture; guint width, height; gint pwidth, pheight, ex, ey; ClutterFixed tx1, ty1, tx2, ty2, tw, th; GLenum target_type; ClutterColor col = { 0xff, 0xff, 0xff, 0xff }; priv = TIDY_TEXTURE_FRAME (self)->priv; /* no need to paint stuff if we don't have a texture to reflect */ if (!clutter_clone_texture_get_parent_texture (CLUTTER_CLONE_TEXTURE(self))) return; /* parent texture may have been hidden, there for need to make sure its * realised with resources available. */ parent_texture = CLUTTER_ACTOR (clutter_clone_texture_get_parent_texture(CLUTTER_CLONE_TEXTURE(self))); if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture)) clutter_actor_realize (parent_texture); if (clutter_texture_is_tiled (CLUTTER_TEXTURE (parent_texture))) { g_warning("tiled textures not yet supported..."); return; } cogl_push_matrix (); #define FX(x) CLUTTER_INT_TO_FIXED(x) clutter_texture_get_base_size (CLUTTER_TEXTURE(parent_texture), &pwidth, &pheight); clutter_actor_get_size (self, &width, &height); tx1 = FX (priv->left); tx2 = FX (pwidth - priv->right); ty1 = FX (priv->top); ty2 = FX (pheight - priv->bottom); tw = FX (pwidth); th = FX (pheight); if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE)) { target_type = CGL_TEXTURE_RECTANGLE_ARB; cogl_enable (CGL_ENABLE_TEXTURE_RECT|CGL_ENABLE_BLEND); } else { target_type = CGL_TEXTURE_2D; cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND); tw = clutter_util_next_p2 (pwidth); th = clutter_util_next_p2 (pheight); tx1 = tx1/tw; tx2 = tx2/tw; ty1 = ty1/th; ty2 = ty2/th; tw = FX(pwidth)/tw; th = FX(pheight)/th; } col.alpha = clutter_actor_get_opacity (self); cogl_color (&col); clutter_texture_bind_tile (CLUTTER_TEXTURE(parent_texture), 0); ex = width - priv->right; if (ex < 0) ex = priv->right; /* FIXME */ ey = height - priv->bottom; if (ey < 0) ey = priv->bottom; /* FIXME */ /* top left corner */ cogl_texture_quad (0, priv->left, /* FIXME: clip if smaller */ 0, priv->top, 0, 0, tx1, ty1); /* top middle */ cogl_texture_quad (priv->left, ex, 0, priv->top, tx1, 0, tx2, ty1); /* top right */ cogl_texture_quad (ex, width, 0, priv->top, tx2, 0, tw, ty1); /* mid left */ cogl_texture_quad (0, priv->left, priv->top, ey, 0, ty1, tx1, ty2); /* center */ cogl_texture_quad (priv->left, ex, priv->top, ey, tx1, ty1, tx2, ty2); /* mid right */ cogl_texture_quad (ex, width, priv->top, ey, tx2, ty1, tw, ty2); /* bottom left */ cogl_texture_quad (0, priv->left, ey, height, 0, ty2, tx1, th); /* bottom center */ cogl_texture_quad (priv->left, ex, ey, height, tx1, ty2, tx2, th); /* bottom right */ cogl_texture_quad (ex, width, ey, height, tx2, ty2, tw, th); cogl_pop_matrix (); #undef FX }
static void clutter_x11_texture_pixmap_paint (ClutterActor *self) { ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (self); ClutterX11TexturePixmapPrivate *priv = texture->priv; gint x_1, y_1, x_2, y_2; ClutterColor col = { 0xff, 0xff, 0xff, 0xff }; ClutterFixed t_w, t_h; GList *shape; CoglHandle cogl_texture; g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture)); /* If we have no shapes, just call what we had before */ if (priv->shapes==0) { CLUTTER_ACTOR_CLASS(clutter_x11_texture_pixmap_parent_class)->paint(self); return; } if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR(texture))) clutter_actor_realize (CLUTTER_ACTOR(texture)); CLUTTER_NOTE (PAINT, "painting X11 texture '%s'", clutter_actor_get_name (self) ? clutter_actor_get_name (self) : "unknown"); col.alpha = clutter_actor_get_paint_opacity (self); cogl_color (&col); clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2); CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i " "opacity: %i", x_1, y_1, x_2, y_2, clutter_actor_get_opacity (self)); t_w = CFX_ONE; t_h = CFX_ONE; cogl_texture = clutter_texture_get_cogl_texture(CLUTTER_TEXTURE(self)); if (cogl_texture == COGL_INVALID_HANDLE) return; /* so now we go through our shapes and render */ for (shape = priv->shapes; shape; shape = shape->next) { gint w = x_2 - x_1; gint h = y_2 - y_1; ClutterGeometry *geo = (ClutterGeometry*)shape->data; cogl_texture_rectangle ( cogl_texture, CLUTTER_INT_TO_FIXED(w * geo->x / priv->pixmap_width), CLUTTER_INT_TO_FIXED(h * geo->y / priv->pixmap_height), CLUTTER_INT_TO_FIXED(w * (geo->x+geo->width) / priv->pixmap_width), CLUTTER_INT_TO_FIXED(h * (geo->y+geo->height) / priv->pixmap_height), t_w * geo->x / priv->pixmap_width, t_h * geo->y / priv->pixmap_height, t_w * (geo->x+geo->width) / priv->pixmap_width, t_h * (geo->y+geo->height) / priv->pixmap_height); } }