1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkColorSpaceXform_A2B_DEFINED 9 #define SkColorSpaceXform_A2B_DEFINED 10 11 #include "SkColorSpace_Base.h" 12 #include "SkColorSpaceXform_Base.h" 13 #include "SkRasterPipeline.h" 14 15 #include <forward_list> 16 #include <functional> 17 #include <vector> 18 19 class SkColorSpace_A2B; 20 class SkColorSpace_XYZ; 21 22 struct SkTableTransferFn { 23 const float* fData; 24 int fSize; 25 }; 26 27 class SkColorSpaceXform_A2B : public SkColorSpaceXform_Base { 28 public: 29 bool onApply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src, 30 int count, SkAlphaType alphaType) const override; 31 32 private: 33 SkColorSpaceXform_A2B(SkColorSpace_A2B* srcSpace, SkColorSpace_XYZ* dstSpace); 34 35 void addTransferFns(const SkColorSpaceTransferFn& fn, int channelCount); 36 37 void addTransferFn(const SkColorSpaceTransferFn& fn, int channelIndex); 38 39 void addTableFn(const SkTableTransferFn& table, int channelIndex); 40 41 void addMatrix(const SkMatrix44& matrix); 42 43 SkRasterPipeline fElementsPipeline; 44 bool fLinearDstGamma; 45 46 // storage used by the pipeline 47 std::forward_list<SkColorSpaceTransferFn> fTransferFns; 48 std::forward_list<SkTableTransferFn> fTableTransferFns; 49 std::forward_list<std::vector<float>> fMatrices; 50 std::vector<sk_sp<const SkColorLookUpTable>> fCLUTs; 51 52 // these are here to maintain ownership of tables used in the pipeline 53 std::forward_list<std::vector<float>> fTableStorage; 54 std::vector<sk_sp<const SkGammas>> fGammaRefs; 55 56 friend class SkColorSpaceXform_Base; 57 }; 58 59 #endif 60