aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2018-05-22 13:47:52 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-22 14:17:15 +0000
commit5b58b7c14c4405163e2af68dd3951a83fa1dabf2 (patch)
treef6d940bd35e271e139613a23e295b47dd4da631b /include/core
parent89735a0f47d2a06542d966a383dcba9f7a00d675 (diff)
Reland "strip down SkICC.cpp"
This reverts commit 27fe397bc0cc1b091f9f85863c62b88156239cf0. Reason for revert: time to fly. Original change's description: > Revert "strip down SkICC.cpp" > > This reverts commit eab50eb9c6117c2a9d0e5648f89cebbb4dbd9d30 > and this tiny bit of e61b969a07ba3ebe9e47e61381ad16c5d2c549a2: > > https://skia-review.googlesource.com/c/skia/+/127122/3/tests/ICCTest.cpp > > Change-Id: I4306e5118a4e5eb88c05078186a28bd443fd76f7 > Reviewed-on: https://skia-review.googlesource.com/127305 > Reviewed-by: Mike Klein <mtklein@chromium.org> > Commit-Queue: Mike Klein <mtklein@chromium.org> TBR=mtklein@chromium.org,brianosman@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I93a6cfb66f0da0e098fdcb77ac1cd619e41614b1 Reviewed-on: https://skia-review.googlesource.com/129446 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkICC.h106
1 files changed, 17 insertions, 89 deletions
diff --git a/include/core/SkICC.h b/include/core/SkICC.h
index 8c5ec566b7..9d2ada347e 100644
--- a/include/core/SkICC.h
+++ b/include/core/SkICC.h
@@ -12,98 +12,26 @@
#include "SkRefCnt.h"
struct SkColorSpaceTransferFn;
-class SkColorSpace;
-class SkData;
-class SkMatrix44;
-class SK_API SkICC : public SkRefCnt {
-public:
+SK_API sk_sp<SkData> SkWriteICCProfile(const SkColorSpaceTransferFn&, const float toXYZD50[9]);
- /**
- * Parse an ICC profile.
- *
- * Returns nullptr if the data is not a valid ICC profile or if the profile
- * input space is not RGB.
- */
- static sk_sp<SkICC> Make(const void*, size_t);
+namespace SkICC {
+ static inline sk_sp<SkData> WriteToICC(const SkColorSpaceTransferFn& fn,
+ const SkMatrix44& toXYZD50) {
+ if (toXYZD50.get(3,0) == 0 && toXYZD50.get(3,1) == 0 && toXYZD50.get(3,2) == 0 &&
+ toXYZD50.get(3,3) == 1 &&
+ toXYZD50.get(0,3) == 0 && toXYZD50.get(1,3) == 0 && toXYZD50.get(2,3) == 0) {
- /**
- * If the gamut can be represented as transformation into XYZ D50, returns
- * true and sets the proper values in |toXYZD50|.
- *
- * If not, returns false. This indicates that the ICC data is too complex
- * to isolate a simple gamut transformation.
- */
- bool toXYZD50(SkMatrix44* toXYZD50) const;
+ float m33[9];
+ for (int r = 0; r < 3; r++)
+ for (int c = 0; c < 3; c++) {
+ m33[3*r+c] = toXYZD50.get(r,c);
+ }
+ return SkWriteICCProfile(fn, m33);
- /**
- * If the transfer function can be represented as coefficients to the standard
- * equation, returns true and sets |fn| to the proper values.
- *
- * 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 we have not managed
- * to match to a standard curve.
- * (3) The ICC data is too complex to isolate a single transfer function.
- */
- bool isNumericalTransferFn(SkColorSpaceTransferFn* fn) const;
-
- /**
- * Please do not call this unless isNumericalTransferFn() has been called and it
- * fails. SkColorSpaceTransferFn is the preferred representation.
- *
- * 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.
- *
- * The lengths of the tables are all guaranteed to be at least 2. 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.
- */
- 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|.
- */
- static sk_sp<SkData> WriteToICC(const SkColorSpaceTransferFn& fn, const SkMatrix44& toXYZD50);
-
-private:
- SkICC(sk_sp<SkColorSpace> colorSpace);
-
- sk_sp<SkColorSpace> fColorSpace;
-
- friend class ICCTest;
-};
+ return nullptr;
+ }
+}
-#endif
+#endif//SkICC_DEFINED