diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | twin_primitive.c | 62 | ||||
-rw-r--r-- | twinint.h | 4 | ||||
-rw-r--r-- | xtwin.c | 19 |
4 files changed, 75 insertions, 21 deletions
@@ -1,5 +1,16 @@ 2004-10-04 Keith Packard <keithp@keithp.com> + * twin_primitive.c: (in_over), (over): + * twinint.h: + Recognize a few special cases to speed up operations + + * xtwin.c: (twin_clock_set_transform), (twin_clock_minute_angle), + (twin_clock_face), (twin_clock): + Fix angular problems in hand position by rotating everything 90 + degrees. + +2004-10-04 Keith Packard <keithp@keithp.com> + * twin_font.c: (twin_has_ucs4), (twin_path_ucs4): Delete old glyph representation support code. diff --git a/twin_primitive.c b/twin_primitive.c index 5c94784..34d75ae 100644 --- a/twin_primitive.c +++ b/twin_primitive.c @@ -34,15 +34,38 @@ in_over (twin_argb32_t dst, uint16_t t1, t2, t3, t4; twin_a8_t a; - src = (twin_in(src,0,msk,t1) | - twin_in(src,8,msk,t2) | - twin_in(src,16,msk,t3) | - twin_in(src,24,msk,t4)); + switch (msk) { + case 0: + return dst; + case 0xff: + break; + default: + src = (twin_in(src,0,msk,t1) | + twin_in(src,8,msk,t2) | + twin_in(src,16,msk,t3) | + twin_in(src,24,msk,t4)); + break; + } + if (!src) + return dst; a = ~(src >> 24); - return (twin_over (src, dst, 0, a, t1) | - twin_over (src, dst, 8, a, t2) | - twin_over (src, dst, 16, a, t3) | - twin_over (src, dst, 24, a, t4)); + switch (a) { + case 0: + return src; + case 0xff: + dst = (twin_add (src, dst, 0, t1) | + twin_add (src, dst, 8, t2) | + twin_add (src, dst, 16, t3) | + twin_add (src, dst, 24, t4)); + break; + default: + dst = (twin_over (src, dst, 0, a, t1) | + twin_over (src, dst, 8, a, t2) | + twin_over (src, dst, 16, a, t3) | + twin_over (src, dst, 24, a, t4)); + break; + } + return dst; } static twin_argb32_t __inline @@ -64,11 +87,26 @@ over (twin_argb32_t dst, uint16_t t1, t2, t3, t4; twin_a8_t a; + if (!src) + return dst; a = ~(src >> 24); - return (twin_over (src, dst, 0, a, t1) | - twin_over (src, dst, 8, a, t2) | - twin_over (src, dst, 16, a, t3) | - twin_over (src, dst, 24, a, t4)); + switch (a) { + case 0: + return src; + case 0xff: + dst = (twin_add (src, dst, 0, t1) | + twin_add (src, dst, 8, t2) | + twin_add (src, dst, 16, t3) | + twin_add (src, dst, 24, t4)); + break; + default: + dst = (twin_over (src, dst, 0, a, t1) | + twin_over (src, dst, 8, a, t2) | + twin_over (src, dst, 16, a, t3) | + twin_over (src, dst, 24, a, t4)); + break; + } + return dst; } static twin_argb32_t __inline @@ -82,6 +82,10 @@ typedef signed char twin_gfixed_t; (((t) = twin_int_mult(twin_get_8(d,i),(m),(t)) + twin_get_8(s,i)),\ (twin_argb32_t) twin_sat (t) << (i)) +#define twin_add(s,d,i,t) \ + (((t) = twin_get_8(d,i) + twin_get_8(s,i)),\ + (twin_argb32_t) twin_sat (t) << (i)) + #define twin_argb32_to_rgb16(s) ((((s) >> 3) & 0x001f) | \ (((s) >> 5) & 0x07e0) | \ (((s) >> 8) & 0xf800)) @@ -61,6 +61,7 @@ twin_clock_set_transform (twin_pixmap_t *clock, twin_path_translate (path, D(1) + TWIN_CLOCK_BORDER_WIDTH * 3, D(1) + TWIN_CLOCK_BORDER_WIDTH * 3); + twin_path_rotate (path, -TWIN_ANGLE_90); } static void @@ -103,7 +104,7 @@ twin_clock_hand (twin_pixmap_t *clock, static twin_angle_t twin_clock_minute_angle (int min) { - return min * TWIN_ANGLE_360 / 60 - TWIN_ANGLE_90; + return min * TWIN_ANGLE_360 / 60; } static void @@ -128,15 +129,15 @@ twin_clock_face (twin_pixmap_t *clock) static char *label = "twin"; twin_path_empty (path); - twin_path_rotate (path, twin_degrees_to_angle (-11)); + twin_path_rotate (path, twin_degrees_to_angle (-11) + TWIN_ANGLE_90); twin_path_set_font_size (path, D(0.5)); twin_path_set_font_style (path, TWIN_TEXT_UNHINTED|TWIN_TEXT_OBLIQUE); twin_text_metrics_utf8 (path, label, &metrics); height = metrics.ascent + metrics.descent; width = metrics.right_side_bearing - metrics.left_side_bearing; - twin_path_move (path, -width / 2, metrics.ascent - height/2); - twin_path_draw (path, width / 2, metrics.ascent - height/2); + twin_path_move (path, -width / 2, metrics.ascent - height/2 + D(0.01)); + twin_path_draw (path, width / 2, metrics.ascent - height/2 + D(0.01)); twin_paint_stroke (clock, TWIN_CLOCK_WATER_UNDER, path, D(0.02)); twin_path_empty (path); @@ -205,11 +206,9 @@ twin_clock (twin_screen_t *screen, int x, int y, int w, int h) localtime_r(&tv.tv_sec, &t); second_angle = ((t.tm_sec * 100 + tv.tv_usec / 10000) * - TWIN_ANGLE_360) / 6000 - TWIN_ANGLE_90; + TWIN_ANGLE_360) / 6000; minute_angle = twin_clock_minute_angle (t.tm_min) + second_angle / 60; - hour_angle = (t.tm_hour * TWIN_ANGLE_360 / 12 + - (minute_angle + TWIN_ANGLE_90) / 12 - - TWIN_ANGLE_90); + hour_angle = (t.tm_hour * TWIN_ANGLE_360 + minute_angle) / 12; twin_clock_face (clock); twin_clock_hand (clock, hour_angle, D(0.4), D(0.07), D(0.01), TWIN_CLOCK_HOUR, TWIN_CLOCK_HOUR_OUT); @@ -222,7 +221,9 @@ twin_clock (twin_screen_t *screen, int x, int y, int w, int h) gettimeofday (&tv, NULL); - usleep (1000000 - tv.tv_usec); +#define INTERVAL 1000000 + + usleep (INTERVAL - (tv.tv_usec % INTERVAL)); } nclock--; } |