コード例 #1
0
static cairo_status_t
_cairo_type3_glyph_surface_emit_image_pattern (cairo_type3_glyph_surface_t *surface,
					       cairo_image_surface_t       *image,
					       cairo_matrix_t              *pattern_matrix)
{
    cairo_matrix_t mat, upside_down;
    cairo_status_t status;

    if (image->width == 0 || image->height == 0)
	return CAIRO_STATUS_SUCCESS;

    mat = *pattern_matrix;

    /* Get the pattern space to user space matrix  */
    status = cairo_matrix_invert (&mat);

    /* cairo_pattern_set_matrix ensures the matrix is invertible */
    assert (status == CAIRO_STATUS_SUCCESS);

    /* Make this a pattern space to Type 3 font space matrix */
    cairo_matrix_multiply (&mat, &mat, &surface->cairo_to_pdf);

    /* PDF images are in a 1 unit by 1 unit image space. Turn the 1 by
     * 1 image upside down to convert to flip the Y-axis going from
     * cairo to PDF. Then scale the image up to the required size. */
    cairo_matrix_scale (&mat, image->width, image->height);
    cairo_matrix_init (&upside_down, 1, 0, 0, -1, 0, 1);
    cairo_matrix_multiply (&mat, &upside_down, &mat);

    return _cairo_type3_glyph_surface_emit_image (surface, image, &mat);
}
コード例 #2
0
GpStatus WINGDIPAPI
GdipMultiplyTextureTransform (GpTexture *texture, GpMatrix *matrix, GpMatrixOrder order)
{
	GpStatus status;
	BOOL invertible = FALSE;
	cairo_matrix_t mat;

	if ((texture == NULL) || (matrix == NULL)) {
		return InvalidParameter;
	}

	/* the matrix MUST be invertible to be used */
	status = GdipIsMatrixInvertible ((GpMatrix*) matrix, &invertible);
	if (!invertible || (status != Ok))
		return InvalidParameter;

	if (order == MatrixOrderPrepend)
		cairo_matrix_multiply (&mat, matrix, &texture->matrix);
	else if (order == MatrixOrderAppend)
		cairo_matrix_multiply (&mat, &texture->matrix, matrix);

	gdip_cairo_matrix_copy (&texture->matrix, &mat);
	texture->base.changed = TRUE;
	return status;
}
コード例 #3
0
ファイル: cairo-surface-wrapper.c プロジェクト: MiKTeX/miktex
static void
_cairo_surface_wrapper_get_transform (cairo_surface_wrapper_t *wrapper,
				      cairo_matrix_t *m)
{
    cairo_matrix_init_identity (m);

    if (! _cairo_matrix_is_identity (&wrapper->transform))
	cairo_matrix_multiply (m, &wrapper->transform, m);

    if (! _cairo_matrix_is_identity (&wrapper->target->device_transform))
	cairo_matrix_multiply (m, &wrapper->target->device_transform, m);
}
コード例 #4
0
ファイル: cairo-surface-wrapper.c プロジェクト: igagis/cairo
static void
_cairo_surface_wrapper_get_transform (cairo_surface_wrapper_t *wrapper,
				      cairo_matrix_t *m)
{
    cairo_matrix_init_identity (m);

    if (wrapper->has_extents && (wrapper->extents.x || wrapper->extents.y))
	cairo_matrix_translate (m, -wrapper->extents.x, -wrapper->extents.y);

    if (! _cairo_matrix_is_identity (&wrapper->transform))
	cairo_matrix_multiply (m, &wrapper->transform, m);

    if (! _cairo_matrix_is_identity (&wrapper->target->device_transform))
	cairo_matrix_multiply (m, &wrapper->target->device_transform, m);
}
コード例 #5
0
ファイル: media.cpp プロジェクト: snorp/moon
Rect
Image::GetCoverageBounds ()
{
	// FIXME: SL3 final only supports PixelFormatPbgra32 which makes this optimization
	// obsolete - unless we keep an "has_alpha" flag with each image ?!?
	return Rect ();
#if FALSE
	ImageSource *source = GetSource ();

	if (!source || source->GetPixelFormat () == PixelFormatPbgra32)
		return Rect ();

	Stretch stretch = GetStretch ();
	if (stretch == StretchFill || stretch == StretchUniformToFill)
		return bounds;

	cairo_matrix_t matrix;
	Rect image = Rect (0, 0, source->GetPixelWidth (), source->GetPixelHeight ());
	Rect paint = Rect (0, 0, GetActualWidth (), GetActualHeight ());

	image_brush_compute_pattern_matrix (&matrix, 
					    paint.width, paint.height,
					    image.width, image.height, stretch, 
					    AlignmentXCenter, AlignmentYCenter, NULL, NULL);

	cairo_matrix_invert (&matrix);
	cairo_matrix_multiply (&matrix, &matrix, &absolute_xform);

	image = image.Transform (&matrix);
	image = image.Intersection (bounds);
	
	return image;
#endif
}
コード例 #6
0
ファイル: l-object.c プロジェクト: IngenicC/xboot
static int m_update_transform_matrix(lua_State * L)
{
	struct lobject_t * obj1 = luaL_checkudata(L, 1, MT_OBJECT);
	struct lobject_t * obj2 = luaL_checkudata(L, 2, MT_OBJECT);
	cairo_matrix_multiply(&obj1->__transform_matrix, &obj1->__transform_matrix, __get_obj_matrix(obj2));
	return 0;
}
コード例 #7
0
static void
clutter_input_device_evdev_set_property (GObject      *object,
                                         guint         prop_id,
                                         const GValue *value,
                                         GParamSpec   *pspec)
{
  ClutterInputDeviceEvdev *device = CLUTTER_INPUT_DEVICE_EVDEV (object);

  switch (prop_id)
    {
    case PROP_DEVICE_MATRIX:
      {
        const cairo_matrix_t *matrix = g_value_get_boxed (value);
        cairo_matrix_init_identity (&device->device_matrix);
        cairo_matrix_multiply (&device->device_matrix,
                               &device->device_matrix, matrix);
        break;
      }
    case PROP_OUTPUT_ASPECT_RATIO:
      device->output_ratio = g_value_get_double (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
コード例 #8
0
cairo_surface_t *
_cairo_type3_glyph_surface_create (cairo_scaled_font_t	 		 *scaled_font,
				   cairo_output_stream_t 		 *stream,
				   cairo_type3_glyph_surface_emit_image_t emit_image,
				   cairo_scaled_font_subsets_t 		 *font_subsets)
{
    cairo_type3_glyph_surface_t *surface;
    cairo_matrix_t invert_y_axis;

    surface = malloc (sizeof (cairo_type3_glyph_surface_t));
    if (surface == NULL)
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    _cairo_surface_init (&surface->base, &cairo_type3_glyph_surface_backend,
			 CAIRO_CONTENT_COLOR_ALPHA);

    surface->scaled_font = scaled_font;
    surface->stream = stream;
    surface->emit_image = emit_image;

    /* Setup the transform from the user-font device space to Type 3
     * font space. The Type 3 font space is defined by the FontMatrix
     * entry in the Type 3 dictionary. In the PDF backend this is an
     * identity matrix. */
    surface->cairo_to_pdf = scaled_font->scale_inverse;
    cairo_matrix_init_scale (&invert_y_axis, 1, -1);
    cairo_matrix_multiply (&surface->cairo_to_pdf, &surface->cairo_to_pdf, &invert_y_axis);

    _cairo_pdf_operators_init (&surface->pdf_operators,
			       surface->stream,
			       &surface->cairo_to_pdf,
			       font_subsets);

    return &surface->base;
}
コード例 #9
0
cairo_status_t
_cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font, 
			 cairo_font_face_t		   *font_face,
			 const cairo_matrix_t              *font_matrix,
			 const cairo_matrix_t              *ctm,
			 const cairo_font_options_t	   *options,
			 const cairo_scaled_font_backend_t *backend)
{
    scaled_font->ref_count = 1;

    _cairo_scaled_font_init_key (scaled_font, font_face,
				 font_matrix, ctm, options);

    cairo_font_face_reference (font_face);

    cairo_matrix_multiply (&scaled_font->scale,
			   &scaled_font->font_matrix,
			   &scaled_font->ctm);

    scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal,
					       _cairo_scaled_glyph_destroy,
					       256);
    
    scaled_font->surface_backend = NULL;
    scaled_font->surface_private = NULL;
    
    scaled_font->backend = backend;

    return CAIRO_STATUS_SUCCESS;
}
コード例 #10
0
static cairo_status_t
_cairo_type3_glyph_surface_emit_fallback_image (cairo_type3_glyph_surface_t *surface,
						unsigned long		     glyph_index)
{
    cairo_scaled_glyph_t *scaled_glyph;
    cairo_status_t status;
    cairo_image_surface_t *image;
    cairo_matrix_t mat;
    double x, y;

    status = _cairo_scaled_glyph_lookup (surface->scaled_font,
					 glyph_index,
					 CAIRO_SCALED_GLYPH_INFO_METRICS |
					 CAIRO_SCALED_GLYPH_INFO_SURFACE,
					 &scaled_glyph);
    if (status)
	return status;

    image = scaled_glyph->surface;
    if (image->width == 0 || image->height == 0)
	return CAIRO_STATUS_SUCCESS;

    x = _cairo_fixed_to_double (scaled_glyph->bbox.p1.x);
    y = _cairo_fixed_to_double (scaled_glyph->bbox.p2.y);
    mat.xx = image->width;
    mat.xy = 0;
    mat.yx = 0;
    mat.yy = image->height;
    mat.x0 = x;
    mat.y0 = y;
    cairo_matrix_multiply (&mat, &mat, &surface->scaled_font->scale_inverse);
    mat.y0 *= -1;

    return _cairo_type3_glyph_surface_emit_image (surface, image, &mat);
}
コード例 #11
0
static PyObject *
matrix_multiply (PycairoMatrix *o, PycairoMatrix *o2)
{
    cairo_matrix_t result;
    cairo_matrix_multiply (&result, &o->matrix, &o2->matrix);
    return PycairoMatrix_FromMatrix (&result);
}
コード例 #12
0
ファイル: commands.c プロジェクト: darcyg/fbcanvas
static void cmd_flip_z (struct document *doc)
{
	int width = (doc->flags & NO_GENERIC_SCALE) ?
		doc->width : ceil(doc->scale * doc->width);
	int height = (doc->flags & NO_GENERIC_SCALE) ?
		doc->height : ceil(doc->scale * doc->height);

	int dir = (this_command == (KEY_Z | SHIFT)) ? 1 : -1;
	cairo_matrix_t flipz;
	cairo_matrix_init (&flipz, 0, dir, -dir, 0,
			   (dir == 1) ? height : 0,
			   (dir == -1) ? width : 0);

	/* TODO: fix images
	 *   dir = 1          dir = -1
	 *
	 * .y         x	   .y      .┌─y
	 *  │   ->    │	    │   ->  │
	 *  └─x    .y─┘	    └─x     x
	 */
	cairo_matrix_multiply (&doc->transform, &doc->transform, &flipz);

	int tmp = doc->height;
	doc->height = doc->width;
	doc->width = tmp;
}
コード例 #13
0
FontPlatformData::FontPlatformData(GDIObject<HFONT> font, cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
    : m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
    , m_size(size)
    , m_syntheticOblique(oblique)
{
    cairo_matrix_t fontMatrix;
    cairo_matrix_init_scale(&fontMatrix, size, size);
    cairo_matrix_t ctm;
    cairo_matrix_init_identity(&ctm);
    cairo_font_options_t* options = cairo_font_options_create();

    // We force antialiasing and disable hinting to provide consistent
    // typographic qualities for custom fonts on all platforms.
    cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
    cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_BEST);

    if (syntheticOblique()) {
        static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
        cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0};
        cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix);
    }

    m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
    cairo_font_options_destroy(options);
}
コード例 #14
0
/* Use 'Tm' operator to set the PDF text matrix. */
static cairo_status_t
_cairo_pdf_operators_set_text_matrix (cairo_pdf_operators_t  *pdf_operators,
				      cairo_matrix_t         *matrix)
{
    cairo_matrix_t inverse;
    cairo_status_t status;

    /* We require the matrix to be invertable. */
    inverse = *matrix;
    status = cairo_matrix_invert (&inverse);
    if (unlikely (status))
	return status;

    pdf_operators->text_matrix = *matrix;
    pdf_operators->cur_x = 0;
    pdf_operators->cur_y = 0;
    pdf_operators->glyph_buf_x_pos = 0;
    _cairo_output_stream_printf (pdf_operators->stream,
				 "%f %f %f %f %f %f Tm\n",
				 pdf_operators->text_matrix.xx,
				 pdf_operators->text_matrix.yx,
				 pdf_operators->text_matrix.xy,
				 pdf_operators->text_matrix.yy,
				 pdf_operators->text_matrix.x0,
				 pdf_operators->text_matrix.y0);

    pdf_operators->cairo_to_pdftext = *matrix;
    status = cairo_matrix_invert (&pdf_operators->cairo_to_pdftext);
    assert (status == CAIRO_STATUS_SUCCESS);
    cairo_matrix_multiply (&pdf_operators->cairo_to_pdftext,
			   &pdf_operators->cairo_to_pdf,
			   &pdf_operators->cairo_to_pdftext);

    return _cairo_output_stream_get_status (pdf_operators->stream);
}
コード例 #15
0
ファイル: Cairo.cpp プロジェクト: Justinmaurer/Cinder
const Matrix& Matrix::operator*=( const Matrix &rhs )
{
	cairo_matrix_t r;
	cairo_matrix_multiply( &r, &getCairoMatrix(), &rhs.getCairoMatrix() );
	init( r.xx, r.yx, r.xy, r.yy, r.x0, r.y0 );
	return *this;
}
コード例 #16
0
void
terranova_mirror_rotate (cairo_t *cr, double radius, double x, double y,
				boolean mirror_horizontally, boolean mirror_vertically)
{
	cairo_matrix_t matrix_rotate;
	cairo_matrix_t matrix_mirror;
	cairo_matrix_t matrix_result;

	double r_cos = cos(radius);
	double r_sin = sin(radius);

	cairo_matrix_init (&matrix_rotate, r_cos,
	                                   r_sin,
	                                   r_sin,
	                                   r_cos,
	                                   x, y);

	cairo_matrix_init (&matrix_mirror, mirror_horizontally ? -1 : 1,
	                                   0,
	                                   0,
	                                   mirror_vertically ? -1 : 1,
								  0, 0);

	cairo_matrix_multiply (&matrix_result, &matrix_mirror, &matrix_rotate);

	cairo_set_matrix (cr, &matrix_result);
}
コード例 #17
0
AffineTransform &AffineTransform::operator*= (const AffineTransform &m2)
{
    cairo_matrix_t result;
    cairo_matrix_multiply(&result, &m_transform, &m2.m_transform);
    m_transform = result;

    return *this;
}
コード例 #18
0
ファイル: cairo-surface-wrapper.c プロジェクト: MiKTeX/miktex
cairo_status_t
_cairo_surface_wrapper_tag (cairo_surface_wrapper_t     *wrapper,
			    cairo_bool_t                 begin,
			    const char                  *tag_name,
			    const char                  *attributes,
			    const cairo_pattern_t	*source,
			    const cairo_stroke_style_t	*stroke_style,
			    const cairo_matrix_t	*ctm,
			    const cairo_matrix_t	*ctm_inverse,
			    const cairo_clip_t		*clip)
{
    cairo_status_t status;
    cairo_clip_t *dev_clip;
    cairo_matrix_t dev_ctm = *ctm;
    cairo_matrix_t dev_ctm_inverse = *ctm_inverse;
    cairo_pattern_union_t source_copy;

    if (unlikely (wrapper->target->status))
	return wrapper->target->status;

    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
    if (wrapper->needs_transform) {
	cairo_matrix_t m;

	_cairo_surface_wrapper_get_transform (wrapper, &m);

	cairo_matrix_multiply (&dev_ctm, &dev_ctm, &m);

	status = cairo_matrix_invert (&m);
	assert (status == CAIRO_STATUS_SUCCESS);

	cairo_matrix_multiply (&dev_ctm_inverse, &m, &dev_ctm_inverse);

	_copy_transformed_pattern (&source_copy.base, source, &m);
	source = &source_copy.base;
    }

    status = _cairo_surface_tag (wrapper->target,
				 begin, tag_name, attributes,
				 source, stroke_style,
				 &dev_ctm, &dev_ctm_inverse,
				 dev_clip);

    _cairo_clip_destroy (dev_clip);
    return status;
}
コード例 #19
0
ファイル: l_cairo_matrix.c プロジェクト: qioixiy/xboot
static int m_cairo_matrix_multiply(lua_State * L)
{
	cairo_matrix_t * result = luaL_checkudata(L, 1, MT_NAME_CAIRO_MATRIX);
	const cairo_matrix_t * a = luaL_checkudata(L, 2, MT_NAME_CAIRO_MATRIX);
	const cairo_matrix_t * b = luaL_checkudata(L, 3, MT_NAME_CAIRO_MATRIX);
	cairo_matrix_multiply(result, a, b);
	return 0;
}
コード例 #20
0
ファイル: image.c プロジェクト: abhijitpotnis/weston
static void
redraw_handler(struct widget *widget, void *data)
{
	struct image *image = data;
	struct rectangle allocation;
	cairo_t *cr;
	cairo_surface_t *surface;
	double width, height, doc_aspect, window_aspect, scale;
	cairo_matrix_t matrix;
	cairo_matrix_t translate;

	surface = window_get_surface(image->window);
	cr = cairo_create(surface);
	widget_get_allocation(image->widget, &allocation);
	cairo_rectangle(cr, allocation.x, allocation.y,
			allocation.width, allocation.height);
	cairo_clip(cr);
	cairo_push_group(cr);
	cairo_translate(cr, allocation.x, allocation.y);

	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgba(cr, 0, 0, 0, 1);
	cairo_paint(cr);

	if (!image->initialized) {
		image->initialized = true;
		width = cairo_image_surface_get_width(image->image);
		height = cairo_image_surface_get_height(image->image);

		doc_aspect = width / height;
		window_aspect = (double) allocation.width / allocation.height;
		if (doc_aspect < window_aspect)
			scale = allocation.height / height;
		else
			scale = allocation.width / width;

		image->width = width;
		image->height = height;
		cairo_matrix_init_scale(&image->matrix, scale, scale);

		clamp_view(image);
	}

	matrix = image->matrix;
	cairo_matrix_init_translate(&translate, allocation.x, allocation.y);
	cairo_matrix_multiply(&matrix, &matrix, &translate);
	cairo_set_matrix(cr, &matrix);

	cairo_set_source_surface(cr, image->image, 0, 0);
	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
	cairo_paint(cr);

	cairo_pop_group_to_source(cr);
	cairo_paint(cr);
	cairo_destroy(cr);

	cairo_surface_destroy(surface);
}
コード例 #21
0
ファイル: obj_matrix.c プロジェクト: awesomeWM/oocairo
static int
cairmat_multiply (lua_State *L) {
    cairo_matrix_t m1, m2;
    from_lua_matrix(L, &m1, 1);
    from_lua_matrix(L, &m2, 2);
    cairo_matrix_multiply(&m1, &m1, &m2);
    to_lua_matrix(L, &m1, 1);
    return 0;
}
コード例 #22
0
static cairo_status_t
_cairo_skia_context_transform (void *abstract_cr,
			       const cairo_matrix_t *matrix)
{
    cairo_skia_context_t *cr = (cairo_skia_context_t *) abstract_cr;

    cairo_matrix_multiply (&cr->matrix, &cr->matrix, matrix);
    return CAIRO_STATUS_SUCCESS;
}
コード例 #23
0
ファイル: cairo-gl-operand.c プロジェクト: zwcloud/CairoSharp
static cairo_status_t
_cairo_gl_subsurface_operand_init (cairo_gl_operand_t *operand,
				   const cairo_pattern_t *_src,
				   cairo_gl_surface_t *dst,
				   const cairo_rectangle_int_t *sample,
				   const cairo_rectangle_int_t *extents,
				   cairo_bool_t use_texgen)
{
    const cairo_surface_pattern_t *src = (cairo_surface_pattern_t *)_src;
    cairo_surface_subsurface_t *sub;
    cairo_gl_surface_t *surface;
    cairo_surface_attributes_t *attributes;
    cairo_int_status_t status;

    sub = (cairo_surface_subsurface_t *) src->surface;

    if (sample->x < 0 || sample->y < 0 ||
	sample->x + sample->width  > sub->extents.width ||
	sample->y + sample->height > sub->extents.height)
    {
	return _cairo_gl_subsurface_clone_operand_init (operand, _src,
							dst, sample, extents,
							use_texgen);
    }

    surface = (cairo_gl_surface_t *) sub->target;
    if (surface->base.device && surface->base.device != dst->base.device)
	return CAIRO_INT_STATUS_UNSUPPORTED;

    if (! _cairo_gl_surface_is_texture (surface))
	return CAIRO_INT_STATUS_UNSUPPORTED;

    status = _cairo_gl_surface_resolve_multisampling (surface);
    if (unlikely (status))
	return status;

    /* Translate the matrix from
     * (unnormalized src -> unnormalized src) to
     * (unnormalized dst -> unnormalized src)
     */
    _cairo_gl_operand_copy(operand, &surface->operand);

    attributes = &operand->texture.attributes;
    attributes->matrix = src->base.matrix;
    attributes->matrix.x0 += sub->extents.x;
    attributes->matrix.y0 += sub->extents.y;
    cairo_matrix_multiply (&attributes->matrix,
			   &attributes->matrix,
			   &surface->operand.texture.attributes.matrix);

    attributes->extend = src->base.extend;
    attributes->filter = src->base.filter;
    attributes->has_component_alpha = src->base.has_component_alpha;

    operand->texture.texgen = use_texgen;
    return CAIRO_STATUS_SUCCESS;
}
コード例 #24
0
/**
 * cairo_matrix_translate:
 * @matrix: a #cairo_matrix_t
 * @tx: amount to translate in the X direction
 * @ty: amount to translate in the Y direction
 *
 * Applies a translation by @tx, @ty to the transformation in
 * @matrix. The effect of the new transformation is to first translate
 * the coordinates by @tx and @ty, then apply the original transformation
 * to the coordinates.
 **/
