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

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

Issue 1810333002: exit computeFilters if filter width is zero (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkBitmapScaler.h" 8 #include "SkBitmapScaler.h"
9 #include "SkBitmapFilter.h" 9 #include "SkBitmapFilter.h"
10 #include "SkConvolver.h" 10 #include "SkConvolver.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 // Sum of the filter values for normalizing. 161 // Sum of the filter values for normalizing.
162 // Distance from the center of the filter, this is the filter coordinate 162 // Distance from the center of the filter, this is the filter coordinate
163 // in source space. We also need to consider the center of the pixel 163 // in source space. We also need to consider the center of the pixel
164 // when comparing distance against 'srcPixel'. In the 5x downscale 164 // when comparing distance against 'srcPixel'. In the 5x downscale
165 // example used above the distance from the center of the filter to 165 // example used above the distance from the center of the filter to
166 // the pixel with coordinates (2, 2) should be 0, because its center 166 // the pixel with coordinates (2, 2) should be 0, because its center
167 // is at (2.5, 2.5). 167 // is at (2.5, 2.5).
168 float destFilterDist = (srcBegin + 0.5f - srcPixel) * clampedScale; 168 float destFilterDist = (srcBegin + 0.5f - srcPixel) * clampedScale;
169 int filterCount = SkScalarTruncToInt(srcEnd - srcBegin) + 1; 169 int filterCount = SkScalarTruncToInt(srcEnd - srcBegin) + 1;
170 SkASSERT(filterCount > 0); 170 if (filterCount <= 0) {
171 // true when srcSize is equal to srcPixel - srcSupport; this may be a bu g
172 return;
173 }
171 filterValuesArray.reset(filterCount); 174 filterValuesArray.reset(filterCount);
172 float filterSum = fBitmapFilter->evaluate_n(destFilterDist, clampedScale, fi lterCount, 175 float filterSum = fBitmapFilter->evaluate_n(destFilterDist, clampedScale, fi lterCount,
173 filterValuesArray.begin()); 176 filterValuesArray.begin());
174 177
175 // The filter must be normalized so that we don't affect the brightness of 178 // The filter must be normalized so that we don't affect the brightness of
176 // the image. Convert to normalized fixed point. 179 // the image. Convert to normalized fixed point.
177 int fixedSum = 0; 180 int fixedSum = 0;
178 fixedFilterValuesArray.reset(filterCount); 181 fixedFilterValuesArray.reset(filterCount);
179 const float* filterValues = filterValuesArray.begin(); 182 const float* filterValues = filterValuesArray.begin();
180 SkConvolutionFilter1D::ConvolutionFixed* fixedFilterValues = fixedFilterValu esArray.begin(); 183 SkConvolutionFilter1D::ConvolutionFixed* fixedFilterValues = fixedFilterValu esArray.begin();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (!result.peekPixels(&resultPM) || !Resize(resultPM, source, method)) { 257 if (!result.peekPixels(&resultPM) || !Resize(resultPM, source, method)) {
255 return false; 258 return false;
256 } 259 }
257 260
258 *resultPtr = result; 261 *resultPtr = result;
259 resultPtr->lockPixels(); 262 resultPtr->lockPixels();
260 SkASSERT(resultPtr->getPixels()); 263 SkASSERT(resultPtr->getPixels());
261 return true; 264 return true;
262 } 265 }
263 266
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698