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

LCOV - code coverage report
| Current view: | directory - gfx/skia/src/core - SkBitmapProcState.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 5 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 3 | 0 | 0.0 %

           1                 :
           2                 : /*
           3                 :  * Copyright 2007 The Android Open Source Project
           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                 :
           9                 :
          10                 : #ifndef SkBitmapProcState_DEFINED
          11                 : #define SkBitmapProcState_DEFINED
          12                 :
          13                 : #include "SkBitmap.h"
          14                 : #include "SkMatrix.h"
          15                 :
          16                 : class SkPaint;
          17                 :
          18               0 : struct SkBitmapProcState {
          19                 :
          20                 :     typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y,
          21                 :                                  SkPMColor[], int count);
          22                 :
          23                 :     typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y,
          24                 :                                  uint16_t[], int count);
          25                 :
          26                 :     typedef void (*MatrixProc)(const SkBitmapProcState&,
          27                 :                                uint32_t bitmapXY[],
          28                 :                                int count,
          29                 :                                int x, int y);
          30                 :
          31                 :     typedef void (*SampleProc32)(const SkBitmapProcState&,
          32                 :                                  const uint32_t[],
          33                 :                                  int count,
          34                 :                                  SkPMColor colors[]);
          35                 :
          36                 :     typedef void (*SampleProc16)(const SkBitmapProcState&,
          37                 :                                  const uint32_t[],
          38                 :                                  int count,
          39                 :                                  uint16_t colors[]);
          40                 :
          41                 :     typedef U16CPU (*FixedTileProc)(SkFixed);   // returns 0..0xFFFF
          42                 :     typedef U16CPU (*IntTileProc)(int value, int count);   // returns 0..count-1
          43                 :
          44                 :     // If a shader proc is present, then the corresponding matrix/sample procs
          45                 :     // are ignored
          46                 :     ShaderProc32        fShaderProc32;      // chooseProcs
          47                 :     ShaderProc16        fShaderProc16;      // chooseProcs
          48                 :     // These are used if the shaderproc is NULL
          49                 :     MatrixProc          fMatrixProc;        // chooseProcs
          50                 :     SampleProc32        fSampleProc32;      // chooseProcs
          51                 :     SampleProc16        fSampleProc16;      // chooseProcs
          52                 :
          53                 :     const SkBitmap*     fBitmap;            // chooseProcs - orig or mip
          54                 :     const SkMatrix*     fInvMatrix;         // chooseProcs
          55                 :     SkMatrix::MapXYProc fInvProc;           // chooseProcs
          56                 :
          57                 :     FixedTileProc       fTileProcX;         // chooseProcs
          58                 :     FixedTileProc       fTileProcY;         // chooseProcs
          59                 :     IntTileProc         fIntTileProcY;      // chooseProcs
          60                 :     SkFixed             fFilterOneX;
          61                 :     SkFixed             fFilterOneY;
          62                 :
          63                 :     SkPMColor           fPaintPMColor;      // chooseProcs - A8 config
          64                 :     SkFixed             fInvSx;             // chooseProcs
          65                 :     SkFixed             fInvKy;             // chooseProcs
          66                 :     uint16_t            fAlphaScale;        // chooseProcs
          67                 :     uint8_t             fInvType;           // chooseProcs
          68                 :     uint8_t             fTileModeX;         // CONSTRUCTOR
          69                 :     uint8_t             fTileModeY;         // CONSTRUCTOR
          70                 :     SkBool8             fDoFilter;          // chooseProcs
          71                 :
          72                 :     /** Platforms implement this, and can optionally overwrite only the
          73                 :         following fields:
          74                 :
          75                 :         fShaderProc32
          76                 :         fShaderProc16
          77                 :         fMatrixProc
          78                 :         fSampleProc32
          79                 :         fSampleProc32
          80                 :
          81                 :         They will already have valid function pointers, so a platform that does
          82                 :         not have an accelerated version can just leave that field as is. A valid
          83                 :         implementation can do nothing (see SkBitmapProcState_opts_none.cpp)
          84                 :      */
          85                 :     void platformProcs();
          86                 :
          87                 :     /** Given the byte size of the index buffer to be passed to the matrix proc,
          88                 :         return the maximum number of resulting pixels that can be computed
          89                 :         (i.e. the number of SkPMColor values to be written by the sample proc).
          90                 :         This routine takes into account that filtering and scale-vs-affine
          91                 :         affect the amount of buffer space needed.
          92                 :
          93                 :         Only valid to call after chooseProcs (setContext) has been called. It is
          94                 :         safe to call this inside the shader's shadeSpan() method.
          95                 :      */
          96                 :     int maxCountForBufferSize(size_t bufferSize) const;
          97                 :
          98                 : private:
          99                 :     friend class SkBitmapProcShader;
         100                 :
         101                 :     SkMatrix            fUnitInvMatrix;     // chooseProcs
         102                 :     SkBitmap            fOrigBitmap;        // CONSTRUCTOR
         103                 :     SkBitmap            fMipBitmap;
         104                 :
         105                 :     MatrixProc chooseMatrixProc(bool trivial_matrix);
         106                 :     bool chooseProcs(const SkMatrix& inv, const SkPaint&);
         107                 : };
         108                 :
         109                 : /*  Macros for packing and unpacking pairs of 16bit values in a 32bit uint.
         110                 :     Used to allow access to a stream of uint16_t either one at a time, or
         111                 :     2 at a time by unpacking a uint32_t
         112                 :  */
         113                 : #ifdef SK_CPU_BENDIAN
         114                 :     #define PACK_TWO_SHORTS(pri, sec) ((pri) << 16 | (sec))
         115                 :     #define UNPACK_PRIMARY_SHORT(packed)    ((uint32_t)(packed) >> 16)
         116                 :     #define UNPACK_SECONDARY_SHORT(packed)  ((packed) & 0xFFFF)
         117                 : #else
         118                 :     #define PACK_TWO_SHORTS(pri, sec) ((pri) | ((sec) << 16))
         119                 :     #define UNPACK_PRIMARY_SHORT(packed)    ((packed) & 0xFFFF)
         120                 :     #define UNPACK_SECONDARY_SHORT(packed)  ((uint32_t)(packed) >> 16)
         121                 : #endif
         122                 :
         123                 : #ifdef SK_DEBUG
         124               0 :     static inline uint32_t pack_two_shorts(U16CPU pri, U16CPU sec) {
         125               0 :         SkASSERT((uint16_t)pri == pri);
         126               0 :         SkASSERT((uint16_t)sec == sec);
         127               0 :         return PACK_TWO_SHORTS(pri, sec);
         128                 :     }
         129                 : #else
         130                 :     #define pack_two_shorts(pri, sec)   PACK_TWO_SHORTS(pri, sec)
         131                 : #endif
         132                 :
         133                 : // These functions are generated via macros, but are exposed here so that
         134                 : // platformProcs may test for them by name.
         135                 : void S32_opaque_D32_filter_DX(const SkBitmapProcState& s, const uint32_t xy[],
         136                 :                               int count, SkPMColor colors[]);
         137                 : void S32_alpha_D32_filter_DX(const SkBitmapProcState& s, const uint32_t xy[],
         138                 :                              int count, SkPMColor colors[]);
         139                 :
         140                 : #endif

Generated by: LCOV version 1.7