[futurebasic] Re: [FB] Slow QuickDraw

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 1999 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Sun, 31 Jan 1999 17:46:45 +1300
>I'm drawing a world map from a handle containing 1311 polygons (polylines
>mostly) defining most of the continents, islands, countries, states etc.
>It takes FB or the compiled app. about 2 seconds on an 8600/250 or a
>7300/200 to draw the while thing.  Its about 264kB of data.
>This seems inordinately slow to me.

>1) Am I out of line expecting faster than this?

I deduce that you are drawing roughly 50000 line segments. That's about 25
lines per millisecond, which doesn't seem unreasonably slow.

>2) Is drawing to a GWorld actually faster than to the screen perhaps?

Rick Brown said:-
>Sending the same drawing commands to an offscreen GWorld would not speed
>things up, I think.

Reluctant as I am to disagree with Rick, a direct comparison shows the
answer to be "yes, and by a substantial factor"  ---   4-5 times faster (on
an iMac). See the comparison program below. A further advantage of the GW
method is that having drawn the polys in the GWorld you can then refresh
your window with a single call to FN CopyGW, which is _very_ fast.

>3) Does the non-PPC nature of FB-II come into play here. Or should
>Quickdraw (I assume it's native by now)  operate at full speed once the
>CALL is placed?

FramePoly is native in OS 8.5.  The overhead in your program is negligible
in comparison with the line drawing in FramePoly.

Robert

'-------------------------------------
LOCAL FN MakeAndClearGWorld&(rectPtr&)
 DIM offPort&
 LONG IF FN NEWGWORLD(offPort&,0,#rectPtr&,0,0,0)=_noErr
  LONG IF (offPort&<>_nil)
   CALL SETGWORLD(offPort&,0)
   CALL FORECOLOR(_blackColor)
   CALL BACKCOLOR(_whiteColor)
   CALL ERASERECT(#rectPtr&)
  END IF
 XELSE
  offPort&=_nil
 END IF
END FN=offPort&

LOCAL FN CopyGW (sPort&,dPort&, sRPtr&,dRPtr&)
 LONG IF FN LOCKPIXELS(FN GETGWORLDPIXMAP(sPort&))
  CALL COPYBITS(#sPort&+2,#dPort&+2,# sRPtr&,#dRPtr&,_srcCopy,0)
  CALL UNLOCKPIXELS(FN GETGWORLDPIXMAP(sPort&))
 END IF
END FN

LOCAL FN MakePoly& ' make a huge polygon
 DIM j,polyH&
 polyH&=FN OPENPOLY
 CALL MOVETO(0,0)
 FOR j=1 TO 8000
  CALL LINETO(RND(579),RND(419))
 NEXT
 CALL LINETO(0,0)
 CALL CLOSEPOLY
END FN=polyH&

WINDOW 1,"",(0,0)-(600,440)
DIM rect;8, polyH&, tk1&, tk2&
DIM offPort&,currPort&,GDevice&
polyH&=FN MakePoly&

tk1&=FN TICKCOUNT
CALL FRAMEPOLY (polyH&)
tk1&=FN TICKCOUNT-tk1&

CLS
CALL SETRECT(rect, 0,0,580,420)
CALL GETGWORLD(currPort&,GDevice&)
offPort&=FN MakeAndClearGWorld&(@rect)
tk2&=FN TICKCOUNT
LONG IF offPort&
 CALL FRAMEPOLY (polyH&)
 CALL SETGWORLD(currPort&,0)
 FN CopyGW (offPort&,currPort&,@rect,@rect)
 CALL DISPOSEGWORLD(offPort&)
END IF
tk2&=FN TICKCOUNT-tk2&

CALL TEXTMODE(_srcCopy)
PRINT tk1& "direct"
PRINT tk2& "GW"

CALL KILLPOLY(polyH&)
DO : UNTIL FN BUTTON