| 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 "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
| 9 #include "SkMipMap.h" | 10 #include "SkMipMap.h" |
| 10 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 11 #include "SkRandom.h" | 12 #include "SkRandom.h" |
| 12 | 13 |
| 13 static void make_bitmap(SkBitmap* bm, SkRandom& rand) { | 14 static void make_bitmap(SkBitmap* bm, SkRandom& rand) { |
| 14 // for now, Build needs a min size of 2, otherwise it will return NULL. | 15 // for now, Build needs a min size of 2, otherwise it will return NULL. |
| 15 // should fix that to support 1 X N, where N > 1 to return non-null. | 16 // should fix that to support 1 X N, where N > 1 to return non-null. |
| 16 int w = 2 + rand.nextU() % 1000; | 17 int w = 2 + rand.nextU() % 1000; |
| 17 int h = 2 + rand.nextU() % 1000; | 18 int h = 2 + rand.nextU() % 1000; |
| 18 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 19 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 19 bm->allocPixels(); | 20 bm->allocPixels(); |
| 20 bm->eraseColor(SK_ColorWHITE); | 21 bm->eraseColor(SK_ColorWHITE); |
| 21 } | 22 } |
| 22 | 23 |
| 23 static void TestMipMap(skiatest::Reporter* reporter) { | 24 DEF_TEST(MipMap, reporter) { |
| 24 SkBitmap bm; | 25 SkBitmap bm; |
| 25 SkRandom rand; | 26 SkRandom rand; |
| 26 | 27 |
| 27 for (int i = 0; i < 500; ++i) { | 28 for (int i = 0; i < 500; ++i) { |
| 28 make_bitmap(&bm, rand); | 29 make_bitmap(&bm, rand); |
| 29 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(bm)); | 30 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(bm)); |
| 30 | 31 |
| 31 REPORTER_ASSERT(reporter, !mm->extractLevel(SK_Scalar1, NULL)); | 32 REPORTER_ASSERT(reporter, !mm->extractLevel(SK_Scalar1, NULL)); |
| 32 REPORTER_ASSERT(reporter, !mm->extractLevel(SK_Scalar1 * 2, NULL)); | 33 REPORTER_ASSERT(reporter, !mm->extractLevel(SK_Scalar1 * 2, NULL)); |
| 33 | 34 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 | 48 |
| 48 if (prevLevel.fPixels) { | 49 if (prevLevel.fPixels) { |
| 49 REPORTER_ASSERT(reporter, level.fWidth <= prevLevel.fWidth); | 50 REPORTER_ASSERT(reporter, level.fWidth <= prevLevel.fWidth); |
| 50 REPORTER_ASSERT(reporter, level.fHeight <= prevLevel.fHeight
); | 51 REPORTER_ASSERT(reporter, level.fHeight <= prevLevel.fHeight
); |
| 51 } | 52 } |
| 52 prevLevel = level; | 53 prevLevel = level; |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 } | 57 } |
| 57 | |
| 58 #include "TestClassDef.h" | |
| 59 DEFINE_TESTCLASS("MipMap", MipMapTestClass, TestMipMap) | |
| OLD | NEW |