aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ICCTest.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2016-12-19 18:37:34 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-20 14:38:38 +0000
commit1bfcf887553a9d39b25f0d8c408b78841cd9d8fc (patch)
tree9f9f10119e05c83ba31c2a7bc7acbe8a8a7cc005 /tests/ICCTest.cpp
parentc468963b967b5e8cde4ed320f7130a9d703c2a4e (diff)
Implement SkICC::WriteICC()
BUG=skia: Change-Id: Idd950c3da2c517780b24e312a4e7cc16ee413c99 Reviewed-on: https://skia-review.googlesource.com/6270 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'tests/ICCTest.cpp')
-rw-r--r--tests/ICCTest.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/ICCTest.cpp b/tests/ICCTest.cpp
index 38d6801c5f..4bc296d140 100644
--- a/tests/ICCTest.cpp
+++ b/tests/ICCTest.cpp
@@ -7,9 +7,11 @@
#include "Resources.h"
#include "SkColorSpace.h"
+#include "SkColorSpacePriv.h"
#include "SkData.h"
#include "SkICC.h"
#include "SkMatrix44.h"
+#include "SkStream.h"
#include "Test.h"
static bool almost_equal(float a, float b) {
@@ -95,3 +97,44 @@ DEF_TEST(ICC_IsNumericalTransferFn, r) {
sk_sp<SkICC> upperRight = SkICC::Make(data->data(), data->size());
test_is_numerical_transfer_fn(r, upperRight.get(), false, referenceFn);
}
+
+static inline void test_write_icc(skiatest::Reporter* r, const SkColorSpaceTransferFn& fn,
+ const SkMatrix44& toXYZD50, SkColorSpace* reference,
+ bool writeToFile) {
+ sk_sp<SkData> profile = SkICC::WriteToICC(fn, toXYZD50);
+ if (writeToFile) {
+ SkFILEWStream stream("out.icc");
+ stream.write(profile->data(), profile->size());
+ }
+
+ sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(profile->data(), profile->size());
+ REPORTER_ASSERT(r, SkColorSpace::Equals(reference, colorSpace.get()));
+}
+
+DEF_TEST(ICC_WriteICC, r) {
+ SkColorSpaceTransferFn adobeFn;
+ adobeFn.fA = 1.0f;
+ adobeFn.fB = 0.0f;
+ adobeFn.fC = 0.0f;
+ adobeFn.fD = 0.0f;
+ adobeFn.fE = 0.0f;
+ adobeFn.fF = 0.0f;
+ adobeFn.fG = 2.2f;
+ SkMatrix44 adobeMatrix(SkMatrix44::kUninitialized_Constructor);
+ adobeMatrix.set3x3RowMajorf(gAdobeRGB_toXYZD50);
+ test_write_icc(r, adobeFn, adobeMatrix,
+ SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named).get(), false);
+
+ SkColorSpaceTransferFn srgbFn;
+ srgbFn.fA = 1.0f / 1.055f;
+ srgbFn.fB = 0.055f / 1.055f;
+ srgbFn.fC = 1.0f / 12.92f;
+ srgbFn.fD = 0.04045f;
+ srgbFn.fE = 0.0f;
+ srgbFn.fF = 0.0f;
+ srgbFn.fG = 2.4f;
+ SkMatrix44 srgbMatrix(SkMatrix44::kUninitialized_Constructor);
+ srgbMatrix.set3x3RowMajorf(gSRGB_toXYZD50);
+ test_write_icc(r, srgbFn, srgbMatrix, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get(),
+ false);
+}