Index: include/core/SkColorSpaceXform.h |
diff --git a/src/core/SkColorSpaceXform.h b/include/core/SkColorSpaceXform.h |
similarity index 50% |
rename from src/core/SkColorSpaceXform.h |
rename to include/core/SkColorSpaceXform.h |
index bb99071fe03388057c63e30327ca95bdb6ba23b5..15b3d49ee4a224d68cb6341c6bb9867768ade476 100644 |
--- a/src/core/SkColorSpaceXform.h |
+++ b/include/core/SkColorSpaceXform.h |
@@ -8,10 +8,10 @@ |
#ifndef SkColorSpaceXform_DEFINED |
#define SkColorSpaceXform_DEFINED |
-#include "SkColorSpace.h" |
-#include "SkColorSpace_Base.h" |
#include "SkImageInfo.h" |
+class SkColorSpace; |
+ |
class SkColorSpaceXform : SkNoncopyable { |
public: |
@@ -24,7 +24,7 @@ public: |
*/ |
static std::unique_ptr<SkColorSpaceXform> New(SkColorSpace* srcSpace, SkColorSpace* dstSpace); |
- enum ColorFormat : uint8_t { |
+ enum ColorFormat { |
kRGBA_8888_ColorFormat, |
kBGRA_8888_ColorFormat, |
kRGBA_F16_ColorFormat, |
@@ -34,6 +34,9 @@ public: |
/** |
* Apply the color conversion to a |src| buffer, storing the output in the |dst| buffer. |
* |
+ * F16 and F32 are only supported as dst color formats, and only when the dst color space |
+ * is linear. This function will return false in unsupported cases. |
+ * |
* @param dst Stored in the format described by |dstColorFormat| |
* @param src Stored in the format described by |srcColorFormat| |
* @param len Number of pixels in the buffers |
@@ -46,57 +49,19 @@ public: |
* kOpaque optimization hint, |dst| alphas set to 1 |
* |
*/ |
- virtual void apply(void* dst, const uint32_t* src, int len, ColorFormat dstColorFormat, |
- ColorFormat srcColorFormat, SkAlphaType alphaType) const = 0; |
- |
- virtual ~SkColorSpaceXform() {} |
-}; |
- |
-enum SrcGamma { |
- kLinear_SrcGamma, |
- kTable_SrcGamma, |
-}; |
- |
-enum DstGamma { |
- kLinear_DstGamma, |
- kSRGB_DstGamma, |
- k2Dot2_DstGamma, |
- kTable_DstGamma, |
-}; |
+ bool apply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src, int count, |
+ SkAlphaType alphaType) const { |
+ return this->onApply(dstFormat, dst, srcFormat, src, count, alphaType); |
+ } |
-enum ColorSpaceMatch { |
- kNone_ColorSpaceMatch, |
- kGamut_ColorSpaceMatch, |
- kFull_ColorSpaceMatch, |
-}; |
- |
-template <SrcGamma kSrc, DstGamma kDst, ColorSpaceMatch kCSM> |
-class SkColorSpaceXform_Base : public SkColorSpaceXform { |
-public: |
- |
- void apply(void* dst, const uint32_t* src, int len, ColorFormat dstColorFormat, |
- ColorFormat srcColorFormat, SkAlphaType alphaType) const override; |
- |
- static constexpr int kDstGammaTableSize = 1024; |
-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; |
+ virtual ~SkColorSpaceXform() {} |
- float fSrcToDst[16]; |
+protected: |
+ virtual bool onApply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src, |
+ int count, SkAlphaType alphaType) const = 0; |
- friend class SkColorSpaceXform; |
- friend std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(SkColorSpace* space); |
+ SkColorSpaceXform() {} |
}; |
-// For testing. Bypasses opts for when src and dst color spaces are equal. |
-std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(SkColorSpace* space); |
- |
#endif |