cairo_surface_t* GlyphLayerInterfaceBlur::createBlurredSurface( cairo_format_t format, cairo_pattern_t* pattern, unsigned int width, unsigned int height ) { unsigned int blurSize = _getBlurSize(); // Create a temporary small surface and then copy that to the bigger one. cairo_surface_t* tmp = cairo_image_surface_create( format, width + (blurSize * 4), height + (blurSize * 4) ); if(cairo_surface_status(tmp)) return 0; cairo_t* tc = cairo_create(tmp); if(cairo_status(tc)) return 0; cairo_translate(tc, blurSize * 2, blurSize * 2); cairo_set_source(tc, pattern); cairo_paint(tc); cairo_destroy(tc); if(_deviation > 0.0f) osgPairo::gaussianBlur(tmp, _radius, _deviation); return tmp; }
bool GlyphLayerShadowInset::render( cairo_t* c, cairo_glyph_t* glyph, unsigned int width, unsigned int height ) { if(cairo_status(c) || !glyph) return false; cairo_push_group(c); cairo_glyph_path(c, glyph, 1); cairo_clip(c); cairo_translate(c, getOffsetX(), getOffsetY()); // cairo_set_line_join(c, CAIRO_LINE_JOIN_ROUND); cairo_set_line_width(c, static_cast<double>(_radius) - 0.5f); cairo_glyph_path(c, glyph, 1); cairo_stroke(c); cairo_pattern_t* pattern = cairo_pop_group(c); cairo_surface_t* tmp = createBlurredSurface(CAIRO_FORMAT_A8, pattern, width, height); cairo_set_source_surface( c, tmp, -static_cast<double>(_getBlurSize()) * 2, -static_cast<double>(_getBlurSize()) * 2 ); cairo_glyph_path(c, glyph, 1); cairo_clip(c); cairo_paint(c); cairo_surface_destroy(tmp); cairo_pattern_destroy(pattern); return true; }