inline void FontCache::render_text(int font_id, bool grid_fitting, Direction dir, int num_glyphs, const int* glyphs, const float* components, image::ImageWriter& img_writer) { BearingType bearing_type; CoordType coord_type; switch (dir) { case dir_LeftToRight: bearing_type = bearing_Left; coord_type = coord_Hori; goto render; case dir_RightToLeft: bearing_type = bearing_Right; coord_type = coord_Hori; goto render; case dir_BottomToTop: bearing_type = bearing_Below; coord_type = coord_Vert; goto render; case dir_TopToBottom: bearing_type = bearing_Above; coord_type = coord_Vert; goto render; } return; render: render_glyphs(font_id, grid_fitting, bearing_type, coord_type, num_glyphs, glyphs, components, img_writer); }
static cairo_int_status_t render_glyphs_via_mask (cairo_gl_surface_t *dst, int dst_x, int dst_y, cairo_operator_t op, cairo_surface_t *source, cairo_composite_glyphs_info_t *info) { cairo_surface_t *mask; cairo_status_t status; cairo_bool_t has_component_alpha; TRACE ((stderr, "%s\n", __FUNCTION__)); /* XXX: For non-CA, this should be CAIRO_CONTENT_ALPHA to save memory */ mask = cairo_gl_surface_create (dst->base.device, CAIRO_CONTENT_COLOR_ALPHA, info->extents.width, info->extents.height); if (unlikely (mask->status)) return mask->status; status = render_glyphs ((cairo_gl_surface_t *) mask, info->extents.x, info->extents.y, CAIRO_OPERATOR_ADD, NULL, info, &has_component_alpha); if (likely (status == CAIRO_STATUS_SUCCESS)) { cairo_surface_pattern_t mask_pattern; cairo_surface_pattern_t source_pattern; mask->is_clear = FALSE; _cairo_pattern_init_for_surface (&mask_pattern, mask); mask_pattern.base.has_component_alpha = has_component_alpha; mask_pattern.base.filter = CAIRO_FILTER_NEAREST; mask_pattern.base.extend = CAIRO_EXTEND_NONE; cairo_matrix_init_translate (&mask_pattern.base.matrix, dst_x-info->extents.x, dst_y-info->extents.y); _cairo_pattern_init_for_surface (&source_pattern, source); cairo_matrix_init_translate (&source_pattern.base.matrix, dst_x-info->extents.x, dst_y-info->extents.y); status = _cairo_surface_mask (&dst->base, op, &source_pattern.base, &mask_pattern.base, NULL); _cairo_pattern_fini (&mask_pattern.base); _cairo_pattern_fini (&source_pattern.base); } cairo_surface_destroy (mask); return status; }
cairo_int_status_t _cairo_gl_composite_glyphs (void *_dst, cairo_operator_t op, cairo_surface_t *_src, int src_x, int src_y, int dst_x, int dst_y, cairo_composite_glyphs_info_t *info) { cairo_gl_surface_t *dst = _dst; cairo_bool_t has_component_alpha; int i; TRACE ((stderr, "%s\n", __FUNCTION__)); /* If any of the glyphs are component alpha, we have to go through a mask, * since only _cairo_gl_surface_composite() currently supports component * alpha. */ if (!dst->base.is_clear && ! info->use_mask && op != CAIRO_OPERATOR_OVER) { for (i = 0; i < info->num_glyphs; i++) { cairo_scaled_glyph_t *scaled_glyph; if (_cairo_scaled_glyph_lookup (info->font, info->glyphs[i].index, CAIRO_SCALED_GLYPH_INFO_SURFACE, &scaled_glyph) == CAIRO_INT_STATUS_SUCCESS && scaled_glyph->surface->format == CAIRO_FORMAT_ARGB32) { info->use_mask = TRUE; break; } } } if (info->use_mask) { return render_glyphs_via_mask (dst, dst_x, dst_y, op, _src, info); } else { return render_glyphs (dst, dst_x, dst_y, op, _src, info, &has_component_alpha); } }
cairo_int_status_t _cairo_gl_composite_glyphs_with_clip (void *_dst, cairo_operator_t op, cairo_surface_t *_src, int src_x, int src_y, int dst_x, int dst_y, cairo_composite_glyphs_info_t *info, cairo_clip_t *clip, cairo_bool_t via_msaa_compositor) { cairo_gl_surface_t *dst = _dst; cairo_bool_t has_component_alpha; TRACE ((stderr, "%s\n", __FUNCTION__)); /* If any of the glyphs require component alpha, we have to go through * a mask, since only _cairo_gl_surface_composite() currently supports * component alpha. */ if (!dst->base.is_clear && ! info->use_mask && op != CAIRO_OPERATOR_OVER && (info->font->options.antialias == CAIRO_ANTIALIAS_SUBPIXEL || info->font->options.antialias == CAIRO_ANTIALIAS_BEST)) { info->use_mask = TRUE; } if (info->use_mask) { return render_glyphs_via_mask (dst, dst_x, dst_y, op, _src, info, clip, via_msaa_compositor); } else { return render_glyphs (dst, dst_x, dst_y, op, _src, info, &has_component_alpha, clip, via_msaa_compositor); } }