| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
However, while profiling my app, I noticed that PlotIconRefInContext calls private APIs to draw CGImages... so I was wondering if drawing CGImageRefs myself wouldn't be faster.
So I converted all my .icns files into .png ones, modified my code to handle CGImageRefs..
The result is odd : it's slower, and the icons don't look as anti-aliased as with IconRefs.
Are you recreating the CGImages every time you want to draw the icons or do you keep the images around and reuse them?
You might try profiling and see if you can determine which step is taking the longest.
Well the Dock does use a separate window for each icon that it presents. How the icons are drawn into that window is not clear but it very well could be going through OpenGL.
Nevertheless, I've had good luck using OpenGL to quickly blit 2D images on the screen. Essentially what is involved is creating an OpenGL texture from your image data and then drawing a rectangle on the screen that uses that texture. The technique has some caveats, particularly if your working with images that are not a power of two. If you are using standard icon sizes (128x128 for example) then I don't think this will be a problem for you. There's also quite a bit of setup what with getting the OpenGL contexts created, the textures enabled and things like that. Nevertheless, once your graphic is in the texture you can get it to the screen screamingly quickly.
There is sample code in the OpenGL sample at Apple's site. The two in particular that I am thinking of are:
<http://developer.apple.com/samplecode/OpenGL_Image/OpenGL_Image.html>
and
<http://developer.apple.com/samplecode/Red_Rocket/Red_Rocket.html>
| References: | |
| >Drawing icons fast : CGImageRef or IconRef ? (From: Jérome Foucher <email@hidden>) | |
| >Re: Drawing icons fast : CGImageRef or IconRef ? (From: Scott Thompson <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.