aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar humper <humper@google.com>2014-06-28 20:12:45 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-28 20:12:45 -0700
commitd92f5b814d01c474a0fb52e32e10a997b2c9b5bf (patch)
treee7aa3ecfa6e9d211461a0be6624b4f3cf42de55b
parent1e2772ff92eadbd22f968faa75218064e592a4e9 (diff)
add a second interface to the resizer to exactly match what Chrome expects. Will make the migration much cleaner
BUG=skia: R=mtklein@google.com Author: humper@google.com Review URL: https://codereview.chromium.org/353163005
-rw-r--r--src/core/SkBitmapScaler.cpp13
-rw-r--r--src/core/SkBitmapScaler.h5
2 files changed, 18 insertions, 0 deletions
diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp
index 35e101efa9..aaee600c8f 100644
--- a/src/core/SkBitmapScaler.cpp
+++ b/src/core/SkBitmapScaler.cpp
@@ -317,3 +317,16 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
SkASSERT(NULL != resultPtr->getPixels());
return true;
}
+
+// static -- simpler interface to the resizer; returns a default bitmap if scaling
+// fails for any reason. This is the interface that Chrome expects.
+SkBitmap SkBitmapScaler::Resize(const SkBitmap& source,
+ ResizeMethod method,
+ float destWidth, float destHeight,
+ SkBitmap::Allocator* allocator) {
+ SkBitmap result;
+ if (!Resize(&result, source, method, destWidth, destHeight, allocator)) {
+ return SkBitmap();
+ }
+ return result;
+}
diff --git a/src/core/SkBitmapScaler.h b/src/core/SkBitmapScaler.h
index ef559df606..ec4c8170bc 100644
--- a/src/core/SkBitmapScaler.h
+++ b/src/core/SkBitmapScaler.h
@@ -85,6 +85,11 @@ public:
float dest_width, float dest_height,
SkBitmap::Allocator* allocator = NULL);
+ static SkBitmap Resize(const SkBitmap& source,
+ ResizeMethod method,
+ float dest_width, float dest_height,
+ SkBitmap::Allocator* allocator = NULL);
+
/** Platforms can also optionally overwrite the convolution functions
if we have SIMD versions of them.
*/