OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkBitmapProcState.h" | 8 #include "SkBitmapProcState.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFilterProc.h" | 10 #include "SkFilterProc.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 | 118 |
119 // see if our platform has any specialized convolution code. | 119 // see if our platform has any specialized convolution code. |
120 | 120 |
121 | 121 |
122 // Set up a pointer to a local (instead of storing the structure in the | 122 // Set up a pointer to a local (instead of storing the structure in the |
123 // proc state) to avoid introducing a header dependency; this makes | 123 // proc state) to avoid introducing a header dependency; this makes |
124 // recompiles a lot less painful. | 124 // recompiles a lot less painful. |
125 | 125 |
126 SkConvolutionProcs simd; | 126 SkConvolutionProcs simd; |
127 fConvolutionProcs = &simd; | 127 sk_bzero(&simd, sizeof(simd)); |
128 | 128 |
129 fConvolutionProcs->fExtraHorizontalReads = 0; | 129 this->platformConvolutionProcs(&simd); |
130 fConvolutionProcs->fConvolveVertically = NULL; | |
131 fConvolutionProcs->fConvolve4RowsHorizontally = NULL; | |
132 fConvolutionProcs->fConvolveHorizontally = NULL; | |
133 fConvolutionProcs->fApplySIMDPadding = NULL; | |
134 | |
135 this->platformConvolutionProcs(); | |
136 | 130 |
137 // STEP 1: Highest quality direct scale? | 131 // STEP 1: Highest quality direct scale? |
138 | 132 |
139 // Check to see if the transformation matrix is simple, and if we're | 133 // Check to see if the transformation matrix is simple, and if we're |
140 // doing high quality scaling. If so, do the bitmap scale here and | 134 // doing high quality scaling. If so, do the bitmap scale here and |
141 // remove the scaling component from the matrix. | 135 // remove the scaling component from the matrix. |
142 | 136 |
143 if (SkPaint::kHigh_FilterLevel == fFilterLevel && | 137 if (SkPaint::kHigh_FilterLevel == fFilterLevel && |
144 fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Ma
sk) && | 138 fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Ma
sk) && |
145 fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) { | 139 fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) { |
146 | 140 |
147 SkScalar invScaleX = fInvMatrix.getScaleX(); | 141 SkScalar invScaleX = fInvMatrix.getScaleX(); |
148 SkScalar invScaleY = fInvMatrix.getScaleY(); | 142 SkScalar invScaleY = fInvMatrix.getScaleY(); |
149 | 143 |
150 SkASSERT(NULL == fScaledCacheID); | 144 SkASSERT(NULL == fScaledCacheID); |
151 fScaledCacheID = SkScaledImageCache::FindAndLock(fOrigBitmap, | 145 fScaledCacheID = SkScaledImageCache::FindAndLock(fOrigBitmap, |
152 invScaleX, invScaleY, | 146 invScaleX, invScaleY, |
153 &fScaledBitmap); | 147 &fScaledBitmap); |
154 if (NULL == fScaledCacheID) { | 148 if (NULL == fScaledCacheID) { |
155 int dest_width = SkScalarCeilToInt(fOrigBitmap.width() / invScaleX)
; | 149 int dest_width = SkScalarCeilToInt(fOrigBitmap.width() / invScaleX)
; |
156 int dest_height = SkScalarCeilToInt(fOrigBitmap.height() / invScaleY
); | 150 int dest_height = SkScalarCeilToInt(fOrigBitmap.height() / invScaleY
); |
157 | 151 |
158 // All the criteria are met; let's make a new bitmap. | 152 // All the criteria are met; let's make a new bitmap. |
159 | 153 |
160 if (!SkBitmapScaler::Resize(&fScaledBitmap, | 154 if (!SkBitmapScaler::Resize(&fScaledBitmap, |
161 fOrigBitmap, | 155 fOrigBitmap, |
162 SkBitmapScaler::RESIZE_BEST, | 156 SkBitmapScaler::RESIZE_BEST, |
163 dest_width, | 157 dest_width, |
164 dest_height, | 158 dest_height, |
165 fConvolutionProcs)) { | 159 simd)) { |
166 // we failed to create fScaledBitmap, so just return and let | 160 // we failed to create fScaledBitmap, so just return and let |
167 // the scanline proc handle it. | 161 // the scanline proc handle it. |
168 return; | 162 return; |
169 | 163 |
170 } | 164 } |
171 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, | 165 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, |
172 invScaleX, | 166 invScaleX, |
173 invScaleY, | 167 invScaleY, |
174 fScaledBitmap); | 168 fScaledBitmap); |
175 } | 169 } |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 } else { | 942 } else { |
949 size >>= 2; | 943 size >>= 2; |
950 } | 944 } |
951 | 945 |
952 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 946 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
953 size >>= 1; | 947 size >>= 1; |
954 } | 948 } |
955 | 949 |
956 return size; | 950 return size; |
957 } | 951 } |
OLD | NEW |