gfx/skia/trunk/src/core/SkBitmapProcState_shaderproc.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/core/SkBitmapProcState_shaderproc.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +#include "SkMathPriv.h"
    1.13 +
    1.14 +#define SCALE_FILTER_NAME       MAKENAME(_filter_DX_shaderproc)
    1.15 +
    1.16 +// Can't be static in the general case because some of these implementations
    1.17 +// will be defined and referenced in different object files.
    1.18 +void SCALE_FILTER_NAME(const SkBitmapProcState& s, int x, int y,
    1.19 +                       DSTTYPE* SK_RESTRICT colors, int count);
    1.20 +
    1.21 +void SCALE_FILTER_NAME(const SkBitmapProcState& s, int x, int y,
    1.22 +                       DSTTYPE* SK_RESTRICT colors, int count) {
    1.23 +    SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
    1.24 +                             SkMatrix::kScale_Mask)) == 0);
    1.25 +    SkASSERT(s.fInvKy == 0);
    1.26 +    SkASSERT(count > 0 && colors != NULL);
    1.27 +    SkASSERT(s.fFilterLevel != SkPaint::kNone_FilterLevel);
    1.28 +    SkDEBUGCODE(CHECKSTATE(s);)
    1.29 +
    1.30 +    const unsigned maxX = s.fBitmap->width() - 1;
    1.31 +    const SkFixed oneX = s.fFilterOneX;
    1.32 +    const SkFixed dx = s.fInvSx;
    1.33 +    SkFixed fx;
    1.34 +    const SRCTYPE* SK_RESTRICT row0;
    1.35 +    const SRCTYPE* SK_RESTRICT row1;
    1.36 +    unsigned subY;
    1.37 +
    1.38 +    {
    1.39 +        SkPoint pt;
    1.40 +        s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
    1.41 +                   SkIntToScalar(y) + SK_ScalarHalf, &pt);
    1.42 +        SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
    1.43 +        const unsigned maxY = s.fBitmap->height() - 1;
    1.44 +        // compute our two Y values up front
    1.45 +        subY = TILEY_LOW_BITS(fy, maxY);
    1.46 +        int y0 = TILEY_PROCF(fy, maxY);
    1.47 +        int y1 = TILEY_PROCF((fy + s.fFilterOneY), maxY);
    1.48 +
    1.49 +        const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
    1.50 +        size_t rb = s.fBitmap->rowBytes();
    1.51 +        row0 = (const SRCTYPE*)(srcAddr + y0 * rb);
    1.52 +        row1 = (const SRCTYPE*)(srcAddr + y1 * rb);
    1.53 +        // now initialize fx
    1.54 +        fx = SkScalarToFixed(pt.fX) - (oneX >> 1);
    1.55 +    }
    1.56 +
    1.57 +#ifdef PREAMBLE
    1.58 +    PREAMBLE(s);
    1.59 +#endif
    1.60 +
    1.61 +    do {
    1.62 +        unsigned subX = TILEX_LOW_BITS(fx, maxX);
    1.63 +        unsigned x0 = TILEX_PROCF(fx, maxX);
    1.64 +        unsigned x1 = TILEX_PROCF((fx + oneX), maxX);
    1.65 +
    1.66 +        FILTER_PROC(subX, subY,
    1.67 +                    SRC_TO_FILTER(row0[x0]),
    1.68 +                    SRC_TO_FILTER(row0[x1]),
    1.69 +                    SRC_TO_FILTER(row1[x0]),
    1.70 +                    SRC_TO_FILTER(row1[x1]),
    1.71 +                    colors);
    1.72 +        colors += 1;
    1.73 +
    1.74 +        fx += dx;
    1.75 +    } while (--count != 0);
    1.76 +
    1.77 +#ifdef POSTAMBLE
    1.78 +    POSTAMBLE(s);
    1.79 +#endif
    1.80 +}
    1.81 +
    1.82 +///////////////////////////////////////////////////////////////////////////////
    1.83 +
    1.84 +#undef TILEX_PROCF
    1.85 +#undef TILEY_PROCF
    1.86 +#undef TILEX_LOW_BITS
    1.87 +#undef TILEY_LOW_BITS
    1.88 +#undef MAKENAME
    1.89 +#undef SRCTYPE
    1.90 +#undef DSTTYPE
    1.91 +#undef CHECKSTATE
    1.92 +#undef SRC_TO_FILTER
    1.93 +#undef FILTER_TO_DST
    1.94 +#undef PREAMBLE
    1.95 +#undef POSTAMBLE
    1.96 +
    1.97 +#undef SCALE_FILTER_NAME

mercurial