diff options
author | reed <reed@google.com> | 2014-09-02 21:56:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-02 21:56:40 -0700 |
commit | 2f6abdecc5c2f21da13003c615903679abc73fc7 (patch) | |
tree | cc3e4ebb378416e16767b424dc6487e6edc96818 /tests | |
parent | 937c9c7eb4e06d4d3bc495e129c7b8103a5d6c0f (diff) |
Add gamma/sRGB tag to SkImageInfo
This reverts commit 1cbc68f9659f15206d920dacd434ddf4b658ad1f.
requires this to land in blink https://codereview.chromium.org/531883002/
R=fmalita@google.com, reed@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/527073003
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ImageInfoTest.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/ImageInfoTest.cpp b/tests/ImageInfoTest.cpp new file mode 100644 index 0000000000..679b302ceb --- /dev/null +++ b/tests/ImageInfoTest.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkImageInfo.h" + +#include "Test.h" + +struct ImageInfoRec { + int fWidth; + int fHeight; + SkColorType fColorType; + SkAlphaType fAlphaType; + float fGamma; + bool fIsSRGB; +}; + +static void check_info(skiatest::Reporter* reporter, + const ImageInfoRec& expected, const SkImageInfo& info) { + REPORTER_ASSERT(reporter, info.width() == expected.fWidth); + REPORTER_ASSERT(reporter, info.height() == expected.fHeight); + REPORTER_ASSERT(reporter, info.colorType() == expected.fColorType); + REPORTER_ASSERT(reporter, info.alphaType() == expected.fAlphaType); + REPORTER_ASSERT(reporter, info.gamma() == expected.fGamma); + REPORTER_ASSERT(reporter, info.isSRGB() == expected.fIsSRGB); +} + +DEF_TEST(ImageInfo, reporter) { + const float nan = SK_ScalarNaN; + const float nice_gamma = 1.5f; + const int W = 100; + const int H = 200; + SkImageInfo info; + + const ImageInfoRec rec[] = { + { 0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType, 0, false }, // MakeUnknown() + { W, H, kUnknown_SkColorType, kIgnore_SkAlphaType, 0, false }, // MakeUnknown(...) + { W, H, kN32_SkColorType, kPremul_SkAlphaType, 1, false }, // MakeN32Premul(...) + { W, H, kN32_SkColorType, kOpaque_SkAlphaType, 1, false }, // MakeN32(...) + { W, H, kAlpha_8_SkColorType, kPremul_SkAlphaType, 0, false }, // MakeA8() + { W, H, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, 1, false }, // Make() + { W, H, kBGRA_8888_SkColorType, kPremul_SkAlphaType, 1, false }, // Make() + { W, H, kBGRA_8888_SkColorType, kPremul_SkAlphaType, 0, true }, // MakeSRGB() + { W, H, kN32_SkColorType, kPremul_SkAlphaType, 1, false }, // MakeWithGamma() NaN + { W, H, kAlpha_8_SkColorType, kPremul_SkAlphaType, 0, false }, // MakeWithGamma() bad ct for gamma + { W, H, kN32_SkColorType, kPremul_SkAlphaType, nice_gamma, false }, // MakeWithGamma() good + }; + + check_info(reporter, rec[ 0], SkImageInfo::MakeUnknown()); + check_info(reporter, rec[ 1], SkImageInfo::MakeUnknown(W, H)); + check_info(reporter, rec[ 2], SkImageInfo::MakeN32Premul(W, H)); + check_info(reporter, rec[ 3], SkImageInfo::MakeN32(W, H, rec[3].fAlphaType)); + check_info(reporter, rec[ 4], SkImageInfo::MakeA8(W, H)); + check_info(reporter, rec[ 5], SkImageInfo::Make(W, H, rec[5].fColorType, rec[5].fAlphaType)); + check_info(reporter, rec[ 6], SkImageInfo::Make(W, H, rec[6].fColorType, rec[6].fAlphaType)); + check_info(reporter, rec[ 7], SkImageInfo::MakeSRGB(W, H, rec[7].fColorType, rec[7].fAlphaType)); + check_info(reporter, rec[ 8], SkImageInfo::MakeWithGamma(W, H, rec[8].fColorType, rec[8].fAlphaType, nan)); + check_info(reporter, rec[ 9], SkImageInfo::MakeWithGamma(W, H, rec[9].fColorType, rec[9].fAlphaType, nice_gamma)); + check_info(reporter, rec[10], SkImageInfo::MakeWithGamma(W, H, rec[10].fColorType, rec[10].fAlphaType, rec[10].fGamma)); +} + |