Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: src/core/SkColorSpace.h

Issue 1925733003: Drafts and half ideas (Closed) Base URL: https://skia.googlesource.com/skia.git@improveparsing
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkColorSpace.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorSpace.h
diff --git a/src/core/SkColorSpace.h b/src/core/SkColorSpace.h
index 0708e5713d5bebe45908bda674d2161241dc8b62..b8e6fac0613728d62fc094e154aac6156d6dfbf5 100644
--- a/src/core/SkColorSpace.h
+++ b/src/core/SkColorSpace.h
@@ -35,6 +35,51 @@ struct SkFloat3x3 {
void dump() const;
};
+struct SkGamma {
+ static const uint32_t kGammaUseValueFlag = 0x1;
+ static const uint32_t kGammaUseTableFlag = 0x2;
+ static const uint32_t kGammaUseParametricFlag = 0x4;
+
+ bool isValue() const { return kGammaUseValueFlag & fFlag; }
+ bool isTable() const { return kGammaUseTableFlag & fFlag; }
+ bool isParametric() const { return kGammaUseParametricFlag & fFlag; }
+
+ uint32_t fFlag;
+
+ // Values
+ float fValue;
+
+ // Table
+ uint32_t fTableSize;
+ std::unique_ptr<float[]> fTable;
+
+ // Parametric
+ // FIXME (msarett): Handle parametric curves.
+
+ SkGamma() {
+ memset(this, 0, sizeof(struct SkGamma));
+ }
+
+ static SkGamma sRGB() {
+ SkGamma gamma;
+ gamma.fFlag = kGammaUseValueFlag;
+ gamma.fValue = 2.2f;
+ return std::move(gamma);
+ }
+};
+
+struct SkGammas {
+ SkGamma fGammas[3];
+
+ static SkGammas sRGB() {
+ SkGammas gammas;
+ gammas.fGammas[0] = std::move(SkGamma::sRGB());
+ gammas.fGammas[1] = std::move(SkGamma::sRGB());
+ gammas.fGammas[2] = std::move(SkGamma::sRGB());
+ return std::move(gammas);
+ }
+};
+
struct SkColorLookUpTable {
static const uint8_t kMaxChannels = 16;
@@ -63,12 +108,12 @@ public:
* Return a colorspace instance, given a 3x3 transform from linear_RGB to D50_XYZ
* and the src-gamma, return a ColorSpace
*/
- static sk_sp<SkColorSpace> NewRGB(const SkFloat3x3& toXYZD50, const SkFloat3& gamma);
+ static sk_sp<SkColorSpace> NewRGB(const SkFloat3x3& toXYZD50, SkGammas gammas);
static sk_sp<SkColorSpace> NewNamed(Named);
static sk_sp<SkColorSpace> NewICC(const void*, size_t);
- SkFloat3 gamma() const { return fGamma; }
+ const SkGammas& gammas() const { return fGammas; }
SkFloat3x3 xyz() const { return fToXYZD50; }
Named named() const { return fNamed; }
uint32_t uniqueID() const { return fUniqueID; }
@@ -89,13 +134,13 @@ public:
void dump() const;
private:
- SkColorSpace(const SkFloat3& gamma, const SkFloat3x3& toXYZ, Named);
+ SkColorSpace(SkGammas gammas, const SkFloat3x3& toXYZ, Named);
- SkColorSpace(SkColorLookUpTable colorLUT, const SkFloat3& gamma, const SkFloat3x3& toXYZ,
+ SkColorSpace(SkColorLookUpTable colorLUT, SkGammas gammas, const SkFloat3x3& toXYZ,
const SkFloat3& toXYZOffset);
const SkColorLookUpTable fColorLUT;
- const SkFloat3 fGamma;
+ const SkGammas fGammas;
const SkFloat3x3 fToXYZD50;
const SkFloat3 fToXYZOffset;
« no previous file with comments | « no previous file | src/core/SkColorSpace.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698