1 /* 2 * Copyright 2015 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 sktext_gpu_DistanceFieldAdjustTable_DEFINED 9 #define sktext_gpu_DistanceFieldAdjustTable_DEFINED 10 11 #include "include/core/SkScalar.h" 12 13 namespace sktext::gpu { 14 15 // Distance field text needs this table to compute a value for use in the fragment shader. 16 class DistanceFieldAdjustTable { 17 public: 18 static const DistanceFieldAdjustTable* Get(); 19 ~DistanceFieldAdjustTable()20 ~DistanceFieldAdjustTable() { 21 delete[] fTable; 22 delete[] fGammaCorrectTable; 23 } 24 getAdjustment(int i,bool useGammaCorrectTable)25 SkScalar getAdjustment(int i, bool useGammaCorrectTable) const { 26 return useGammaCorrectTable ? fGammaCorrectTable[i] : fTable[i]; 27 } 28 29 private: 30 DistanceFieldAdjustTable(); 31 32 SkScalar* fTable; 33 SkScalar* fGammaCorrectTable; 34 }; 35 36 } // namespace sktext::gpu 37 38 #endif 39