| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 static const size_t kGetSizeKey = 0xDEADBEEF; | 25 static const size_t kGetSizeKey = 0xDEADBEEF; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // Returns a deterministic data of the given size that should be | 28 // Returns a deterministic data of the given size that should be |
| 29 // very compressible. | 29 // very compressible. |
| 30 static SkData* new_test_data(size_t dataSize) { | 30 static SkData* new_test_data(size_t dataSize) { |
| 31 SkAutoTMalloc<uint8_t> testBuffer(dataSize); | 31 SkAutoTMalloc<uint8_t> testBuffer(dataSize); |
| 32 for (size_t i = 0; i < dataSize; ++i) { | 32 for (size_t i = 0; i < dataSize; ++i) { |
| 33 testBuffer[i] = i % 64; | 33 testBuffer[SkToInt(i)] = i % 64; |
| 34 } | 34 } |
| 35 return SkData::NewFromMalloc(testBuffer.detach(), dataSize); | 35 return SkData::NewFromMalloc(testBuffer.detach(), dataSize); |
| 36 } | 36 } |
| 37 | 37 |
| 38 static void TestFlate(skiatest::Reporter* reporter, SkMemoryStream* testStream, | 38 static void TestFlate(skiatest::Reporter* reporter, SkMemoryStream* testStream, |
| 39 size_t dataSize) { | 39 size_t dataSize) { |
| 40 SkASSERT(testStream != NULL); | 40 SkASSERT(testStream != NULL); |
| 41 | 41 |
| 42 SkAutoDataUnref testData(new_test_data(dataSize)); | 42 SkAutoDataUnref testData(new_test_data(dataSize)); |
| 43 SkASSERT(testData->size() == dataSize); | 43 SkASSERT(testData->size() == dataSize); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (SkFlate::HaveFlate()) { | 110 if (SkFlate::HaveFlate()) { |
| 111 SkMemoryStream memStream; | 111 SkMemoryStream memStream; |
| 112 TestFlate(reporter, &memStream, 512); | 112 TestFlate(reporter, &memStream, 512); |
| 113 TestFlate(reporter, &memStream, 10240); | 113 TestFlate(reporter, &memStream, 10240); |
| 114 | 114 |
| 115 SkZeroSizeMemStream fileStream; | 115 SkZeroSizeMemStream fileStream; |
| 116 TestFlate(reporter, &fileStream, 512); | 116 TestFlate(reporter, &fileStream, 512); |
| 117 TestFlate(reporter, &fileStream, 10240); | 117 TestFlate(reporter, &fileStream, 10240); |
| 118 } | 118 } |
| 119 } | 119 } |
| OLD | NEW |