Re: Quickly drawing non-antialiased, discrete, pixels
Re: Quickly drawing non-antialiased, discrete, pixels
- Subject: Re: Quickly drawing non-antialiased, discrete, pixels
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 11 Jan 2003 11:30:44 -0500
NSRectFillList() is definitely the winner for 2D rendering of discrete
points.
After creating a bridge for NSRectFillList in PyObjC, I modified the
aforementioned code to use NSRectFillList() to draw the points.
The rendering time for 113,000 points dropped from 16 seconds to 9
seconds.
Now I have another problem. How do I cache the rendered points such
that I don't have to rerender all points with each 'frame'?
Rendering into an NSImage and compositing that will be a lose as
discussed previously. Is there a way to grab a snapshot of the current
view's pixels and tell the AppKit to effectively use those bits as the
'background' for the view in a highly efficient manner?
I think not.
It appears that NSBitmapImageRep can be instantiated against the
focused view's contents, but that will leave me with the same bitmap
format mismatch with the screen bits.
Nope -- I'm wrong. The following code dropped the rendering time to 8
seconds.
def drawRect_(self, aRect):
if self.backingStore:
self.backingStore.draw()
else:
self.eraseView_(aRect)
for pointArray, rectCount, color in self.pointsCountsAndColors:
color.set()
NSRectFillList(pointArray, rectCount)
self.pointsCountsAndColors = []
self.backingStore =
NSBitmapImageRep.alloc().initWithFocusedViewRect_(self.bounds())
BTW: I believe that most of my rendering acceleration is actually due
to the very efficient bridging of NSRectFillList() more than it is
because of the drawing code. However, the drawing code itself is much
faster now than it was originally.
b.bum
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.