mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-01 10:18:09 +02:00
Fix close-path failure by adding explicit move_to after close_path.
Besides the bug fix, this is a user-visible change since the new move_to element after the close_path element can be seen in the results of cairo_copy_path, so we document that here. We are also careful to fix up _cairo_path_fixed_line_to to defer to _cairo_path_fixed_move_to to avoid letting the last_move_point state get stale. This avoids introducing the second bug that is also tested by the close-path test case.
This commit is contained in:
parent
200a2d811e
commit
53f74e59fa
2 changed files with 19 additions and 4 deletions
|
|
@ -228,8 +228,13 @@ _cairo_path_fixed_line_to (cairo_path_fixed_t *path,
|
|||
point.x = x;
|
||||
point.y = y;
|
||||
|
||||
/* When there is not yet a current point, the line_to operation
|
||||
* becomes a move_to instead. Note: We have to do this by
|
||||
* explicitly calling into _cairo_path_fixed_line_to to ensure
|
||||
* that the last_move_point state is updated properly.
|
||||
*/
|
||||
if (! path->has_current_point)
|
||||
status = _cairo_path_fixed_add (path, CAIRO_PATH_OP_MOVE_TO, &point, 1);
|
||||
status = _cairo_path_fixed_move_to (path, point.x, point.y);
|
||||
else
|
||||
status = _cairo_path_fixed_add (path, CAIRO_PATH_OP_LINE_TO, &point, 1);
|
||||
|
||||
|
|
@ -328,9 +333,11 @@ _cairo_path_fixed_close_path (cairo_path_fixed_t *path)
|
|||
if (status)
|
||||
return status;
|
||||
|
||||
path->current_point.x = path->last_move_point.x;
|
||||
path->current_point.y = path->last_move_point.y;
|
||||
path->has_current_point = TRUE;
|
||||
status = _cairo_path_fixed_move_to (path,
|
||||
path->last_move_point.x,
|
||||
path->last_move_point.y);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1645,6 +1645,14 @@ cairo_stroke_to_path (cairo_t *cr)
|
|||
*
|
||||
* If there is no current point before the call to cairo_close_path,
|
||||
* this function will have no effect.
|
||||
*
|
||||
* Note: As of cairo version 1.2.4 any call to cairo_close_path will
|
||||
* place an explicit MOVE_TO element into the path immediately after
|
||||
* the CLOSE_PATH element, (which can be seen in cairo_copy_path() for
|
||||
* example). This can simplify path processing in some cases as it may
|
||||
* not be necessary to save the "last move_to point" during processing
|
||||
* as the MOVE_TO immediately after the CLOSE_PATH will provide that
|
||||
* point.
|
||||
**/
|
||||
void
|
||||
cairo_close_path (cairo_t *cr)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue