grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] GSoC #09 Bitmap scaling


From: Colin D Bennett
Subject: Re: [PATCH] GSoC #09 Bitmap scaling
Date: Tue, 14 Oct 2008 22:42:51 -0700

On Tue, 14 Oct 2008 00:11:42 +0300
Vesa Jääskeläinen <address@hidden> wrote:

> Colin D Bennett wrote:
> > On Mon, 13 Oct 2008 21:27:46 +0300
> > Vesa Jääskeläinen <address@hidden> wrote:
> >> Idea is that if bitmap is still locked you cannot optimize it or
> >> you cannot lock it again. And if bitmap is optimized you cannot get
> >> pointer to modify it. Eg. Function call returns memory pointer.
> > 
> > I thought perhaps the 'optimize' operation would simply return a
> > _new_ (and completely independent from that point forward) bitmap
> > equivalent to the input bitmap but in the same format as the
> > current video mode uses.
> 
> Problem with that is that it makes supporting code harder to use. With
> only handful of supported formats it much easier to write support code
> to modify bitmap. If you allow to use any format supported by video
> subsystem it is nightmare to support them all.
> 
> So if we just support two formats. We only need to care about RGB and
> RGBA formats, rather easy task. Can be modified by using simple loops
> or indexing. When we know that there is no modifications to be done
> for bitmap, we can just call optimize() and it will convert (edited)
> bitmap to fast to blit format.

A minor point:  You mentioned "RGB" and "RGBA" format--do you mean "true
color" (either RGB[A] or BGR[A] layout) or do you mean literal RGB byte
order? If we are talking about picking a single component order to
standardize on, it should be BGR[A].  Every video adapter I have tested
on so far (nVidia 7600GT, VIA Unichrome, VMware, QEMU) has supported
BGRA (32 bpp) or BGR (24 bpp) but not RGBA or RGB.  Perhaps others have
found the contrary to be true; if so I would like to know.

> As we have same handle all the time for bitmap we can just continue to
> use it as is. If we would make new instance of it, would either need
> to delete previous one and replace its usage with new one. Of course
> use case here affects.

Ok.  That's fine.  I'm still a little confused about the purpose of
lock/unlock, however.  Is it basically a way of catching mistakes in
the code where we accidentally try to modify bitmap data when we don't
want to?  I guess what I'm asking is, do lock/unlock do anything more
than set a flag that is checked, as in: (pseudocode)


void *get_ptr(bitmap b)
{
  if (b.optimized) return error();
  return b.ptr; 
}
void optimize(bitmap b)
{
  if (b.locked) error();
  /* optimize b... */
}
void lock(bitmap b)
{
  if (b.locked) error();
  b.locked = 1; 
}
void unlock(bitmap b) { b.locked = 0; }


> > Are you thinking that it would be best to have the
> > 'optimize'/'unoptimize' operations actually just modify the bitmap
> > in place?  I guess this is nice from a memory conservation
> > standpoint, but in some cases it wouldn't work well (i.e., 24-bit
> > to 32-bit formats).
> 
> I do not think at this point how optimize() or unoptimize() will be
> implemented. Just general idea. Whether it is in-place operation or
> re-allocation for memory, is same to me. It just have to work :)

Ok.

Another idea:  What if the image-loading functions automatically
optimize()'d the bitmaps when loaded, since we don't normally expect to
modify loaded bitmaps before display.  Then most all the bitmaps in use
would automatically get the performance benefit with no change to all
the users of the code.  The only thing we do with loaded images is the
scale them and blit them.

The scaling algorithms can easily work on any 24 or 32 bit color mode
without knowing details of which components are which (the process is
the same regardless of the color component).  Thus optimized images
could still be scaled highly efficiently (without an
unoptimize->scale->optimize process).  For 15/16 bit or indexed color
modes, we would have to unopt->scale->opt, but I really think that no
one should be using those modes.  If your video memory is too limited
for 24 or 32 bit color, then just use the perfectly great text mode
menu.

Regards,
Colin

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]