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

Side by Side Diff: src/core/SkBitmapProcState.cpp

Issue 1753903002: fission bitmapprocstate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use real types instead of uint8_t, fix formatting Created 4 years, 9 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
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkBitmapController.h" 9 #include "SkBitmapController.h"
10 #include "SkBitmapProcState.h" 10 #include "SkBitmapProcState.h"
(...skipping 18 matching lines...) Expand all
29 extern void SI8_opaque_D32_filter_DX_shaderproc_neon(const void *, int, int, ui nt32_t*, int); 29 extern void SI8_opaque_D32_filter_DX_shaderproc_neon(const void *, int, int, ui nt32_t*, int);
30 extern void Clamp_SI8_opaque_D32_filter_DX_shaderproc_neon(const void*, int, in t, uint32_t*, int); 30 extern void Clamp_SI8_opaque_D32_filter_DX_shaderproc_neon(const void*, int, in t, uint32_t*, int);
31 #endif 31 #endif
32 32
33 extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void*, int, int, u int32_t*, int); 33 extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void*, int, int, u int32_t*, int);
34 34
35 #define NAME_WRAP(x) x 35 #define NAME_WRAP(x) x
36 #include "SkBitmapProcState_filter.h" 36 #include "SkBitmapProcState_filter.h"
37 #include "SkBitmapProcState_procs.h" 37 #include "SkBitmapProcState_procs.h"
38 38
39 SkBitmapProcState::SkBitmapProcState(const SkBitmapProvider& provider, 39 SkBitmapProcInfo::SkBitmapProcInfo(const SkBitmapProvider& provider,
40 SkShader::TileMode tmx, SkShader::TileMode tmy) 40 SkShader::TileMode tmx, SkShader::TileMode tm y)
41 : fProvider(provider) 41 : fProvider(provider)
42 , fTileModeX(tmx)
43 , fTileModeY(tmy)
42 , fBMState(nullptr) 44 , fBMState(nullptr)
43 { 45 {}
44 fTileModeX = tmx;
45 fTileModeY = tmy;
46 }
47 46
48 SkBitmapProcState::SkBitmapProcState(const SkBitmap& bm, 47 SkBitmapProcInfo::SkBitmapProcInfo(const SkBitmap& bm,
49 SkShader::TileMode tmx, SkShader::TileMode tmy) 48 SkShader::TileMode tmx, SkShader::TileMode tm y)
50 : fProvider(SkBitmapProvider(bm)) 49 : fProvider(SkBitmapProvider(bm))
50 , fTileModeX(tmx)
51 , fTileModeY(tmy)
51 , fBMState(nullptr) 52 , fBMState(nullptr)
52 { 53 {}
53 fTileModeX = tmx;
54 fTileModeY = tmy;
55 }
56 54
57 SkBitmapProcState::~SkBitmapProcState() { 55 SkBitmapProcInfo::~SkBitmapProcInfo() {
58 SkInPlaceDeleteCheck(fBMState, fBMStateStorage.get()); 56 SkInPlaceDeleteCheck(fBMState, fBMStateStorage.get());
59 } 57 }
60 58
61 /////////////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////////////
62 60
63 // true iff the matrix contains, at most, scale and translate elements 61 // true iff the matrix contains, at most, scale and translate elements
64 static bool matrix_only_scale_translate(const SkMatrix& m) { 62 static bool matrix_only_scale_translate(const SkMatrix& m) {
65 return m.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask); 63 return m.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask);
66 } 64 }
67 65
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // if we got here, treat us as either kTranslate_Mask or identity 109 // if we got here, treat us as either kTranslate_Mask or identity
112 return true; 110 return true;
113 } 111 }
114 112
115 static bool valid_for_filtering(unsigned dimension) { 113 static bool valid_for_filtering(unsigned dimension) {
116 // for filtering, width and height must fit in 14bits, since we use steal 114 // for filtering, width and height must fit in 14bits, since we use steal
117 // 2 bits from each to store our 4bit subpixel data 115 // 2 bits from each to store our 4bit subpixel data
118 return (dimension & ~0x3FFF) == 0; 116 return (dimension & ~0x3FFF) == 0;
119 } 117 }
120 118
121 /* 119 bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) {
122 * Analyze filter-quality and matrix, and decide how to implement that. 120 const int origW = fProvider.info().width();
123 * 121 const int origH = fProvider.info().height();
124 * In general, we cascade down the request level [ High ... None ] 122
125 * - for a given level, if we can fulfill it, fine, else
126 * - else we downgrade to the next lower level and try again.
127 * We can always fulfill requests for Low and None
128 * - sometimes we will "ignore" Low and give None, but this is likely a legacy perf hack
129 * and may be removed.
130 */
131 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
132 fPixmap.reset(); 123 fPixmap.reset();
133 fInvMatrix = inv; 124 fInvMatrix = inv;
134 fFilterLevel = paint.getFilterQuality(); 125 fFilterQuality = paint.getFilterQuality();
135 126
136 const int origW = fProvider.info().width();
137 const int origH = fProvider.info().height();
138 bool allow_ignore_fractional_translate = true; // historical default 127 bool allow_ignore_fractional_translate = true; // historical default
139 if (kMedium_SkFilterQuality == fFilterLevel) { 128 if (kMedium_SkFilterQuality == fFilterQuality) {
140 allow_ignore_fractional_translate = false; 129 allow_ignore_fractional_translate = false;
141 } 130 }
142 131
143 SkDefaultBitmapController controller; 132 SkDefaultBitmapController controller;
144 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality() , 133 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality() ,
145 fBMStateStorage.get(), fBMStateStorage.s ize()); 134 fBMStateStorage.get(), fBMStateStorage.s ize());
146 // Note : we allow the controller to return an empty (zero-dimension) result . Should we? 135 // Note : we allow the controller to return an empty (zero-dimension) result . Should we?
147 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) { 136 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) {
148 return false; 137 return false;
149 } 138 }
150 fPixmap = fBMState->pixmap(); 139 fPixmap = fBMState->pixmap();
151 fInvMatrix = fBMState->invMatrix(); 140 fInvMatrix = fBMState->invMatrix();
152 fFilterLevel = fBMState->quality(); 141 fPaintColor = paint.getColor();
142 fFilterQuality = fBMState->quality();
153 SkASSERT(fPixmap.addr()); 143 SkASSERT(fPixmap.addr());
154 144
155 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; 145 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
156 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && 146 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
157 SkShader::kClamp_TileMode == fTileModeY; 147 SkShader::kClamp_TileMode == fTileModeY;
158 148
159 // Most of the scanline procs deal with "unit" texture coordinates, as this 149 // Most of the scanline procs deal with "unit" texture coordinates, as this
160 // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generat e 150 // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generat e
161 // those, we divide the matrix by its dimensions here. 151 // those, we divide the matrix by its dimensions here.
162 // 152 //
163 // We don't do this if we're either trivial (can ignore the matrix) or clamp ing 153 // We don't do this if we're either trivial (can ignore the matrix) or clamp ing
164 // in both X and Y since clamping to width,height is just as easy as to 0xFF FF. 154 // in both X and Y since clamping to width,height is just as easy as to 0xFF FF.
165 155
166 if (!(clampClamp || trivialMatrix)) { 156 if (!(clampClamp || trivialMatrix)) {
167 fInvMatrix.postIDiv(fPixmap.width(), fPixmap.height()); 157 fInvMatrix.postIDiv(fPixmap.width(), fPixmap.height());
168 } 158 }
169 159
170 // Now that all possible changes to the matrix have taken place, check 160 // Now that all possible changes to the matrix have taken place, check
171 // to see if we're really close to a no-scale matrix. If so, explicitly 161 // to see if we're really close to a no-scale matrix. If so, explicitly
172 // set it to be so. Subsequent code may inspect this matrix to choose 162 // set it to be so. Subsequent code may inspect this matrix to choose
173 // a faster path in this case. 163 // a faster path in this case.
174 164
175 // This code will only execute if the matrix has some scale component; 165 // This code will only execute if the matrix has some scale component;
176 // if it's already pure translate then we won't do this inversion. 166 // if it's already pure translate then we won't do this inversion.
177 167
178 if (matrix_only_scale_translate(fInvMatrix)) { 168 if (matrix_only_scale_translate(fInvMatrix)) {
179 SkMatrix forward; 169 SkMatrix forward;
180 if (fInvMatrix.invert(&forward)) { 170 if (fInvMatrix.invert(&forward)) {
181 if ((clampClamp && allow_ignore_fractional_translate) 171 if ((clampClamp && allow_ignore_fractional_translate)
182 ? just_trans_clamp(forward, fPixmap) 172 ? just_trans_clamp(forward, fPixmap)
183 : just_trans_general(forward)) { 173 : just_trans_general(forward)) {
184 fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTr anslateY()); 174 fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTr anslateY());
185 } 175 }
186 } 176 }
187 } 177 }
188 178
189 fInvProc = fInvMatrix.getMapXYProc(); 179 fInvType = fInvMatrix.getType();
190 fInvType = fInvMatrix.getType();
191 fInvSx = SkScalarToFixed(fInvMatrix.getScaleX());
192 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX());
193 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY());
194 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY());
195
196 fAlphaScale = SkAlpha255To256(paint.getAlpha());
197
198 fShaderProc32 = nullptr;
199 fShaderProc16 = nullptr;
200 fSampleProc32 = nullptr;
201
202 // recompute the triviality of the matrix here because we may have
203 // changed it!
204
205 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
206 180
207 // If our target pixmap is the same as the original, then we revert back to legacy behavior 181 // If our target pixmap is the same as the original, then we revert back to legacy behavior
208 // and allow the code to ignore fractional translate. 182 // and allow the code to ignore fractional translate.
209 // 183 //
210 // The width/height check allows allow_ignore_fractional_translate to stay f alse if we 184 // The width/height check allows allow_ignore_fractional_translate to stay f alse if we
211 // previously set it that way (e.g. we started in kMedium). 185 // previously set it that way (e.g. we started in kMedium).
212 // 186 //
213 if (fPixmap.width() == origW && fPixmap.height() == origH) { 187 if (fPixmap.width() == origW && fPixmap.height() == origH) {
214 allow_ignore_fractional_translate = true; 188 allow_ignore_fractional_translate = true;
215 } 189 }
216 190
217 if (kLow_SkFilterQuality == fFilterLevel && allow_ignore_fractional_translat e) { 191 if (kLow_SkFilterQuality == fFilterQuality && allow_ignore_fractional_transl ate) {
218 // Only try bilerp if the matrix is "interesting" and 192 // Only try bilerp if the matrix is "interesting" and
219 // the image has a suitable size. 193 // the image has a suitable size.
220 194
221 if (fInvType <= SkMatrix::kTranslate_Mask || 195 if (fInvType <= SkMatrix::kTranslate_Mask ||
222 !valid_for_filtering(fPixmap.width() | fPixmap.height())) 196 !valid_for_filtering(fPixmap.width() | fPixmap.height()))
223 { 197 {
224 fFilterLevel = kNone_SkFilterQuality; 198 fFilterQuality = kNone_SkFilterQuality;
225 } 199 }
226 } 200 }
227 201
228 return this->chooseScanlineProcs(trivialMatrix, clampClamp, paint); 202 return true;
229 } 203 }
230 204
231 bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp, 205 /*
232 const SkPaint& paint) { 206 * Analyze filter-quality and matrix, and decide how to implement that.
207 *
208 * In general, we cascade down the request level [ High ... None ]
209 * - for a given level, if we can fulfill it, fine, else
210 * - else we downgrade to the next lower level and try again.
211 * We can always fulfill requests for Low and None
212 * - sometimes we will "ignore" Low and give None, but this is likely a legacy perf hack
213 * and may be removed.
214 */
215 bool SkBitmapProcState::chooseProcs() {
216 fInvProc = fInvMatrix.getMapXYProc();
217 fInvSx = SkScalarToFixed(fInvMatrix.getScaleX());
218 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX());
219 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY());
220 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY());
221
222 fAlphaScale = SkAlpha255To256(SkColorGetA(fPaintColor));
223
224 fShaderProc32 = nullptr;
225 fShaderProc16 = nullptr;
226 fSampleProc32 = nullptr;
227
228 const bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mas k) == 0;
229 const bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
230 SkShader::kClamp_TileMode == fTileModeY;
231
232 return this->chooseScanlineProcs(trivialMatrix, clampClamp);
233 }
234
235 bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp) {
233 fMatrixProc = this->chooseMatrixProc(trivialMatrix); 236 fMatrixProc = this->chooseMatrixProc(trivialMatrix);
234 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns nullptr. 237 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns nullptr.
235 if (nullptr == fMatrixProc) { 238 if (nullptr == fMatrixProc) {
236 return false; 239 return false;
237 } 240 }
238 241
239 /////////////////////////////////////////////////////////////////////// 242 ///////////////////////////////////////////////////////////////////////
240 243
241 const SkAlphaType at = fPixmap.alphaType(); 244 const SkAlphaType at = fPixmap.alphaType();
242 245
243 // No need to do this if we're doing HQ sampling; if filter quality is 246 // No need to do this if we're doing HQ sampling; if filter quality is
244 // still set to HQ by the time we get here, then we must have installed 247 // still set to HQ by the time we get here, then we must have installed
245 // the shader procs above and can skip all this. 248 // the shader procs above and can skip all this.
246 249
247 if (fFilterLevel < kHigh_SkFilterQuality) { 250 if (fFilterQuality < kHigh_SkFilterQuality) {
248 251
249 int index = 0; 252 int index = 0;
250 if (fAlphaScale < 256) { // note: this distinction is not used for D16 253 if (fAlphaScale < 256) { // note: this distinction is not used for D16
251 index |= 1; 254 index |= 1;
252 } 255 }
253 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 256 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
254 index |= 2; 257 index |= 2;
255 } 258 }
256 if (fFilterLevel > kNone_SkFilterQuality) { 259 if (fFilterQuality > kNone_SkFilterQuality) {
257 index |= 4; 260 index |= 4;
258 } 261 }
259 // bits 3,4,5 encoding the source bitmap format 262 // bits 3,4,5 encoding the source bitmap format
260 switch (fPixmap.colorType()) { 263 switch (fPixmap.colorType()) {
261 case kN32_SkColorType: 264 case kN32_SkColorType:
262 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { 265 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) {
263 return false; 266 return false;
264 } 267 }
265 index |= 0; 268 index |= 0;
266 break; 269 break;
267 case kRGB_565_SkColorType: 270 case kRGB_565_SkColorType:
268 index |= 8; 271 index |= 8;
269 break; 272 break;
270 case kIndex_8_SkColorType: 273 case kIndex_8_SkColorType:
271 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { 274 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) {
272 return false; 275 return false;
273 } 276 }
274 index |= 16; 277 index |= 16;
275 break; 278 break;
276 case kARGB_4444_SkColorType: 279 case kARGB_4444_SkColorType:
277 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { 280 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) {
278 return false; 281 return false;
279 } 282 }
280 index |= 24; 283 index |= 24;
281 break; 284 break;
282 case kAlpha_8_SkColorType: 285 case kAlpha_8_SkColorType:
283 index |= 32; 286 index |= 32;
284 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); 287 fPaintPMColor = SkPreMultiplyColor(fPaintColor);
285 break; 288 break;
286 case kGray_8_SkColorType: 289 case kGray_8_SkColorType:
287 index |= 40; 290 index |= 40;
288 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); 291 fPaintPMColor = SkPreMultiplyColor(fPaintColor);
289 break; 292 break;
290 default: 293 default:
291 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead? 294 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead?
292 return false; 295 return false;
293 } 296 }
294 297
295 #if !SK_ARM_NEON_IS_ALWAYS 298 #if !SK_ARM_NEON_IS_ALWAYS
296 static const SampleProc32 gSkBitmapProcStateSample32[] = { 299 static const SampleProc32 gSkBitmapProcStateSample32[] = {
297 S32_opaque_D32_nofilter_DXDY, 300 S32_opaque_D32_nofilter_DXDY,
298 S32_alpha_D32_nofilter_DXDY, 301 S32_alpha_D32_nofilter_DXDY,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 377 }
375 378
376 static void Clamp_S32_D32_nofilter_trans_shaderproc(const void* sIn, 379 static void Clamp_S32_D32_nofilter_trans_shaderproc(const void* sIn,
377 int x, int y, 380 int x, int y,
378 SkPMColor* SK_RESTRICT color s, 381 SkPMColor* SK_RESTRICT color s,
379 int count) { 382 int count) {
380 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); 383 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn);
381 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 384 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
382 SkASSERT(s.fInvKy == 0); 385 SkASSERT(s.fInvKy == 0);
383 SkASSERT(count > 0 && colors != nullptr); 386 SkASSERT(count > 0 && colors != nullptr);
384 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); 387 SkASSERT(kNone_SkFilterQuality == s.fFilterQuality);
385 388
386 const int maxX = s.fPixmap.width() - 1; 389 const int maxX = s.fPixmap.width() - 1;
387 const int maxY = s.fPixmap.height() - 1; 390 const int maxY = s.fPixmap.height() - 1;
388 int ix = s.fFilterOneX + x; 391 int ix = s.fFilterOneX + x;
389 int iy = SkClampMax(s.fFilterOneY + y, maxY); 392 int iy = SkClampMax(s.fFilterOneY + y, maxY);
390 const SkPMColor* row = s.fPixmap.addr32(0, iy); 393 const SkPMColor* row = s.fPixmap.addr32(0, iy);
391 394
392 // clamp to the left 395 // clamp to the left
393 if (ix < 0) { 396 if (ix < 0) {
394 int n = SkMin32(-ix, count); 397 int n = SkMin32(-ix, count);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 440 }
438 441
439 static void Repeat_S32_D32_nofilter_trans_shaderproc(const void* sIn, 442 static void Repeat_S32_D32_nofilter_trans_shaderproc(const void* sIn,
440 int x, int y, 443 int x, int y,
441 SkPMColor* SK_RESTRICT colo rs, 444 SkPMColor* SK_RESTRICT colo rs,
442 int count) { 445 int count) {
443 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); 446 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn);
444 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 447 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
445 SkASSERT(s.fInvKy == 0); 448 SkASSERT(s.fInvKy == 0);
446 SkASSERT(count > 0 && colors != nullptr); 449 SkASSERT(count > 0 && colors != nullptr);
447 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); 450 SkASSERT(kNone_SkFilterQuality == s.fFilterQuality);
448 451
449 const int stopX = s.fPixmap.width(); 452 const int stopX = s.fPixmap.width();
450 const int stopY = s.fPixmap.height(); 453 const int stopY = s.fPixmap.height();
451 int ix = s.fFilterOneX + x; 454 int ix = s.fFilterOneX + x;
452 int iy = sk_int_mod(s.fFilterOneY + y, stopY); 455 int iy = sk_int_mod(s.fFilterOneY + y, stopY);
453 const SkPMColor* row = s.fPixmap.addr32(0, iy); 456 const SkPMColor* row = s.fPixmap.addr32(0, iy);
454 457
455 ix = sk_int_mod(ix, stopX); 458 ix = sk_int_mod(ix, stopX);
456 for (;;) { 459 for (;;) {
457 int n = SkMin32(stopX - ix, count); 460 int n = SkMin32(stopX - ix, count);
(...skipping 14 matching lines...) Expand all
472 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); 475 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn);
473 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0); 476 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0);
474 SkASSERT(s.fInvKy == 0); 477 SkASSERT(s.fInvKy == 0);
475 SkASSERT(count > 0 && colors != nullptr); 478 SkASSERT(count > 0 && colors != nullptr);
476 SkASSERT(1 == s.fPixmap.width()); 479 SkASSERT(1 == s.fPixmap.width());
477 480
478 int iY0; 481 int iY0;
479 int iY1 SK_INIT_TO_AVOID_WARNING; 482 int iY1 SK_INIT_TO_AVOID_WARNING;
480 int iSubY SK_INIT_TO_AVOID_WARNING; 483 int iSubY SK_INIT_TO_AVOID_WARNING;
481 484
482 if (kNone_SkFilterQuality != s.fFilterLevel) { 485 if (kNone_SkFilterQuality != s.fFilterQuality) {
483 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc(); 486 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc();
484 uint32_t xy[2]; 487 uint32_t xy[2];
485 488
486 mproc(s, xy, 1, x, y); 489 mproc(s, xy, 1, x, y);
487 490
488 iY0 = xy[0] >> 18; 491 iY0 = xy[0] >> 18;
489 iY1 = xy[0] & 0x3FFF; 492 iY1 = xy[0] & 0x3FFF;
490 iSubY = (xy[0] >> 14) & 0xF; 493 iSubY = (xy[0] >> 14) & 0xF;
491 } else { 494 } else {
492 int yTemp; 495 int yTemp;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 552 }
550 553
551 SkASSERT(iY0 == iY2); 554 SkASSERT(iY0 == iY2);
552 } 555 }
553 #endif 556 #endif
554 } 557 }
555 558
556 const SkPMColor* row0 = s.fPixmap.addr32(0, iY0); 559 const SkPMColor* row0 = s.fPixmap.addr32(0, iY0);
557 SkPMColor color; 560 SkPMColor color;
558 561
559 if (kNone_SkFilterQuality != s.fFilterLevel) { 562 if (kNone_SkFilterQuality != s.fFilterQuality) {
560 const SkPMColor* row1 = s.fPixmap.addr32(0, iY1); 563 const SkPMColor* row1 = s.fPixmap.addr32(0, iY1);
561 564
562 if (s.fAlphaScale < 256) { 565 if (s.fAlphaScale < 256) {
563 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale); 566 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale);
564 } else { 567 } else {
565 Filter_32_opaque(iSubY, *row0, *row1, &color); 568 Filter_32_opaque(iSubY, *row0, *row1, &color);
566 } 569 }
567 } else { 570 } else {
568 if (s.fAlphaScale < 256) { 571 if (s.fAlphaScale < 256) {
569 color = SkAlphaMulQ(*row0, s.fAlphaScale); 572 color = SkAlphaMulQ(*row0, s.fAlphaScale);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 609
607 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { 610 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() {
608 611
609 if (kN32_SkColorType != fPixmap.colorType()) { 612 if (kN32_SkColorType != fPixmap.colorType()) {
610 return nullptr; 613 return nullptr;
611 } 614 }
612 615
613 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M ask; 616 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M ask;
614 617
615 if (1 == fPixmap.width() && 0 == (fInvType & ~kMask)) { 618 if (1 == fPixmap.width() && 0 == (fInvType & ~kMask)) {
616 if (kNone_SkFilterQuality == fFilterLevel && 619 if (kNone_SkFilterQuality == fFilterQuality &&
617 fInvType <= SkMatrix::kTranslate_Mask && 620 fInvType <= SkMatrix::kTranslate_Mask &&
618 !this->setupForTranslate()) { 621 !this->setupForTranslate()) {
619 return DoNothing_shaderproc; 622 return DoNothing_shaderproc;
620 } 623 }
621 return S32_D32_constX_shaderproc; 624 return S32_D32_constX_shaderproc;
622 } 625 }
623 626
624 if (fAlphaScale < 256) { 627 if (fAlphaScale < 256) {
625 return nullptr; 628 return nullptr;
626 } 629 }
627 if (fInvType > SkMatrix::kTranslate_Mask) { 630 if (fInvType > SkMatrix::kTranslate_Mask) {
628 return nullptr; 631 return nullptr;
629 } 632 }
630 if (kNone_SkFilterQuality != fFilterLevel) { 633 if (kNone_SkFilterQuality != fFilterQuality) {
631 return nullptr; 634 return nullptr;
632 } 635 }
633 636
634 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX; 637 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX;
635 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY; 638 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY;
636 639
637 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) { 640 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) {
638 if (this->setupForTranslate()) { 641 if (this->setupForTranslate()) {
639 return Clamp_S32_D32_nofilter_trans_shaderproc; 642 return Clamp_S32_D32_nofilter_trans_shaderproc;
640 } 643 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 SkASSERT(count > 0); 719 SkASSERT(count > 0);
717 720
718 state.fMatrixProc(state, bitmapXY, count, x, y); 721 state.fMatrixProc(state, bitmapXY, count, x, y);
719 722
720 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my); 723 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my);
721 724
722 // There are four formats possible: 725 // There are four formats possible:
723 // scale -vs- affine 726 // scale -vs- affine
724 // filter -vs- nofilter 727 // filter -vs- nofilter
725 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 728 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
726 proc = state.fFilterLevel != kNone_SkFilterQuality ? check_scale_filter : check_scale_nofilter; 729 proc = state.fFilterQuality != kNone_SkFilterQuality ?
730 check_scale_filter : check_scale_nofilter;
727 } else { 731 } else {
728 proc = state.fFilterLevel != kNone_SkFilterQuality ? check_affine_filter : check_affine_nofilter; 732 proc = state.fFilterQuality != kNone_SkFilterQuality ?
733 check_affine_filter : check_affine_nofilter;
729 } 734 }
730 proc(bitmapXY, count, state.fPixmap.width(), state.fPixmap.height()); 735 proc(bitmapXY, count, state.fPixmap.width(), state.fPixmap.height());
731 } 736 }
732 737
733 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const { 738 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const {
734 return DebugMatrixProc; 739 return DebugMatrixProc;
735 } 740 }
736 741
737 #endif 742 #endif
738 743
(...skipping 14 matching lines...) Expand all
753 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 758 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
754 size -= 4; // the shared Y (or YY) coordinate 759 size -= 4; // the shared Y (or YY) coordinate
755 if (size < 0) { 760 if (size < 0) {
756 size = 0; 761 size = 0;
757 } 762 }
758 size >>= 1; 763 size >>= 1;
759 } else { 764 } else {
760 size >>= 2; 765 size >>= 2;
761 } 766 }
762 767
763 if (fFilterLevel != kNone_SkFilterQuality) { 768 if (fFilterQuality != kNone_SkFilterQuality) {
764 size >>= 1; 769 size >>= 1;
765 } 770 }
766 771
767 return size; 772 return size;
768 } 773 }
769 774
770 /////////////////////// 775 ///////////////////////
771 776
772 void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void* sIn, int x, int y, 777 void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void* sIn, int x, int y,
773 SkPMColor* SK_RESTRICT dst, in t count) { 778 SkPMColor* SK_RESTRICT dst, in t count) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 fx += dx; 817 fx += dx;
813 } 818 }
814 } else { 819 } else {
815 for (int i = 0; i < count; ++i) { 820 for (int i = 0; i < count; ++i) {
816 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 821 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
817 fx += dx; 822 fx += dx;
818 } 823 }
819 } 824 }
820 } 825 }
821 826
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698