tips
[Top] [All Lists]

REALbasic Tip: Improving graphics performance on Mac OS X

To: "REALbasic Tips" <realbasic-tips at lists dot realsoftware dot com>
Subject: REALbasic Tip: Improving graphics performance on Mac OS X
From: Geoff Perlman <geoff at realsoftware dot com>
Date: Thu, 13 Mar 2003 17:45:33 -0600
REALbasic 5 uses the Quartz graphics engine on Mac OS X when you call
methods of the graphics class such as DrawLine, DrawRect, DrawOval, etc. The
Quartz engine uses anti-aliasing to make lines look smoother. The downside
is that this takes longer than the way lines were rendered in earlier
versions of REALbasic. For most applications, the Quartz engine will be fast
enough and it generally provides a more native look on Mac OS X. However, if
you're feeling the need for speed, you can significantly boost the
performance of the drawing methods by turning off the Quartz rendering
engine and using the old QuickDraw rendering engine instead. This is done by
setting the UseOldRenderer property of the graphics class to true before you
begin drawing.

In a simple example (see the code below) that draws an oval over and over,
the performance was 10 times faster using the old renderer. Your mileage may
vary.

To try this example, drag a canvas onto a window, change the size to 300 by
300 and put the following code in the action event of a pushbutton:

  dim i, start, stop as integer
  
  Canvas1.Graphics.UseOldRenderer = false
  start = ticks
  for i = 1 to 1000
    Canvas1.Graphics.DrawOval 0, 0, 200, 200
  next
  stop = ticks
  MsgBox "Total Time: " + str(stop - start)

Run the example, then change UseOldRenderer property to true instead of
false and run it again. And while the example is drawing a simple oval,
you'll get the same performance gain when drawing a picture with the
DrawPicture method. The Quartz rendering engine can also be turned on and
off throughout your code to improve the performance of some methods and not
others.

This tip was inspired by Joe Strout.
-- 
Geoff Perlman
President and CEO
REAL Software, Inc.
512-328-7325 x711 (voice)
512-328-7372 (fax)


 - - - - - - - - - -
Got a useful tip to share? Send it to us at:
<REALbasic-tips at lists dot realsoftware dot com>.

To unsubscribe from the Tips list, send an email to 
<mailto:realbasic-tips-off at lists dot realsoftware dot com>

<Prev in Thread] Current Thread [Next in Thread>
  • REALbasic Tip: Improving graphics performance on Mac OS X, Geoff Perlman <=