I'm looking at updating our ruler control. Each document window gets
a horizontal ruler across the top and a vertical ruler across the
side. They change their displayed origin based on the scale and
scroll position of the document within the window. They look like a
standard ruler; a bunch of ticks with text labels at major
dimensions. They also display guides that follow the mouse, and icons
that show the position of guides or tabs and paragraph margins for
text flows.
Most of the time, the ruler remains unchanged with only the mouse
guides changing. The only time the rulers need to totally draw is
when the document is scrolled, the scale changed, or [de]active text
flows. Our existing model keeps the background (gray gradient, ticks,
labels) in a gworld, then composites that background into another
gworld, draws the mouse guides and icons, then finally blits that to
the window. Everything is drawn with QD.
To make them work with our newer model of drawing all custom controls
with Quartz, I drag the final gworld via a CGImageRef and data
provider that reads the data from the gworld. This seems speedy
enough (on a dual 2G G5 at least:).
What I'm toying with is changing the gworlds to CGImageRefs or
CGBitmapContextRefs. (I currently can't figure that out, because one
of the docs says you can draw a CGBitmapContextRef with
CGContextDrawImage, but that just crashes required a cast too).) Can
anyone tell me if it would be faster to draw all the background stuff
(gray gradient, ticks, labels) straight to the window context every
time, or would caching it in some type of Quartz "offscreen" and
drawing that to the window context be faster? Keep in mind that each
ruler can show a few hundred ticks and a couple dozen text labels
when zoomed way out, so that's a lot of calls to draw each line as a
path and each label via HIThemeDrawTextBox.
I don't know much about the internals of Quartz 2D, but it sure seems
like blitting a bitmap would be much faster than hundreds of
individual path strokes.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden