Index:
[thread]
[date]
[subject]
[author]
From: Andreas Beck <becka@rz.uni-duesseldorf.de>
To : ggi-develop@eskimo.com
Date: Fri, 2 Jul 1999 15:12:41 +0200
Re: Got to be a faster way.
> That is still difficult. See the tiles for my engine are stored in .png
> files. libpng likes to return 64 bit pixels. That is 4 16 bit componets,
> red, green, blue, and alpha. That is exactly what I need. The GGI lib
> seemed like a good choise because of it's 16 bit RGB componets.
O.K. - so as I assumed you are more or less using a bgbuffer of a
ggi_colors (not _pixels).
> So what I need is a fast way to get these 48 bit colors mapped down into a
> buffer that can be put into the display visual. I think low-order
> truncation of bits might be accurate enough for the map down.
O.K. - then DirectBuffer is the way to go for TrueColor targets. You query a
DirectBuffer structure and see if it has shift/mask entries for
red/green/blue. If yes, the rest is pretty simple: Two nested loops going
through the visual, doing something like
*pixel=((bg.red>>shift.r)&mask.r) | ... green | ... blue.
You'll need three or four versions for the different pixel sizes, though.
If that doesn't work, as you are using a palettized visual, you will very
probably want to set up the palette in a way that allows to calculate the
palette entry from the pixelvalues. Everything else is slow.
If it doesn't work because the target has no DirectBuffer, you can as well
assemble a pixelbuffer and use Putbox.
> I'm really considering writing a put buffer manipulation extention lib. I
> will stand by my belief that the core funtions in libggi are too slow to be
> of any use (so why have them?).
The problem is, that you induce a lot of call overhead by using pixel
oriented functions. If you have a truecolor visual, the MapColor and
Putpixel operations are pretty much as fast as one can get them. The problem
is the calling overhead. Using ggiPackColors and ggiPutHline should gain an
order or magnitude in speed for that case.
Of course if you use a palettized visual, this will always be slow, as the
color matching is an expensive operation. Setting a palette with an indexing
the can be calculated from the RGB values helps there.
> Now for a question: Is a memory visual different than raw get/put buffer in
> structure?
Well - a memory visual is a fully fledged visual where you can use and
LibGGI function on. A GetPut buffer is just raw memory. Querying the
structure is done using ggi_pixelformat *ggiGetPixelFormat(ggi_visual_t vis);
for pixelbuffers (get/putbuffers), while you use ggiDBGetBuffer for
a visual.
Usually the format is the same for linearly encoded modes. For planar or
otherwise weird modes Pixelbuffers are usually linearized.
CU, Andy
--
= Andreas Beck | Email : <andreas.beck@ggi-project.org> =
Index:
[thread]
[date]
[subject]
[author]