| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkData.h" | 8 #include "SkData.h" |
| 9 #include "SkFlate.h" | 9 #include "SkFlate.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| 11 #include "Test.h" | 11 #include "Test.h" |
| 12 | 12 |
| 13 #ifndef SK_NO_FLATE |
| 14 |
| 13 // A memory stream that reports zero size with the standard call, like | 15 // A memory stream that reports zero size with the standard call, like |
| 14 // an unseekable file stream would. | 16 // an unseekable file stream would. |
| 15 class SkZeroSizeMemStream : public SkMemoryStream { | 17 class SkZeroSizeMemStream : public SkMemoryStream { |
| 16 public: | 18 public: |
| 17 virtual size_t read(void* buffer, size_t size) { | 19 virtual size_t read(void* buffer, size_t size) { |
| 18 if (buffer == NULL && size == 0) | 20 if (buffer == NULL && size == 0) |
| 19 return 0; | 21 return 0; |
| 20 if (buffer == NULL && size == kGetSizeKey) | 22 if (buffer == NULL && size == kGetSizeKey) |
| 21 size = 0; | 23 size = 0; |
| 22 return SkMemoryStream::read(buffer, size); | 24 return SkMemoryStream::read(buffer, size); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 99 |
| 98 if (reporter->verbose()) { | 100 if (reporter->verbose()) { |
| 99 SkDebugf("Flate Test: \t input size: " SK_SIZE_T_SPECIFIER | 101 SkDebugf("Flate Test: \t input size: " SK_SIZE_T_SPECIFIER |
| 100 "\tcompressed size: " SK_SIZE_T_SPECIFIER | 102 "\tcompressed size: " SK_SIZE_T_SPECIFIER |
| 101 "\tratio: %.4g\n", | 103 "\tratio: %.4g\n", |
| 102 dataSize, compressedSize, compressionRatio); | 104 dataSize, compressedSize, compressionRatio); |
| 103 } | 105 } |
| 104 } | 106 } |
| 105 | 107 |
| 106 DEF_TEST(Flate, reporter) { | 108 DEF_TEST(Flate, reporter) { |
| 107 #ifndef SK_NO_FLATE | 109 SkMemoryStream memStream; |
| 108 REPORTER_ASSERT(reporter, SkFlate::HaveFlate()); | 110 TestFlate(reporter, &memStream, 512); |
| 109 #endif | 111 TestFlate(reporter, &memStream, 10240); |
| 110 if (SkFlate::HaveFlate()) { | |
| 111 SkMemoryStream memStream; | |
| 112 TestFlate(reporter, &memStream, 512); | |
| 113 TestFlate(reporter, &memStream, 10240); | |
| 114 | 112 |
| 115 SkZeroSizeMemStream fileStream; | 113 SkZeroSizeMemStream fileStream; |
| 116 TestFlate(reporter, &fileStream, 512); | 114 TestFlate(reporter, &fileStream, 512); |
| 117 TestFlate(reporter, &fileStream, 10240); | 115 TestFlate(reporter, &fileStream, 10240); |
| 118 } | |
| 119 } | 116 } |
| 117 #endif // SK_NO_FLATE |
| OLD | NEW |