mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
Copy dash and clipping.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@25461 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
355aa2db1e
commit
ce58b92800
2 changed files with 97 additions and 43 deletions
|
@ -1,3 +1,8 @@
|
|||
2007-09-06 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/cairo/CairoGState.m (-copyWithZone:): Copy dash and clipping.
|
||||
* Source/cairo/CairoGState.m (-_setPath:): Clear the cairo path.
|
||||
|
||||
2007-09-05 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/x11/XGGeneric.h: Add ivars for event time keeping.
|
||||
|
|
|
@ -91,6 +91,8 @@
|
|||
{
|
||||
CairoGState *copy = (CairoGState *)[super copyWithZone: zone];
|
||||
|
||||
RETAIN(_surface);
|
||||
|
||||
if (_ct)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
@ -108,11 +110,22 @@
|
|||
{
|
||||
cairo_path_t *cpath;
|
||||
cairo_matrix_t local_matrix;
|
||||
cairo_rectangle_list_t *clip_rects;
|
||||
int num_dashes;
|
||||
|
||||
cairo_get_matrix(_ct, &local_matrix);
|
||||
cairo_set_matrix(copy->_ct, &local_matrix);
|
||||
|
||||
cpath = cairo_copy_path(_ct);
|
||||
status = cpath->status;
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
NSLog(@"Cairo status %s in copy path", cairo_status_to_string(status));
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_append_path(copy->_ct, cpath);
|
||||
}
|
||||
cairo_path_destroy(cpath);
|
||||
|
||||
cairo_set_operator(copy->_ct, cairo_get_operator(_ct));
|
||||
|
@ -124,11 +137,45 @@
|
|||
cairo_set_line_join(copy->_ct, cairo_get_line_join(_ct));
|
||||
cairo_set_miter_limit(copy->_ct, cairo_get_miter_limit(_ct));
|
||||
|
||||
// FIXME: In cairo 1.2.4 there is no way get the dash or copy it.
|
||||
// There also is no way to get the current clipping path
|
||||
// In cairo 1.4 there is a way get the dash.
|
||||
num_dashes = cairo_get_dash_count(_ct);
|
||||
if (num_dashes != 0)
|
||||
{
|
||||
double dash_offset;
|
||||
GS_BEGINITEMBUF(dashes, num_dashes, double);
|
||||
|
||||
dashes = (double *)malloc(sizeof(double) * num_dashes);
|
||||
cairo_get_dash(_ct, dashes, &dash_offset);
|
||||
cairo_set_dash (copy->_ct, dashes, num_dashes, dash_offset);
|
||||
GS_ENDITEMBUF();
|
||||
}
|
||||
|
||||
// In cairo 1.4 there also is a way to get the current clipping path
|
||||
clip_rects = cairo_copy_clip_rectangle_list(_ct);
|
||||
status = clip_rects->status;
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
NSLog(@"Cairo status %s in copy clip", cairo_status_to_string(status));
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < clip_rects->num_rectangles; i++)
|
||||
{
|
||||
cairo_rectangle_t rect = clip_rects->rectangles[i];
|
||||
NSSize size = [_surface size];
|
||||
|
||||
// This strange computation is due to the device offset.
|
||||
cairo_rectangle(copy->_ct, rect.x,
|
||||
rect.y + 2*(offset.y - size.height),
|
||||
rect.width, rect.height);
|
||||
cairo_clip(copy->_ct);
|
||||
}
|
||||
}
|
||||
cairo_rectangle_list_destroy(clip_rects);
|
||||
}
|
||||
}
|
||||
RETAIN(_surface);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -628,6 +675,8 @@
|
|||
[self _adjustPath:offs];
|
||||
}
|
||||
|
||||
// reset current cairo path
|
||||
cairo_new_path(_ct);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSBezierPathElement type;
|
||||
|
|
Loading…
Reference in a new issue