diff options
author | Matt Sarett <msarett@google.com> | 2017-01-26 13:10:49 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-26 19:29:29 +0000 |
commit | 6f67fc29eddfb6f415f7e6a86197db5d8c8539ed (patch) | |
tree | ab93d86ab532012e6abebee476866b09cf1fcb15 /include | |
parent | 7e0489da25c578bd04ce74d03ad48198280ca3fd (diff) |
Add SkICC::rawTransferFnData()
BUG=skia:
Change-Id: I912b044a0091a4d396c954d1ad1d84f5f8d50f56
Reviewed-on: https://skia-review.googlesource.com/7366
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkICC.h | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/include/core/SkICC.h b/include/core/SkICC.h index 3780498df9..04fa1dafab 100644 --- a/include/core/SkICC.h +++ b/include/core/SkICC.h @@ -8,6 +8,7 @@ #ifndef SkICC_DEFINED #define SkICC_DEFINED +#include "SkData.h" #include "SkRefCnt.h" struct SkColorSpaceTransferFn; @@ -48,16 +49,48 @@ public: bool isNumericalTransferFn(SkColorSpaceTransferFn* fn) const; /** - * If the transfer function can be approximated as coefficients to the standard - * equation, returns true and sets |fn| to the proper values. + * Please do not call this unless isNumericalTransferFn() has been called and it + * fails. SkColorSpaceTransferFn is the preferred representation. * - * If not, returns false. This indicates one of the following: - * (1) The R, G, and B transfer functions are not the same. - * (2) The transfer function is represented as a table that is not increasing with - * end points at zero and one. - * (3) The ICC data is too complex to isolate a single transfer function. + * If it is not possible to represent the R, G, and B transfer functions numerically + * and it is still necessary to get the transfer function, this will return the + * transfer functions as three tables (R, G, and B). + * + * If possible, this will return tables of the same length as they were specified in + * the ICC profile. This means that the lengths of the three tables are not + * guaranteed to be the same. If the ICC representation was not a table, the length + * will be chosen arbitrarily. + * + * Entries in the tables are guaranteed to be in [0, 1]. + * + * This API may be deleted in favor of a numerical approximation of the raw data. + * + * This function may fail, indicating that the ICC profile does not have transfer + * functions. */ - bool approximateNumericalTransferFn(SkColorSpaceTransferFn* fn) const; + struct Channel { + // Byte offset of the start of the table in |fStorage| + size_t fOffset; + int fCount; + }; + struct Tables { + Channel fRed; + Channel fGreen; + Channel fBlue; + + const float* red() { + return (const float*) (fStorage->bytes() + fRed.fOffset); + } + const float* green() { + return (const float*) (fStorage->bytes() + fGreen.fOffset); + } + const float* blue() { + return (const float*) (fStorage->bytes() + fBlue.fOffset); + } + + sk_sp<SkData> fStorage; + }; + bool rawTransferFnData(Tables* tables) const; /** * Write an ICC profile with transfer function |fn| and gamut |toXYZD50|. @@ -68,6 +101,8 @@ private: SkICC(sk_sp<SkColorSpace> colorSpace); sk_sp<SkColorSpace> fColorSpace; + + friend class ICCTest; }; #endif |