| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkErrorInternals.h" | 8 #include "SkErrorInternals.h" |
| 9 #include "SkConvolver.h" | 9 #include "SkConvolver.h" |
| 10 #include "SkBitmapProcState.h" | 10 #include "SkBitmapProcState.h" |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 #include "SkColorPriv.h" | 13 #include "SkColorPriv.h" |
| 14 #include "SkConvolver.h" | 14 #include "SkConvolver.h" |
| 15 #include "SkUnPreMultiply.h" | 15 #include "SkUnPreMultiply.h" |
| 16 #include "SkShader.h" | 16 #include "SkShader.h" |
| 17 #include "SkRTConf.h" | 17 #include "SkRTConf.h" |
| 18 #include "SkMath.h" | 18 #include "SkMath.h" |
| 19 | 19 |
| 20 // These are the per-scanline callbacks that are used when we must resort to | 20 // These are the per-scanline callbacks that are used when we must resort to |
| 21 // resampling an image as it is blitted. Typically these are used only when | 21 // resampling an image as it is blitted. Typically these are used only when |
| 22 // the image is rotated or has some other complex transformation applied. | 22 // the image is rotated or has some other complex transformation applied. |
| 23 // Scaled images will usually be rescaled directly before rasterization. | 23 // Scaled images will usually be rescaled directly before rasterization. |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 template <typename Color, typename ColorPacker> | 27 template <typename Color, typename ColorPacker> |
| 28 void highQualityFilter(ColorPacker pack, const SkBitmapProcState& s, int x, int
y, Color* SK_RESTRICT colors, int count) { | 28 void highQualityFilter(ColorPacker pack, const SkBitmapProcState& s, int x, int
y, Color* SK_RESTRICT colors, int count) { |
| 29 const int maxX = s.fBitmap->width() - 1; | 29 const int maxX = s.fBitmap->width(); |
| 30 const int maxY = s.fBitmap->height() - 1; | 30 const int maxY = s.fBitmap->height(); |
| 31 | 31 |
| 32 while (count-- > 0) { | 32 while (count-- > 0) { |
| 33 SkPoint srcPt; | 33 SkPoint srcPt; |
| 34 s.fInvProc(s.fInvMatrix, x + 0.5f, | 34 s.fInvProc(s.fInvMatrix, x + 0.5f, |
| 35 y + 0.5f, &srcPt); | 35 y + 0.5f, &srcPt); |
| 36 srcPt.fX -= SK_ScalarHalf; | 36 srcPt.fX -= SK_ScalarHalf; |
| 37 srcPt.fY -= SK_ScalarHalf; | 37 srcPt.fY -= SK_ScalarHalf; |
| 38 | 38 |
| 39 SkScalar weight = 0; | 39 SkScalar weight = 0; |
| 40 SkScalar fr = 0, fg = 0, fb = 0, fa = 0; | 40 SkScalar fr = 0, fg = 0, fb = 0, fa = 0; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 if (fInvType & SkMatrix::kScale_Mask) { | 141 if (fInvType & SkMatrix::kScale_Mask) { |
| 142 fShaderProc32 = highQualityFilter32; | 142 fShaderProc32 = highQualityFilter32; |
| 143 fShaderProc16 = highQualityFilter16; | 143 fShaderProc16 = highQualityFilter16; |
| 144 return true; | 144 return true; |
| 145 } else { | 145 } else { |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 } | 148 } |
| OLD | NEW |