LCOV - app.info - gfx/skia/src/core/SkBitmapProcState_sample.h

LCOV - code coverage report
| Current view: | directory - gfx/skia/src/core - SkBitmapProcState_sample.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 102 | 0 | 0.0 %
| Date: | 2012-06-02 | Functions: | 48 | 0 | 0.0 %

           1                 :
           2                 : /*
           3                 :  * Copyright 2011 Google Inc.
           4                 :  *
           5                 :  * Use of this source code is governed by a BSD-style license that can be
           6                 :  * found in the LICENSE file.
           7                 :  */
           8                 : #include "SkUtils.h"
           9                 :
          10                 : #if DSTSIZE==32
          11                 :     #define DSTTYPE SkPMColor
          12                 : #elif DSTSIZE==16
          13                 :     #define DSTTYPE uint16_t
          14                 : #else
          15                 :     #error "need DSTSIZE to be 32 or 16"
          16                 : #endif
          17                 :
          18                 : #if (DSTSIZE == 32)
          19                 :     #define BITMAPPROC_MEMSET(ptr, value, n) sk_memset32(ptr, value, n)
          20                 : #elif (DSTSIZE == 16)
          21                 :     #define BITMAPPROC_MEMSET(ptr, value, n) sk_memset16(ptr, value, n)
          22                 : #else
          23                 :     #error "unsupported DSTSIZE"
          24                 : #endif
          25                 :
          26               0 : void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s,
          27                 :                               const uint32_t* SK_RESTRICT xy,
          28                 :                               int count, DSTTYPE* SK_RESTRICT colors) {
          29               0 :     SkASSERT(count > 0 && colors != NULL);
          30               0 :     SkASSERT(s.fDoFilter == false);
          31               0 :     SkDEBUGCODE(CHECKSTATE(s);)
          32                 :
          33                 : #ifdef PREAMBLE
          34               0 :     PREAMBLE(s);
          35                 : #endif
          36               0 :     const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
          37               0 :     int i, rb = s.fBitmap->rowBytes();
          38                 :
          39                 :     uint32_t XY;
          40                 :     SRCTYPE src;
          41                 :
          42               0 :     for (i = (count >> 1); i > 0; --i) {
          43               0 :         XY = *xy++;
          44               0 :         SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() &&
          45                 :                  (XY & 0xFFFF) < (unsigned)s.fBitmap->width());
          46               0 :         src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
          47               0 :         *colors++ = RETURNDST(src);
          48                 :
          49               0 :         XY = *xy++;
          50               0 :         SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() &&
          51                 :                  (XY & 0xFFFF) < (unsigned)s.fBitmap->width());
          52               0 :         src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
          53               0 :         *colors++ = RETURNDST(src);
          54                 :     }
          55               0 :     if (count & 1) {
          56               0 :         XY = *xy++;
          57               0 :         SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() &&
          58                 :                  (XY & 0xFFFF) < (unsigned)s.fBitmap->width());
          59               0 :         src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
          60               0 :         *colors++ = RETURNDST(src);
          61                 :     }
          62                 :
          63                 : #ifdef POSTAMBLE
          64               0 :     POSTAMBLE(s);
          65                 : #endif
          66               0 : }
          67                 :
          68               0 : void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s,
          69                 :                             const uint32_t* SK_RESTRICT xy,
          70                 :                             int count, DSTTYPE* SK_RESTRICT colors) {
          71               0 :     SkASSERT(count > 0 && colors != NULL);
          72               0 :     SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
          73               0 :     SkASSERT(s.fDoFilter == false);
          74               0 :     SkDEBUGCODE(CHECKSTATE(s);)
          75                 :
          76                 : #ifdef PREAMBLE
          77               0 :     PREAMBLE(s);
          78                 : #endif
          79               0 :     const SRCTYPE* SK_RESTRICT srcAddr = (const SRCTYPE*)s.fBitmap->getPixels();
          80                 :
          81                 :     // buffer is y32, x16, x16, x16, x16, x16
          82                 :     // bump srcAddr to the proper row, since we're told Y never changes
          83               0 :     SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height());
          84                 :     srcAddr = (const SRCTYPE*)((const char*)srcAddr +
          85               0 :                                                 xy[0] * s.fBitmap->rowBytes());
          86               0 :     xy += 1;
          87                 :
          88                 :     SRCTYPE src;
          89                 :
          90               0 :     if (1 == s.fBitmap->width()) {
          91               0 :         src = srcAddr[0];
          92               0 :         DSTTYPE dstValue = RETURNDST(src);
          93               0 :         BITMAPPROC_MEMSET(colors, dstValue, count);
          94                 :     } else {
          95                 :         int i;
          96               0 :         for (i = (count >> 2); i > 0; --i) {
          97               0 :             uint32_t xx0 = *xy++;
          98               0 :             uint32_t xx1 = *xy++;
          99               0 :             SRCTYPE x0 = srcAddr[UNPACK_PRIMARY_SHORT(xx0)];
         100               0 :             SRCTYPE x1 = srcAddr[UNPACK_SECONDARY_SHORT(xx0)];
         101               0 :             SRCTYPE x2 = srcAddr[UNPACK_PRIMARY_SHORT(xx1)];
         102               0 :             SRCTYPE x3 = srcAddr[UNPACK_SECONDARY_SHORT(xx1)];
         103                 :
         104               0 :             *colors++ = RETURNDST(x0);
         105               0 :             *colors++ = RETURNDST(x1);
         106               0 :             *colors++ = RETURNDST(x2);
         107               0 :             *colors++ = RETURNDST(x3);
         108                 :         }
         109               0 :         const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy);
         110               0 :         for (i = (count & 3); i > 0; --i) {
         111               0 :             SkASSERT(*xx < (unsigned)s.fBitmap->width());
         112               0 :             src = srcAddr[*xx++]; *colors++ = RETURNDST(src);
         113                 :         }
         114                 :     }
         115                 :
         116                 : #ifdef POSTAMBLE
         117               0 :     POSTAMBLE(s);
         118                 : #endif
         119               0 : }
         120                 :
         121                 : ///////////////////////////////////////////////////////////////////////////////
         122                 :
         123               0 : void MAKENAME(_filter_DX)(const SkBitmapProcState& s,
         124                 :                           const uint32_t* SK_RESTRICT xy,
         125                 :                            int count, DSTTYPE* SK_RESTRICT colors) {
         126               0 :     SkASSERT(count > 0 && colors != NULL);
         127               0 :     SkASSERT(s.fDoFilter);
         128               0 :     SkDEBUGCODE(CHECKSTATE(s);)
         129                 :
         130                 : #ifdef PREAMBLE
         131               0 :     PREAMBLE(s);
         132                 : #endif
         133               0 :     const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
         134               0 :     unsigned rb = s.fBitmap->rowBytes();
         135                 :     unsigned subY;
         136                 :     const SRCTYPE* SK_RESTRICT row0;
         137                 :     const SRCTYPE* SK_RESTRICT row1;
         138                 :
         139                 :     // setup row ptrs and update proc_table
         140                 :     {
         141               0 :         uint32_t XY = *xy++;
         142               0 :         unsigned y0 = XY >> 14;
         143               0 :         row0 = (const SRCTYPE*)(srcAddr + (y0 >> 4) * rb);
         144               0 :         row1 = (const SRCTYPE*)(srcAddr + (XY & 0x3FFF) * rb);
         145               0 :         subY = y0 & 0xF;
         146                 :     }
         147                 :
         148               0 :     do {
         149               0 :         uint32_t XX = *xy++;    // x0:14 | 4 | x1:14
         150               0 :         unsigned x0 = XX >> 14;
         151               0 :         unsigned x1 = XX & 0x3FFF;
         152               0 :         unsigned subX = x0 & 0xF;
         153               0 :         x0 >>= 4;
         154                 :
         155               0 :         FILTER_PROC(subX, subY,
         156                 :                     SRC_TO_FILTER(row0[x0]),
         157                 :                     SRC_TO_FILTER(row0[x1]),
         158                 :                     SRC_TO_FILTER(row1[x0]),
         159                 :                     SRC_TO_FILTER(row1[x1]),
         160               0 :                     colors);
         161               0 :         colors += 1;
         162                 :
         163                 :     } while (--count != 0);
         164                 :
         165                 : #ifdef POSTAMBLE
         166               0 :     POSTAMBLE(s);
         167                 : #endif
         168               0 : }
         169               0 : void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s,
         170                 :                             const uint32_t* SK_RESTRICT xy,
         171                 :                             int count, DSTTYPE* SK_RESTRICT colors) {
         172               0 :     SkASSERT(count > 0 && colors != NULL);
         173               0 :     SkASSERT(s.fDoFilter);
         174               0 :     SkDEBUGCODE(CHECKSTATE(s);)
         175                 :
         176                 : #ifdef PREAMBLE
         177               0 :         PREAMBLE(s);
         178                 : #endif
         179               0 :     const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
         180               0 :     int rb = s.fBitmap->rowBytes();
         181                 :
         182               0 :     do {
         183               0 :         uint32_t data = *xy++;
         184               0 :         unsigned y0 = data >> 14;
         185               0 :         unsigned y1 = data & 0x3FFF;
         186               0 :         unsigned subY = y0 & 0xF;
         187               0 :         y0 >>= 4;
         188                 :
         189               0 :         data = *xy++;
         190               0 :         unsigned x0 = data >> 14;
         191               0 :         unsigned x1 = data & 0x3FFF;
         192               0 :         unsigned subX = x0 & 0xF;
         193               0 :         x0 >>= 4;
         194                 :
         195               0 :         const SRCTYPE* SK_RESTRICT row0 = (const SRCTYPE*)(srcAddr + y0 * rb);
         196               0 :         const SRCTYPE* SK_RESTRICT row1 = (const SRCTYPE*)(srcAddr + y1 * rb);
         197                 :
         198               0 :         FILTER_PROC(subX, subY,
         199                 :                     SRC_TO_FILTER(row0[x0]),
         200                 :                     SRC_TO_FILTER(row0[x1]),
         201                 :                     SRC_TO_FILTER(row1[x0]),
         202                 :                     SRC_TO_FILTER(row1[x1]),
         203               0 :                     colors);
         204               0 :         colors += 1;
         205                 :     } while (--count != 0);
         206                 :
         207                 : #ifdef POSTAMBLE
         208               0 :     POSTAMBLE(s);
         209                 : #endif
         210               0 : }
         211                 :
         212                 : #undef MAKENAME
         213                 : #undef DSTSIZE
         214                 : #undef DSTTYPE
         215                 : #undef SRCTYPE
         216                 : #undef CHECKSTATE
         217                 : #undef RETURNDST
         218                 : #undef SRC_TO_FILTER
         219                 : #undef FILTER_TO_DST
         220                 :
         221                 : #ifdef PREAMBLE
         222                 :     #undef PREAMBLE
         223                 : #endif
         224                 : #ifdef POSTAMBLE
         225                 :     #undef POSTAMBLE
         226                 : #endif
         227                 :
         228                 : #undef FILTER_PROC_TYPE
         229                 : #undef GET_FILTER_TABLE
         230                 : #undef GET_FILTER_ROW
         231                 : #undef GET_FILTER_ROW_PROC
         232                 : #undef GET_FILTER_PROC
         233                 : #undef BITMAPPROC_MEMSET

Generated by: LCOV version 1.7