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