aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-05-23 09:29:29 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-23 09:29:29 -0700
commit8cc209111876b7c78b5ec577c9221d8ed5e21024 (patch)
tree741998d90dcda0765375e79eedc28e119b8cc980 /include
parenta0af771612db5ae36b74f1f536bfb335ecd0ec99 (diff)
Make SkColorSpace a public API
I've trimmed uniqueID for now, and added some comments. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1996973002 Review-Url: https://codereview.chromium.org/1996973002
Diffstat (limited to 'include')
-rw-r--r--include/core/SkColorSpace.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/include/core/SkColorSpace.h b/include/core/SkColorSpace.h
new file mode 100644
index 0000000000..9630fe4c25
--- /dev/null
+++ b/include/core/SkColorSpace.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkColorSpace_DEFINED
+#define SkColorSpace_DEFINED
+
+#include "SkMatrix44.h"
+#include "SkRefCnt.h"
+#include "../private/SkTemplates.h"
+
+class SkColorSpace : public SkRefCnt {
+public:
+
+ /**
+ * Common, named profiles that we can recognize.
+ */
+ enum Named {
+ kUnknown_Named,
+ kSRGB_Named,
+ kAdobeRGB_Named,
+ };
+
+ /**
+ * Create an SkColorSpace from the src gamma and a transform from src gamut to D50 XYZ.
+ */
+ static sk_sp<SkColorSpace> NewRGB(float gammas[3], const SkMatrix44& toXYZD50);
+
+ /**
+ * Create a common, named SkColorSpace.
+ */
+ static sk_sp<SkColorSpace> NewNamed(Named);
+
+ /**
+ * Create an SkColorSpace from an ICC profile.
+ */
+ static sk_sp<SkColorSpace> NewICC(const void*, size_t);
+
+ enum GammaNamed {
+ kLinear_GammaNamed,
+
+ /**
+ * Gamma curve is a close match to the 2.2f exponential curve. This is by far
+ * the most common gamma, and is used by sRGB and Adobe RGB profiles.
+ */
+ k2Dot2Curve_GammaNamed,
+
+ /**
+ * Gamma is represented by a look-up table, a parametric curve, or an uncommon
+ * exponential curve. Or there is an additional pre-processing step before the
+ * applying the gamma.
+ */
+ kNonStandard_GammaNamed,
+ };
+
+ GammaNamed gammaNamed() const { return fGammaNamed; }
+
+ /**
+ * Returns the matrix used to transform src gamut to XYZ D50.
+ */
+ SkMatrix44 xyz() const { return fToXYZD50; }
+
+protected:
+
+ SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named);
+
+ const GammaNamed fGammaNamed;
+ const SkMatrix44 fToXYZD50;
+ const Named fNamed;
+};
+
+#endif