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

Unified Diff: src/core/SkColorSpaceXformPriv.h

Issue 2389983002: Refactored SkColorSpace and added in a Lab PCS GM (Closed)
Patch Set: multiplied the matrix for the temporary XYZTRC profile from an A2B0 profile code to match what woul… Created 4 years, 2 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
Index: src/core/SkColorSpaceXformPriv.h
diff --git a/src/core/SkColorSpaceXformPriv.h b/src/core/SkColorSpaceXformPriv.h
new file mode 100644
index 0000000000000000000000000000000000000000..1924fe0eeda3d19c7cff30afefbda16b9e226b28
--- /dev/null
+++ b/src/core/SkColorSpaceXformPriv.h
@@ -0,0 +1,137 @@
+/*
+ * 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 SkColorSpaceXformPriv_DEFINED
+#define SkColorSpaceXformPriv_DEFINED
+
+#include "SkColorSpace_Base.h"
+#include "SkSRGB.h"
+
+void interp_3d_clut(float dst[3], float src[3], const SkColorLookUpTable* colorLUT);
+
+extern float sk_linear_from_2dot2[256];
+
+void build_table_linear_from_gamma(float* outTable, float exponent);
msarett 2016/10/05 19:05:52 It seems like there were some functions move here
raftias 2016/10/06 14:43:04 Done.
+
+// Interpolating lookup in a variably sized table.
+float interp_lut(float input, const float* table, int tableSize);
+
+// outTable is always 256 entries, inTable may be larger or smaller.
+void build_table_linear_from_gamma(float* outTable, const float* inTable, int inTableSize);
+
+void build_table_linear_from_gamma(float* outTable, float g, float a, float b, float c,
+ float d, float e, float f);
+
+// Expand range from 0-1 to 0-255, then convert.
+uint8_t clamp_normalized_float_to_byte(float v);
+
+extern const int kDstGammaTableSize;
+
+void build_table_linear_to_gamma(uint8_t* outTable, float exponent);
+
+// Inverse table lookup. Ex: what index corresponds to the input value? This will
+// have strange results when the table is non-increasing. But any sane gamma
+// function will be increasing.
+float inverse_interp_lut(float input, const float* table, int tableSize);
+
+void build_table_linear_to_gamma(uint8_t* outTable, const float* inTable, int inTableSize);
+
+float inverse_parametric(float x, float g, float a, float b, float c, float d, float e, float f);
+
+void build_table_linear_to_gamma(uint8_t* outTable, float g, float a,
+ float b, float c, float d, float e, float f);
+
+
+
+template <typename T>
+struct GammaFns {
+ const T* fSRGBTable;
+ const T* f2Dot2Table;
+ void (*fBuildFromValue)(T*, float);
+ void (*fBuildFromTable)(T*, const float*, int);
+ void (*fBuildFromParam)(T*, float, float, float, float, float, float, float);
+};
+
+extern const GammaFns<float> kToLinear;
+
+extern const GammaFns<uint8_t> kFromLinear;
+
+// Build tables to transform src gamma to linear.
+template <typename T>
+void build_gamma_tables(const T* outGammaTables[3], T* gammaTableStorage, int gammaTableSize,
+ SkGammaNamed gammaNamed, const SkGammas* gammas, const GammaFns<T>& fns,
+ bool gammasAreMatching)
+{
+ switch (gammaNamed) {
+ case kSRGB_SkGammaNamed:
+ outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = fns.fSRGBTable;
+ break;
+ case k2Dot2Curve_SkGammaNamed:
+ outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = fns.f2Dot2Table;
+ break;
+ case kLinear_SkGammaNamed:
+ outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = nullptr;
+ break;
+ default: {
+ SkASSERT(gammas);
+
+ auto build_table = [=](int i) {
+ if (gammas->isNamed(i)) {
+ switch (gammas->data(i).fNamed) {
+ case kSRGB_SkGammaNamed:
+ (*fns.fBuildFromParam)(&gammaTableStorage[i * gammaTableSize], 2.4f,
+ (1.0f / 1.055f), (0.055f / 1.055f), 0.0f,
+ 0.04045f, (1.0f / 12.92f), 0.0f);
+ outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
+ break;
+ case k2Dot2Curve_SkGammaNamed:
+ (*fns.fBuildFromValue)(&gammaTableStorage[i * gammaTableSize], 2.2f);
+ outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
+ break;
+ case kLinear_SkGammaNamed:
+ (*fns.fBuildFromValue)(&gammaTableStorage[i * gammaTableSize], 1.0f);
+ outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
+ break;
+ default:
+ SkASSERT(false);
+ break;
+ }
+ } else if (gammas->isValue(i)) {
+ (*fns.fBuildFromValue)(&gammaTableStorage[i * gammaTableSize],
+ gammas->data(i).fValue);
+ outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
+ } else if (gammas->isTable(i)) {
+ (*fns.fBuildFromTable)(&gammaTableStorage[i * gammaTableSize], gammas->table(i),
+ gammas->data(i).fTable.fSize);
+ outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
+ } else {
+ SkASSERT(gammas->isParametric(i));
+ const SkGammas::Params& params = gammas->params(i);
+ (*fns.fBuildFromParam)(&gammaTableStorage[i * gammaTableSize], params.fG,
+ params.fA, params.fB, params.fC, params.fD, params.fE,
+ params.fF);
+ outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
+ }
+ };
+
+ if (gammasAreMatching) {
+ build_table(0);
+ outGammaTables[1] = outGammaTables[0];
+ outGammaTables[2] = outGammaTables[0];
+ } else {
+ build_table(0);
+ build_table(1);
+ build_table(2);
+ }
+
+ break;
+ }
+ }
+}
+
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698