summaryrefslogtreecommitdiffstats
path: root/skia/images/SkImageDecoder.cpp
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 21:01:41 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 21:01:41 +0000
commit52e935d04c59135739c3a68fb6e19d313dc6d5ad (patch)
tree95f7ab178b045bef4456cbf92c6aa7e476becd99 /skia/images/SkImageDecoder.cpp
parent30fab79877b4bb067944b74d98346ac9bb6bfc7e (diff)
downloadchromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.zip
chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.gz
chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.bz2
New drop of Skia. This is up to CL 121320.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/images/SkImageDecoder.cpp')
-rw-r--r--skia/images/SkImageDecoder.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/skia/images/SkImageDecoder.cpp b/skia/images/SkImageDecoder.cpp
index 3579e3c..405b660 100644
--- a/skia/images/SkImageDecoder.cpp
+++ b/skia/images/SkImageDecoder.cpp
@@ -1,6 +1,6 @@
/* libs/graphics/images/SkImageDecoder.cpp
**
-** Copyright 2006, Google Inc.
+** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -89,6 +89,29 @@ bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap,
///////////////////////////////////////////////////////////////////////////////
+bool SkImageDecoder::decode(SkStream* stream, SkBitmap* bm,
+ SkBitmap::Config pref, Mode mode) {
+ SkBitmap tmp;
+
+ // we reset this to false before calling onDecode
+ fShouldCancelDecode = false;
+
+ // pass a temporary bitmap, so that if we return false, we are assured of
+ // leaving the caller's bitmap untouched.
+ if (this->onDecode(stream, &tmp, pref, mode)) {
+ /* We operate on a tmp bitmap until we know we succeed. This way
+ we're sure we don't change the caller's bitmap and then later
+ return false. Returning false must mean that their parameter
+ is unchanged.
+ */
+ bm->swap(tmp);
+ return true;
+ }
+ return false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
bool SkImageDecoder::DecodeFile(const char file[], SkBitmap* bm,
SkBitmap::Config pref, Mode mode) {
SkASSERT(file);
@@ -115,23 +138,14 @@ bool SkImageDecoder::DecodeStream(SkStream* stream, SkBitmap* bm,
SkASSERT(stream);
SkASSERT(bm);
+ bool success = false;
SkImageDecoder* codec = SkImageDecoder::Factory(stream);
+
if (NULL != codec) {
- SkBitmap tmp;
-
- SkAutoTDelete<SkImageDecoder> ad(codec);
-
- if (codec->onDecode(stream, &tmp, pref, mode)) {
- /* We operate on a tmp bitmap until we know we succeed. This way
- we're sure we don't change the caller's bitmap and then later
- return false. Returning false must mean that their parameter
- is unchanged.
- */
- bm->swap(tmp);
- return true;
- }
+ success = codec->decode(stream, bm, pref, mode);
+ delete codec;
}
- return false;
+ return success;
}
///////////////////////////////////////////////////////////////////////////////