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

Unified Diff: src/core/SkColorSpaceXform_Base.h

Issue 2390263002: Add SkColorSpaceXform to the public API (Closed)
Patch Set: Remove type on enum 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
« no previous file with comments | « src/core/SkColorSpaceXform.cpp ('k') | tests/ColorSpaceXformTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorSpaceXform_Base.h
diff --git a/src/core/SkColorSpaceXform_Base.h b/src/core/SkColorSpaceXform_Base.h
new file mode 100644
index 0000000000000000000000000000000000000000..02714ad59ee4800a9c5960aafd0ef72283375b08
--- /dev/null
+++ b/src/core/SkColorSpaceXform_Base.h
@@ -0,0 +1,62 @@
+/*
+ * 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 SkColorSpaceXform_Base_DEFINED
+#define SkColorSpaceXform_Base_DEFINED
+
+#include "SkColorSpace.h"
+#include "SkColorSpace_Base.h"
+#include "SkColorSpaceXform.h"
+
+enum SrcGamma {
+ kLinear_SrcGamma,
+ kTable_SrcGamma,
+};
+
+enum DstGamma {
+ kLinear_DstGamma,
+ kSRGB_DstGamma,
+ k2Dot2_DstGamma,
+ kTable_DstGamma,
+};
+
+enum ColorSpaceMatch {
+ kNone_ColorSpaceMatch,
+ kGamut_ColorSpaceMatch,
+ kFull_ColorSpaceMatch,
+};
+
+template <SrcGamma kSrc, DstGamma kDst, ColorSpaceMatch kCSM>
+class SkColorSpaceXform_Base : public SkColorSpaceXform {
+public:
+ static constexpr int kDstGammaTableSize = 1024;
+
+protected:
+ bool onApply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src,
+ int count, SkAlphaType alphaType) const override;
+
+private:
+ SkColorSpaceXform_Base(SkColorSpace* srcSpace, const SkMatrix44& srcToDst,
+ SkColorSpace* dstSpace);
+
+ sk_sp<SkColorLookUpTable> fColorLUT;
+
+ // Contain pointers into storage or pointers into precomputed tables.
+ const float* fSrcGammaTables[3];
+ const uint8_t* fDstGammaTables[3];
+ SkAutoMalloc fStorage;
+
+ float fSrcToDst[16];
+
+ friend class SkColorSpaceXform;
+ friend std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(SkColorSpace* space);
+};
+
+// For testing. Bypasses opts for when src and dst color spaces are equal.
+std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(SkColorSpace* space);
+
+#endif
« no previous file with comments | « src/core/SkColorSpaceXform.cpp ('k') | tests/ColorSpaceXformTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698