Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: skia/sgl/SkBitmapProcState_matrixProcs.cpp

Issue 113827: Remove the remainder of the skia source code from the Chromium repo.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « skia/sgl/SkBitmapProcState_matrix.h ('k') | skia/sgl/SkBitmapProcState_sample.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "SkBitmapProcState.h"
2 #include "SkPerspIter.h"
3 #include "SkShader.h"
4
5 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count);
6 void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count);
7
8 #ifdef SK_CPU_BENDIAN
9 #define PACK_TWO_SHORTS(pri, sec) ((pri) << 16 | (sec))
10 #else
11 #define PACK_TWO_SHORTS(pri, sec) ((pri) | ((sec) << 16))
12 #endif
13
14 #ifdef SK_DEBUG
15 static uint32_t pack_two_shorts(U16CPU pri, U16CPU sec)
16 {
17 SkASSERT((uint16_t)pri == pri);
18 SkASSERT((uint16_t)sec == sec);
19 return PACK_TWO_SHORTS(pri, sec);
20 }
21 #else
22 #define pack_two_shorts(pri, sec) PACK_TWO_SHORTS(pri, sec)
23 #endif
24
25 #define MAKENAME(suffix) ClampX_ClampY ## suffix
26 #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max)
27 #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max)
28 #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF)
29 #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF)
30 #define CHECK_FOR_DECAL
31 #define TILEX_TRANS(x, max) SkClampMax(x, max)
32 #define TILEY_TRANS(y, max) SkClampMax(y, max)
33 #include "SkBitmapProcState_matrix.h"
34
35 #define MAKENAME(suffix) RepeatX_RepeatY ## suffix
36 #define TILEX_PROCF(fx, max) (((fx) & 0xFFFF) * ((max) + 1) >> 16)
37 #define TILEY_PROCF(fy, max) (((fy) & 0xFFFF) * ((max) + 1) >> 16)
38 #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
39 #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
40 #define SK_MOD(a, b) (((a)%(b)) < 0 ? ((a)%(b) + (b)) : (a)%(b))
41 #define TILEX_TRANS(x, max) (SK_MOD((x), ((max) + 1)))
42 #define TILEY_TRANS(y, max) (SK_MOD((y), ((max) + 1)))
43 #include "SkBitmapProcState_matrix.h"
44
45 #define MAKENAME(suffix) GeneralXY ## suffix
46 #define PREAMBLE(state) SkBitmapProcState::FixedTileProc tileProcX = (st ate).fTileProcX; \
47 SkBitmapProcState::FixedTileProc tileProcY = (st ate).fTileProcY
48 #define PREAMBLE_PARAM_X , SkBitmapProcState::FixedTileProc tileProcX
49 #define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY
50 #define PREAMBLE_ARG_X , tileProcX
51 #define PREAMBLE_ARG_Y , tileProcY
52 #define TILEX_PROCF(fx, max) (tileProcX(fx, max) >> 16)
53 #define TILEY_PROCF(fy, max) (tileProcY(fy, max) >> 16)
54 #define TILEX_LOW_BITS(fx, max) ((tileProcX(fx, max) >> 14) & 0x3)
55 #define TILEY_LOW_BITS(fy, max) ((tileProcY(fy, max) >> 14) & 0x3)
56 #define PREAMBLE_TRANS(state) SkBitmapProcState::IntTileProc tileProcX = (stat e).iTileProcX; \
57 SkBitmapProcState::IntTileProc tileProcY = (stat e).iTileProcY
58 #define TILEX_TRANS(x, max) tileProcX(x, max)
59 #define TILEY_TRANS(y, max) tileProcY(y, max)
60 #include "SkBitmapProcState_matrix.h"
61
62
63
64 static inline SkFixed fixed_clamp(SkFixed x, int max)
65 {
66 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
67 if (x >> 16)
68 x = 0xFFFF;
69 if (x < 0)
70 x = 0;
71 #else
72 if (x >> 16)
73 {
74 if (x < 0)
75 x = 0;
76 else
77 x = 0xFFFF;
78 }
79 #endif
80 return x * (max + 1);
81 }
82
83 static inline SkFixed fixed_repeat(SkFixed x, int max)
84 {
85 return (x & 0xFFFF) * (max + 1);
86 }
87
88 static inline SkFixed fixed_mirror(SkFixed x, int max)
89 {
90 SkFixed s = x << 15 >> 31;
91 // s is FFFFFFFF if we're on an odd interval, or 0 if an even interval
92 x = ((x ^ s) & 0xFFFF) * (max + 1);
93 return s ? (x ^ 0xFFFF) : x;
94 }
95
96 static SkBitmapProcState::FixedTileProc choose_tile_proc(unsigned m)
97 {
98 if (SkShader::kClamp_TileMode == m)
99 return fixed_clamp;
100 if (SkShader::kRepeat_TileMode == m)
101 return fixed_repeat;
102 SkASSERT(SkShader::kMirror_TileMode == m);
103 return fixed_mirror;
104 }
105
106 static inline int int_clamp(int x, int max)
107 {
108 SkASSERT(max >= 0);
109
110 return SkClampMax(x, max);
111 }
112
113 static inline int int_repeat(int x, int max)
114 {
115 SkASSERT(max >= 0);
116
117 return x % (max + 1);
118 }
119
120 static inline int int_mirror(int x, int max)
121 {
122 SkASSERT(max >= 0);
123
124 int dx = x % (max + 1);
125 if (dx < 0)
126 dx = -dx - 1;
127
128 return (x / (max + 1) % 2) ? max - dx : dx;
129 }
130
131 static SkBitmapProcState::IntTileProc choose_int_tile_proc(unsigned m)
132 {
133 if (SkShader::kClamp_TileMode == m)
134 return int_clamp;
135 if (SkShader::kRepeat_TileMode == m)
136 return int_repeat;
137 SkASSERT(SkShader::kMirror_TileMode == m);
138 return int_mirror;
139 }
140
141 SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc()
142 {
143 int index = 0;
144 if (fDoFilter)
145 index = 1;
146 if (fInvType & SkMatrix::kPerspective_Mask)
147 index |= 6;
148 else if (fInvType & SkMatrix::kAffine_Mask)
149 index |= 4;
150 else if (fInvType & SkMatrix::kScale_Mask)
151 index |= 2;
152
153 if (SkShader::kClamp_TileMode == fTileModeX &&
154 SkShader::kClamp_TileMode == fTileModeY)
155 {
156 // clamp gets special version of filterOne
157 fFilterOneX = SK_Fixed1;
158 fFilterOneY = SK_Fixed1;
159 return ClampX_ClampY_Procs[index];
160 }
161
162 // all remaining procs use this form for filterOne
163 fFilterOneX = SK_Fixed1 / fBitmap->width();
164 fFilterOneY = SK_Fixed1 / fBitmap->height();
165
166 if (SkShader::kRepeat_TileMode == fTileModeX &&
167 SkShader::kRepeat_TileMode == fTileModeY)
168 {
169 return RepeatX_RepeatY_Procs[index];
170 }
171
172 // only general needs these procs
173 fTileProcX = choose_tile_proc(fTileModeX);
174 fTileProcY = choose_tile_proc(fTileModeY);
175 iTileProcX = choose_int_tile_proc(fTileModeX);
176 iTileProcY = choose_int_tile_proc(fTileModeY);
177 return GeneralXY_Procs[index];
178 }
179
180 //////////////////////////////////////////////////////////////////////////////
181
182 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count)
183 {
184 int i;
185
186 for (i = (count >> 2); i > 0; --i)
187 {
188 *dst++ = pack_two_shorts(fx >> 16, (fx + dx) >> 16);
189 fx += dx+dx;
190 *dst++ = pack_two_shorts(fx >> 16, (fx + dx) >> 16);
191 fx += dx+dx;
192 }
193 uint16_t* xx = (uint16_t*)dst;
194
195 for (i = (count & 3); i > 0; --i)
196 {
197 *xx++ = SkToU16(fx >> 16); fx += dx;
198 }
199 }
200
201 void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count)
202 {
203 if (count & 1)
204 {
205 SkASSERT((fx >> (16 + 14)) == 0);
206 *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1);
207 fx += dx;
208 }
209 while ((count -= 2) >= 0)
210 {
211 SkASSERT((fx >> (16 + 14)) == 0);
212 *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1);
213 fx += dx;
214
215 *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1);
216 fx += dx;
217 }
218 }
219
220 ///////////////////////////////////
221
222 void repeat_nofilter_identity(uint32_t dst[], int x, int width, int count)
223 {
224 if (x >= width)
225 x %= width;
226
227 int i;
228 uint16_t* xx = (uint16_t*)dst;
229
230 // do the first partial run
231 int n = width - x;
232 if (n > count)
233 n = count;
234
235 count -= n;
236 n += x;
237 for (i = x; i < n; i++)
238 *xx++ = SkToU16(i);
239
240 // do all the full-width runs
241 while ((count -= width) >= 0)
242 for (i = 0; i < width; i++)
243 *xx++ = SkToU16(i);
244
245 // final cleanup run
246 count += width;
247 for (i = 0; i < count; i++)
248 *xx++ = SkToU16(i);
249 }
250
OLDNEW
« no previous file with comments | « skia/sgl/SkBitmapProcState_matrix.h ('k') | skia/sgl/SkBitmapProcState_sample.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698