Line data Source code
1 : /*
2 : * Copyright 2011 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #include "SkMathPriv.h"
9 :
10 : #define SCALE_FILTER_NAME MAKENAME(_filter_DX_shaderproc)
11 :
12 : // Can't be static in the general case because some of these implementations
13 : // will be defined and referenced in different object files.
14 : void SCALE_FILTER_NAME(const void* sIn, int x, int y, SkPMColor* SK_RESTRICT colors, int count);
15 :
16 0 : void SCALE_FILTER_NAME(const void* sIn, int x, int y, SkPMColor* SK_RESTRICT colors, int count) {
17 0 : const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn);
18 0 : SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
19 : SkMatrix::kScale_Mask)) == 0);
20 0 : SkASSERT(s.fInvKy == 0);
21 0 : SkASSERT(count > 0 && colors != nullptr);
22 0 : SkASSERT(s.fFilterQuality != kNone_SkFilterQuality);
23 0 : SkDEBUGCODE(CHECKSTATE(s);)
24 :
25 0 : const unsigned maxX = s.fPixmap.width() - 1;
26 0 : const SkFixed oneX = s.fFilterOneX;
27 0 : const SkFixed dx = s.fInvSx;
28 : SkFixed fx;
29 : const SRCTYPE* SK_RESTRICT row0;
30 : const SRCTYPE* SK_RESTRICT row1;
31 : unsigned subY;
32 :
33 : {
34 0 : const SkBitmapProcStateAutoMapper mapper(s, x, y);
35 0 : SkFixed fy = mapper.fixedY();
36 0 : const unsigned maxY = s.fPixmap.height() - 1;
37 : // compute our two Y values up front
38 0 : subY = EXTRACT_LOW_BITS(fy, maxY);
39 0 : int y0 = TILEY_PROCF(fy, maxY);
40 0 : int y1 = TILEY_PROCF((fy + s.fFilterOneY), maxY);
41 :
42 0 : const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
43 0 : size_t rb = s.fPixmap.rowBytes();
44 0 : row0 = (const SRCTYPE*)(srcAddr + y0 * rb);
45 0 : row1 = (const SRCTYPE*)(srcAddr + y1 * rb);
46 : // now initialize fx
47 0 : fx = mapper.fixedX();
48 : }
49 :
50 : #ifdef PREAMBLE
51 0 : PREAMBLE(s);
52 : #endif
53 :
54 0 : do {
55 0 : unsigned subX = EXTRACT_LOW_BITS(fx, maxX);
56 0 : unsigned x0 = TILEX_PROCF(fx, maxX);
57 0 : unsigned x1 = TILEX_PROCF((fx + oneX), maxX);
58 :
59 0 : FILTER_PROC(subX, subY,
60 : SRC_TO_FILTER(row0[x0]),
61 : SRC_TO_FILTER(row0[x1]),
62 : SRC_TO_FILTER(row1[x0]),
63 : SRC_TO_FILTER(row1[x1]),
64 0 : colors);
65 0 : colors += 1;
66 :
67 0 : fx += dx;
68 : } while (--count != 0);
69 :
70 : #ifdef POSTAMBLE
71 : POSTAMBLE(s);
72 : #endif
73 0 : }
74 :
75 : ///////////////////////////////////////////////////////////////////////////////
76 :
77 : #undef TILEX_PROCF
78 : #undef TILEY_PROCF
79 : #undef EXTRACT_LOW_BITS
80 : #undef MAKENAME
81 : #undef SRCTYPE
82 : #undef CHECKSTATE
83 : #undef SRC_TO_FILTER
84 : #undef FILTER_TO_DST
85 : #undef PREAMBLE
86 : #undef POSTAMBLE
87 :
88 : #undef SCALE_FILTER_NAME
|