cairo image drawing corrections.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24301 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2006-12-31 17:48:58 +00:00
parent fc3254d9fc
commit 5d958c119d
2 changed files with 53 additions and 52 deletions

View file

@ -1,3 +1,12 @@
2006-12-31 Fred Kiefer <FredKiefer@gmx.de>
* Source/cairo/CairoGState.m (-setOffset:, -DPSinitmatrix): Use
cairo functions to handle offset.
* Source/cairo/CairoGState.m (-GSCurrentCTM): Changed order of
transformations.
* Source/cairo/CairoGState.m (-compositeGState:...fraction:):
Corrected cases for flipped surface.
2006-12-31 Richard Frith-Macdonald <rfm@gnu.org> 2006-12-31 Richard Frith-Macdonald <rfm@gnu.org>
* configure.ac: Explicitly add freetype libs and flags when building * configure.ac: Explicitly add freetype libs and flags when building

View file

@ -1,4 +1,3 @@
/* /*
* CairoGState.m * CairoGState.m
@ -125,6 +124,19 @@
[self DPSinitgraphics]; [self DPSinitgraphics];
} }
- (void) setOffset: (NSPoint)theOffset
{
NSSize size = {0, 0};
if (_surface != nil)
{
size = [_surface size];
}
[super setOffset: theOffset];
cairo_surface_set_device_offset([_surface surface], -theOffset.x,
theOffset.y - size.height);
}
/* /*
* Color operations * Color operations
*/ */
@ -395,22 +407,15 @@
{ {
cairo_matrix_t local_matrix; cairo_matrix_t local_matrix;
// cairo draws the other way around.
cairo_matrix_init_scale(&local_matrix, 1, -1); cairo_matrix_init_scale(&local_matrix, 1, -1);
if (_surface != nil) if (_surface != nil)
{ {
cairo_matrix_translate(&local_matrix, -offset.x, -offset.y); cairo_matrix_translate(&local_matrix, 0, -[_surface size].height);
} }
cairo_set_matrix(_ct, &local_matrix); cairo_set_matrix(_ct, &local_matrix);
} }
else if (_surface != nil)
{
cairo_matrix_t local_matrix;
cairo_matrix_init_translate(&local_matrix, -offset.x,
offset.y - [_surface size].height);
cairo_set_matrix(_ct, &local_matrix);
}
} }
- (void) DPSrotate: (float)angle - (void) DPSrotate: (float)angle
@ -437,24 +442,20 @@
transform = [NSAffineTransform transform]; transform = [NSAffineTransform transform];
cairo_get_matrix(_ct, &local_matrix); cairo_get_matrix(_ct, &local_matrix);
/*
NSLog(@"Before flip %f %f, %f, %f, %f, %f", local_matrix.xx, local_matrix.yx, // Undo changes in DPSinitmatrix
local_matrix.xy, local_matrix.yy, local_matrix.x0, local_matrix.y0);
*/
if (!viewIsFlipped) if (!viewIsFlipped)
{ {
if (_surface)
{
cairo_matrix_init_translate(&flip_matrix, 0, -[_surface size].height);
cairo_matrix_multiply(&local_matrix, &local_matrix, &flip_matrix);
}
cairo_matrix_init_scale(&flip_matrix, 1, -1); cairo_matrix_init_scale(&flip_matrix, 1, -1);
cairo_matrix_multiply(&local_matrix, &local_matrix, &flip_matrix); cairo_matrix_multiply(&local_matrix, &local_matrix, &flip_matrix);
if (_surface)
{
cairo_matrix_init_translate(&flip_matrix, 0, [_surface size].height);
cairo_matrix_multiply(&local_matrix, &local_matrix, &flip_matrix);
} }
/* }
NSLog(@"After flip %f %f, %f, %f, %f, %f", local_matrix.xx, local_matrix.yx,
local_matrix.xy, local_matrix.yy, local_matrix.x0, local_matrix.y0);
*/
tstruct.m11 = local_matrix.xx; tstruct.m11 = local_matrix.xx;
tstruct.m12 = local_matrix.yx; tstruct.m12 = local_matrix.yx;
tstruct.m21 = local_matrix.xy; tstruct.m21 = local_matrix.xy;
@ -972,41 +973,37 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
double minx, miny; double minx, miny;
double width, height; double width, height;
cairo_save(_ct);
cairo_new_path(_ct);
_set_op(_ct, op);
src = cairo_get_target(source->_ct);
if (src == cairo_get_target(_ct))
{
/* /*
NSLog(@"Copy onto self");
NSLog(NSStringFromRect(aRect)); NSLog(NSStringFromRect(aRect));
NSLog(NSStringFromPoint(aPoint)); NSLog(NSStringFromPoint(aPoint));
NSLog(@"src %p(%p,%@) des %p(%p,%@)", NSLog(@"src %p(%p,%@) des %p(%p,%@)",
source,cairo_get_target(source->_ct),NSStringFromSize([source->_surface size]), source,cairo_get_target(source->_ct),NSStringFromSize([source->_surface size]),
self,cairo_get_target(_ct),NSStringFromSize([_surface size])); self,cairo_get_target(_ct),NSStringFromSize([_surface size]));
*/ */
cairo_save(_ct);
//cairo_new_path(_ct);
_set_op(_ct, op);
src = cairo_get_target(source->_ct);
if (src == cairo_get_target(_ct))
{
//NSLog(@"Copy onto self");
} }
minx = NSMinX(aRect); minx = NSMinX(aRect);
miny = NSMinY(aRect); miny = NSMinY(aRect);
width = NSWidth(aRect); width = NSWidth(aRect);
height = NSHeight(aRect); height = NSHeight(aRect);
/*
cairo_user_to_device(source->_ct, &minx, &miny);
cairo_user_to_device_distance(source->_ct, &width, &height);
cairo_device_to_user(_ct, &minx, &miny);
cairo_device_to_user_distance(_ct, &width, &height);
NSLog(@"Rect %@ = %f, %f, %f, %f", NSStringFromRect(aRect), minx, miny, width, height);
*/
if (viewIsFlipped) if (viewIsFlipped)
{ {
/*
if (!source->viewIsFlipped) if (!source->viewIsFlipped)
{ {
// Undo flipping of the source coordinate system cairo_set_source_surface(_ct, src, aPoint.x - minx, aPoint.y - miny - height);
}
else
{
// Both flipped
cairo_pattern_t *cpattern; cairo_pattern_t *cpattern;
cairo_matrix_t local_matrix; cairo_matrix_t local_matrix;
@ -1017,18 +1014,13 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
cairo_set_source(_ct, cpattern); cairo_set_source(_ct, cpattern);
cairo_pattern_destroy(cpattern); cairo_pattern_destroy(cpattern);
} }
else
*/
{
cairo_set_source_surface(_ct, src, aPoint.x - minx, aPoint.y - miny - height);
}
cairo_rectangle(_ct, aPoint.x, aPoint.y - height, width, height); cairo_rectangle(_ct, aPoint.x, aPoint.y - height, width, height);
} }
else else
{ {
if (!source->viewIsFlipped) if (!source->viewIsFlipped)
{ {
// Undo flipping of the source coordinate system // Both non-flipped.
cairo_pattern_t *cpattern; cairo_pattern_t *cpattern;
cairo_matrix_t local_matrix; cairo_matrix_t local_matrix;