void dfb_font_destroy( CoreFont *font ) { int i; D_MAGIC_ASSERT( font, CoreFont ); D_MAGIC_CLEAR( font ); pthread_mutex_lock( &font->lock ); dfb_state_set_destination( &font->state, NULL ); dfb_state_set_source( &font->state, NULL ); dfb_state_destroy( &font->state ); direct_tree_destroy( font->glyph_infos ); if (font->surfaces) { for (i = 0; i < font->rows; i++) dfb_surface_unref( font->surfaces[i] ); D_FREE( font->surfaces ); } pthread_mutex_unlock( &font->lock ); pthread_mutex_destroy( &font->lock ); D_FREE( font ); }
DFBResult IGraphicsState_Real__ReleaseSource( CoreGraphicsState *obj ) { D_DEBUG_AT( DirectFB_CoreGraphicsState, "IGraphicsState_Real::%s()\n", __FUNCTION__ ); dfb_state_set_source( &obj->state, NULL ); dfb_state_set_source_mask( &obj->state, NULL ); dfb_state_set_source2( &obj->state, NULL ); return DFB_OK; }
DFBResult IGraphicsState_Real__SetSource( CoreGraphicsState *obj, CoreSurface *surface ) { D_DEBUG_AT( DirectFB_CoreGraphicsState, "%s()\n", __FUNCTION__ ); D_ASSERT( surface != NULL ); dfb_state_set_source( &obj->state, surface ); return DFB_OK; }
static DFBResult IDirectFBImageProvider_WebP_RenderTo( IDirectFBImageProvider *thiz, IDirectFBSurface *destination, const DFBRectangle *dest_rect ) { DFBResult ret; DFBRegion clip; CoreSurface *dst_surface; CardState state; CoreSurfaceBufferLock lock; IDirectFBSurface_data *dst_data; DIRenderCallbackResult cb_result = DIRCR_OK; DFBRectangle src_rect; DFBRectangle rect; DIRECT_INTERFACE_GET_DATA( IDirectFBImageProvider_WebP ) if (!destination) return DFB_INVARG; dst_data = destination->priv; if (!dst_data || !dst_data->surface) return DFB_DESTROYED; dst_surface = dst_data->surface; if (dest_rect) { if (dest_rect->w < 1 || dest_rect->h < 1) return DFB_INVARG; rect = *dest_rect; rect.x += dst_data->area.wanted.x; rect.y += dst_data->area.wanted.y; } else { rect = dst_data->area.wanted; } dfb_region_from_rectangle( &clip, &dst_data->area.current ); if (!dfb_rectangle_region_intersects( &rect, &clip )) return DFB_OK; ret = dfb_surface_create_simple( data->base.core, data->width, data->height, data->pixelformat, DSCS_RGB, DSCAPS_NONE, CSTF_NONE, 0, NULL, &data->decode_surface ); if (ret) { D_ERROR( "Failed to create surface : '%s'\n", DirectResultString(ret) ); goto error; } ret = dfb_surface_lock_buffer( data->decode_surface, CSBR_BACK, CSAID_CPU, CSAF_WRITE, &lock ); if (ret) { D_ERROR( "Failed to lock the surface : '%s'\n", DirectResultString(ret) ); goto error; } ret = WebP_decode_image( data, &lock ); if (ret) { D_ERROR( "Failed to decode the image : '%s'\n", DirectResultString(ret) ); goto error; } dfb_surface_unlock_buffer( data->decode_surface, &lock ); dfb_state_init( &state, data->base.core ); state.modified |= SMF_CLIP; state.clip = DFB_REGION_INIT_FROM_RECTANGLE_VALS( rect.x, rect.y, rect.w, rect.h ); src_rect = (DFBRectangle){0, 0, data->width, data->height}; dfb_state_set_source( &state, data->decode_surface ); dfb_state_set_destination( &state, dst_surface ); dfb_gfxcard_batchstretchblit( &src_rect, &rect, 1, &state ); data->serial = &state.serial; dfb_state_set_source(&state, NULL); dfb_state_set_destination(&state, NULL); dfb_state_destroy(&state); if (data->base.render_callback) { DFBRectangle r = { 0, 0, data->width, data->height }; cb_result=data->base.render_callback( &r, data->base.render_callback_context ); } if (cb_result == DIRCR_OK) { data->base.buffer->Release( data->base.buffer ); data->base.buffer = NULL; } return DFB_OK; error: if (data->decode_surface && lock.pitch) dfb_surface_unlock_buffer( data->decode_surface, &lock ); dfb_surface_unref( data->decode_surface ); data->base.buffer->Release( data->base.buffer ); data->base.buffer = NULL; return ret; }