#include "SkTypes.h"
+class SkData;
class SkWStream;
class SkStream;
*/
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.
*/
* limitations under the License.
*/
+#include "SkData.h"
#include "SkFlate.h"
#include "SkStream.h"
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);