Article View: comp.sys.mac
Article #22905Color CopyBits Is Too Slow!
From: Juri Munkki
Date: Sun, 06 Dec 1987 21:13
Date: Sun, 06 Dec 1987 21:13
76 lines
2328 bytes
2328 bytes
I experimented with offscreen pixmaps today. It seems that Color
Quickdraw is very flexible, but too slow for good animation. Most of the
overhead comes from color matching and conversion. I guess I could write
my own color matching routine, but I think there should be a fast way to
do a simple copy operation.
In most painting programs the actual painting could be done on an
offscreen bitmap with the same color table as the best gDevice.
It takes about twice as much time to do a copybits in srcCopy mode than
it takes in the srcXor mode. Below is a short program that draws to an
offscreen pixmap and then copies it back to the screen. Try different
transfer modes and note the speed difference. The code is written in LS
C 2.13. Even srcXor, which is the fastest usable mode, is too slow for
really high quality animation.
How can it be done faster?
#include <MacTypes.h>
#include <QuickDraw.h>
#include <Color.h>
#include <WindowMgr.h>
WindowPtr onScreen;
CGrafPtr offS;
RGBColor temp;
PixMapPtr offP;
void main()
{
int i;
InitGraf(&thePort); InitCursor();
InitFonts(); InitWindows();
onScreen=GetNewWindow(1000,0L,-1);
offS=(CGrafPtr)NewPtr(sizeof(*offS));
OpenCPort(offS);
HLock(offS->portPixMap);
offP=*(offS->portPixMap);
SetRect(&offP->bounds,0,0,256,256);
PortSize(256,256);
offP->rowBytes=32768L+256;
offP->baseAddr=NewPtr(65536L);
EraseRect(&offS->portRect);
temp.blue=65535;
temp.red=0;
temp.green=0;
RGBForeColor(&temp);
for(i=0;i<256;i+=4)
{ MoveTo(i,0);
LineTo(255-i,255);
}
SysBeep(10);
HideCursor();
for(i=100;i;i--)
CopyBits(&((GrafPtr)offS)->portBits,&onScreen->portBits,
&offS->portRect,&offS->portRect,srcXor,0);
SysBeep(10);
while(!Button());
}
Juri Munkki
jmunkki@santra.hut.fi
jmunkki@fingate.bitnet
lk-jmu@finhut.bitnet
P.S. The window is longword aligned and a color table was copied from the
system file.
Technical Details
Message-ID:
<9130@santra.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!enea!tut!santra!jmunkkiShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!enea!tut!santra!jmunkki From: jmunkki@santra.UUCP (Juri Munkki) Newsgroups: comp.sys.mac Subject: Color CopyBits Is Too Slow! Message-ID: <9130@santra.UUCP> Date: 6 Dec 87 21:13:10 GMT Organization: Helsinki University of Technology, Finland Lines: 76 Keywords: Mac II Color QuickDraw Animation Speed Optimization