aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text/GrDistanceFieldAdjustTable.h
blob: 0f5c6f29abb19ba8825d13238b791f7ccfbf0bac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * 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 GrDistanceFieldAdjustTable_DEFINED
#define GrDistanceFieldAdjustTable_DEFINED

#include "SkRefCnt.h"
#include "SkScalar.h"

// Distance field text needs this table to compute a value for use in the fragment shader.
// Because the GrAtlasTextContext can go out of scope before the final flush, this needs to be
// refcnted and malloced
struct GrDistanceFieldAdjustTable : public SkNVRefCnt<GrDistanceFieldAdjustTable> {
    GrDistanceFieldAdjustTable() { this->buildDistanceAdjustTables(); }
    ~GrDistanceFieldAdjustTable() {
        delete[] fTable;
        delete[] fGammaCorrectTable;
    }

    const SkScalar& getAdjustment(int i, bool useGammaCorrectTable) const {
        return useGammaCorrectTable ? fGammaCorrectTable[i] : fTable[i];
    }

private:
    void buildDistanceAdjustTables();

    SkScalar* fTable;
    SkScalar* fGammaCorrectTable;
};

#endif