/** * clutter_shader_release: * @shader: a #ClutterShader * * Frees up any GL context resources held by the shader. * * Since: 0.6 */ void clutter_shader_release (ClutterShader *shader) { ClutterShaderPrivate *priv; g_return_if_fail (CLUTTER_IS_SHADER (shader)); priv = shader->priv; if (!priv->compiled) return; g_assert (priv->program != COGL_INVALID_HANDLE); if (priv->vertex_is_glsl && priv->vertex_shader != COGL_INVALID_HANDLE) cogl_handle_unref (priv->vertex_shader); if (priv->fragment_is_glsl && priv->fragment_shader != COGL_INVALID_HANDLE) cogl_handle_unref (priv->fragment_shader); if (priv->program != COGL_INVALID_HANDLE) cogl_handle_unref (priv->program); priv->vertex_shader = COGL_INVALID_HANDLE; priv->fragment_shader = COGL_INVALID_HANDLE; priv->program = COGL_INVALID_HANDLE; priv->compiled = FALSE; g_object_notify (G_OBJECT (shader), "compiled"); }
void test_cogl_backface_culling (TestUtilsGTestFixture *fixture, void *data) { TestUtilsSharedState *shared_state = data; TestState state; CoglHandle tex; state.fb = shared_state->fb; state.width = cogl_framebuffer_get_width (shared_state->fb); state.height = cogl_framebuffer_get_height (shared_state->fb); state.offscreen = COGL_INVALID_HANDLE; state.texture = make_texture (); tex = cogl_texture_new_with_size (state.width, state.height, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY); /* internal fmt */ state.offscreen = cogl_offscreen_new_to_texture (tex); state.offscreen_tex = tex; paint (&state); cogl_object_unref (state.offscreen); cogl_handle_unref (state.offscreen_tex); cogl_handle_unref (state.texture); if (g_test_verbose ()) g_print ("OK\n"); }
static void _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap) { set_damage_object_internal (tex_pixmap, 0, 0); if (tex_pixmap->image) XDestroyImage (tex_pixmap->image); if (tex_pixmap->shm_info.shmid != -1) { XShmDetach (_cogl_xlib_get_display (), &tex_pixmap->shm_info); shmdt (tex_pixmap->shm_info.shmaddr); shmctl (tex_pixmap->shm_info.shmid, IPC_RMID, 0); } if (tex_pixmap->tex) cogl_handle_unref (tex_pixmap->tex); #ifdef COGL_HAS_GLX_SUPPORT _cogl_texture_pixmap_x11_free_glx_pixmap (tex_pixmap); if (tex_pixmap->glx_tex) cogl_handle_unref (tex_pixmap->glx_tex); #endif /* Chain up */ _cogl_texture_free (COGL_TEXTURE (tex_pixmap)); }
static inline void clutter_shader_effect_clear (ClutterShaderEffect *self, gboolean reset_uniforms) { ClutterShaderEffectPrivate *priv = self->priv; if (priv->shader != COGL_INVALID_HANDLE && !priv->is_compiled) cogl_handle_unref (priv->shader); if (priv->program != COGL_INVALID_HANDLE) { cogl_handle_unref (priv->program); priv->program = COGL_INVALID_HANDLE; priv->shader = COGL_INVALID_HANDLE; } if (reset_uniforms && priv->uniforms != NULL) { g_hash_table_destroy (priv->uniforms); priv->uniforms = NULL; } priv->actor = NULL; priv->is_compiled = FALSE; priv->source_set = FALSE; }
static gboolean _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data) { CoglHandle fbo; _COGL_GET_CONTEXT (ctx, FALSE); /* This will only work if the target texture is a CoglTexture2D */ if (!cogl_is_texture_2d (data->dst_tex)) return FALSE; fbo = _cogl_offscreen_new_to_texture_full (data->src_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */); if (fbo == COGL_INVALID_HANDLE) return FALSE; if (!cogl_framebuffer_allocate (fbo, NULL)) { cogl_handle_unref (fbo); return FALSE; } cogl_push_framebuffer (fbo); cogl_handle_unref (fbo); return TRUE; }
CoglHandle _st_create_shadow_material_from_actor (StShadow *shadow_spec, ClutterActor *actor) { CoglHandle shadow_material = COGL_INVALID_HANDLE; if (CLUTTER_IS_TEXTURE (actor)) { CoglHandle texture; texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (actor)); shadow_material = _st_create_shadow_material (shadow_spec, texture); } else { CoglHandle buffer, offscreen; ClutterActorBox box; CoglColor clear_color; float width, height; clutter_actor_get_allocation_box (actor, &box); clutter_actor_box_get_size (&box, &width, &height); if (width == 0 || height == 0) return COGL_INVALID_HANDLE; buffer = st_cogl_texture_new_with_size_wrapper (width, height, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY); if (buffer == COGL_INVALID_HANDLE) return COGL_INVALID_HANDLE; offscreen = cogl_offscreen_new_to_texture (buffer); if (offscreen == COGL_INVALID_HANDLE) { cogl_handle_unref (buffer); return COGL_INVALID_HANDLE; } cogl_color_set_from_4ub (&clear_color, 0, 0, 0, 0); cogl_push_framebuffer (offscreen); cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR); cogl_translate (-box.x1, -box.y1, 0); cogl_ortho (0, width, height, 0, 0, 1.0); clutter_actor_paint (actor); cogl_pop_framebuffer (); cogl_handle_unref (offscreen); shadow_material = _st_create_shadow_material (shadow_spec, buffer); cogl_handle_unref (buffer); } return shadow_material; }
static void st_background_effect_dispose (GObject *gobject) { StBackgroundEffect *self = ST_BACKGROUND_EFFECT (gobject); if (self->pipeline0 != NULL) { cogl_object_unref (self->pipeline0); self->pipeline0 = NULL; } if (self->pipeline1 != NULL) { cogl_object_unref (self->pipeline1); self->pipeline1 = NULL; } if (self->pipeline2 != NULL) { cogl_object_unref (self->pipeline2); self->pipeline2 = NULL; } if (self->pipeline3 != NULL) { cogl_object_unref (self->pipeline3); self->pipeline3 = NULL; } if (self->pipeline4 != NULL) { cogl_object_unref (self->pipeline4); self->pipeline4 = NULL; } if (self->bg_texture != NULL) { cogl_handle_unref (self->bg_texture); self->bg_texture = NULL; } if (self->bg_sub_texture != NULL) { cogl_handle_unref (self->bg_sub_texture); self->bg_sub_texture = NULL; } if (self->bg_bumpmap != NULL) { cogl_handle_unref (self->bg_bumpmap); self->bg_bumpmap = NULL; } G_OBJECT_CLASS (st_background_effect_parent_class)->dispose (gobject); }
static void wayland_free_buffer (ClutterStageWaylandWaylandBuffer *buffer) { cogl_handle_unref (buffer->tex); wl_buffer_destroy (buffer->wayland_buffer); cogl_handle_unref (buffer->offscreen); if (buffer->type == BUFFER_TYPE_DRM) wayland_free_drm_buffer(buffer); else if (buffer->type == BUFFER_TYPE_SHM) wayland_free_shm_buffer(buffer); }
G_MODULE_EXPORT int test_cogl_vertex_buffer_main (int argc, char *argv[]) { TestState state; ClutterActor *stage; gfloat stage_w, stage_h; gint dummy_width, dummy_height; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Vertex Buffers"); clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); g_signal_connect (stage, "destroy", G_CALLBACK (stop_and_quit), &state); clutter_actor_get_size (stage, &stage_w, &stage_h); dummy_width = MESH_WIDTH * QUAD_WIDTH; dummy_height = MESH_HEIGHT * QUAD_HEIGHT; state.dummy = create_dummy_actor (dummy_width, dummy_height); clutter_container_add_actor (CLUTTER_CONTAINER (stage), state.dummy); clutter_actor_set_position (state.dummy, (stage_w / 2.0) - (dummy_width / 2.0), (stage_h / 2.0) - (dummy_height / 2.0)); state.timeline = clutter_timeline_new (1000); clutter_timeline_set_loop (state.timeline, TRUE); state.frame_id = g_signal_connect (state.timeline, "new-frame", G_CALLBACK (frame_cb), &state); g_signal_connect (state.dummy, "paint", G_CALLBACK (on_paint), &state); init_quad_mesh (&state); clutter_actor_show_all (stage); clutter_timeline_start (state.timeline); clutter_main (); cogl_handle_unref (state.buffer); cogl_handle_unref (state.indices); return 0; }
static gboolean _cogl_blit_framebuffer_begin (CoglBlitData *data) { CoglHandle dst_fbo, src_fbo; gboolean ret; _COGL_GET_CONTEXT (ctx, FALSE); /* We can only blit between FBOs if both textures are the same format and the blit framebuffer extension is supported */ if ((cogl_texture_get_format (data->src_tex) & ~COGL_A_BIT) != (cogl_texture_get_format (data->dst_tex) & ~COGL_A_BIT) || !(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT)) return FALSE; dst_fbo = _cogl_offscreen_new_to_texture_full (data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */); if (dst_fbo == COGL_INVALID_HANDLE) ret = FALSE; else { if (!cogl_framebuffer_allocate (dst_fbo, NULL)) ret = FALSE; else { src_fbo = _cogl_offscreen_new_to_texture_full (data->src_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */); if (src_fbo == COGL_INVALID_HANDLE) ret = FALSE; else { if (!cogl_framebuffer_allocate (src_fbo, NULL)) ret = FALSE; else _cogl_push_framebuffers (dst_fbo, src_fbo); cogl_handle_unref (src_fbo); } } cogl_handle_unref (dst_fbo); } return ret; }
static void mash_data_free_vbos (MashData *self){ MashDataPrivate *priv = self->priv; if (priv->loaded_data.vertices_vbo){ cogl_handle_unref (priv->loaded_data.vertices_vbo); priv->loaded_data.vertices_vbo = NULL; } if (priv->loaded_data.indices) { cogl_handle_unref (priv->loaded_data.indices); priv->loaded_data.indices = NULL; } }
CoglHandle _st_create_shadow_material (StShadow *shadow_spec, CoglHandle src_texture) { static CoglHandle shadow_material_template = COGL_INVALID_HANDLE; CoglHandle material; CoglHandle texture; guchar *pixels_in, *pixels_out; gint width_in, height_in, rowstride_in; gint width_out, height_out, rowstride_out; g_return_val_if_fail (shadow_spec != NULL, COGL_INVALID_HANDLE); g_return_val_if_fail (src_texture != COGL_INVALID_HANDLE, COGL_INVALID_HANDLE); width_in = cogl_texture_get_width (src_texture); height_in = cogl_texture_get_height (src_texture); rowstride_in = (width_in + 3) & ~3; pixels_in = g_malloc0 (rowstride_in * height_in); cogl_texture_get_data (src_texture, COGL_PIXEL_FORMAT_A_8, rowstride_in, pixels_in); pixels_out = blur_pixels (pixels_in, width_in, height_in, rowstride_in, shadow_spec->blur, &width_out, &height_out, &rowstride_out); g_free (pixels_in); texture = cogl_texture_new_from_data (width_out, height_out, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_A_8, COGL_PIXEL_FORMAT_A_8, rowstride_out, pixels_out); g_free (pixels_out); if (G_UNLIKELY (shadow_material_template == COGL_INVALID_HANDLE)) { shadow_material_template = cogl_material_new (); /* We set up the material to blend the shadow texture with the combine * constant, but defer setting the latter until painting, so that we can * take the actor's overall opacity into account. */ cogl_material_set_layer_combine (shadow_material_template, 0, "RGBA = MODULATE (CONSTANT, TEXTURE[A])", NULL); } material = cogl_material_copy (shadow_material_template); cogl_material_set_layer (material, 0, texture); cogl_handle_unref (texture); return material; }
static void _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap) { _COGL_GET_CONTEXT (ctxt, NO_RETVAL); set_damage_object_internal (ctxt, tex_pixmap, 0, 0); if (tex_pixmap->image) XDestroyImage (tex_pixmap->image); if (tex_pixmap->shm_info.shmid != -1) { XShmDetach (cogl_xlib_get_display (), &tex_pixmap->shm_info); shmdt (tex_pixmap->shm_info.shmaddr); shmctl (tex_pixmap->shm_info.shmid, IPC_RMID, 0); } if (tex_pixmap->tex) cogl_handle_unref (tex_pixmap->tex); if (tex_pixmap->winsys) { const CoglWinsysVtable *winsys = _cogl_texture_pixmap_x11_get_winsys (tex_pixmap); winsys->texture_pixmap_x11_free (tex_pixmap); } /* Chain up */ _cogl_texture_free (COGL_TEXTURE (tex_pixmap)); }
static void aisleriot_slot_renderer_dispose (GObject *object) { AisleriotSlotRenderer *self = (AisleriotSlotRenderer *) object; AisleriotSlotRendererPrivate *priv = self->priv; aisleriot_slot_renderer_set_cache (self, NULL); /* Get rid of any running animations */ aisleriot_slot_renderer_set_animations (self, 0, NULL, 0); if (priv->timeline) { g_object_unref (priv->timeline); priv->timeline = NULL; } if (priv->material != COGL_INVALID_HANDLE) { cogl_handle_unref (priv->material); priv->material = COGL_INVALID_HANDLE; } aisleriot_slot_renderer_set_animation_layer (self, NULL); G_OBJECT_CLASS (aisleriot_slot_renderer_parent_class)->dispose (object); }
static void xfixes_cursor_reset_image (ShellXFixesCursor *xfixes_cursor) { XFixesCursorImage *cursor_image; CoglHandle sprite = COGL_INVALID_HANDLE; if (!xfixes_cursor->have_xfixes) return; cursor_image = XFixesGetCursorImage (clutter_x11_get_default_display ()); sprite = cogl_texture_new_from_data (cursor_image->width, cursor_image->height, COGL_TEXTURE_NONE, #if G_BYTE_ORDER == G_LITTLE_ENDIAN COGL_PIXEL_FORMAT_BGRA_8888_PRE, #else COGL_PIXEL_FORMAT_ARGB_8888_PRE, #endif COGL_PIXEL_FORMAT_ANY, cursor_image->width * 4, /* stride */ (const guint8 *) cursor_image->pixels); if (sprite != COGL_INVALID_HANDLE) { if (xfixes_cursor->cursor_sprite != NULL) cogl_handle_unref (xfixes_cursor->cursor_sprite); xfixes_cursor->cursor_sprite = sprite; xfixes_cursor->cursor_hot_x = cursor_image->xhot; xfixes_cursor->cursor_hot_y = cursor_image->yhot; g_signal_emit (xfixes_cursor, signals[CURSOR_CHANGED], 0); } }
static void st_icon_update_shadow_material (StIcon *icon) { StIconPrivate *priv = icon->priv; if (priv->shadow_material) { cogl_handle_unref (priv->shadow_material); priv->shadow_material = COGL_INVALID_HANDLE; } if (priv->shadow_spec) { CoglHandle material; gint width, height; clutter_texture_get_base_size (CLUTTER_TEXTURE (priv->icon_texture), &width, &height); material = _st_create_shadow_material_from_actor (priv->shadow_spec, priv->icon_texture); priv->shadow_material = material; priv->shadow_width = width; priv->shadow_height = height; } }
static void st_icon_style_changed (StWidget *widget) { StIcon *self = ST_ICON (widget); StThemeNode *theme_node = st_widget_get_theme_node (widget); StIconPrivate *priv = self->priv; if (priv->shadow_spec) { st_shadow_unref (priv->shadow_spec); priv->shadow_spec = NULL; } if (priv->shadow_material) { cogl_handle_unref (priv->shadow_material); priv->shadow_material = COGL_INVALID_HANDLE; } priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow"); if (priv->shadow_spec && priv->shadow_spec->inset) { g_warning ("The icon-shadow property does not support inset shadows"); st_shadow_unref (priv->shadow_spec); priv->shadow_spec = NULL; } priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size")); st_icon_update_icon_size (self); st_icon_update (self); }
static cairo_surface_t * clutter_cairo_texture_create_surface (ClutterCairoTexture *self, guint width, guint height) { cairo_surface_t *surface; guint cairo_stride; guint8 *cairo_data; CoglHandle cogl_texture; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cairo_stride = cairo_image_surface_get_stride (surface); cairo_data = cairo_image_surface_get_data (surface); self->priv->surface_width = width; self->priv->surface_height = height; /* create a backing Cogl texture */ cogl_texture = cogl_texture_new_from_data (width, height, COGL_TEXTURE_NONE, CLUTTER_CAIRO_FORMAT_ARGB32, COGL_PIXEL_FORMAT_ANY, cairo_stride, cairo_data); clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (self), cogl_texture); cogl_handle_unref (cogl_texture); return surface; }
void mx_texture_frame_paint_texture (CoglHandle texture, guint8 opacity, gfloat top, gfloat right, gfloat bottom, gfloat left, gfloat width, gfloat height) { CoglHandle material; /* setup the template material */ if (!template_material) template_material = cogl_material_new (); /* create the material and apply opacity */ material = cogl_material_copy (template_material); mx_texture_frame_paint_texture_internal (material, texture, opacity, top, right, bottom, left, width, height); cogl_handle_unref (material); }
static void pp_super_aa_paint (ClutterActor *actor) { CoglHandle texture; gfloat width, height; PPSuperAAPrivate *priv = PP_SUPER_AA (actor)->priv; clutter_actor_get_size (actor, &width, &height); texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (actor)); if (!texture || (cogl_texture_get_width (texture) != (guint)(width * priv->x_res)) || (cogl_texture_get_height (texture) != (guint)(height * priv->y_res))) { texture = cogl_texture_new_with_size ((guint)(width * priv->x_res), (guint)(height * priv->y_res), COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_RGBA_8888_PRE); clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (actor), texture); cogl_handle_unref (texture); } CLUTTER_ACTOR_CLASS (pp_super_aa_parent_class)->paint (actor); }
static void st_scroll_view_fade_dispose (GObject *gobject) { StScrollViewFade *self = ST_SCROLL_VIEW_FADE (gobject); if (self->program != COGL_INVALID_HANDLE) { cogl_handle_unref (self->program); self->program = COGL_INVALID_HANDLE; self->shader = COGL_INVALID_HANDLE; } if (self->vadjustment) { g_signal_handlers_disconnect_by_func (self->vadjustment, (gpointer)on_vadjustment_changed, self); self->vadjustment = NULL; } self->actor = NULL; G_OBJECT_CLASS (st_scroll_view_fade_parent_class)->dispose (gobject); }
static void set_texture (MetaScreenBackground *background, CoglHandle texture) { MetaDisplay *display = meta_screen_get_display (background->screen); GSList *l; /* This may trigger destruction of an old texture pixmap, which, if * the underlying X pixmap is already gone has the tendency to trigger * X errors inside DRI. For safety, trap errors */ meta_error_trap_push (display); if (background->texture != COGL_INVALID_HANDLE) { cogl_handle_unref (background->texture); background->texture = COGL_INVALID_HANDLE; } meta_error_trap_pop (display); if (texture != COGL_INVALID_HANDLE) background->texture = cogl_handle_ref (texture); background->texture_width = cogl_texture_get_width (background->texture); background->texture_height = cogl_texture_get_height (background->texture); for (l = background->actors; l; l = l->next) set_texture_on_actor (l->data); update_wrap_mode (background); }
/** * meta_create_texture_material: * @src_texture: (allow-none): texture to use initially for the layer * * Creates a material with a single layer. Using a common template * allows sharing a shader for different uses in Muffin. To share the same * shader with all other materials that are just texture plus opacity * would require Cogl fixes. * (See http://bugzilla.clutter-project.org/show_bug.cgi?id=2425) * * Return value: (transfer full): a newly created Cogl material */ CoglHandle meta_create_texture_material (CoglHandle src_texture) { static CoglHandle texture_material_template = COGL_INVALID_HANDLE; CoglHandle material; /* We use a material that has a dummy texture as a base for all texture materials. The idea is that only the Cogl texture object would be different in the children so it is likely that Cogl will be able to share GL programs between all the textures. */ if (G_UNLIKELY (texture_material_template == COGL_INVALID_HANDLE)) { CoglHandle dummy_texture; dummy_texture = meta_create_color_texture_4ub (0xff, 0xff, 0xff, 0xff, COGL_TEXTURE_NONE); texture_material_template = cogl_material_new (); cogl_material_set_layer (texture_material_template, 0, dummy_texture); cogl_handle_unref (dummy_texture); } material = cogl_material_copy (texture_material_template); if (src_texture != COGL_INVALID_HANDLE) cogl_material_set_layer (material, 0, src_texture); return material; }
/** * _st_create_texture_material: * @src_texture: The CoglTexture for the material * * Creates a simple material which contains the given texture as a * single layer. */ CoglHandle _st_create_texture_material (CoglHandle src_texture) { static CoglHandle texture_material_template = COGL_INVALID_HANDLE; CoglHandle material; g_return_val_if_fail (src_texture != COGL_INVALID_HANDLE, COGL_INVALID_HANDLE); /* We use a material that has a dummy texture as a base for all texture materials. The idea is that only the Cogl texture object would be different in the children so it is likely that Cogl will be able to share GL programs between all the textures. */ if (G_UNLIKELY (texture_material_template == COGL_INVALID_HANDLE)) { static const guint8 white_pixel[] = { 0xff, 0xff, 0xff, 0xff }; CoglHandle dummy_texture; dummy_texture = st_cogl_texture_new_from_data_wrapper (1, 1, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_PIXEL_FORMAT_ANY, 4, white_pixel); texture_material_template = cogl_material_new (); cogl_material_set_layer (texture_material_template, 0, dummy_texture); cogl_handle_unref (dummy_texture); } material = cogl_material_copy (texture_material_template); cogl_material_set_layer (material, 0, src_texture); return material; }
static void _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node) { if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE) { g_array_free (node->d.texture.verts, TRUE); if (node->d.texture.texture != COGL_INVALID_HANDLE) cogl_handle_unref (node->d.texture.texture); if (node->d.texture.vertex_buffer != COGL_INVALID_HANDLE) cogl_handle_unref (node->d.texture.vertex_buffer); } if (node->pipeline) cogl_object_unref (node->pipeline); g_slice_free (CoglPangoDisplayListNode, node); }
static void st_background_effect_set_property (GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec) { StBackgroundEffect *self = ST_BACKGROUND_EFFECT (gobject); switch (prop_id) { case PROP_BUMPMAP: self->bumpmap_location = g_value_dup_string (value); if (self->bg_bumpmap != NULL) { cogl_handle_unref (self->bg_bumpmap); self->bg_bumpmap = NULL; } if (self->bumpmap_location == NULL) { break; } GFile *file = g_file_new_for_path (g_strdup (self->bumpmap_location)); if (g_file_query_exists (file, NULL)) { self->bg_bumpmap = cogl_texture_new_from_file (self->bumpmap_location, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_RGBA_8888_PRE, NULL); } g_object_unref (file); if (self->bg_bumpmap != NULL) { self->bumptex_width_i = cogl_texture_get_width (self->bg_bumpmap); self->bumptex_height_i = cogl_texture_get_height (self->bg_bumpmap); cogl_pipeline_set_layer_texture (self->pipeline0, 1, self->bg_bumpmap); } else { cogl_pipeline_set_layer_null_texture (self->pipeline0, 1, COGL_TEXTURE_TYPE_2D); } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
G_MODULE_EXPORT int test_clip_main (int argc, char **argv) { CallbackData data; ClutterActor *stub_actor, *label; gchar *file; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; data.current_clip.type = CLIP_NONE; data.clips = NULL; data.stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (data.stage), "Clipping"); g_signal_connect (data.stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); stub_actor = clutter_rectangle_new (); clutter_container_add (CLUTTER_CONTAINER (data.stage), stub_actor, NULL); file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); data.hand = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); g_free (file); label = clutter_text_new_with_text ("Sans 12px", instructions); clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE); clutter_actor_set_width (label, clutter_actor_get_width (data.stage) - 310); clutter_actor_set_y (label, clutter_actor_get_height (data.stage) - clutter_actor_get_height (label)); clutter_container_add (CLUTTER_CONTAINER (data.stage), label, NULL); g_signal_connect (stub_actor, "paint", G_CALLBACK (on_paint), &data); g_signal_connect (data.stage, "button-press-event", G_CALLBACK (on_button_press), &data); g_signal_connect (data.stage, "button-release-event", G_CALLBACK (on_button_release), &data); g_signal_connect (data.stage, "motion-event", G_CALLBACK (on_motion), &data); g_signal_connect (data.stage, "key-press-event", G_CALLBACK (on_key_press), &data); clutter_actor_show (data.stage); clutter_main (); cogl_handle_unref (data.hand); free_clips (&data); return 0; }
static void float_prop_free (FloatProp *prop) { if (prop->object) g_object_unref (prop->object); if (prop->material) cogl_handle_unref (prop->material); g_free (prop->prop_name); g_slice_free (FloatProp, prop); }
void meta_shadow_unref (MetaShadow *shadow) { shadow->ref_count--; if (shadow->ref_count == 0) { if (shadow->factory) { g_hash_table_remove (shadow->factory->shadows, &shadow->key); } meta_window_shape_unref (shadow->key.shape); cogl_handle_unref (shadow->texture); cogl_handle_unref (shadow->material); g_slice_free (MetaShadow, shadow); } }
static void st_drawing_area_dispose (GObject *object) { StDrawingArea *area = ST_DRAWING_AREA (object); StDrawingAreaPrivate *priv = area->priv; if (priv->material != COGL_INVALID_HANDLE) { cogl_handle_unref (priv->material); priv->material = COGL_INVALID_HANDLE; } if (priv->texture != COGL_INVALID_HANDLE) { cogl_handle_unref (priv->texture); priv->texture = COGL_INVALID_HANDLE; } G_OBJECT_CLASS (st_drawing_area_parent_class)->dispose (object); }