add ptr/len and SkData versions of Deflate()

git-svn-id: http://skia.googlecode.com/svn/trunk@1726 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-06-27 17:41:22 +00:00
parent effc5016f0
commit 314e9b3ba0
2 changed files with 31 additions and 3 deletions

View File

@ -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.
*/

View File

@ -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);