Flutter Engine
The Flutter Engine
DistanceFieldAdjustTable.h
Go to the documentation of this file.
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
12
13template <typename T> class SkNoDestructor;
14
15namespace sktext::gpu {
16
17// Distance field text needs this table to compute a value for use in the fragment shader.
19public:
20 static const DistanceFieldAdjustTable* Get();
21
23 delete[] fTable;
24 delete[] fGammaCorrectTable;
25 }
26
27 SkScalar getAdjustment(int lum, bool useGammaCorrectTable) const {
28 lum >>= kDistanceAdjustLumShift;
29 return useGammaCorrectTable ? fGammaCorrectTable[lum] : fTable[lum];
30 }
31
32private:
34
35 static constexpr int kDistanceAdjustLumShift = 5;
36
37 SkScalar* fTable;
38 SkScalar* fGammaCorrectTable;
39
41};
42
43} // namespace sktext::gpu
44
45#endif
static const DistanceFieldAdjustTable * Get()
SkScalar getAdjustment(int lum, bool useGammaCorrectTable) const
float SkScalar
Definition: extension.cpp:12
static float lum(float r, float g, float b)
Definition: hsl.cpp:52