diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-27 17:41:22 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-27 17:41:22 +0000 |
commit | 314e9b3ba0b950b99e4d11e3302933014c35c3ed (patch) | |
tree | 035be6e65eb1344811eae37e59fbf70f29f5cef0 | |
parent | effc5016f040945a53ab0ea47f9ea02404c17805 (diff) |
add ptr/len and SkData versions of Deflate()
git-svn-id: http://skia.googlecode.com/svn/trunk@1726 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkFlate.h | 20 | ||||
-rw-r--r-- | src/core/SkFlate.cpp | 14 |
2 files changed, 31 insertions, 3 deletions
diff --git a/include/core/SkFlate.h b/include/core/SkFlate.h index ef76f68450..38f0fd1724 100644 --- a/include/core/SkFlate.h +++ b/include/core/SkFlate.h @@ -19,6 +19,7 @@ #include "SkTypes.h" +class SkData; class SkWStream; class SkStream; @@ -31,11 +32,24 @@ public: */ static bool HaveFlate(); - /** Use the flate compression algorithm to compress the data in src, - putting the result into dst. Returns false if an error occurs. + /** + * Use the flate compression algorithm to compress the data in src, + * putting the result into dst. Returns false if an error occurs. */ static bool Deflate(SkStream* src, SkWStream* dst); - + + /** + * Use the flate compression algorithm to compress the data in src, + * putting the result into dst. Returns false if an error occurs. + */ + static bool Deflate(const void* src, size_t len, SkWStream* dst); + + /** + * Use the flate compression algorithm to compress the data, + * putting the result into dst. Returns false if an error occurs. + */ + static bool Deflate(const SkData*, SkWStream* dst); + /** Use the flate compression algorithm to decompress the data in src, putting the result into dst. Returns false if an error occurs. */ diff --git a/src/core/SkFlate.cpp b/src/core/SkFlate.cpp index 5acf2abfa0..3bae8a9334 100644 --- a/src/core/SkFlate.cpp +++ b/src/core/SkFlate.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "SkData.h" #include "SkFlate.h" #include "SkStream.h" @@ -123,6 +124,19 @@ bool SkFlate::Deflate(SkStream* src, SkWStream* dst) { return doFlate(true, src, dst); } +bool SkFlate::Deflate(const void* ptr, size_t len, SkWStream* dst) { + SkMemoryStream stream(ptr, len); + return doFlate(true, &stream, dst); +} + +bool SkFlate::Deflate(const SkData* data, SkWStream* dst) { + if (data) { + SkMemoryStream stream(data->data(), data->size()); + return doFlate(true, &stream, dst); + } + return false; +} + // static bool SkFlate::Inflate(SkStream* src, SkWStream* dst) { return doFlate(false, src, dst); |