void
cairo_matrix_translate (cairo_matrix_t *matrix, double tx, double ty)
{
    cairo_matrix_t tmp;

    cairo_matrix_init_translate (&tmp, tx, ty);

    cairo_matrix_multiply (matrix, &tmp, matrix);
}
コード例 #25
0
/**
 * cairo_matrix_rotate:
 * @matrix: a #cairo_matrix_t
 * @radians: angle of rotation, in radians. The direction of rotation
 * is defined such that positive angles rotate in the direction from
 * the positive X axis toward the positive Y axis. With the default
 * axis orientation of cairo, positive angles rotate in a clockwise
 * direction.
 *
 * Applies rotation by @radians to the transformation in
 * @matrix. The effect of the new transformation is to first rotate the
 * coordinates by @radians, then apply the original transformation
 * to the coordinates.
 **/
void
cairo_matrix_rotate (cairo_matrix_t *matrix, double radians)
{
    cairo_matrix_t tmp;

    cairo_matrix_init_rotate (&tmp, radians);

    cairo_matrix_multiply (matrix, &tmp, matrix);
}
コード例 #26
0
/**
 * cairo_matrix_scale:
 * @matrix: a #cairo_matrix_t
 * @sx: scale factor in the X direction
 * @sy: scale factor in the Y direction
 *
 * Applies scaling by @sx, @sy to the transformation in @matrix. The
 * effect of the new transformation is to first scale the coordinates
 * by @sx and @sy, then apply the original transformation to the coordinates.
 **/
