aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar humper <humper@google.com>2015-02-26 11:07:23 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-26 11:07:23 -0800
commitaae1a26039b52e2b47063b166e40e6c41feb24db (patch)
treeeb146b3d6aed9af9f532ae85824a4eef4ce39ca6
parent870b9ea38672276a3e8506a0101dc559fa04583a (diff)
remove unnecessary and confusing error message from scaler
(also fix whitespace) BUG=skia: Review URL: https://codereview.chromium.org/958013004
-rw-r--r--src/core/SkBitmapScaler.cpp104
1 files changed, 48 insertions, 56 deletions
diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp
index 3501ac8a87..4bd3cc732d 100644
--- a/src/core/SkBitmapScaler.cpp
+++ b/src/core/SkBitmapScaler.cpp
@@ -254,69 +254,61 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
SkRect destSubset = { 0, 0, destWidth, destHeight };
// Ensure that the ResizeMethod enumeration is sound.
- SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) &&
- (method <= RESIZE_LAST_QUALITY_METHOD)) ||
- ((RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
- (method <= RESIZE_LAST_ALGORITHM_METHOD)));
-
- SkRect dest = { 0, 0, destWidth, destHeight };
- if (!dest.contains(destSubset)) {
- SkErrorInternals::SetError( kInvalidArgument_SkError,
- "Sorry, the destination bitmap scale subset "
- "falls outside the full destination bitmap." );
- return false;
- }
+ SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) &&
+ (method <= RESIZE_LAST_QUALITY_METHOD)) ||
+ ((RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
+ (method <= RESIZE_LAST_ALGORITHM_METHOD)));
+
+ // If the size of source or destination is 0, i.e. 0x0, 0xN or Nx0, just
+ // return empty.
+ if (source.width() < 1 || source.height() < 1 ||
+ destWidth < 1 || destHeight < 1) {
+ // todo: seems like we could handle negative dstWidth/Height, since that
+ // is just a negative scale (flip)
+ return false;
+ }
- // If the size of source or destination is 0, i.e. 0x0, 0xN or Nx0, just
- // return empty.
- if (source.width() < 1 || source.height() < 1 ||
- destWidth < 1 || destHeight < 1) {
- // todo: seems like we could handle negative dstWidth/Height, since that
- // is just a negative scale (flip)
- return false;
- }
+ method = ResizeMethodToAlgorithmMethod(method);
- method = ResizeMethodToAlgorithmMethod(method);
+ // Check that we deal with an "algorithm methods" from this point onward.
+ SkASSERT((SkBitmapScaler::RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
+ (method <= SkBitmapScaler::RESIZE_LAST_ALGORITHM_METHOD));
- // Check that we deal with an "algorithm methods" from this point onward.
- SkASSERT((SkBitmapScaler::RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
- (method <= SkBitmapScaler::RESIZE_LAST_ALGORITHM_METHOD));
+ SkAutoLockPixels locker(source);
+ if (!source.readyToDraw() ||
+ source.colorType() != kN32_SkColorType) {
+ return false;
+ }
- SkAutoLockPixels locker(source);
- if (!source.readyToDraw() ||
- source.colorType() != kN32_SkColorType) {
- return false;
- }
+ SkResizeFilter filter(method, source.width(), source.height(),
+ destWidth, destHeight, destSubset, convolveProcs);
- SkResizeFilter filter(method, source.width(), source.height(),
- destWidth, destHeight, destSubset, convolveProcs);
-
- // Get a source bitmap encompassing this touched area. We construct the
- // offsets and row strides such that it looks like a new bitmap, while
- // referring to the old data.
- const unsigned char* sourceSubset =
- reinterpret_cast<const unsigned char*>(source.getPixels());
-
- // Convolve into the result.
- SkBitmap result;
- result.setInfo(SkImageInfo::MakeN32(SkScalarCeilToInt(destSubset.width()),
- SkScalarCeilToInt(destSubset.height()),
- source.alphaType()));
- result.allocPixels(allocator, NULL);
- if (!result.readyToDraw()) {
- return false;
- }
+ // Get a source bitmap encompassing this touched area. We construct the
+ // offsets and row strides such that it looks like a new bitmap, while
+ // referring to the old data.
+ const unsigned char* sourceSubset =
+ reinterpret_cast<const unsigned char*>(source.getPixels());
+
+ // Convolve into the result.
+ SkBitmap result;
+ result.setInfo(SkImageInfo::MakeN32(SkScalarCeilToInt(destSubset.width()),
+ SkScalarCeilToInt(destSubset.height()),
+ source.alphaType()));
+ result.allocPixels(allocator, NULL);
+ if (!result.readyToDraw()) {
+ return false;
+ }
- BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()),
- !source.isOpaque(), filter.xFilter(), filter.yFilter(),
- static_cast<int>(result.rowBytes()),
- static_cast<unsigned char*>(result.getPixels()),
- convolveProcs, true);
+ BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()),
+ !source.isOpaque(), filter.xFilter(), filter.yFilter(),
+ static_cast<int>(result.rowBytes()),
+ static_cast<unsigned char*>(result.getPixels()),
+ convolveProcs, true);
- *resultPtr = result;
- resultPtr->lockPixels();
- SkASSERT(resultPtr->getPixels());
- return true;
+ *resultPtr = result;
+ resultPtr->lockPixels();
+ SkASSERT(resultPtr->getPixels());
+ return true;
}
// static -- simpler interface to the resizer; returns a default bitmap if scaling