blob: c39fb339a97179d2fb554ca240ea3e60848b9d0d [file] [log] [blame]
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef sktext_gpu_DistanceFieldAdjustTable_DEFINED
#define sktext_gpu_DistanceFieldAdjustTable_DEFINED
#include "include/core/SkScalar.h"
template <typename T> class SkNoDestructor;
namespace sktext::gpu {
// Distance field text needs this table to compute a value for use in the fragment shader.
class DistanceFieldAdjustTable {
public:
static const DistanceFieldAdjustTable* Get();
~DistanceFieldAdjustTable() {
delete[] fTable;
delete[] fGammaCorrectTable;
}
SkScalar getAdjustment(int lum, bool useGammaCorrectTable) const {
lum >>= kDistanceAdjustLumShift;
return useGammaCorrectTable ? fGammaCorrectTable[lum] : fTable[lum];
}
private:
DistanceFieldAdjustTable();
static constexpr int kDistanceAdjustLumShift = 5;
SkScalar* fTable;
SkScalar* fGammaCorrectTable;
friend class SkNoDestructor<DistanceFieldAdjustTable>;
};
} // namespace sktext::gpu
#endif