All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vesa Jääskeläinen" <chaac@nic.fi>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] GSoC #09 Bitmap scaling
Date: Wed, 15 Oct 2008 17:34:12 +0300	[thread overview]
Message-ID: <48F5FF64.6010500@nic.fi> (raw)
In-Reply-To: <20081014224251.78ee2aa0@gibibit.com>

Colin D Bennett wrote:
> On Tue, 14 Oct 2008 00:11:42 +0300
> Vesa Jääskeläinen <chaac@nic.fi> wrote:
> 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 I stated before order is not an issue. We can use BGR[A].

I am just used to speak about RGB :)

>> 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; }

No, more like:

void *lock(bitmap b)
{
  if (b.locked) return NULL;
  if (b.optimized) return NULL;

  b.locked = 1;

  return b.dataptr;
}

void unlock(bitmap b)
{
  b.locked = 0;
}

grub_err_t optimize(bitmap b, rendertarget r)
{
  if (b.locked) return error;
  if (b.optimized) return error;

  // do magic
  b.optimized = 1;

  return success;
}

Now one would use it like:

ptr = lock();
if (ptr)
{
  // modify it.
  ptr[0] = blue;
  ptr[1] = green;
  ptr[2] = red;
  if (has_alpha)
    ptr[3] = alpha;

  unlock();
}

>>> 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.

No. If user has low color mode optimize will really make image look
ugly. So best to postpone this conversion to far as possible.

> 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.

I would still like to support all RGB modes. Indexed color modes are
just backup option.




  reply	other threads:[~2008-10-15 14:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31  7:01 [PATCH] GSoC #09 Bitmap scaling Colin D Bennett
2008-08-31 16:21 ` Vesa Jääskeläinen
2008-08-31 16:24   ` Vesa Jääskeläinen
2008-09-02 15:42   ` Vesa Jääskeläinen
2008-10-03 20:16     ` Vesa Jääskeläinen
2008-10-13 17:00       ` Colin D Bennett
2008-10-13 18:27         ` Vesa Jääskeläinen
2008-10-13 20:00           ` Colin D Bennett
2008-10-13 21:11             ` Vesa Jääskeläinen
2008-10-15  5:42               ` Colin D Bennett
2008-10-15 14:34                 ` Vesa Jääskeläinen [this message]
2008-10-30  3:20                   ` Colin D Bennett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48F5FF64.6010500@nic.fi \
    --to=chaac@nic.fi \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.