void
cairo_matrix_scale (cairo_matrix_t *matrix, double sx, double sy)
{
    cairo_matrix_t tmp;

    cairo_matrix_init_scale (&tmp, sx, sy);

    cairo_matrix_multiply (matrix, &tmp, matrix);
}
コード例 #27
0
ファイル: griddle.c プロジェクト: jotok/griddle
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");
    }
}
コード例 #28
0
ファイル: cairo-surface-wrapper.c プロジェクト: MiKTeX/miktex
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);
    }
}
コード例 #29
0
ファイル: drawmatrix.c プロジェクト: 123vipulj/libui
void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src)
{
	cairo_matrix_t c;
	cairo_matrix_t d;

	m2c(dest, &c);
	m2c(src, &d);
	cairo_matrix_multiply(&c, &c, &d);
	c2m(&c, dest);
}
コード例 #30
0
/* Set the translation components of the PDF text matrix to x, y. The
 * 'Td' operator is used to transform the text matrix.
 */
static cairo_status_t
_cairo_pdf_operators_set_text_position (cairo_pdf_operators_t  *pdf_operators,
					double 			x,
					double 			y)
{
    cairo_matrix_t translate, inverse;
    cairo_status_t status;

    /* The Td operator transforms the text_matrix with:
     *
     *   text_matrix' = T x text_matrix
     *
     * where T is a translation matrix with the translation components
     * set to the Td operands tx and ty.
     */
    inverse = pdf_operators->text_matrix;
    status = cairo_matrix_invert (&inverse);
    assert (status == CAIRO_STATUS_SUCCESS);
    pdf_operators->text_matrix.x0 = x;
    pdf_operators->text_matrix.y0 = y;
    cairo_matrix_multiply (&translate, &pdf_operators->text_matrix, &inverse);
    if (fabs(translate.x0) < TEXT_MATRIX_TOLERANCE)
	translate.x0 = 0.0;
    if (fabs(translate.y0) < TEXT_MATRIX_TOLERANCE)
	translate.y0 = 0.0;
    _cairo_output_stream_printf (pdf_operators->stream,
				 "%f %f Td\n",
				 translate.x0,
				 translate.y0);
    pdf_operators->cur_x = 0;
    pdf_operators->cur_y = 0;
    pdf_operators->glyph_buf_x_pos = 0;

    pdf_operators->cairo_to_pdftext = pdf_operators->text_matrix;
    status = cairo_matrix_invert (&pdf_operators->cairo_to_pdftext);
    assert (status == CAIRO_STATUS_SUCCESS);
    cairo_matrix_multiply (&pdf_operators->cairo_to_pdftext,
			   &pdf_operators->cairo_to_pdf,
			   &pdf_operators->cairo_to_pdftext);

    return _cairo_output_stream_get_status (pdf_operators->stream);
}