Debian Codegraph @

NOTES

raw
1 ===========
2 Buici NOTES $Id: NOTES,v 1.3 1997/10/15 22:33:28 elf Exp $
3 ===========
4
5 by Marc Singer, [email protected]
6 12 October 1997 (date of last revision)
7
8 Why write another clock program? Have you looked at the published
9 ones? At the time I started on this track, the best one I found
10 doesn't draw a round face. A clock must
11
12 1) Draw a correct representation of the clock face
13 2) Support configurable clock face elements
14 3) Respond to some sort of mousing request to display today's date
15
16 Nothing came close, so I wrote Buici. The rest of this document
17 describes some of the interesting design issues and notes about
18 enhancements.
19
20 - Fetching the current time
21 I'm using gettimeofday () which returns the seconds since
22 midnight, January 1, 1970, do the timezone and daylight savings
23 corrections, and use this number of seconds to position the clock
24 hands. I need to figure out how to do daylight savings
25 corrections for non-US zones. I could use another call that
26 already does the conversion, but this may add some calculation
27 that I can omit if I do the math myself.
28
29 - Rendering timer
30 We set an interval timer to interrupt us every 100ms, or so. At
31 this point we fetch the current value for seconds and decide if
32 the time has changed. If so we draw into the m_pixmap and copy it
33 to the screen.
34
35 - Exposure
36 Since we draw to the screen when the timer alarm fires we need to
37 be concerned about race conditions. The simple solution is to set
38 a flag when we receive an exposure and check this when we next
39 receive a timer alarm. Thus, we draw the clock face when it
40 changes or when we are exposed.
41
42 - SIN COS and correct face representation
43 The rendering routine uses floating point math to locate the
44 positions of the clock face elements. I spent a few hours trying
45 to make everything look good, but found that the hands were not
46 always pointing straight at the hour marks. All of the default
47 hands are longer than face radius, extending away from the mark
48 that the hand indicates. For some reason not yet understood, the
49 angle of this short line segment is not the same as the segment
50 extending toward the mark. We solved the display problem by
51 drawing lines that cross the face center in two pieces.
52
53 - Efficiency
54 There is something very inefficient about the drawing. For some
55 reason the NCD pauses a lot when we use the Buici clock. I'm
56 thinking we either need to batch the strokes, use more backing
57 storage for the fixed face elements, or check that we are updating
58 only once a second.
59 * This has been resolved. On the NCD, the problem appears to be
60 drawing. Batching the line segments into a fewer number of
61 requests did not affect the clock performance. Using a backing
62 pixmap for the clock marks does help. We note that this
63 requires that the server has memory for the backing pixmap.
64 Should the clock be very large, the backing pixmap may be
65 excessively large.
66 * We need to evaluate the drawing performance of other servers.
67 It may be OK to fallback to drawing marks every second because
68 more contemporary servers are more efficient.
69 * An alternative solution to the size of the backing store is to
70 use color mapped bitmaps for marks and BLT them by color instead
71 of using XCopyArea. As long as we have fewer than depth layers,
72 the extra work may be justified.
73
74