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 "SkArenaAlloc.h" 12 #include "SkColorSpaceXform_Base.h" 13 #include "SkRasterPipeline.h" 14 15 class SkColorSpace_A2B; 16 class SkColorSpace_XYZ; 17 18 struct SkTableTransferFn { 19 const float* fData; 20 int fSize; 21 }; 22 23 class SkColorSpaceXform_A2B : public SkColorSpaceXform_Base { 24 public: 25 SkColorSpaceXform_A2B(SkColorSpace_A2B* srcSpace, SkColorSpace_XYZ* dstSpace); 26 27 bool onApply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src, 28 int count, SkAlphaType alphaType) const override; 29 30 private: 31 void addTransferFn(const SkColorSpaceTransferFn& fn, int channelIndex); 32 33 bool buildTableFn(SkTableTransferFn* table); 34 void addTableFn(const SkTableTransferFn& table, int channelIndex); 35 36 void addMatrix(const SkMatrix44& matrix); 37 38 SkRasterPipeline fElementsPipeline; 39 bool fLinearDstGamma; 40 SkArenaAlloc fAlloc{128}; // TODO: tune? 41 42 template <typename T> 43 T* copy(const T& val) { return fAlloc.make<T>(val); } 44 }; 45 46 #endif 47