LCOV - code coverage report
Current view: top level - gfx/cairo/libpixman/src - pixman-edge-imp.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 54 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright © 2004 Keith Packard
       3             :  *
       4             :  * Permission to use, copy, modify, distribute, and sell this software and its
       5             :  * documentation for any purpose is hereby granted without fee, provided that
       6             :  * the above copyright notice appear in all copies and that both that
       7             :  * copyright notice and this permission notice appear in supporting
       8             :  * documentation, and that the name of Keith Packard not be used in
       9             :  * advertising or publicity pertaining to distribution of the software without
      10             :  * specific, written prior permission.  Keith Packard makes no
      11             :  * representations about the suitability of this software for any purpose.  It
      12             :  * is provided "as is" without express or implied warranty.
      13             :  *
      14             :  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
      15             :  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
      16             :  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
      17             :  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
      18             :  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
      19             :  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      20             :  * PERFORMANCE OF THIS SOFTWARE.
      21             :  */
      22             : 
      23             : #ifndef rasterize_span
      24             : #endif
      25             : 
      26             : static void
      27           0 : RASTERIZE_EDGES (pixman_image_t  *image,
      28             :                 pixman_edge_t   *l,
      29             :                 pixman_edge_t   *r,
      30             :                 pixman_fixed_t          t,
      31             :                 pixman_fixed_t          b)
      32             : {
      33           0 :     pixman_fixed_t  y = t;
      34             :     uint32_t  *line;
      35           0 :     uint32_t *buf = (image)->bits.bits;
      36           0 :     int stride = (image)->bits.rowstride;
      37           0 :     int width = (image)->bits.width;
      38             : 
      39           0 :     line = buf + pixman_fixed_to_int (y) * stride;
      40             : 
      41             :     for (;;)
      42           0 :     {
      43             :         pixman_fixed_t  lx;
      44             :         pixman_fixed_t      rx;
      45             :         int     lxi;
      46             :         int rxi;
      47             : 
      48           0 :         lx = l->x;
      49           0 :         rx = r->x;
      50             : #if N_BITS == 1
      51             :         /* For the non-antialiased case, round the coordinates up, in effect
      52             :          * sampling just slightly to the left of the pixel. This is so that
      53             :          * when the sample point lies exactly on the line, we round towards
      54             :          * north-west.
      55             :          *
      56             :          * (The AA case does a similar  adjustment in RENDER_SAMPLES_X)
      57             :          */
      58             :         /* we cast to unsigned to get defined behaviour for overflow */
      59           0 :         lx = (unsigned)lx + X_FRAC_FIRST(1) - pixman_fixed_e;
      60           0 :         rx = (unsigned)rx + X_FRAC_FIRST(1) - pixman_fixed_e;
      61             : #endif
      62             :         /* clip X */
      63           0 :         if (lx < 0)
      64           0 :             lx = 0;
      65           0 :         if (pixman_fixed_to_int (rx) >= width)
      66             : #if N_BITS == 1
      67           0 :             rx = pixman_int_to_fixed (width);
      68             : #else
      69             :             /* Use the last pixel of the scanline, covered 100%.
      70             :              * We can't use the first pixel following the scanline,
      71             :              * because accessing it could result in a buffer overrun.
      72             :              */
      73           0 :             rx = pixman_int_to_fixed (width) - 1;
      74             : #endif
      75             : 
      76             :         /* Skip empty (or backwards) sections */
      77           0 :         if (rx > lx)
      78             :         {
      79             : 
      80             :             /* Find pixel bounds for span */
      81           0 :             lxi = pixman_fixed_to_int (lx);
      82           0 :             rxi = pixman_fixed_to_int (rx);
      83             : 
      84             : #if N_BITS == 1
      85             :             {
      86             : 
      87             : #define LEFT_MASK(x)                                                    \
      88             :                 (((x) & 0x1f) ?                                             \
      89             :                  SCREEN_SHIFT_RIGHT (0xffffffff, (x) & 0x1f) : 0)
      90             : #define RIGHT_MASK(x)                                                   \
      91             :                 (((32 - (x)) & 0x1f) ?                                      \
      92             :                  SCREEN_SHIFT_LEFT (0xffffffff, (32 - (x)) & 0x1f) : 0)
      93             :                 
      94             : #define MASK_BITS(x,w,l,n,r) {                                          \
      95             :                     n = (w);                                            \
      96             :                     r = RIGHT_MASK ((x) + n);                           \
      97             :                     l = LEFT_MASK (x);                                  \
      98             :                     if (l) {                                            \
      99             :                         n -= 32 - ((x) & 0x1f);                             \
     100             :                         if (n < 0) {                                 \
     101             :                             n = 0;                                      \
     102             :                             l &= r;                                 \
     103             :                             r = 0;                                      \
     104             :                         }                                               \
     105             :                     }                                                   \
     106             :                     n >>= 5;                                              \
     107             :                 }
     108             :                 
     109           0 :                 uint32_t  *a = line;
     110             :                 uint32_t  startmask;
     111             :                 uint32_t  endmask;
     112             :                 int         nmiddle;
     113           0 :                 int         width = rxi - lxi;
     114           0 :                 int         x = lxi;
     115             :                 
     116           0 :                 a += x >> 5;
     117           0 :                 x &= 0x1f;
     118             :                 
     119           0 :                 MASK_BITS (x, width, startmask, nmiddle, endmask);
     120             : 
     121           0 :                 if (startmask) {
     122           0 :                     WRITE(image, a, READ(image, a) | startmask);
     123           0 :                     a++;
     124             :                 }
     125           0 :                 while (nmiddle--)
     126           0 :                     WRITE(image, a++, 0xffffffff);
     127           0 :                 if (endmask)
     128           0 :                     WRITE(image, a, READ(image, a) | endmask);
     129             :             }
     130             : #else
     131             :             {
     132           0 :                 DEFINE_ALPHA(line,lxi);
     133             :                 int         lxs;
     134             :                 int     rxs;
     135             : 
     136             :                 /* Sample coverage for edge pixels */
     137           0 :                 lxs = RENDER_SAMPLES_X (lx, N_BITS);
     138           0 :                 rxs = RENDER_SAMPLES_X (rx, N_BITS);
     139             : 
     140             :                 /* Add coverage across row */
     141           0 :                 if (lxi == rxi)
     142             :                 {
     143           0 :                     ADD_ALPHA (rxs - lxs);
     144             :                 }
     145             :                 else
     146             :                 {
     147             :                     int xi;
     148             : 
     149           0 :                     ADD_ALPHA (N_X_FRAC(N_BITS) - lxs);
     150           0 :                     STEP_ALPHA;
     151           0 :                     for (xi = lxi + 1; xi < rxi; xi++)
     152             :                     {
     153           0 :                         ADD_ALPHA (N_X_FRAC(N_BITS));
     154           0 :                         STEP_ALPHA;
     155             :                     }
     156           0 :                     ADD_ALPHA (rxs);
     157             :                 }
     158             :             }
     159             : #endif
     160             :         }
     161             : 
     162           0 :         if (y == b)
     163           0 :             break;
     164             : 
     165             : #if N_BITS > 1
     166           0 :         if (pixman_fixed_frac (y) != Y_FRAC_LAST(N_BITS))
     167             :         {
     168           0 :             RENDER_EDGE_STEP_SMALL (l);
     169           0 :             RENDER_EDGE_STEP_SMALL (r);
     170           0 :             y += STEP_Y_SMALL(N_BITS);
     171             :         }
     172             :         else
     173             : #endif
     174             :         {
     175           0 :             RENDER_EDGE_STEP_BIG (l);
     176           0 :             RENDER_EDGE_STEP_BIG (r);
     177           0 :             y += STEP_Y_BIG(N_BITS);
     178           0 :             line += stride;
     179             :         }
     180             :     }
     181           0 : }
     182             : 
     183             : #undef rasterize_span

Generated by: LCOV version 1.13