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 "SkCachingPixelRef.h" | 9 #include "SkCachingPixelRef.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkDecodingImageGenerator.h" | 12 #include "SkDecodingImageGenerator.h" |
13 #include "SkDiscardableMemoryPool.h" | 13 #include "SkDiscardableMemoryPool.h" |
14 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
15 #include "SkImageGeneratorPriv.h" | 15 #include "SkImageGeneratorPriv.h" |
16 #include "SkScaledImageCache.h" | 16 #include "SkResourceCache.h" |
17 #include "SkStream.h" | 17 #include "SkStream.h" |
18 #include "SkUtils.h" | 18 #include "SkUtils.h" |
19 | 19 |
20 #include "Test.h" | 20 #include "Test.h" |
21 | 21 |
22 /** | 22 /** |
23 * Fill this bitmap with some color. | 23 * Fill this bitmap with some color. |
24 */ | 24 */ |
25 static void make_test_image(SkBitmap* bm) { | 25 static void make_test_image(SkBitmap* bm) { |
26 const int W = 50, H = 50; | 26 const int W = 50, H = 50; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 skiatest::Reporter* reporter, | 250 skiatest::Reporter* reporter, |
251 PixelRefType pixelRefType, | 251 PixelRefType pixelRefType, |
252 SkDiscardableMemory::Factory* factory) { | 252 SkDiscardableMemory::Factory* factory) { |
253 SkASSERT((pixelRefType >= 0) && (pixelRefType <= kLast_PixelRefType)); | 253 SkASSERT((pixelRefType >= 0) && (pixelRefType <= kLast_PixelRefType)); |
254 SkAutoTDelete<SkImageGenerator> gen(SkNEW_ARGS(TestImageGenerator, | 254 SkAutoTDelete<SkImageGenerator> gen(SkNEW_ARGS(TestImageGenerator, |
255 (type, reporter))); | 255 (type, reporter))); |
256 REPORTER_ASSERT(reporter, gen.get() != NULL); | 256 REPORTER_ASSERT(reporter, gen.get() != NULL); |
257 SkBitmap lazy; | 257 SkBitmap lazy; |
258 bool success; | 258 bool success; |
259 if (kSkCaching_PixelRefType == pixelRefType) { | 259 if (kSkCaching_PixelRefType == pixelRefType) { |
260 // Ignore factory; use global SkScaledImageCache. | 260 // Ignore factory; use global cache. |
261 success = SkCachingPixelRef::Install(gen.detach(), &lazy); | 261 success = SkCachingPixelRef::Install(gen.detach(), &lazy); |
262 } else { | 262 } else { |
263 success = SkInstallDiscardablePixelRef(gen.detach(), &lazy, factory); | 263 success = SkInstallDiscardablePixelRef(gen.detach(), &lazy, factory); |
264 } | 264 } |
265 REPORTER_ASSERT(reporter, success | 265 REPORTER_ASSERT(reporter, success |
266 == (TestImageGenerator::kFailGetInfo_TestType != type)); | 266 == (TestImageGenerator::kFailGetInfo_TestType != type)); |
267 if (TestImageGenerator::kSucceedGetPixels_TestType == type) { | 267 if (TestImageGenerator::kSucceedGetPixels_TestType == type) { |
268 check_test_image_generator_bitmap(reporter, lazy); | 268 check_test_image_generator_bitmap(reporter, lazy); |
269 } else if (TestImageGenerator::kFailGetPixels_TestType == type) { | 269 } else if (TestImageGenerator::kFailGetPixels_TestType == type) { |
270 SkAutoLockPixels autoLockPixels(lazy); | 270 SkAutoLockPixels autoLockPixels(lazy); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 canvas.clear(kDefaultColor); | 355 canvas.clear(kDefaultColor); |
356 image->draw(&canvas, 0, 0, NULL); | 356 image->draw(&canvas, 0, 0, NULL); |
357 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { | 357 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { |
358 REPORTER_ASSERT( | 358 REPORTER_ASSERT( |
359 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); | 359 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); |
360 } else { | 360 } else { |
361 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); | 361 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); |
362 } | 362 } |
363 } | 363 } |
364 } | 364 } |
OLD | NEW |