LCOV - code coverage report
Current view: top level - evg - raster_565.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 339 360 94.2 %
Date: 2021-04-29 23:48:07 Functions: 24 24 100.0 %

          Line data    Source code
       1             : /*
       2             :  *                      GPAC - Multimedia Framework C SDK
       3             :  *
       4             :  *                      Authors: Jean Le Feuvre
       5             :  *                      Copyright (c) Telecom ParisTech 2000-2019
       6             :  *                                      All rights reserved
       7             :  *
       8             :  *  This file is part of GPAC / software 2D rasterizer
       9             :  *
      10             :  *  GPAC is free software; you can redistribute it and/or modify
      11             :  *  it under the terms of the GNU Lesser General Public License as published by
      12             :  *  the Free Software Foundation; either version 2, or (at your option)
      13             :  *  any later version.
      14             :  *
      15             :  *  GPAC is distributed in the hope that it will be useful,
      16             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             :  *  GNU Lesser General Public License for more details.
      19             :  *
      20             :  *  You should have received a copy of the GNU Lesser General Public
      21             :  *  License along with this library; see the file COPYING.  If not, write to
      22             :  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
      23             :  *
      24             :  *
      25             :  */
      26             : 
      27             : 
      28             : #include "rast_soft.h"
      29             : 
      30             : 
      31             : /*
      32             :         FIXME / WARNING - this code only works for little endian platfoms
      33             :                 not seen any big endian platform using RGB565/RGB555 output
      34             : */
      35             : 
      36             : 
      37             : static GFINLINE s32
      38             : mul255(s32 a, s32 b)
      39             : {
      40       68556 :         return ((a + 1) * b) >> 8;
      41             : }
      42             : 
      43             : 
      44             : /*
      45             :                         RGB 565 part
      46             : */
      47             : 
      48             : static void write_565(u8 *dst, u8 r, u8 g, u8 b)
      49             : {
      50       67594 :         r>>=3;
      51       67594 :         g>>=2;
      52       66782 :         b>>=3;
      53             : 
      54             :         dst[0] = r;
      55       67594 :         dst[0] <<= 3;
      56       67594 :         dst[0] |= ((g >> 3) & 0x7);
      57             :         dst[1] = (g & 0x7);
      58             :         dst[1] <<= 5;
      59       67594 :         dst[1] |= b;
      60             : }
      61             : 
      62        2650 : static void overmask_565(u32 src, u8 *dst, u32 alpha)
      63             : {
      64             :         u32 resr, resg, resb;
      65        2650 :         s32 srca = (src >> 24) & 0xff;
      66        2650 :         s32 srcr = (src >> 16) & 0xff;
      67        2650 :         s32 srcg = (src >> 8) & 0xff;
      68        2650 :         s32 srcb = (src >> 0) & 0xff;
      69             : 
      70        2650 :         s32 dstr = (dst[0] >> 3) & 0x1f;
      71        2650 :         s32 dstg = (dst[0]) & 0x7;
      72        2650 :         dstg <<= 3;
      73        2650 :         dstg |= (dst[1]>>3) & 0x7;
      74        2650 :         s32 dstb = (dst[1]) & 0x1f;
      75             : 
      76        2650 :         dstr<<=3;
      77        2650 :         dstg<<=2;
      78        2650 :         dstb<<=3;
      79             : 
      80        2650 :         srca = mul255(srca, alpha);
      81        5300 :         resr = mul255(srca, srcr - dstr) + dstr;
      82        5300 :         resg = mul255(srca, srcg - dstg) + dstg;
      83        5300 :         resb = mul255(srca, srcb - dstb) + dstb;
      84        2650 :         write_565(dst, resr, resg, resb);
      85        2650 : }
      86             : 
      87        1672 : void overmask_565_const_run(u32 src, u8 *dst, s32 dst_pitch_x, u32 count)
      88             : {
      89             :         u32 resr, resg, resb;
      90        1672 :         u8 srca = (src >> 24) & 0xff;
      91        1672 :         u8 srcr = (src >> 16) & 0xff;
      92        1672 :         u8 srcg = (src >> 8) & 0xff;
      93             :         u8 srcb = (src >> 0) & 0xff;
      94             : 
      95        5816 :         while (count) {
      96        2472 :                 s32 dstr = (dst[0] >> 3) & 0x1f;
      97        2472 :                 s32 dstg = (dst[0]) & 0x7;
      98        2472 :                 dstg <<= 3;
      99        2472 :                 dstg |= (dst[1]>>3) & 0x7;
     100        2472 :                 s32 dstb = (dst[1]) & 0x1f;
     101             : 
     102        2472 :                 dstr<<=3;
     103        2472 :                 dstg<<=2;
     104        2472 :                 dstb<<=3;
     105             : 
     106        4944 :                 resr = mul255(srca, srcr - dstr) + dstr;
     107        4944 :                 resg = mul255(srca, srcg - dstg) + dstg;
     108        4944 :                 resb = mul255(srca, srcb - dstb) + dstb;
     109        2472 :                 write_565(dst, resr, resg, resb);
     110        2472 :                 dst += dst_pitch_x;
     111        2472 :                 count--;
     112             :         }
     113        1672 : }
     114             : 
     115             : 
     116        8410 : void evg_565_fill_single(s32 y, s32 x, u32 col, GF_EVGSurface *surf)
     117             : {
     118        8410 :         u8 *dst = surf->pixels + y * surf->pitch_y + x * surf->pitch_x;
     119        8410 :         u8 r = GF_COL_R(col);
     120        8410 :         u8 g = GF_COL_G(col);
     121        8410 :         u8 b = GF_COL_B(col);
     122             :         write_565(dst, r, g, b);
     123        8410 : }
     124             : 
     125         792 : void evg_565_fill_single_a(s32 y, s32 x, u8 coverage, u32 col, GF_EVGSurface *surf)
     126             : {
     127         792 :         u8 *dst = surf->pixels + y * surf->pitch_y + x * surf->pitch_x;
     128         792 :         overmask_565(col, dst, coverage);
     129         792 : }
     130             : 
     131             : 
     132         307 : void evg_565_fill_const(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     133             : {
     134         307 :         u32 col = surf->fill_col;
     135             :         u32 a, fin, col_no_a;
     136             :         u8 r, g, b;
     137         307 :         u8 *dst = (u8 *) surf->pixels + y * surf->pitch_y;
     138             :         register s32 i;
     139             :         u32 len;
     140             :         s32 x;
     141             : 
     142         307 :         col_no_a = col&0x00FFFFFF;
     143         307 :         r = GF_COL_R(col);
     144         307 :         g = GF_COL_G(col);
     145         307 :         b = GF_COL_B(col);
     146             : 
     147        2032 :         for (i=0; i<count; i++) {
     148        1725 :                 x = spans[i].x * surf->pitch_x;
     149        1725 :                 len = spans[i].len;
     150        1725 :                 if (spans[i].coverage != 0xFF) {
     151        2856 :                         a = mul255(0xFF, spans[i].coverage);
     152        1428 :                         fin = (a<<24) | (col_no_a);
     153        1428 :                         overmask_565_const_run(fin, dst+x, surf->pitch_x, len);
     154             :                 } else {
     155        3226 :                         while (len--) {
     156        2929 :                                 write_565(dst+x, r, g, b);
     157        2929 :                                 x+=surf->pitch_x;
     158             :                         }
     159             :                 }
     160             :         }
     161         307 : }
     162             : 
     163          56 : void evg_565_fill_const_a(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     164             : {
     165          56 :         u8 *dst = (u8 *) surf->pixels + y * surf->pitch_y;
     166          56 :         u32 col = surf->fill_col;
     167             :         register u32 a, fin, col_no_a;
     168             :         register s32 i;
     169             : 
     170          56 :         a = (col>>24)&0xFF;
     171          56 :         col_no_a = col&0x00FFFFFF;
     172          56 :         if (surf->get_alpha) {
     173           0 :                 for (i=0; i<count; i++) {
     174             :                         u32 j;
     175           0 :                         for (j=0; j<spans[i].len; j++) {
     176           0 :                                 s32 x = spans[i].x + j;
     177           0 :                                 u8 aa = surf->get_alpha(surf->get_alpha_udta, a, x, y);
     178           0 :                                 fin = mul255(aa, spans[i].coverage);
     179           0 :                                 fin = (fin<<24) | col_no_a;
     180           0 :                                 overmask_565_const_run(fin, dst + x * surf->pitch_x, surf->pitch_x, 1);
     181             :                         }
     182             :                 }
     183             :         } else {
     184         244 :                 for (i=0; i<count; i++) {
     185         488 :                         fin = mul255(a, spans[i].coverage);
     186         244 :                         fin = (fin<<24) | col_no_a;
     187         244 :                         overmask_565_const_run(fin, dst + spans[i].x * surf->pitch_x, surf->pitch_x, spans[i].len);
     188             :                 }
     189             :         }
     190          56 : }
     191             : 
     192             : 
     193         619 : void evg_565_fill_var(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     194             : {
     195         619 :         u8 *dst = (u8 *) surf->pixels + y * surf->pitch_y;
     196             :         register s32 i;
     197             : 
     198        1958 :         for (i=0; i<count; i++) {
     199             :                 register u8 spanalpha, col_a;
     200             :                 register s32 x;
     201             :                 register u32 len;
     202             :                 register u32 *col;
     203        1339 :                 len = spans[i].len;
     204        1339 :                 spanalpha = spans[i].coverage;
     205        1339 :                 evg_fill_run(surf->sten, surf, spans[i].x, y, len);
     206        1339 :                 col = surf->stencil_pix_run;
     207        1339 :                 x = spans[i].x * surf->pitch_x;
     208       56821 :                 while (len--) {
     209       54143 :                         col_a = GF_COL_A(*col);
     210       54143 :                         if (col_a) {
     211             :                                 u32 _col = *col;
     212       52179 :                                 if ((spanalpha!=0xFF) || (col_a != 0xFF)) {
     213        1858 :                                         overmask_565(_col, dst+x, spanalpha);
     214             :                                 } else {
     215       50321 :                                         write_565(dst+x, GF_COL_R(_col), GF_COL_G(_col), GF_COL_B(_col));
     216             :                                 }
     217             :                         }
     218       54143 :                         col++;
     219       54143 :                         x += surf->pitch_x;
     220             :                 }
     221             :         }
     222         619 : }
     223             : 
     224           5 : GF_Err evg_surface_clear_565(GF_EVGSurface *surf, GF_IRect rc, GF_Color col)
     225             : {
     226             :         register u32 x, y, w, h, sx, sy;
     227             :         register u8 r, g, b;
     228             :         u8 *data_o;
     229             : 
     230           5 :         h = rc.height;
     231           5 :         w = rc.width;
     232           5 :         sx = rc.x;
     233           5 :         sy = rc.y;
     234             : 
     235             :         /*convert to 565*/
     236           5 :         r = GF_COL_R(col);
     237             :         g = GF_COL_R(col);
     238             :         b = GF_COL_R(col);
     239             : 
     240             :         data_o = NULL;
     241         817 :         for (y=0; y<h; y++) {
     242         812 :                 u8 *data = (u8 *) surf->pixels + (sy+y) * surf->pitch_y + surf->pitch_x*sx;
     243         812 :                 if (!y) {
     244             :                         data_o = data;
     245         812 :                         for (x=0; x<w; x++)  {
     246             :                                 write_565(data, r, g, b);
     247         812 :                                 data += surf->pitch_x;
     248             :                         }
     249             :                 } else {
     250         807 :                         memcpy(data, data_o, w*surf->pitch_x);
     251             :                 }
     252             :         }
     253           5 :         return GF_OK;
     254             : }
     255             : 
     256             : 
     257             : 
     258             : /*
     259             :                         RGB 555 part
     260             : */
     261             : 
     262             : static void write_555(u8 *dst, u8 r, u8 g, u8 b)
     263             : {
     264       67594 :         r>>=3;
     265       67594 :         g>>=3;
     266       67594 :         b>>=3;
     267             : 
     268             :         dst[0] = r;
     269       67594 :         dst[0] <<= 2;
     270       67594 :         dst[0] |= ((g >> 3) & 0x3);
     271             :         dst[1] = (g & 0x7);
     272             :         dst[1] <<= 5;
     273       67594 :         dst[1] |= b;
     274             : }
     275             : 
     276        2650 : static void overmask_555(u32 src, u8 *dst, u32 alpha)
     277             : {
     278             :         u32 resr, resg, resb;
     279        2650 :         s32 srca = (src >> 24) & 0xff;
     280        2650 :         s32 srcr = (src >> 16) & 0xff;
     281        2650 :         s32 srcg = (src >> 8) & 0xff;
     282        2650 :         s32 srcb = (src >> 0) & 0xff;
     283             : 
     284        2650 :         s32 dstr = (dst[0] >> 2) & 0x1f;
     285        2650 :         s32 dstg = (dst[0] ) & 0x3;
     286        2650 :         dstg <<= 3;
     287        2650 :         dstg |= (dst[1]>>5 ) & 0x7;
     288        2650 :         s32 dstb = (dst[1] ) & 0x1f;
     289        2650 :         dstr<<=3;
     290        2650 :         dstg<<=3;
     291        2650 :         dstb<<=3;
     292             : 
     293        2650 :         srca = mul255(srca, alpha);
     294        5300 :         resr = mul255(srca, srcr - dstr) + dstr;
     295        5300 :         resg = mul255(srca, srcg - dstg) + dstg;
     296        5300 :         resb = mul255(srca, srcb - dstb) + dstb;
     297        2650 :         write_555(dst, resr, resg, resb);
     298        2650 : }
     299             : 
     300        1672 : static void overmask_555_const_run(u32 src, u8 *dst, s32 dst_pitch_x, u32 count)
     301             : {
     302             :         u32 resr, resg, resb;
     303        1672 :         u8 srca = (src >> 24) & 0xff;
     304        1672 :         u8 srcr = (src >> 16) & 0xff;
     305        1672 :         u8 srcg = (src >> 8) & 0xff;
     306             :         u8 srcb = (src >> 0) & 0xff;
     307             : 
     308        5816 :         while (count) {
     309        2472 :                 s32 dstr = (dst[0] >> 2) & 0x1f;
     310        2472 :                 s32 dstg = (dst[0] ) & 0x3;
     311        2472 :                 dstg <<= 3;
     312        2472 :                 dstg |= (dst[1]>>5 ) & 0x7;
     313        2472 :                 s32 dstb = (dst[1] ) & 0x1f;
     314        2472 :                 dstr<<=3;
     315        2472 :                 dstg<<=3;
     316        2472 :                 dstb<<=3;
     317             : 
     318        4944 :                 resr = mul255(srca, srcr - dstr) + dstr;
     319        4944 :                 resg = mul255(srca, srcg - dstg) + dstg;
     320        4944 :                 resb = mul255(srca, srcb - dstb) + dstb;
     321        2472 :                 write_555(dst, resr, resg, resb);
     322        2472 :                 dst += dst_pitch_x;
     323        2472 :                 count--;
     324             :         }
     325        1672 : }
     326             : 
     327             : 
     328        8410 : void evg_555_fill_single(s32 y, s32 x, u32 col, GF_EVGSurface *surf)
     329             : {
     330        8410 :         u8 *dst = surf->pixels + y * surf->pitch_y + x * surf->pitch_x;
     331        8410 :         u8 r = GF_COL_R(col);
     332        8410 :         u8 g = GF_COL_G(col);
     333        8410 :         u8 b = GF_COL_B(col);
     334             :         write_555(dst, r, g, b);
     335        8410 : }
     336             : 
     337         792 : void evg_555_fill_single_a(s32 y, s32 x, u8 coverage, u32 col, GF_EVGSurface *surf)
     338             : {
     339         792 :         u8 *dst = surf->pixels + y * surf->pitch_y + x * surf->pitch_x;
     340         792 :         overmask_555(col, dst, coverage);
     341         792 : }
     342             : 
     343         307 : void evg_555_fill_const(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     344             : {
     345         307 :         u32 col = surf->fill_col;
     346             :         u32 a, fin, col_no_a;
     347         307 :         u8 *dst = surf->pixels + y * surf->pitch_y;
     348             :         u8 r, g, b;
     349             :         s32 i, x;
     350             :         u32 len;
     351             : 
     352         307 :         r = GF_COL_R(col);
     353         307 :         g = GF_COL_G(col);
     354         307 :         b = GF_COL_B(col);
     355             : 
     356         307 :         col_no_a = col&0x00FFFFFF;
     357        2032 :         for (i=0; i<count; i++) {
     358        1725 :                 x = spans[i].x * surf->pitch_x;
     359        1725 :                 len = spans[i].len;
     360        1725 :                 if (spans[i].coverage != 0xFF) {
     361        2856 :                         a = mul255(0xFF, spans[i].coverage);
     362        1428 :                         fin = (a<<24) | col_no_a;
     363        1428 :                         overmask_555_const_run(fin, dst+x, surf->pitch_x, len);
     364             :                 } else {
     365        3226 :                         while (len--) {
     366        2929 :                                 write_555(dst+x, r, g, b);
     367        2929 :                                 x+=surf->pitch_x;
     368             :                         }
     369             :                 }
     370             :         }
     371         307 : }
     372             : 
     373          56 : void evg_555_fill_const_a(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     374             : {
     375          56 :         u8 *dst = surf->pixels + y * surf->pitch_y;
     376          56 :         u32 col = surf->fill_col;
     377             :         u32 a, fin, col_no_a;
     378             :         s32 i;
     379             : 
     380          56 :         a = (col>>24)&0xFF;
     381          56 :         col_no_a = col & 0x00FFFFFF;
     382          56 :         if (surf->get_alpha) {
     383           0 :                 for (i=0; i<count; i++) {
     384             :                         u32 j;
     385           0 :                         for (j=0; j<spans[i].len; j++) {
     386           0 :                                 s32 x = spans[i].x + j;
     387           0 :                                 u8 aa = surf->get_alpha(surf->get_alpha_udta, a, x, y);
     388           0 :                                 fin = mul255(aa, spans[i].coverage);
     389           0 :                                 fin = (fin<<24) | col_no_a;
     390           0 :                                 overmask_555_const_run(fin, dst + x*surf->pitch_x, surf->pitch_x, 1);
     391             :                         }
     392             :                 }
     393             :         } else {
     394         244 :                 for (i=0; i<count; i++) {
     395         488 :                         fin = mul255(a, spans[i].coverage);
     396         244 :                         fin = (fin<<24) | col_no_a;
     397         244 :                         overmask_555_const_run(fin, dst + spans[i].x*surf->pitch_x, surf->pitch_x, spans[i].len);
     398             :                 }
     399             :         }
     400          56 : }
     401             : 
     402             : 
     403         619 : void evg_555_fill_var(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     404             : {
     405         619 :         u8 *dst = surf->pixels + y * surf->pitch_y;
     406             :         s32 i;
     407             : 
     408        1958 :         for (i=0; i<count; i++) {
     409             :                 u8 spanalpha, col_a;
     410             :                 s32 x;
     411             :                 u32 len;
     412             :                 u32 *col;
     413        1339 :                 len = spans[i].len;
     414        1339 :                 spanalpha = spans[i].coverage;
     415        1339 :                 evg_fill_run(surf->sten, surf, spans[i].x, y, len);
     416        1339 :                 col = surf->stencil_pix_run;
     417        1339 :                 x = spans[i].x * surf->pitch_x;
     418       56821 :                 while (len--) {
     419       54143 :                         col_a = GF_COL_A(*col);
     420       54143 :                         if (col_a) {
     421             :                                 u32 _col = *col;
     422       52179 :                                 if ((spanalpha!=0xFF) || (col_a != 0xFF)) {
     423        1858 :                                         overmask_555(*col, dst+x, spanalpha);
     424             :                                 } else {
     425       50321 :                                         write_555(dst+x, GF_COL_R(_col), GF_COL_G(_col), GF_COL_B(_col) );
     426             :                                 }
     427             :                         }
     428       54143 :                         col++;
     429       54143 :                         x += surf->pitch_x;
     430             :                 }
     431             :         }
     432         619 : }
     433             : 
     434           5 : GF_Err evg_surface_clear_555(GF_EVGSurface *surf, GF_IRect rc, GF_Color col)
     435             : {
     436             :         u32 x, y, w, h, sx, sy;
     437             :         u8 r, g, b;
     438             :         u8 *data_o;
     439             : 
     440           5 :         h = rc.height;
     441           5 :         w = rc.width;
     442           5 :         sx = rc.x;
     443           5 :         sy = rc.y;
     444           5 :         r = GF_COL_R(col);
     445           5 :         g = GF_COL_G(col);
     446           5 :         b = GF_COL_B(col);
     447             : 
     448             :         data_o = NULL;
     449         817 :         for (y=0; y<h; y++) {
     450         812 :                 u8 *data = surf->pixels + (sy+y) * surf->pitch_y + surf->pitch_x*sx;
     451         812 :                 if (!y) {
     452             :                         data_o = data;
     453         812 :                         for (x=0; x<w; x++)  {
     454             :                                 write_555(data, r, g, b);
     455         812 :                                 data += surf->pitch_x;
     456             :                         }
     457             :                 } else {
     458         807 :                         memcpy(data, data_o, w*surf->pitch_x);
     459             :                 }
     460             :         }
     461           5 :         return GF_OK;
     462             : }
     463             : 
     464             : 
     465             : /*
     466             :                         RGB 444 part
     467             : */
     468             : 
     469             : static void write_444(u8 *dst, u8 r, u8 g, u8 b)
     470             : {
     471      123394 :         dst[0] = r >> 4;
     472      123394 :         dst[1] = g >> 4;
     473      123394 :         dst[1]<<=4;
     474      123394 :         dst[1] |= b >> 4;
     475             : }
     476             : 
     477        5023 : static void overmask_444(u8 *dst, u32 src, u32 alpha)
     478             : {
     479             :         u32 resr, resg, resb;
     480        5023 :         s32 srca = (src >> 24) & 0xff;
     481        5023 :         s32 srcr = (src >> 16) & 0xff;
     482        5023 :         s32 srcg = (src >> 8) & 0xff;
     483        5023 :         s32 srcb = (src >> 0) & 0xff;
     484             : 
     485        5023 :         s32 dstr = (dst[0] & 0x0f) << 4;
     486        5023 :         s32 dstg = ((dst[1] >> 4) & 0x0f) << 4;
     487        5023 :         s32 dstb = (dst[1] & 0x0f) << 4;
     488             : 
     489        5023 :         srca = mul255(srca, alpha);
     490       10046 :         resr = mul255(srca, srcr - dstr) + dstr;
     491       10046 :         resg = mul255(srca, srcg - dstg) + dstg;
     492       10046 :         resb = mul255(srca, srcb - dstb) + dstb;
     493        5023 :         write_444(dst, resr, resg, resb);
     494        5023 : }
     495             : 
     496        1672 : static void overmask_444_const_run(u32 src, u8 *dst, s32 dst_pitch_x, u32 count)
     497             : {
     498             :         u32 resr, resg, resb;
     499        1672 :         s32 srca = (src >> 24) & 0xff;
     500        1672 :         s32 srcr = (src >> 16) & 0xff;
     501        1672 :         s32 srcg = (src >> 8) & 0xff;
     502        1672 :         s32 srcb = (src >> 0) & 0xff;
     503             : 
     504        5816 :         while (count) {
     505        2472 :                 s32 dstr = dst[0] & 0x0f;
     506        2472 :                 s32 dstg = (dst[1]>>4) & 0x0f;
     507        2472 :                 s32 dstb = (dst[1]) & 0x0f;
     508             : 
     509        2472 :                 dstr<<=4;
     510        2472 :                 dstg<<=4;
     511        2472 :                 dstb<<=4;
     512             : 
     513        4944 :                 resr = mul255(srca, srcr - dstr) + dstr;
     514        4944 :                 resg = mul255(srca, srcg - dstg) + dstg;
     515        4944 :                 resb = mul255(srca, srcb - dstb) + dstb;
     516        2472 :                 write_444(dst, resr, resg, resb);
     517             : 
     518        2472 :                 dst += dst_pitch_x;
     519        2472 :                 count--;
     520             :         }
     521        1672 : }
     522             : 
     523             : 
     524        8410 : void evg_444_fill_single(s32 y, s32 x, u32 col, GF_EVGSurface *surf)
     525             : {
     526        8410 :         u8 *dst = surf->pixels + y * surf->pitch_y + x * surf->pitch_x;
     527        8410 :         u8 r = GF_COL_R(col);
     528        8410 :         u8 g = GF_COL_G(col);
     529        8410 :         u8 b = GF_COL_B(col);
     530             :         write_444(dst, r, g, b);
     531        8410 : }
     532             : 
     533         792 : void evg_444_fill_single_a(s32 y, s32 x, u8 coverage, u32 col, GF_EVGSurface *surf)
     534             : {
     535         792 :         u8 *dst = surf->pixels + y * surf->pitch_y + x * surf->pitch_x;
     536         792 :         overmask_444(dst, col, coverage);
     537         792 : }
     538             : 
     539         307 : void evg_444_fill_const(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     540             : {
     541         307 :         u32 col = surf->fill_col;
     542             :         u32 a, fin, col_no_a;
     543         307 :         u8 *dst = surf->pixels + y * surf->pitch_y;
     544             :         u8 r, g, b;
     545             :         s32 i, x;
     546             :         u32 len;
     547             : 
     548         307 :         r = GF_COL_R(col);
     549         307 :         g = GF_COL_G(col);
     550         307 :         b = GF_COL_B(col);
     551             : 
     552         307 :         col_no_a = col&0x00FFFFFF;
     553        2032 :         for (i=0; i<count; i++) {
     554        1725 :                 x = spans[i].x * surf->pitch_x;
     555        1725 :                 len = spans[i].len;
     556        1725 :                 if (spans[i].coverage != 0xFF) {
     557        2856 :                         a = mul255(0xFF, spans[i].coverage);
     558        1428 :                         fin = (a<<24) | col_no_a;
     559        1428 :                         overmask_444_const_run(fin, dst+x, surf->pitch_x, len);
     560             :                 } else {
     561        3226 :                         while (len--) {
     562        2929 :                                 write_444(dst+x, r, g, b);
     563        2929 :                                 x+=surf->pitch_x;
     564             :                         }
     565             :                 }
     566             :         }
     567         307 : }
     568             : 
     569          56 : void evg_444_fill_const_a(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     570             : {
     571          56 :         u8 *dst = surf->pixels + y * surf->pitch_y;
     572          56 :         u32 col = surf->fill_col;
     573             :         u32 a, fin, col_no_a;
     574             :         s32 i;
     575             : 
     576          56 :         a = (col>>24)&0xFF;
     577          56 :         col_no_a = col & 0x00FFFFFF;
     578             : 
     579             : 
     580          56 :         if (surf->get_alpha) {
     581           0 :                 for (i=0; i<count; i++) {
     582             :                         u32 j;
     583           0 :                         for (j=0; j<spans[i].len; j++) {
     584           0 :                                 s32 x = spans[i].x + j;
     585           0 :                                 u8 aa = surf->get_alpha(surf->get_alpha_udta, a, x, y);
     586           0 :                                 fin = mul255(aa, spans[i].coverage);
     587           0 :                                 fin = (fin<<24) | col_no_a;
     588           0 :                                 overmask_444_const_run(fin, dst + x*surf->pitch_x, surf->pitch_x, 1);
     589             :                         }
     590             :                 }
     591             :         } else {
     592         244 :                 for (i=0; i<count; i++) {
     593         488 :                         fin = mul255(a, spans[i].coverage);
     594         244 :                         fin = (fin<<24) | col_no_a;
     595         244 :                         overmask_444_const_run(fin, dst + spans[i].x*surf->pitch_x, surf->pitch_x, spans[i].len);
     596             :                 }
     597             :         }
     598          56 : }
     599             : 
     600             : 
     601        1131 : void evg_444_fill_var(s32 y, s32 count, EVG_Span *spans, GF_EVGSurface *surf)
     602             : {
     603        1131 :         u8 *dst = surf->pixels + y * surf->pitch_y;
     604             :         s32 i;
     605             : 
     606        2982 :         for (i=0; i<count; i++) {
     607             :                 u8 spanalpha, col_a;
     608             :                 s32 x;
     609             :                 u32 len;
     610             :                 u32 *col;
     611        1851 :                 len = spans[i].len;
     612        1851 :                 spanalpha = spans[i].coverage;
     613        1851 :                 evg_fill_run(surf->sten, surf, spans[i].x, y, len);
     614        1851 :                 col = surf->stencil_pix_run;
     615        1851 :                 x = spans[i].x * surf->pitch_x;
     616      123381 :                 while (len--) {
     617      119679 :                         col_a = GF_COL_A(*col);
     618      119679 :                         if (col_a) {
     619             :                                 u32 _col = *col;
     620      107979 :                                 if ((spanalpha!=0xFF) || (col_a != 0xFF)) {
     621        4231 :                                         overmask_444(dst+x, _col, spanalpha);
     622             :                                 } else {
     623      103748 :                                         write_444(dst+x, GF_COL_R(_col), GF_COL_G(_col), GF_COL_B(_col) );
     624             :                                 }
     625             :                         }
     626      119679 :                         col++;
     627      119679 :                         x += surf->pitch_x;
     628             :                 }
     629             :         }
     630        1131 : }
     631             : 
     632           5 : GF_Err evg_surface_clear_444(GF_EVGSurface *surf, GF_IRect rc, GF_Color col)
     633             : {
     634             :         u32 x, y, w, h, sx, sy;
     635             :         u8 r, g, b;
     636             :         u8 *data_o;
     637             : 
     638           5 :         h = rc.height;
     639           5 :         w = rc.width;
     640           5 :         sx = rc.x;
     641           5 :         sy = rc.y;
     642             : 
     643           5 :         r = GF_COL_R(col);
     644           5 :         g = GF_COL_G(col);
     645           5 :         b = GF_COL_B(col);
     646             : 
     647             :         data_o = NULL;
     648         817 :         for (y=0; y<h; y++) {
     649         812 :                 u8 *data = surf->pixels + (sy+y) * surf->pitch_y + surf->pitch_x*sx;
     650         812 :                 if (!y) {
     651             :                         data_o = data;
     652         812 :                         for (x=0; x<w; x++)  {
     653             :                                 write_444(data, r, g, b);
     654         812 :                                 data += surf->pitch_x;
     655             :                         }
     656             :                 } else {
     657         807 :                         memcpy(data, data_o, w * surf->pitch_x);
     658             :                 }
     659             :         }
     660           5 :         return GF_OK;
     661             : }
     662             : 

Generated by: LCOV version 1.13