OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 139 } |
140 } | 140 } |
141 bool comparePixels = (SkImageEncoder::kPNG_Type == type); | 141 bool comparePixels = (SkImageEncoder::kPNG_Type == type); |
142 compare_bitmaps(reporter, original, lazy, comparePixels); | 142 compare_bitmaps(reporter, original, lazy, comparePixels); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 //////////////////////////////////////////////////////////////////////////////// | 146 //////////////////////////////////////////////////////////////////////////////// |
147 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) { | 147 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) { |
148 return SkCachingPixelRef::Install( | 148 return SkCachingPixelRef::Install( |
149 SkNEW_ARGS(SkDecodingImageGenerator, (encoded)), dst); | 149 SkNewDecodingImageGenerator(encoded, SkDecoderOptions()), dst); |
150 } | 150 } |
151 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { | 151 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { |
152 // Use system-default discardable memory. | 152 // Use system-default discardable memory. |
153 return SkDecodingImageGenerator::Install(encoded, dst, NULL); | 153 return SkInstallDiscardablePixelRef( |
| 154 SkNewDecodingImageGenerator(encoded, SkDecoderOptions()), dst, NULL); |
154 } | 155 } |
155 | 156 |
156 //////////////////////////////////////////////////////////////////////////////// | 157 //////////////////////////////////////////////////////////////////////////////// |
157 /** | 158 /** |
158 * This checks to see that a SkCachingPixelRef and a | 159 * This checks to see that a SkCachingPixelRef and a |
159 * SkDiscardablePixelRef works as advertised with a | 160 * SkDiscardablePixelRef works as advertised with a |
160 * SkDecodingImageGenerator. | 161 * SkDecodingImageGenerator. |
161 */ | 162 */ |
162 DEF_TEST(DecodingImageGenerator, reporter) { | 163 DEF_TEST(DecodingImageGenerator, reporter) { |
163 test_three_encodings(reporter, install_skCachingPixelRef); | 164 test_three_encodings(reporter, install_skCachingPixelRef); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return false; | 207 return false; |
207 } | 208 } |
208 char* bytePtr = static_cast<char*>(pixels); | 209 char* bytePtr = static_cast<char*>(pixels); |
209 for (int y = 0; y < info.fHeight; ++y) { | 210 for (int y = 0; y < info.fHeight; ++y) { |
210 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), | 211 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), |
211 TestImageGenerator::Color(), info.fWidth); | 212 TestImageGenerator::Color(), info.fWidth); |
212 bytePtr += rowBytes; | 213 bytePtr += rowBytes; |
213 } | 214 } |
214 return true; | 215 return true; |
215 } | 216 } |
| 217 |
216 private: | 218 private: |
217 const TestType fType; | 219 const TestType fType; |
218 skiatest::Reporter* const fReporter; | 220 skiatest::Reporter* const fReporter; |
219 }; | 221 }; |
| 222 |
220 void CheckTestImageGeneratorBitmap(skiatest::Reporter* reporter, | 223 void CheckTestImageGeneratorBitmap(skiatest::Reporter* reporter, |
221 const SkBitmap& bm) { | 224 const SkBitmap& bm) { |
222 REPORTER_ASSERT(reporter, TestImageGenerator::Width() == bm.width()); | 225 REPORTER_ASSERT(reporter, TestImageGenerator::Width() == bm.width()); |
223 REPORTER_ASSERT(reporter, TestImageGenerator::Height() == bm.height()); | 226 REPORTER_ASSERT(reporter, TestImageGenerator::Height() == bm.height()); |
224 SkAutoLockPixels autoLockPixels(bm); | 227 SkAutoLockPixels autoLockPixels(bm); |
225 REPORTER_ASSERT(reporter, NULL != bm.getPixels()); | 228 REPORTER_ASSERT(reporter, NULL != bm.getPixels()); |
226 if (NULL == bm.getPixels()) { | 229 if (NULL == bm.getPixels()) { |
227 return; | 230 return; |
228 } | 231 } |
229 int errors = 0; | 232 int errors = 0; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); | 317 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); |
315 // Only acts differently from NULL on a platform that has a | 318 // Only acts differently from NULL on a platform that has a |
316 // default discardable memory implementation that differs from the | 319 // default discardable memory implementation that differs from the |
317 // global DM pool. | 320 // global DM pool. |
318 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, | 321 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, |
319 reporter, kSkDiscardable_PixelRefType, globalPool); | 322 reporter, kSkDiscardable_PixelRefType, globalPool); |
320 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, | 323 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, |
321 reporter, kSkDiscardable_PixelRefType, globalPool); | 324 reporter, kSkDiscardable_PixelRefType, globalPool); |
322 } | 325 } |
323 //////////////////////////////////////////////////////////////////////////////// | 326 //////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |