freetype
[Top][All Lists]
Advanced

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

[ft] Trying to understand the gblender_lookup_channel function...


From: Paul Pedriana
Subject: [ft] Trying to understand the gblender_lookup_channel function...
Date: Tue, 11 Feb 2014 00:49:45 -0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7

I'm trying to understand what the ftview demo gblender_lookup_channel function does. It's not obvious to me, there aren't any comments or documentation, there is nothing in the mailing list archive, and I did spend some time tracing it to try to make sense of it. The key = (GBlenderChanKey)blender->keys + idx; line in particular is confusing to me because it's casting between two unrelated structs. But in general I don't know what this function is trying to do, or what it means by keys, channels and indexes. Any help would be useful. I understand the concepts of color and alpha blending fine, so it's not a newbie kind of problem.


GBLENDER_APIDEF( unsigned char* )
gblender_lookup_channel( GBlender       blender,
                         int            background,
                         int            foreground )
{
  int              idx, idx0;
unsigned short backfore = (unsigned short)((foreground << 8) | background);
  GBlenderChanKey  key;

  idx0 = ( background + foreground*17 ) % (GBLENDER_KEY_COUNT);
  idx  = idx0;
  do
  {
    key = (GBlenderChanKey)blender->keys + idx;

    if ( key->index < 0 )
      goto NewNode;

    if ( key->backfore == backfore )
      goto Exit;

    idx = (idx+1) & (GBLENDER_KEY_COUNT-1);
  }
  while ( idx != idx0 );

NewNode:
  key->backfore   = backfore;
  key->index      = (signed short)( idx * GBLENDER_SHADE_COUNT );

  gblender_reset_channel_key( blender, key );

Exit:
  return  (unsigned char*)blender->cells + key->index;
}





reply via email to

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