本文整理汇总了C++中cairo_matrix_invert函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_matrix_invert函数的具体用法?C++ cairo_matrix_invert怎么用?C++ cairo_matrix_invert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_matrix_invert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pattern
void cairo_context::add_image(agg::trans_affine const& tr, image_data_rgba8 & data, double opacity)
{
cairo_pattern pattern(data);
if (!tr.is_identity())
{
double m[6];
tr.store_to(m);
cairo_matrix_t cairo_matrix;
cairo_matrix_init(&cairo_matrix,m[0],m[1],m[2],m[3],m[4],m[5]);
cairo_matrix_invert(&cairo_matrix);
pattern.set_matrix(cairo_matrix);
}
cairo_save(cairo_.get());
cairo_set_source(cairo_.get(), const_cast<cairo_pattern_t*>(pattern.pattern()));
cairo_paint_with_alpha(cairo_.get(), opacity);
cairo_restore(cairo_.get());
check_object_status_and_throw_exception(*this);
}
开发者ID:NavtechInc,项目名称:mapnik,代码行数:18,代码来源:cairo_context.cpp
示例2: grid_push_named_viewport
void
grid_push_named_viewport(grid_context_t *gr,
const char *name, const grid_viewport_t *vp)
{
double x = unit_to_npc(gr, 'x', vp->x);
double y = unit_to_npc(gr, 'y', vp->y);
double w = unit_to_npc(gr, 'x', vp->w);
double h = unit_to_npc(gr, 'y', vp->h);
cairo_matrix_t vp_mtx, temp_mtx;
cairo_matrix_init(&vp_mtx, w, 0, 0, h, x, y);
cairo_matrix_init(&temp_mtx, w, 0, 0, h, x, y);
cairo_status_t status = cairo_matrix_invert(&temp_mtx);
if (status == CAIRO_STATUS_SUCCESS) {
grid_viewport_node_t *node = new_grid_viewport_node();
cairo_matrix_multiply(node->npc_to_dev, &vp_mtx, gr->current_node->npc_to_dev);
if (vp->has_ntv) {
cairo_matrix_init(node->npc_to_ntv, vp->w_ntv, 0, 0, vp->h_ntv,
vp->x_ntv, vp->y_ntv);
} else {
// inherit native coordinates from parent
cairo_matrix_multiply(node->npc_to_ntv,
&vp_mtx, gr->current_node->npc_to_ntv);
}
if (name) {
node->name = malloc(strlen(name) + 1);
strcpy(node->name, name);
}
if (gr->current_node->child) {
gr->current_node->child->didi = node;
node->gege = gr->current_node->child;
}
gr->current_node->child = node;
node->parent = gr->current_node;
gr->current_node = node;
} else {
fprintf(stderr, "Warning: can't create singular viewport\n");
}
}
开发者ID:jotok,项目名称:griddle,代码行数:44,代码来源:griddle.c
示例3: _cairo_surface_wrapper_get_inverse_transform
static void
_cairo_surface_wrapper_get_inverse_transform (cairo_surface_wrapper_t *wrapper,
cairo_matrix_t *m)
{
cairo_matrix_init_identity (m);
if (! _cairo_matrix_is_identity (&wrapper->target->device_transform_inverse))
cairo_matrix_multiply (m, &wrapper->target->device_transform_inverse, m);
if (! _cairo_matrix_is_identity (&wrapper->transform)) {
cairo_matrix_t inv;
cairo_status_t status;
inv = wrapper->transform;
status = cairo_matrix_invert (&inv);
assert (status == CAIRO_STATUS_SUCCESS);
cairo_matrix_multiply (m, &inv, m);
}
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:19,代码来源:cairo-surface-wrapper.c
示例4: _cairo_surface_wrapper_set_inverse_transform
void
_cairo_surface_wrapper_set_inverse_transform (cairo_surface_wrapper_t *wrapper,
const cairo_matrix_t *transform)
{
cairo_status_t status;
if (transform == NULL || _cairo_matrix_is_identity (transform)) {
cairo_matrix_init_identity (&wrapper->transform);
wrapper->needs_transform =
_cairo_surface_wrapper_needs_device_transform (wrapper);
} else {
wrapper->transform = *transform;
status = cairo_matrix_invert (&wrapper->transform);
/* should always be invertible unless given pathological input */
assert (status == CAIRO_STATUS_SUCCESS);
wrapper->needs_transform = TRUE;
}
}
开发者ID:igagis,项目名称:cairo,代码行数:20,代码来源:cairo-surface-wrapper.c
示例5: swfdec_text_render
static void
swfdec_text_render (SwfdecGraphic *graphic, cairo_t *cr,
const SwfdecColorTransform *trans)
{
guint i;
SwfdecColor color;
SwfdecText *text = SWFDEC_TEXT (graphic);
SwfdecColorTransform force_color;
cairo_transform (cr, &text->transform);
/* scale by bounds */
for (i = 0; i < text->glyphs->len; i++) {
SwfdecTextGlyph *glyph;
SwfdecDraw *draw;
cairo_matrix_t pos;
glyph = &g_array_index (text->glyphs, SwfdecTextGlyph, i);
draw = swfdec_font_get_glyph (glyph->font, glyph->glyph);
if (draw == NULL) {
SWFDEC_INFO ("failed getting glyph %d, maybe an empty glyph?", glyph->glyph);
continue;
}
cairo_matrix_init_translate (&pos,
glyph->x, glyph->y);
cairo_matrix_scale (&pos,
(double) glyph->height / glyph->font->scale_factor,
(double) glyph->height / glyph->font->scale_factor);
cairo_save (cr);
cairo_transform (cr, &pos);
if (!cairo_matrix_invert (&pos)) {
color = swfdec_color_apply_transform (glyph->color, trans);
swfdec_color_transform_init_color (&force_color, color);
swfdec_draw_paint (draw, cr, &force_color);
} else {
SWFDEC_ERROR ("non-invertible matrix!");
}
cairo_restore (cr);
}
}
开发者ID:fengye,项目名称:swfdec,代码行数:41,代码来源:swfdec_text.c
示例6: _cairo_type3_glyph_surface_show_glyphs
static cairo_int_status_t
_cairo_type3_glyph_surface_show_glyphs (void *abstract_surface,
cairo_operator_t op,
cairo_pattern_t *source,
cairo_glyph_t *glyphs,
int num_glyphs,
cairo_scaled_font_t *scaled_font,
int *remaining_glyphs)
{
cairo_type3_glyph_surface_t *surface = abstract_surface;
cairo_int_status_t status;
cairo_scaled_font_t *font;
cairo_matrix_t new_ctm, ctm_inverse;
int i;
for (i = 0; i < num_glyphs; i++)
cairo_matrix_transform_point (&surface->cairo_to_pdf, &glyphs[i].x, &glyphs[i].y);
/* We require the matrix to be invertable. */
ctm_inverse = scaled_font->ctm;
status = cairo_matrix_invert (&ctm_inverse);
if (status)
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
cairo_matrix_multiply (&new_ctm, &scaled_font->ctm, &ctm_inverse);
font = cairo_scaled_font_create (scaled_font->font_face,
&scaled_font->font_matrix,
&new_ctm,
&scaled_font->options);
status = _cairo_pdf_operators_show_text_glyphs (&surface->pdf_operators,
NULL, 0,
glyphs, num_glyphs,
NULL, 0,
FALSE,
font);
cairo_scaled_font_destroy (font);
return status;
}
开发者ID:jwmcglynn,项目名称:Gadgets,代码行数:41,代码来源:cairo-type3-glyph-surface.c
示例7: gnome_canvas_item_invoke_point
/* This routine invokes the point method of the item. The argument x, y
* should be in the parent's item-relative coordinate system. This routine
* applies the inverse of the item's transform, maintaining the affine
* invariant. */
static GnomeCanvasItem *
gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
gint cy)
{
cairo_matrix_t inverse;
/* Calculate x & y in item local coordinates */
inverse = item->matrix;
if (cairo_matrix_invert (&inverse) != CAIRO_STATUS_SUCCESS)
return NULL;
cairo_matrix_transform_point (&inverse, &x, &y);
if (GNOME_CANVAS_ITEM_GET_CLASS (item)->point)
return GNOME_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy);
return NULL;
}
开发者ID:UIKit0,项目名称:evolution,代码行数:25,代码来源:e-canvas.c
示例8: cairo_matrix_init
wxSVGRect wxSVGCanvasPathCairo::GetResultBBox(const wxCSSStyleDeclaration& style, const wxSVGMatrix* matrix) {
if (matrix) {
cairo_matrix_t m;
cairo_matrix_init(&m, matrix->GetA(), matrix->GetB(), matrix->GetC(), matrix->GetD(),
matrix->GetE(), matrix->GetF());
cairo_matrix_invert(&m);
cairo_set_matrix(m_cr, &m);
}
ApplyStrokeStyle(m_cr, style);
double x1, y1, x2, y2;
if (style.GetStrokeWidth() > 0)
cairo_stroke_extents(m_cr, &x1, &y1, &x2, &y2);
else
cairo_fill_extents(m_cr, &x1, &y1, &x2, &y2);
if (matrix) {
cairo_matrix_t mat;
cairo_matrix_init(&mat, 1, 0, 0, 1, 0, 0);
cairo_set_matrix(m_cr, &mat);
}
return wxSVGRect(x1, y1, x2 - x1, y2 - y1);
}
开发者ID:jfiguinha,项目名称:Regards,代码行数:21,代码来源:SVGCanvasPathCairo.cpp
示例9: test_scaled_font_render_glyph
static cairo_status_t
test_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
unsigned long glyph,
cairo_t *cr,
cairo_text_extents_t *metrics)
{
test_scaled_font_glyph_t *glyphs = cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
&test_font_face_glyphs_key);
int i;
unsigned char *data;
cairo_surface_t *image;
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
uint8_t byte;
/* FIXME: We simply crash on out-of-bound glyph indices */
metrics->x_advance = (glyphs[glyph].width + 1) / 8.0;
image = cairo_image_surface_create (CAIRO_FORMAT_A1, glyphs[glyph].width, 8);
data = cairo_image_surface_get_data (image);
for (i = 0; i < 8; i++) {
byte = glyphs[glyph].data[i];
*data = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (byte);
data += cairo_image_surface_get_stride (image);
}
pattern = cairo_pattern_create_for_surface (image);
cairo_matrix_init_identity (&matrix);
cairo_matrix_scale (&matrix, 1.0/8.0, 1.0/8.0);
cairo_matrix_translate (&matrix, 0, -8);
cairo_matrix_invert (&matrix);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
cairo_mask (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (image);
return CAIRO_STATUS_SUCCESS;
}
开发者ID:AliYousuf,项目名称:cairo,代码行数:40,代码来源:user-font-mask.c
示例10: platformDestroy
cairo_pattern_t* Gradient::platformGradient(float globalAlpha)
{
if (m_gradient && m_platformGradientAlpha == globalAlpha)
return m_gradient;
platformDestroy();
m_platformGradientAlpha = globalAlpha;
if (m_radial)
m_gradient = cairo_pattern_create_radial(m_p0.x(), m_p0.y(), m_r0, m_p1.x(), m_p1.y(), m_r1);
else
m_gradient = cairo_pattern_create_linear(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y());
Vector<ColorStop>::iterator stopIterator = m_stops.begin();
while (stopIterator != m_stops.end()) {
cairo_pattern_add_color_stop_rgba(m_gradient, stopIterator->stop,
stopIterator->red, stopIterator->green, stopIterator->blue,
stopIterator->alpha * globalAlpha);
++stopIterator;
}
switch (m_spreadMethod) {
case SpreadMethodPad:
cairo_pattern_set_extend(m_gradient, CAIRO_EXTEND_PAD);
break;
case SpreadMethodReflect:
cairo_pattern_set_extend(m_gradient, CAIRO_EXTEND_REFLECT);
break;
case SpreadMethodRepeat:
cairo_pattern_set_extend(m_gradient, CAIRO_EXTEND_REPEAT);
break;
}
cairo_matrix_t matrix = m_gradientSpaceTransformation;
cairo_matrix_invert(&matrix);
cairo_pattern_set_matrix(m_gradient, &matrix);
return m_gradient;
}
开发者ID:CannedFish,项目名称:deepin-webkit,代码行数:39,代码来源:GradientCairo.cpp
示例11: _cairo_surface_wrapper_mask
cairo_status_t
_cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper,
cairo_operator_t op,
const cairo_pattern_t *source,
const cairo_pattern_t *mask,
const cairo_clip_t *clip)
{
cairo_status_t status;
cairo_clip_t *dev_clip;
cairo_pattern_union_t source_copy;
cairo_pattern_union_t mask_copy;
if (unlikely (wrapper->target->status))
return wrapper->target->status;
dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
if (_cairo_clip_is_all_clipped (dev_clip))
return (cairo_status_t)CAIRO_INT_STATUS_NOTHING_TO_DO;
if (wrapper->needs_transform) {
cairo_matrix_t m;
_cairo_surface_wrapper_get_transform (wrapper, &m);
status = cairo_matrix_invert (&m);
assert (status == CAIRO_STATUS_SUCCESS);
_copy_transformed_pattern (&source_copy.base, source, &m);
source = &source_copy.base;
_copy_transformed_pattern (&mask_copy.base, mask, &m);
mask = &mask_copy.base;
}
status = _cairo_surface_mask (wrapper->target, op, source, mask, dev_clip);
_cairo_clip_destroy (dev_clip);
return status;
}
开发者ID:igagis,项目名称:cairo,代码行数:39,代码来源:cairo-surface-wrapper.c
示例12: updateMatrix
void QCairoPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
{
double w, h;
cairo_surface_t *image;
QImage img=pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
if (!img.isNull()) {
cairo_format_t imgformat=CAIRO_FORMAT_ARGB32;
updateMatrix();
image = cairo_image_surface_create_for_data(img.bits(), imgformat, img.width(), img.height(), img.bytesPerLine());
w = img.width();
h = img.height();
cairo_matrix_t cm;
cairo_matrix_init_identity(&cm);
cairo_matrix_translate (&cm, s.x(), s.y());
cairo_matrix_invert(&cm);
cairo_pattern_t* brush=cairo_pattern_create_for_surface(image);
cairo_pattern_set_matrix(brush, &cm);
cairo_pattern_set_extend(brush, CAIRO_EXTEND_REPEAT);
cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
cairo_set_source(cr, brush);
cairo_fill_preserve(cr);
cairo_set_source_rgba(cr, 0,0,0,0);
cairo_set_line_width(cr, 0.0);
cairo_stroke(cr);
//cairo_fill(cr);
//cairo_set_source_surface (cr, image, 0, 0);
//cairo_paint(cr);
releasePattern(brush);
updateMatrix();
}
}
开发者ID:jkriege2,项目名称:cairoQPaintDevice,代码行数:39,代码来源:qcairopaintengine.cpp
示例13: cgDrawImage
void cgDrawImage(cairo_t *cr, int x, int y, int width, int height, cairo_surface_t *img_surface, int img_w, int img_h) {
if (img_surface && img_w>0 && img_h>0 && width>0 && height>0) {
cairo_save(cr);
cairo_matrix_t cm;
cairo_matrix_init_identity(&cm);
cairo_matrix_translate (&cm, x, y);
if (width!=img_w || height!=img_h) cairo_matrix_scale(&cm, float(width)/float(img_w), float(height)/float(img_h));
cairo_matrix_invert(&cm);
cairo_pattern_t* brush=cairo_pattern_create_for_surface(img_surface);
cairo_pattern_set_matrix(brush, &cm);
cairo_pattern_set_extend(brush, CAIRO_EXTEND_NONE);
cairo_rectangle(cr, x, y, width, height);
cairo_set_source(cr, brush);
cairo_fill_preserve(cr);
cairo_set_source_rgba(cr, 0,0,0,0);
cairo_set_line_width(cr, 0.0);
cairo_stroke(cr);
cairo_pattern_destroy(brush);
cairo_restore(cr);
}
}
开发者ID:jkriege2,项目名称:rpi_webradio,代码行数:23,代码来源:cgbasics.cpp
示例14: _adg_get_map
static gboolean
_adg_get_map(GtkWidget *widget, gboolean local_space,
cairo_matrix_t *map, cairo_matrix_t *inverted)
{
AdgGtkAreaPrivate *data = adg_gtk_area_get_instance_private((AdgGtkArea *) widget);
AdgEntity *entity = (AdgEntity *) data->canvas;
if (entity == NULL)
return FALSE;
if (local_space) {
adg_matrix_copy(map, adg_entity_get_local_map(entity));
/* The inverted map is subject to the global matrix */
adg_matrix_copy(inverted, adg_entity_get_global_matrix(entity));
adg_matrix_transform(inverted, map, ADG_TRANSFORM_BEFORE);
} else {
adg_matrix_copy(map, adg_entity_get_global_map(entity));
adg_matrix_copy(inverted, map);
}
return cairo_matrix_invert(inverted) == CAIRO_STATUS_SUCCESS;
}
开发者ID:ntd,项目名称:adg,代码行数:23,代码来源:adg-gtk-area.c
示例15: gimp_display_shell_rotate_update_transform
void
gimp_display_shell_rotate_update_transform (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_free (shell->rotate_transform);
g_free (shell->rotate_untransform);
if (shell->rotate_angle != 0.0 && gimp_display_get_image (shell->display))
{
gint image_width, image_height;
gdouble cx, cy;
shell->rotate_transform = g_new (cairo_matrix_t, 1);
shell->rotate_untransform = g_new (cairo_matrix_t, 1);
gimp_display_shell_scale_get_image_size (shell,
&image_width, &image_height);
cx = -shell->offset_x + image_width / 2;
cy = -shell->offset_y + image_height / 2;
cairo_matrix_init_translate (shell->rotate_transform, cx, cy);
cairo_matrix_rotate (shell->rotate_transform,
shell->rotate_angle / 180.0 * G_PI);
cairo_matrix_translate (shell->rotate_transform, -cx, -cy);
*shell->rotate_untransform = *shell->rotate_transform;
cairo_matrix_invert (shell->rotate_untransform);
}
else
{
shell->rotate_transform = NULL;
shell->rotate_untransform = NULL;
}
}
开发者ID:Natella,项目名称:gimp,代码行数:36,代码来源:gimpdisplayshell-rotate.c
示例16: _cairo_surface_wrapper_fill_stroke
cairo_status_t
_cairo_surface_wrapper_fill_stroke (cairo_surface_wrapper_t *wrapper,
cairo_operator_t fill_op,
const cairo_pattern_t *fill_source,
cairo_fill_rule_t fill_rule,
double fill_tolerance,
cairo_antialias_t fill_antialias,
cairo_path_fixed_t *path,
cairo_operator_t stroke_op,
const cairo_pattern_t *stroke_source,
cairo_stroke_style_t *stroke_style,
cairo_matrix_t *stroke_ctm,
cairo_matrix_t *stroke_ctm_inverse,
double stroke_tolerance,
cairo_antialias_t stroke_antialias,
cairo_clip_t *clip)
{
cairo_status_t status;
cairo_matrix_t device_transform;
cairo_path_fixed_t path_copy, *dev_path = path;
cairo_clip_t clip_copy, *dev_clip = clip;
cairo_matrix_t dev_ctm = *stroke_ctm;
cairo_matrix_t dev_ctm_inverse = *stroke_ctm_inverse;
if (unlikely (wrapper->target->status))
return wrapper->target->status;
if (clip && clip->all_clipped)
return CAIRO_STATUS_SUCCESS;
if (_cairo_surface_wrapper_needs_device_transform (wrapper,
&device_transform))
{
status = _cairo_path_fixed_init_copy (&path_copy, dev_path);
if (unlikely (status))
goto FINISH;
_cairo_path_fixed_transform (&path_copy, &device_transform);
dev_path = &path_copy;
if (clip != NULL) {
status = _cairo_clip_init_copy_transformed (&clip_copy, clip,
&device_transform);
if (unlikely (status))
goto FINISH;
dev_clip = &clip_copy;
}
cairo_matrix_multiply (&dev_ctm, &dev_ctm, &device_transform);
status = cairo_matrix_invert (&device_transform);
assert (status == CAIRO_STATUS_SUCCESS);
cairo_matrix_multiply (&dev_ctm_inverse,
&device_transform,
&dev_ctm_inverse);
} else {
if (clip != NULL) {
dev_clip = &clip_copy;
_cairo_clip_init_copy (&clip_copy, clip);
}
}
status = _cairo_surface_fill_stroke (wrapper->target,
fill_op, fill_source, fill_rule,
fill_tolerance, fill_antialias,
dev_path,
stroke_op, stroke_source,
stroke_style,
&dev_ctm, &dev_ctm_inverse,
stroke_tolerance, stroke_antialias,
dev_clip);
FINISH:
if (dev_path != path)
_cairo_path_fixed_fini (dev_path);
if (dev_clip != clip)
_cairo_clip_reset (dev_clip);
return status;
}
开发者ID:angerangel,项目名称:livecode-thirdparty,代码行数:79,代码来源:cairo-surface-wrapper.c
示例17: cairo_matrix_init_identity
bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
{
m_ownerElement->buildGradient();
cairo_t* cr = context->platformContext();
cairo_pattern_t* pattern;
cairo_matrix_t matrix;
cairo_matrix_init_identity (&matrix);
const cairo_matrix_t gradient_matrix = gradientTransform();
if (this->type() == LinearGradientPaintServer) {
const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(this);
if (boundingBoxMode()) {
FloatRect bbox = object->relativeBBox(false);
cairo_matrix_translate(&matrix, bbox.x(), bbox.y());
cairo_matrix_scale(&matrix, bbox.width(), bbox.height());
}
double x0 = linear->gradientStart().x();
double y0 = linear->gradientStart().y();
double x1 = linear->gradientEnd().x();
double y1 = linear->gradientEnd().y();
pattern = cairo_pattern_create_linear(x0, y0, x1, y1);
} else if (this->type() == RadialGradientPaintServer) {
const SVGPaintServerRadialGradient* radial = static_cast<const SVGPaintServerRadialGradient*>(this);
if (boundingBoxMode()) {
FloatRect bbox = object->relativeBBox(false);
cairo_matrix_translate(&matrix, bbox.x(), bbox.y());
cairo_matrix_scale(&matrix, bbox.width(), bbox.height());
}
double cx = radial->gradientCenter().x();
double cy = radial->gradientCenter().y();
double radius = radial->gradientRadius();
double fx = radial->gradientFocal().x();
double fy = radial->gradientFocal().y();
fx -= cx;
fy -= cy;
double fradius = 0.0;
if (sqrt(fx * fx + fy * fy) > radius) {
double angle = atan2(fy, fx);
if ((fx + cx) < cx)
fx = int(cos(angle) * radius) + 1;
else
fx = int(cos(angle) * radius) - 1;
if ((fy + cy) < cy)
fy = int(sin(angle) * radius) + 1;
else
fy = int(sin(angle) * radius) - 1;
}
pattern = cairo_pattern_create_radial(fx + cx, fy + cy, fradius, cx, cy, radius);
} else {
return false;
}
cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR);
switch (spreadMethod()) {
case SPREADMETHOD_PAD:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
break;
case SPREADMETHOD_REFLECT:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
break;
case SPREADMETHOD_REPEAT:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
break;
default:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
break;
}
cairo_matrix_multiply(&matrix, &matrix, &gradient_matrix);
cairo_matrix_invert(&matrix);
cairo_pattern_set_matrix(pattern, &matrix);
const Vector<SVGGradientStop>& stops = gradientStops();
for (unsigned i = 0; i < stops.size(); ++i) {
float offset = stops[i].first;
Color color = stops[i].second;
cairo_pattern_add_color_stop_rgba(pattern, offset, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
}
cairo_set_source(cr, pattern);
cairo_pattern_destroy(pattern);
return true;
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:99,代码来源:SVGPaintServerGradientCairo.cpp
示例18: _cairo_surface_wrapper_show_text_glyphs
cairo_status_t
_cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
cairo_operator_t op,
const cairo_pattern_t *source,
const char *utf8,
int utf8_len,
const cairo_glyph_t *glyphs,
int num_glyphs,
const cairo_text_cluster_t *clusters,
int num_clusters,
cairo_text_cluster_flags_t cluster_flags,
cairo_scaled_font_t *scaled_font,
const cairo_clip_t *clip)
{
cairo_status_t status;
cairo_clip_t *dev_clip;
cairo_glyph_t stack_glyphs [CAIRO_STACK_ARRAY_LENGTH(cairo_glyph_t)];
cairo_glyph_t *dev_glyphs = stack_glyphs;
cairo_scaled_font_t *dev_scaled_font = scaled_font;
cairo_pattern_union_t source_copy;
cairo_font_options_t options;
if (unlikely (wrapper->target->status))
return wrapper->target->status;
dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
if (_cairo_clip_is_all_clipped (dev_clip))
return CAIRO_INT_STATUS_NOTHING_TO_DO;
cairo_surface_get_font_options (wrapper->target, &options);
cairo_font_options_merge (&options, &scaled_font->options);
if (wrapper->needs_transform) {
cairo_matrix_t m;
int i;
_cairo_surface_wrapper_get_transform (wrapper, &m);
if (! _cairo_matrix_is_translation (&wrapper->transform)) {
cairo_matrix_t ctm;
/* XXX No device-transform? A bug in the tangle of layers? */
_cairo_matrix_multiply (&ctm,
&wrapper->transform,
&scaled_font->ctm);
dev_scaled_font = cairo_scaled_font_create (scaled_font->font_face,
&scaled_font->font_matrix,
&ctm, &options);
}
if (num_glyphs > ARRAY_LENGTH (stack_glyphs)) {
dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
if (unlikely (dev_glyphs == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FINISH;
}
}
for (i = 0; i < num_glyphs; i++) {
dev_glyphs[i] = glyphs[i];
cairo_matrix_transform_point (&m,
&dev_glyphs[i].x,
&dev_glyphs[i].y);
}
status = cairo_matrix_invert (&m);
assert (status == CAIRO_STATUS_SUCCESS);
_copy_transformed_pattern (&source_copy.base, source, &m);
source = &source_copy.base;
} else {
if (! cairo_font_options_equal (&options, &scaled_font->options)) {
dev_scaled_font = cairo_scaled_font_create (scaled_font->font_face,
&scaled_font->font_matrix,
&scaled_font->ctm,
&options);
}
/* show_text_glyphs is special because _cairo_surface_show_text_glyphs is allowed
* to modify the glyph array that's passed in. We must always
* copy the array before handing it to the backend.
*/
if (num_glyphs > ARRAY_LENGTH (stack_glyphs)) {
dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
if (unlikely (dev_glyphs == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FINISH;
}
}
memcpy (dev_glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
}
status = _cairo_surface_show_text_glyphs (wrapper->target, op, source,
utf8, utf8_len,
dev_glyphs, num_glyphs,
clusters, num_clusters,
cluster_flags,
dev_scaled_font,
dev_clip);
//.........这里部分代码省略.........
开发者ID:igagis,项目名称:cairo,代码行数:101,代码来源:cairo-surface-wrapper.c
示例19: _cairo_pdf_operators_show_text_glyphs
cairo_int_status_t
_cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t *pdf_operators,
const char *utf8,
int utf8_len,
cairo_glyph_t *glyphs,
int num_glyphs,
const cairo_text_cluster_t *clusters,
int num_clusters,
cairo_text_cluster_flags_t cluster_flags,
cairo_scaled_font_t *scaled_font)
{
cairo_status_t status;
int i;
cairo_matrix_t text_matrix, invert_y_axis;
double x, y;
const char *cur_text;
cairo_glyph_t *cur_glyph;
pdf_operators->font_matrix_inverse = scaled_font->font_matrix;
status = cairo_matrix_invert (&pdf_operators->font_matrix_inverse);
if (status == CAIRO_STATUS_INVALID_MATRIX)
return CAIRO_STATUS_SUCCESS;
assert (status == CAIRO_STATUS_SUCCESS);
pdf_operators->is_new_text_object = FALSE;
if (pdf_operators->in_text_object == FALSE) {
status = _cairo_pdf_operators_begin_text (pdf_operators);
if (unlikely (status))
return status;
/* Force Tm and Tf to be emitted when starting a new text
* object.*/
pdf_operators->is_new_text_object = TRUE;
}
cairo_matrix_init_scale (&invert_y_axis, 1, -1);
text_matrix = scaled_font->scale;
/* Invert y axis in font space */
cairo_matrix_multiply (&text_matrix, &text_matrix, &invert_y_axis);
/* Invert y axis in device space */
cairo_matrix_multiply (&text_matrix, &invert_y_axis, &text_matrix);
if (pdf_operators->is_new_text_object ||
! _cairo_matrix_scale_equal (&pdf_operators->text_matrix, &text_matrix))
{
status = _cairo_pdf_operators_flush_glyphs (pdf_operators);
if (unlikely (status))
return status;
x = glyphs[0].x;
y = glyphs[0].y;
cairo_matrix_transform_point (&pdf_operators->cairo_to_pdf, &x, &y);
text_matrix.x0 = x;
text_matrix.y0 = y;
status = _cairo_pdf_operators_set_text_matrix (pdf_operators, &text_matrix);
if (status == CAIRO_STATUS_INVALID_MATRIX)
return CAIRO_STATUS_SUCCESS;
if (unlikely (status))
return status;
}
if (num_clusters > 0) {
cur_text = utf8;
if ((cluster_flags & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD))
cur_glyph = glyphs + num_glyphs;
else
cur_glyph = glyphs;
for (i = 0; i < num_clusters; i++) {
if ((cluster_flags & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD))
cur_glyph -= clusters[i].num_glyphs;
status = _cairo_pdf_operators_emit_cluster (pdf_operators,
cur_text,
clusters[i].num_bytes,
cur_glyph,
clusters[i].num_glyphs,
cluster_flags,
scaled_font);
if (unlikely (status))
return status;
cur_text += clusters[i].num_bytes;
if (!(cluster_flags & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD))
cur_glyph += clusters[i].num_glyphs;
}
} else {
for (i = 0; i < num_glyphs; i++) {
status = _cairo_pdf_operators_emit_cluster (pdf_operators,
NULL,
-1, /* no unicode string available */
&glyphs[i],
1,
FALSE,
scaled_font);
if (unlikely (status))
return status;
}
}
//.........这里部分代码省略.........
开发者ID:Blueprintts,项目名称:npm-pdf2svg,代码行数:101,代码来源:cairo-pdf-operators.c
示例20: cairo_matrix_invert
int32_t Matrix::invert()
{
return static_cast<int32_t>( cairo_matrix_invert( &getCairoMatrix() ) );
}
开发者ID:Justinmaurer,项目名称:Cinder,代码行数:4,代码来源:Cairo.cpp
注:本文中的cairo_matrix_invert函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论