180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2007 The Android Open Source Project
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkBitmapProcState_DEFINED
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkBitmapProcState_DEFINED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkBitmap.h"
1458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger#include "SkBitmapFilter.h"
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkMatrix.h"
1658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger#include "SkScaledImageCache.h"
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define FractionalInt_IS_64BIT
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef FractionalInt_IS_64BIT
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef SkFixed48    SkFractionalInt;
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkScalarToFractionalInt(x)  SkScalarToFixed48(x)
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkFractionalIntToFixed(x)   SkFixed48ToFixed(x)
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkFixedToFractionalInt(x)   SkFixedToFixed48(x)
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkFractionalIntToInt(x)     SkFixed48ToInt(x)
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef SkFixed    SkFractionalInt;
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkScalarToFractionalInt(x)  SkScalarToFixed(x)
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkFractionalIntToFixed(x)   (x)
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkFixedToFractionalInt(x)   (x)
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define SkFractionalIntToInt(x)     ((x) >> 16)
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPaint;
3558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenbergerstruct SkConvolutionProcs;
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkBitmapProcState {
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkBitmapProcState(): fScaledCacheID(NULL), fBitmapFilter(NULL) {}
4058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    ~SkBitmapProcState();
4158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y,
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 SkPMColor[], int count);
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y,
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 uint16_t[], int count);
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*MatrixProc)(const SkBitmapProcState&,
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                               uint32_t bitmapXY[],
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                               int count,
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                               int x, int y);
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*SampleProc32)(const SkBitmapProcState&,
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 const uint32_t[],
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 int count,
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 SkPMColor colors[]);
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*SampleProc16)(const SkBitmapProcState&,
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 const uint32_t[],
6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 int count,
6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 uint16_t colors[]);
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef U16CPU (*FixedTileProc)(SkFixed);   // returns 0..0xFFFF
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int);   // returns 0..0xF
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef U16CPU (*IntTileProc)(int value, int count);   // returns 0..count-1
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    const SkBitmap*     fBitmap;            // chooseProcs - orig or scaled
6858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkMatrix            fInvMatrix;         // chooseProcs
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMatrix::MapXYProc fInvProc;           // chooseProcs
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFractionalInt     fInvSxFractionalInt;
7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFractionalInt     fInvKyFractionalInt;
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    FixedTileProc       fTileProcX;         // chooseProcs
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    FixedTileProc       fTileProcY;         // chooseProcs
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    IntTileProc         fIntTileProcY;      // chooseProcs
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFixed             fFilterOneX;
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFixed             fFilterOneY;
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
8258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkConvolutionProcs* fConvolutionProcs;         // possiblyScaleImage
8358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPMColor           fPaintPMColor;      // chooseProcs - A8 config
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFixed             fInvSx;             // chooseProcs
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFixed             fInvKy;             // chooseProcs
8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint16_t            fAlphaScale;        // chooseProcs
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint8_t             fInvType;           // chooseProcs
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint8_t             fTileModeX;         // CONSTRUCTOR
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint8_t             fTileModeY;         // CONSTRUCTOR
9158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    uint8_t             fFilterLevel;       // chooseProcs
9258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
9358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /** The shader will let us know when we can release some of our resources
9458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger      * like scaled bitmaps.
9558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger      */
9658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
9758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    void endContext();
9880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Platforms implement this, and can optionally overwrite only the
10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        following fields:
10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fShaderProc32
10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fShaderProc16
10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fMatrixProc
10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fSampleProc32
10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fSampleProc32
10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        They will already have valid function pointers, so a platform that does
10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        not have an accelerated version can just leave that field as is. A valid
11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        implementation can do nothing (see SkBitmapProcState_opts_none.cpp)
11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void platformProcs();
11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
11458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /** Platforms can also optionally overwrite the convolution functions
11558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        if we have SIMD versions of them.
11658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger      */
11758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
11858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    void platformConvolutionProcs();
119779bf8a99dc7f03e5c43b26d4b85d7920ce89aeeDerek Sollenberger
12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Given the byte size of the index buffer to be passed to the matrix proc,
12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return the maximum number of resulting pixels that can be computed
12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        (i.e. the number of SkPMColor values to be written by the sample proc).
12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        This routine takes into account that filtering and scale-vs-affine
12480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        affect the amount of buffer space needed.
12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Only valid to call after chooseProcs (setContext) has been called. It is
12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        safe to call this inside the shader's shadeSpan() method.
12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int maxCountForBufferSize(size_t bufferSize) const;
13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // If a shader proc is present, then the corresponding matrix/sample procs
13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // are ignored
13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ShaderProc32 getShaderProc32() const { return fShaderProc32; }
13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ShaderProc16 getShaderProc16() const { return fShaderProc16; }
13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
13658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkBitmapFilter* getBitmapFilter() const { return fBitmapFilter; }
13758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DEBUG
13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    MatrixProc getMatrixProc() const;
14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else
14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    MatrixProc getMatrixProc() const { return fMatrixProc; }
14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SampleProc32 getSampleProc32() const { return fSampleProc32; }
14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SampleProc16 getSampleProc16() const { return fSampleProc16; }
14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkBitmapProcShader;
14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ShaderProc32        fShaderProc32;      // chooseProcs
15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ShaderProc16        fShaderProc16;      // chooseProcs
15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // These are used if the shaderproc is NULL
15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    MatrixProc          fMatrixProc;        // chooseProcs
15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SampleProc32        fSampleProc32;      // chooseProcs
15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SampleProc16        fSampleProc16;      // chooseProcs
15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkBitmap            fOrigBitmap;        // CONSTRUCTOR
15758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkBitmap            fScaledBitmap;      // chooseProcs
15858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
15958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkScaledImageCache::ID* fScaledCacheID;
16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    MatrixProc chooseMatrixProc(bool trivial_matrix);
16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool chooseProcs(const SkMatrix& inv, const SkPaint&);
16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ShaderProc32 chooseShaderProc32();
16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
16558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    void possiblyScaleImage();
166779bf8a99dc7f03e5c43b26d4b85d7920ce89aeeDerek Sollenberger
16758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkBitmapFilter* fBitmapFilter;
168779bf8a99dc7f03e5c43b26d4b85d7920ce89aeeDerek Sollenberger
16958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    ShaderProc32 chooseBitmapFilterProc();
170779bf8a99dc7f03e5c43b26d4b85d7920ce89aeeDerek Sollenberger
171363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    // Return false if we failed to setup for fast translate (e.g. overflow)
172363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    bool setupForTranslate();
173363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DEBUG
17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static void DebugMatrixProc(const SkBitmapProcState&,
17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                uint32_t[], int count, int x, int y);
17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*  Macros for packing and unpacking pairs of 16bit values in a 32bit uint.
18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Used to allow access to a stream of uint16_t either one at a time, or
18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    2 at a time by unpacking a uint32_t
18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_CPU_BENDIAN
18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define PACK_TWO_SHORTS(pri, sec) ((pri) << 16 | (sec))
18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define UNPACK_PRIMARY_SHORT(packed)    ((uint32_t)(packed) >> 16)
18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define UNPACK_SECONDARY_SHORT(packed)  ((packed) & 0xFFFF)
18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else
18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define PACK_TWO_SHORTS(pri, sec) ((pri) | ((sec) << 16))
19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define UNPACK_PRIMARY_SHORT(packed)    ((packed) & 0xFFFF)
19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define UNPACK_SECONDARY_SHORT(packed)  ((uint32_t)(packed) >> 16)
19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DEBUG
19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static inline uint32_t pack_two_shorts(U16CPU pri, U16CPU sec) {
19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT((uint16_t)pri == pri);
19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT((uint16_t)sec == sec);
19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return PACK_TWO_SHORTS(pri, sec);
19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else
20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    #define pack_two_shorts(pri, sec)   PACK_TWO_SHORTS(pri, sec)
20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// These functions are generated via macros, but are exposed here so that
20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// platformProcs may test for them by name.
20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid S32_opaque_D32_filter_DX(const SkBitmapProcState& s, const uint32_t xy[],
20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              int count, SkPMColor colors[]);
20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid S32_alpha_D32_filter_DX(const SkBitmapProcState& s, const uint32_t xy[],
20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                             int count, SkPMColor colors[]);
21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid S32_opaque_D32_filter_DXDY(const SkBitmapProcState& s,
21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                           const uint32_t xy[], int count, SkPMColor colors[]);
21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid S32_alpha_D32_filter_DXDY(const SkBitmapProcState& s,
21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                           const uint32_t xy[], int count, SkPMColor colors[]);
21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid ClampX_ClampY_filter_scale(const SkBitmapProcState& s, uint32_t xy[],
21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                int count, int x, int y);
21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid ClampX_ClampY_nofilter_scale(const SkBitmapProcState& s, uint32_t xy[],
21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                  int count, int x, int y);
21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid ClampX_ClampY_filter_affine(const SkBitmapProcState& s,
21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                 uint32_t xy[], int count, int x, int y);
22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s,
22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                   uint32_t xy[], int count, int x, int y);
22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid S32_D16_filter_DX(const SkBitmapProcState& s,
22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                   const uint32_t* xy, int count, uint16_t* colors);
22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
22558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenbergervoid highQualityFilter(const SkBitmapProcState &s, int x, int y,
22658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger                   SkPMColor *SK_RESTRICT colors, int count);
22758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
22858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
230