Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
GpStatus WINGDIPAPI
GdipGetPenTransform (GpPen *pen, GpMatrix *matrix)
{
	if (!pen || !matrix)
		return InvalidParameter;

	gdip_cairo_matrix_copy (matrix, &pen->matrix);
	return Ok;
}
Ejemplo n.º 3
0
GpStatus WINGDIPAPI
GdipGetTextureTransform (GpTexture *texture, GpMatrix *matrix)
{
	if (!texture || !matrix)
		return InvalidParameter;

	gdip_cairo_matrix_copy (matrix, &texture->matrix);
	return Ok;
}
Ejemplo n.º 4
0
GpStatus WINGDIPAPI
GdipGetTextureTransform (GpTexture *texture, GpMatrix *matrix)
{
	if ((texture == NULL) || (matrix == NULL)) {
		return InvalidParameter;
	}

	gdip_cairo_matrix_copy(matrix, &texture->matrix);
	return Ok;
}
Ejemplo n.º 5
0
GpStatus WINGDIPAPI
GdipSetTextureTransform (GpTexture *texture, GDIPCONST GpMatrix *matrix)
{
	if ((texture == NULL) || (matrix == NULL)) {
		return InvalidParameter;
	}

	gdip_cairo_matrix_copy(&texture->matrix, matrix);
	texture->base.changed = TRUE;

	return Ok;
}
Ejemplo n.º 6
0
GpStatus WINGDIPAPI
GdipSetPenTransform (GpPen *pen, GpMatrix *matrix)
{
	BOOL invertible;

	if (!pen || !matrix)
		return InvalidParameter;

	/* the matrix MUST be invertible to be used */
	GdipIsMatrixInvertible (matrix, &invertible);
	if (!invertible)
		return InvalidParameter;

	gdip_cairo_matrix_copy (&pen->matrix, matrix);
	pen->changed = TRUE;
	return Ok;
}
Ejemplo n.º 7
0
GpStatus WINGDIPAPI
GdipSetTextureTransform (GpTexture *texture, GDIPCONST GpMatrix *matrix)
{
	BOOL invertible;

	if (!texture || !matrix)
		return InvalidParameter;
		
	GdipIsMatrixInvertible ((GpMatrix *) matrix, &invertible);
	if (!invertible)
		return InvalidParameter;

	gdip_cairo_matrix_copy (&texture->matrix, matrix);
	texture->base.changed = TRUE;

	return Ok;
}
Ejemplo n.º 8
0
GpStatus
gdip_texture_clone (GpBrush *brush, GpBrush **clonedBrush)
{
	GpTexture *result;
	GpTexture *texture;
	GpStatus status;

	if (!brush || !clonedBrush)
		return InvalidParameter;

	result = (GpTexture *) GdipAlloc (sizeof (GpTexture));
	if (result == NULL) {
		return OutOfMemory;
	}

	texture = (GpTexture *) brush;
	result->base = texture->base;
	result->wrapMode = texture->wrapMode;

	/* Let the clone create its own pattern. */
	result->pattern = NULL;
	result->base.changed = TRUE;

	gdip_cairo_matrix_copy (&result->matrix, &texture->matrix);
	result->rectangle.X = texture->rectangle.X;
	result->rectangle.Y = texture->rectangle.Y;
	result->rectangle.Width = texture->rectangle.Width;
	result->rectangle.Height = texture->rectangle.Height;

	result->image = NULL;
	status = GdipCloneImage (texture->image, &result->image);
	if (status != Ok) {
		if (result->image)
			GdipDisposeImage (result->image);
		GdipFree (result);
		result = NULL;
	} else {
		cairo_surface_reference (result->image->surface);
	}

	*clonedBrush = (GpBrush *) result;

	return status;
}
Ejemplo n.º 9
0
// coverity[+alloc : arg-*1]
GpStatus WINGDIPAPI
GdipClonePen (GpPen *pen, GpPen **clonepen)
{
	GpPen *result;

	if (!pen || !clonepen)
		return InvalidParameter;

	result = gdip_pen_new ();
	if (!result) {
		*clonepen = NULL;
		return OutOfMemory;
	}

	result->own_brush = pen->own_brush;
	result->color = pen->color;
	result->width = pen->width;
	result->miter_limit = pen->miter_limit;
	result->line_join = pen->line_join;
	result->dash_style = pen->dash_style;
	result->line_cap = pen->line_cap;
	result->end_cap = pen->end_cap;
	result->mode = pen->mode;
	result->dash_offset = pen->dash_offset;
	result->dash_count = pen->dash_count;
	result->own_dash_array = pen->own_dash_array;
	result->compound_count = pen->compound_count;
	result->unit = pen->unit;
	gdip_cairo_matrix_copy (&result->matrix, &pen->matrix);
	result->changed = pen->changed;

	/* Make a copy of dash array only if it is owned by the pen - i.e. it is not
	 * a global array. */
	if (pen->dash_count > 0 && pen->own_dash_array) {
		result->dash_array = (float *) GdipAlloc (pen->dash_count * sizeof (float));
		if (!result->dash_array)
			goto error;

		memcpy (result->dash_array, pen->dash_array, pen->dash_count * sizeof (float));
	}
	else
		result->dash_array = pen->dash_array;

	if (pen->compound_count > 0) {
		result->compound_array = (float *) GdipAlloc (pen->compound_count * sizeof (float));
		if (!result->compound_array)
			goto error;

		memcpy (result->compound_array, pen->compound_array, pen->compound_count * sizeof (float));
	}

	if (pen->custom_start_cap) {
		GpStatus status = GdipCloneCustomLineCap (pen->custom_start_cap, &result->custom_start_cap);
		if (status != Ok)
			goto error;
	}

	if (pen->custom_end_cap) {
		GpStatus status = GdipCloneCustomLineCap (pen->custom_end_cap, &result->custom_end_cap);
		if (status != Ok)
			goto error;
	}

	if (pen->own_brush) {
		GpSolidFill *oldBrush = (GpSolidFill *) pen->brush;
		GpStatus status = GdipCreateSolidFill (oldBrush->color, (GpSolidFill **) &result->brush);
		if (status != Ok)
			goto error;
	} else {
		result->brush = pen->brush;
	}

	*clonepen = result;
	return Ok;

error:
	GdipDeletePen (result);
	*clonepen = NULL;
	return OutOfMemory;
}
Ejemplo n.º 10
0
GpStatus
gdip_texture_setup (GpGraphics *graphics, GpBrush *brush)
{
	cairo_t		*ct;
	cairo_pattern_t	*pattern;
	GpTexture	*texture;
	GpImage		*img;
	GpStatus	status = Ok;
	BOOL		dispose_bitmap;

	if (!graphics || !brush || !graphics->ct)
		return InvalidParameter;

	texture = (GpTexture *) brush;
	img = texture->image;
	if (!img)
		return InvalidParameter;

	if (img->type != ImageTypeBitmap)
		return NotImplemented;

	if (gdip_is_an_indexed_pixelformat (img->active_bitmap->pixel_format)) {
		/* Unable to create a surface for the bitmap; it is an indexed image.
		 * Instead, it will first be converted to 32-bit RGB. */
		img = gdip_convert_indexed_to_rgb (img);
		if (!img)
			return OutOfMemory;

		gdip_bitmap_ensure_surface (img);
		dispose_bitmap = TRUE;
	} else {
		dispose_bitmap = FALSE;
	}

	ct = graphics->ct;

	/* We create the new pattern for brush, if the brush is changed
	 * or if pattern has not been created yet. */
	if (texture->base.changed || !texture->pattern) {
		if (texture->pattern)
			cairo_pattern_destroy (texture->pattern);

		switch (texture->wrapMode) {
			case WrapModeTile:
				status = draw_tile_texture (ct, img, texture);
				break;

			case WrapModeTileFlipX:
				status = draw_tile_flipX_texture (ct, img, texture);
				break;

			case WrapModeTileFlipY:
				status = draw_tile_flipY_texture (ct, img, texture);
				break;

			case WrapModeTileFlipXY:
				status = draw_tile_flipXY_texture (ct, img, texture);
				break;

			case WrapModeClamp:
				status = draw_clamp_texture (ct, img, texture);
				break;

			default:
				status = InvalidParameter;
		}
	}

	if (dispose_bitmap) {
		GdipDisposeImage((GpImage *)img);
	}

	if ((status != Ok) || (gdip_get_pattern_status(texture->pattern) != Ok)) {
		return GenericError;
	}

	pattern = texture->pattern;
	if (pattern != NULL) {
		/* got something to apply ? */
		if (!gdip_is_matrix_empty (&texture->matrix)) {
			cairo_matrix_t product;

			gdip_cairo_matrix_copy (&product, &texture->matrix);
			cairo_matrix_invert (&product);
			cairo_pattern_set_matrix (pattern, &product);
		}
		cairo_set_source (ct, pattern);
	}

	return gdip_get_status (cairo_status (ct));
}