Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 } | 130 } |
| 131 | 131 |
| 132 SkDefaultBitmapController controller; | 132 SkDefaultBitmapController controller; |
| 133 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality() , | 133 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality() , |
| 134 fBMStateStorage.get(), fBMStateStorage.s ize()); | 134 fBMStateStorage.get(), fBMStateStorage.s ize()); |
| 135 // 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? |
| 136 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) { | 136 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) { |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 fPixmap = fBMState->pixmap(); | 139 fPixmap = fBMState->pixmap(); |
| 140 //SkASSERT(fPixmap.colorType() == fProvider.info().colorType()); | |
|
reed1
2016/03/22 19:17:45
can we restore this assert? do we want to?
herb_g
2016/03/22 20:26:57
I should remove this assert. I think we proved to
| |
| 140 fInvMatrix = fBMState->invMatrix(); | 141 fInvMatrix = fBMState->invMatrix(); |
| 142 fRealInvMatrix = fBMState->invMatrix(); | |
| 141 fPaintColor = paint.getColor(); | 143 fPaintColor = paint.getColor(); |
| 142 fFilterQuality = fBMState->quality(); | 144 fFilterQuality = fBMState->quality(); |
| 143 SkASSERT(fPixmap.addr()); | 145 SkASSERT(fPixmap.addr()); |
| 144 | 146 |
| 145 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; | 147 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
| 146 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && | 148 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && |
| 147 SkShader::kClamp_TileMode == fTileModeY; | 149 SkShader::kClamp_TileMode == fTileModeY; |
| 148 | 150 |
| 149 // Most of the scanline procs deal with "unit" texture coordinates, as this | 151 // Most of the scanline procs deal with "unit" texture coordinates, as this |
| 150 // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generat e | 152 // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generat e |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 if (kLow_SkFilterQuality == fFilterQuality && allow_ignore_fractional_transl ate) { | 193 if (kLow_SkFilterQuality == fFilterQuality && allow_ignore_fractional_transl ate) { |
| 192 // Only try bilerp if the matrix is "interesting" and | 194 // Only try bilerp if the matrix is "interesting" and |
| 193 // the image has a suitable size. | 195 // the image has a suitable size. |
| 194 | 196 |
| 195 if (fInvType <= SkMatrix::kTranslate_Mask || | 197 if (fInvType <= SkMatrix::kTranslate_Mask || |
| 196 !valid_for_filtering(fPixmap.width() | fPixmap.height())) | 198 !valid_for_filtering(fPixmap.width() | fPixmap.height())) |
| 197 { | 199 { |
| 198 fFilterQuality = kNone_SkFilterQuality; | 200 fFilterQuality = kNone_SkFilterQuality; |
| 199 } | 201 } |
| 200 } | 202 } |
| 201 | 203 |
| 202 return true; | 204 return true; |
| 203 } | 205 } |
| 204 | 206 |
| 205 /* | 207 /* |
| 206 * Analyze filter-quality and matrix, and decide how to implement that. | 208 * Analyze filter-quality and matrix, and decide how to implement that. |
| 207 * | 209 * |
| 208 * In general, we cascade down the request level [ High ... None ] | 210 * In general, we cascade down the request level [ High ... None ] |
| 209 * - for a given level, if we can fulfill it, fine, else | 211 * - for a given level, if we can fulfill it, fine, else |
| 210 * - else we downgrade to the next lower level and try again. | 212 * - else we downgrade to the next lower level and try again. |
| 211 * We can always fulfill requests for Low and None | 213 * We can always fulfill requests for Low and None |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 SI8_alpha_D32_filter_DX, | 327 SI8_alpha_D32_filter_DX, |
| 326 | 328 |
| 327 S4444_opaque_D32_nofilter_DXDY, | 329 S4444_opaque_D32_nofilter_DXDY, |
| 328 S4444_alpha_D32_nofilter_DXDY, | 330 S4444_alpha_D32_nofilter_DXDY, |
| 329 S4444_opaque_D32_nofilter_DX, | 331 S4444_opaque_D32_nofilter_DX, |
| 330 S4444_alpha_D32_nofilter_DX, | 332 S4444_alpha_D32_nofilter_DX, |
| 331 S4444_opaque_D32_filter_DXDY, | 333 S4444_opaque_D32_filter_DXDY, |
| 332 S4444_alpha_D32_filter_DXDY, | 334 S4444_alpha_D32_filter_DXDY, |
| 333 S4444_opaque_D32_filter_DX, | 335 S4444_opaque_D32_filter_DX, |
| 334 S4444_alpha_D32_filter_DX, | 336 S4444_alpha_D32_filter_DX, |
| 335 | 337 |
| 336 // A8 treats alpha/opaque the same (equally efficient) | 338 // A8 treats alpha/opaque the same (equally efficient) |
| 337 SA8_alpha_D32_nofilter_DXDY, | 339 SA8_alpha_D32_nofilter_DXDY, |
| 338 SA8_alpha_D32_nofilter_DXDY, | 340 SA8_alpha_D32_nofilter_DXDY, |
| 339 SA8_alpha_D32_nofilter_DX, | 341 SA8_alpha_D32_nofilter_DX, |
| 340 SA8_alpha_D32_nofilter_DX, | 342 SA8_alpha_D32_nofilter_DX, |
| 341 SA8_alpha_D32_filter_DXDY, | 343 SA8_alpha_D32_filter_DXDY, |
| 342 SA8_alpha_D32_filter_DXDY, | 344 SA8_alpha_D32_filter_DXDY, |
| 343 SA8_alpha_D32_filter_DX, | 345 SA8_alpha_D32_filter_DX, |
| 344 SA8_alpha_D32_filter_DX, | 346 SA8_alpha_D32_filter_DX, |
| 345 | 347 |
| 346 // todo: possibly specialize on opaqueness | 348 // todo: possibly specialize on opaqueness |
| 347 SG8_alpha_D32_nofilter_DXDY, | 349 SG8_alpha_D32_nofilter_DXDY, |
| 348 SG8_alpha_D32_nofilter_DXDY, | 350 SG8_alpha_D32_nofilter_DXDY, |
| 349 SG8_alpha_D32_nofilter_DX, | 351 SG8_alpha_D32_nofilter_DX, |
| 350 SG8_alpha_D32_nofilter_DX, | 352 SG8_alpha_D32_nofilter_DX, |
| 351 SG8_alpha_D32_filter_DXDY, | 353 SG8_alpha_D32_filter_DXDY, |
| 352 SG8_alpha_D32_filter_DXDY, | 354 SG8_alpha_D32_filter_DXDY, |
| 353 SG8_alpha_D32_filter_DX, | 355 SG8_alpha_D32_filter_DX, |
| 354 SG8_alpha_D32_filter_DX | 356 SG8_alpha_D32_filter_DX |
| 355 }; | 357 }; |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 fx += dx; | 819 fx += dx; |
| 818 } | 820 } |
| 819 } else { | 821 } else { |
| 820 for (int i = 0; i < count; ++i) { | 822 for (int i = 0; i < count; ++i) { |
| 821 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 823 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
| 822 fx += dx; | 824 fx += dx; |
| 823 } | 825 } |
| 824 } | 826 } |
| 825 } | 827 } |
| 826 | 828 |
| OLD | NEW |