summaryrefslogtreecommitdiffstats
path: root/kernel/kls_ttf/ftview/gblhbgr.h
blob: a2740abd124d1d34da12a05a6911fbd04ea645a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  GBLENDER_CHANNEL_VARS(blender,r,g,b);

  int                   h        = blit->height;
  const unsigned char*  src_line = blit->src_line;
  unsigned char*        dst_line = blit->dst_line;

  do
  {
    const unsigned char*  src = src_line + blit->src_x*3;
    unsigned char*        dst = dst_line + blit->dst_x*GDST_INCR;
    int                   w   = blit->width;

    do
    {
      int  ab = GBLENDER_SHADE_INDEX(src[0]);
      int  ag = GBLENDER_SHADE_INDEX(src[1]);
      int  ar = GBLENDER_SHADE_INDEX(src[2]);
      int  aa = (ar << 16) | (ag << 8) | ab;

      if ( aa == 0 )
      {
        /* nothing */
      }
      else if ( aa == ((GBLENDER_SHADE_COUNT << 16) |
                       (GBLENDER_SHADE_COUNT << 8)  |
                       (GBLENDER_SHADE_COUNT)       ) )
      {
        GDST_COPY(dst);
      }
      else
      {
        GBlenderPixel  back;
        int            pix_r, pix_g, pix_b;

        GDST_READ(dst,back);

        {
          int  back_r = (back >> 16) & 255;
          
          GBLENDER_LOOKUP_R( blender, back_r );
          
          pix_r = _grcells[ar];
        }
        
        {
          int  back_g = (back >> 8) & 255;
          
          GBLENDER_LOOKUP_G( blender, back_g );
          
          pix_g = _ggcells[ag];
        }

        {
          int  back_b = (back) & 255;
          
          GBLENDER_LOOKUP_B( blender, back_b );
          
          pix_b = _gbcells[ab];
        }

        GDST_STOREC(dst,pix_r,pix_g,pix_b);
      }

      src += 3;
      dst += GDST_INCR;
    }
    while (--w > 0);

    src_line += blit->src_pitch;
    dst_line += blit->dst_pitch;
  }
  while (--h > 0);
  
  GBLENDER_CHANNEL_CLOSE(blender);