mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-04 04:00:19 +01:00
[fixpt] Use _cairo_fixed_mul insted of manual multiplication
This commit is contained in:
parent
0048a26a44
commit
9c38aa3b96
3 changed files with 14 additions and 24 deletions
|
|
@ -71,7 +71,6 @@ typedef uint32_t cairo_fixed_unsigned_t;
|
|||
* No configurable bits below this.
|
||||
*/
|
||||
|
||||
|
||||
#if (CAIRO_FIXED_BITS != 32)
|
||||
# error CAIRO_FIXED_BITS must be 32, and the type must be a 32-bit type.
|
||||
# error To remove this limitation, you will have to fix the tesselator.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2002 University of Southern California
|
||||
|
|
@ -509,25 +510,19 @@ _cairo_path_fixed_offset_and_scale (cairo_path_fixed_t *path,
|
|||
{
|
||||
cairo_path_buf_t *buf = path->buf_head;
|
||||
int i;
|
||||
cairo_int64_t i64temp;
|
||||
cairo_fixed_t fixedtemp;
|
||||
|
||||
while (buf) {
|
||||
for (i = 0; i < buf->num_points; i++) {
|
||||
if (scalex == CAIRO_FIXED_ONE) {
|
||||
buf->points[i].x += offx;
|
||||
} else {
|
||||
fixedtemp = buf->points[i].x + offx;
|
||||
i64temp = _cairo_int32x32_64_mul (fixedtemp, scalex);
|
||||
buf->points[i].x = _cairo_int64_to_int32(_cairo_int64_rsl (i64temp, 16));
|
||||
buf->points[i].x = _cairo_fixed_mul (buf->points[i].x + offx, scalex);
|
||||
}
|
||||
|
||||
if (scaley == CAIRO_FIXED_ONE) {
|
||||
buf->points[i].y += offy;
|
||||
} else {
|
||||
fixedtemp = buf->points[i].y + offy;
|
||||
i64temp = _cairo_int32x32_64_mul (fixedtemp, scaley);
|
||||
buf->points[i].y = _cairo_int64_to_int32(_cairo_int64_rsl (i64temp, 16));
|
||||
buf->points[i].y = _cairo_fixed_mul (buf->points[i].y + offy, scaley);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/*
|
||||
* Copyright © 2002 Keith Packard
|
||||
* Copyright © 2007 Red Hat, Inc.
|
||||
|
|
@ -348,21 +349,16 @@ _cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
|
|||
cairo_fixed_t ysc = _cairo_fixed_from_double (sy);
|
||||
|
||||
for (i = 0; i < num_traps; i++) {
|
||||
#define FIXED_MUL(_a, _b) \
|
||||
(_cairo_int64_to_int32(_cairo_int64_rsl(_cairo_int32x32_64_mul((_a), (_b)), 16)))
|
||||
|
||||
offset_traps[i].top = FIXED_MUL(src_traps[i].top + yoff, ysc);
|
||||
offset_traps[i].bottom = FIXED_MUL(src_traps[i].bottom + yoff, ysc);
|
||||
offset_traps[i].left.p1.x = FIXED_MUL(src_traps[i].left.p1.x + xoff, xsc);
|
||||
offset_traps[i].left.p1.y = FIXED_MUL(src_traps[i].left.p1.y + yoff, ysc);
|
||||
offset_traps[i].left.p2.x = FIXED_MUL(src_traps[i].left.p2.x + xoff, xsc);
|
||||
offset_traps[i].left.p2.y = FIXED_MUL(src_traps[i].left.p2.y + yoff, ysc);
|
||||
offset_traps[i].right.p1.x = FIXED_MUL(src_traps[i].right.p1.x + xoff, xsc);
|
||||
offset_traps[i].right.p1.y = FIXED_MUL(src_traps[i].right.p1.y + yoff, ysc);
|
||||
offset_traps[i].right.p2.x = FIXED_MUL(src_traps[i].right.p2.x + xoff, xsc);
|
||||
offset_traps[i].right.p2.y = FIXED_MUL(src_traps[i].right.p2.y + yoff, ysc);
|
||||
|
||||
#undef FIXED_MUL
|
||||
offset_traps[i].top = _cairo_fixed_mul (src_traps[i].top + yoff, ysc);
|
||||
offset_traps[i].bottom = _cairo_fixed_mul (src_traps[i].bottom + yoff, ysc);
|
||||
offset_traps[i].left.p1.x = _cairo_fixed_mul (src_traps[i].left.p1.x + xoff, xsc);
|
||||
offset_traps[i].left.p1.y = _cairo_fixed_mul (src_traps[i].left.p1.y + yoff, ysc);
|
||||
offset_traps[i].left.p2.x = _cairo_fixed_mul (src_traps[i].left.p2.x + xoff, xsc);
|
||||
offset_traps[i].left.p2.y = _cairo_fixed_mul (src_traps[i].left.p2.y + yoff, ysc);
|
||||
offset_traps[i].right.p1.x = _cairo_fixed_mul (src_traps[i].right.p1.x + xoff, xsc);
|
||||
offset_traps[i].right.p1.y = _cairo_fixed_mul (src_traps[i].right.p1.y + yoff, ysc);
|
||||
offset_traps[i].right.p2.x = _cairo_fixed_mul (src_traps[i].right.p2.x + xoff, xsc);
|
||||
offset_traps[i].right.p2.y = _cairo_fixed_mul (src_traps[i].right.p2.y + yoff, ysc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue