SkPdfNativeObject SkPdfNativeObject::kNull = SkPdfNativeObject::makeNull();
bool SkPdfNativeObject::applyFlateDecodeFilter() {
- if (!SkFlate::HaveFlate()) {
- SkPdfReport(kIgnoreError_SkPdfIssueSeverity, kNoFlateLibrary_SkPdfIssue,
- "forgot to link with flate library?", NULL, NULL);
- return false;
- }
-
const unsigned char* old = fStr.fBuffer;
bool deleteOld = isStreamOwned();
],
'conditions': [
# When zlib is not availible on a system,
- # SkFlate::HaveFlate will just return false.
+ # SK_NO_FLATE will be defined.
[ 'skia_os != "win"',
{
'dependencies': [
#include "SkFlate.h"
#include "SkStream.h"
-#ifdef SK_NO_FLATE
-bool SkFlate::HaveFlate() { return false; }
-bool SkFlate::Deflate(SkStream*, SkWStream*) { return false; }
-bool SkFlate::Deflate(const void*, size_t, SkWStream*) { return false; }
-bool SkFlate::Deflate(const SkData*, SkWStream*) { return false; }
-bool SkFlate::Inflate(SkStream*, SkWStream*) { return false; }
-#else
-
-// static
-bool SkFlate::HaveFlate() {
- return true;
-}
+#ifndef SK_NO_FLATE
namespace {
return doFlate(false, src, dst);
}
-#endif
+#endif // SK_NO_FLATE
+
#include "SkTypes.h"
+#ifndef Sk_NO_FLATE
+
class SkData;
class SkWStream;
class SkStream;
*/
class SkFlate {
public:
- /** Indicates if the flate algorithm is available.
- */
- 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.
static bool Inflate(SkStream* src, SkWStream* dst);
};
-#endif
+#endif // SK_NO_FLATE
+#endif // SkFlate_DEFINED
fStreamValid = true;
}
return INHERITED::populate(catalog);
- } else if (getState() == kNoCompression_State &&
- !skip_compression(catalog) &&
- (SkFlate::HaveFlate() || fEncoder)) {
+ }
+#ifndef SK_NO_FLATE
+ else if (getState() == kNoCompression_State && !skip_compression(catalog)) {
+#else // SK_NO_FLATE
+ else if (getState() == kNoCompression_State &&
+ !skip_compression(catalog) &&
+ fEncoder) {
+#endif // SK_NO_FLATE
// Compression has not been requested when the stream was first created,
// but the new catalog wants it compressed.
if (!getSubstitute()) {
}
bool SkPDFStream::populate(SkPDFCatalog* catalog) {
+#ifdef SK_NO_FLATE
if (fState == kUnused_State) {
- if (!skip_compression(catalog) && SkFlate::HaveFlate()) {
+ fState = kNoCompression_State;
+ insertInt("Length", this->dataSize());
+ }
+ return true;
+
+#else // !SK_NO_FLATE
+
+ if (fState == kUnused_State) {
+ fState = kNoCompression_State;
+ if (!skip_compression(catalog)) {
SkDynamicMemoryWStream compressedData;
SkAssertResult(
fState = kNoCompression_State;
}
insertInt("Length", this->dataSize());
- } else if (fState == kNoCompression_State && !skip_compression(catalog) &&
- SkFlate::HaveFlate()) {
+ }
+ else if (fState == kNoCompression_State && !skip_compression(catalog)) {
if (!fSubstitute.get()) {
fSubstitute.reset(new SkPDFStream(*this));
catalog->setSubstitute(this, fSubstitute.get());
return false;
}
return true;
+#endif // SK_NO_FLATE
}
#include "SkStream.h"
#include "Test.h"
+#ifndef SK_NO_FLATE
+
// A memory stream that reports zero size with the standard call, like
// an unseekable file stream would.
class SkZeroSizeMemStream : public SkMemoryStream {
}
DEF_TEST(Flate, reporter) {
-#ifndef SK_NO_FLATE
- REPORTER_ASSERT(reporter, SkFlate::HaveFlate());
-#endif
- if (SkFlate::HaveFlate()) {
- SkMemoryStream memStream;
- TestFlate(reporter, &memStream, 512);
- TestFlate(reporter, &memStream, 10240);
-
- SkZeroSizeMemStream fileStream;
- TestFlate(reporter, &fileStream, 512);
- TestFlate(reporter, &fileStream, 10240);
- }
+ SkMemoryStream memStream;
+ TestFlate(reporter, &memStream, 512);
+ TestFlate(reporter, &memStream, 10240);
+
+ SkZeroSizeMemStream fileStream;
+ TestFlate(reporter, &fileStream, 512);
+ TestFlate(reporter, &fileStream, 10240);
}
+#endif // SK_NO_FLATE
"<</Length 12\n/Attribute 42\n>> stream\n"
"Test\nFoo\tBar\nendstream");
- if (SkFlate::HaveFlate()) {
+#ifndef SK_NO_FLATE
+ {
char streamBytes2[] = "This is a longer string, so that compression "
"can do something with it. With shorter strings, "
"the short circuit logic cuts in and we end up "
(const char*) expectedResultData2->data(),
expectedResultData2->size(), true, true);
}
+#endif // SK_NO_FLATE
}
static void TestCatalog(skiatest::Reporter* reporter) {
}
static void TestFlateDecode(skiatest::Reporter* reporter) {
- if (!SkFlate::HaveFlate()) {
- return;
- }
+#ifndef SK_NO_FLATE
SkBitmap bitmap;
setup_bitmap(&bitmap, 10, 10);
TestImage(reporter, bitmap,
"/Length 13\n"
">> stream",
false);
+#endif // SK_NO_FLATE
}
static void TestDCTDecode(skiatest::Reporter* reporter) {