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

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

Issue 300113008: Make image scaling have floating point scales. Third attempt to land this (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Windows build fix Created 6 years, 6 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 | « gyp/gmslides.gypi ('k') | src/core/SkBitmapScaler.h » ('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 /* 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"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkShader.h" // for tilemodes 12 #include "SkShader.h" // for tilemodes
13 #include "SkUtilsArm.h" 13 #include "SkUtilsArm.h"
14 #include "SkBitmapScaler.h" 14 #include "SkBitmapScaler.h"
15 #include "SkMipMap.h" 15 #include "SkMipMap.h"
16 #include "SkPixelRef.h" 16 #include "SkPixelRef.h"
17 #include "SkScaledImageCache.h" 17 #include "SkScaledImageCache.h"
18 #include "SkImageEncoder.h"
18 19
19 #if !SK_ARM_NEON_IS_NONE 20 #if !SK_ARM_NEON_IS_NONE
20 // These are defined in src/opts/SkBitmapProcState_arm_neon.cpp 21 // These are defined in src/opts/SkBitmapProcState_arm_neon.cpp
21 extern const SkBitmapProcState::SampleProc16 gSkBitmapProcStateSample16_neon[]; 22 extern const SkBitmapProcState::SampleProc16 gSkBitmapProcStateSample16_neon[];
22 extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[]; 23 extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[];
23 extern void S16_D16_filter_DX_neon(const SkBitmapProcState&, const uint32_t*, i nt, uint16_t*); 24 extern void S16_D16_filter_DX_neon(const SkBitmapProcState&, const uint32_t*, i nt, uint16_t*);
24 extern void Clamp_S16_D16_filter_DX_shaderproc_neon(const SkBitmapProcState&, i nt, int, uint16_t*, int); 25 extern void Clamp_S16_D16_filter_DX_shaderproc_neon(const SkBitmapProcState&, i nt, int, uint16_t*, int);
25 extern void Repeat_S16_D16_filter_DX_shaderproc_neon(const SkBitmapProcState&, int, int, uint16_t*, int); 26 extern void Repeat_S16_D16_filter_DX_shaderproc_neon(const SkBitmapProcState&, int, int, uint16_t*, int);
26 extern void SI8_opaque_D32_filter_DX_neon(const SkBitmapProcState&, const uint3 2_t*, int, SkPMColor*); 27 extern void SI8_opaque_D32_filter_DX_neon(const SkBitmapProcState&, const uint3 2_t*, int, SkPMColor*);
27 extern void SI8_opaque_D32_filter_DX_shaderproc_neon(const SkBitmapProcState&, int, int, uint32_t*, int); 28 extern void SI8_opaque_D32_filter_DX_shaderproc_neon(const SkBitmapProcState&, int, int, uint32_t*, int);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (!fScaledBitmap.getPixels()) { 160 if (!fScaledBitmap.getPixels()) {
160 fScaledBitmap.unlockPixels(); 161 fScaledBitmap.unlockPixels();
161 // found a purged entry (discardablememory?), release it 162 // found a purged entry (discardablememory?), release it
162 SkScaledImageCache::Unlock(fScaledCacheID); 163 SkScaledImageCache::Unlock(fScaledCacheID);
163 fScaledCacheID = NULL; 164 fScaledCacheID = NULL;
164 // fall through to rebuild 165 // fall through to rebuild
165 } 166 }
166 } 167 }
167 168
168 if (NULL == fScaledCacheID) { 169 if (NULL == fScaledCacheID) {
169 int dest_width = SkScalarCeilToInt(fOrigBitmap.width() / invScaleX) ; 170 float dest_width = fOrigBitmap.width() / invScaleX;
170 int dest_height = SkScalarCeilToInt(fOrigBitmap.height() / invScaleY ); 171 float dest_height = fOrigBitmap.height() / invScaleY;
172
173 #ifdef SK_IGNORE_CORRECT_HIGH_QUALITY_IMAGE_SCALE
174 dest_width = SkScalarCeilToScalar(dest_width);
175 dest_height = SkScalarCeilToScalar(dest_height);
176 #endif
171 177
172 // All the criteria are met; let's make a new bitmap. 178 // All the criteria are met; let's make a new bitmap.
173 179
174 SkConvolutionProcs simd; 180 SkConvolutionProcs simd;
175 sk_bzero(&simd, sizeof(simd)); 181 sk_bzero(&simd, sizeof(simd));
176 this->platformConvolutionProcs(&simd); 182 this->platformConvolutionProcs(&simd);
177 183
178 if (!SkBitmapScaler::Resize(&fScaledBitmap, 184 if (!SkBitmapScaler::Resize(&fScaledBitmap,
179 fOrigBitmap, 185 fOrigBitmap,
180 SkBitmapScaler::RESIZE_BEST, 186 SkBitmapScaler::RESIZE_BEST,
181 dest_width, 187 dest_width,
182 dest_height, 188 dest_height,
183 simd, 189 simd,
184 SkScaledImageCache::GetAllocator())) { 190 SkScaledImageCache::GetAllocator())) {
185 // we failed to create fScaledBitmap, so just return and let 191 // we failed to create fScaledBitmap, so just return and let
186 // the scanline proc handle it. 192 // the scanline proc handle it.
187 return false; 193 return false;
188 194
189 } 195 }
196
190 SkASSERT(NULL != fScaledBitmap.getPixels()); 197 SkASSERT(NULL != fScaledBitmap.getPixels());
191 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, 198 fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap,
192 invScaleX, 199 invScaleX,
193 invScaleY, 200 invScaleY,
194 fScaledBitmap); 201 fScaledBitmap);
195 if (!fScaledCacheID) { 202 if (!fScaledCacheID) {
196 fScaledBitmap.reset(); 203 fScaledBitmap.reset();
197 return false; 204 return false;
198 } 205 }
199 SkASSERT(NULL != fScaledBitmap.getPixels()); 206 SkASSERT(NULL != fScaledBitmap.getPixels());
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 } else { 1039 } else {
1033 size >>= 2; 1040 size >>= 2;
1034 } 1041 }
1035 1042
1036 if (fFilterLevel != SkPaint::kNone_FilterLevel) { 1043 if (fFilterLevel != SkPaint::kNone_FilterLevel) {
1037 size >>= 1; 1044 size >>= 1;
1038 } 1045 }
1039 1046
1040 return size; 1047 return size;
1041 } 1048 }
OLDNEW
« no previous file with comments | « gyp/gmslides.gypi ('k') | src/core/SkBitmapScaler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698