| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "SkImageInfo.h" | |
| 9 | |
| 10 #include "Test.h" | |
| 11 | |
| 12 struct ImageInfoRec { | |
| 13 int fWidth; | |
| 14 int fHeight; | |
| 15 SkColorType fColorType; | |
| 16 SkAlphaType fAlphaType; | |
| 17 float fGamma; | |
| 18 bool fIsSRGB; | |
| 19 }; | |
| 20 | |
| 21 static void check_info(skiatest::Reporter* reporter, | |
| 22 const ImageInfoRec& expected, const SkImageInfo& info) { | |
| 23 REPORTER_ASSERT(reporter, info.width() == expected.fWidth); | |
| 24 REPORTER_ASSERT(reporter, info.height() == expected.fHeight); | |
| 25 REPORTER_ASSERT(reporter, info.colorType() == expected.fColorType); | |
| 26 REPORTER_ASSERT(reporter, info.alphaType() == expected.fAlphaType); | |
| 27 REPORTER_ASSERT(reporter, info.gamma() == expected.fGamma); | |
| 28 REPORTER_ASSERT(reporter, info.isSRGB() == expected.fIsSRGB); | |
| 29 } | |
| 30 | |
| 31 DEF_TEST(ImageInfo, reporter) { | |
| 32 const float nan = SK_ScalarNaN; | |
| 33 const float nice_gamma = 1.5f; | |
| 34 const int W = 100; | |
| 35 const int H = 200; | |
| 36 SkImageInfo info; | |
| 37 | |
| 38 const ImageInfoRec rec[] = { | |
| 39 { 0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType, 0, false }, // M
akeUnknown() | |
| 40 { W, H, kUnknown_SkColorType, kIgnore_SkAlphaType, 0, false }, // M
akeUnknown(...) | |
| 41 { W, H, kN32_SkColorType, kPremul_SkAlphaType, 1, false }, // M
akeN32Premul(...) | |
| 42 { W, H, kN32_SkColorType, kOpaque_SkAlphaType, 1, false }, // M
akeN32(...) | |
| 43 { W, H, kAlpha_8_SkColorType, kPremul_SkAlphaType, 0, false }, // M
akeA8() | |
| 44 { W, H, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, 1, false }, // M
ake() | |
| 45 { W, H, kBGRA_8888_SkColorType, kPremul_SkAlphaType, 1, false }, // M
ake() | |
| 46 { W, H, kBGRA_8888_SkColorType, kPremul_SkAlphaType, 0, true }, // Ma
keSRGB() | |
| 47 { W, H, kN32_SkColorType, kPremul_SkAlphaType, 1, false }, // M
akeWithGamma() NaN | |
| 48 { W, H, kAlpha_8_SkColorType, kPremul_SkAlphaType, 0, false }, // M
akeWithGamma() bad ct for gamma | |
| 49 { W, H, kN32_SkColorType, kPremul_SkAlphaType, nice_gamma, false
}, // MakeWithGamma() good | |
| 50 }; | |
| 51 | |
| 52 check_info(reporter, rec[ 0], SkImageInfo::MakeUnknown()); | |
| 53 check_info(reporter, rec[ 1], SkImageInfo::MakeUnknown(W, H)); | |
| 54 check_info(reporter, rec[ 2], SkImageInfo::MakeN32Premul(W, H)); | |
| 55 check_info(reporter, rec[ 3], SkImageInfo::MakeN32(W, H, rec[3].fAlphaType))
; | |
| 56 check_info(reporter, rec[ 4], SkImageInfo::MakeA8(W, H)); | |
| 57 check_info(reporter, rec[ 5], SkImageInfo::Make(W, H, rec[5].fColorType, rec
[5].fAlphaType)); | |
| 58 check_info(reporter, rec[ 6], SkImageInfo::Make(W, H, rec[6].fColorType, rec
[6].fAlphaType)); | |
| 59 check_info(reporter, rec[ 7], SkImageInfo::MakeSRGB(W, H, rec[7].fColorType,
rec[7].fAlphaType)); | |
| 60 check_info(reporter, rec[ 8], SkImageInfo::MakeWithGamma(W, H, rec[8].fColor
Type, rec[8].fAlphaType, nan)); | |
| 61 check_info(reporter, rec[ 9], SkImageInfo::MakeWithGamma(W, H, rec[9].fColor
Type, rec[9].fAlphaType, nice_gamma)); | |
| 62 check_info(reporter, rec[10], SkImageInfo::MakeWithGamma(W, H, rec[10].fColo
rType, rec[10].fAlphaType, rec[10].fGamma)); | |
| 63 } | |
| 64 | |
| OLD | NEW |