aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ast/SkSLASTPrecision.h
blob: a2f427c9ce5e7df4953196024b88a164da02a165 (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
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
 
#ifndef SKSL_ASTPRECISION
#define SKSL_ASTPRECISION

#include "SkSLASTDeclaration.h"
#include "../ir/SkSLModifiers.h"

namespace SkSL {

/**
 * Represents a precision declaration (e.g. 'precision mediump float;').
 */
struct ASTPrecision : public ASTDeclaration {
    // FIXME handle the type
    ASTPrecision(Position position, Modifiers::Flag precision)
    : INHERITED(position, kPrecision_Kind)
    , fPrecision(precision) {}

    SkString description() const {
        switch (fPrecision) {
            case Modifiers::kLowp_Flag: return SkString("precision lowp float;");
            case Modifiers::kMediump_Flag: return SkString("precision mediump float;");
            case Modifiers::kHighp_Flag: return SkString("precision highp float;");
            default: 
                ASSERT(false); 
                return SkString("<error>");
        }
        ASSERT(false);
        return SkString("<error>");
    }

    const Modifiers::Flag fPrecision;

    typedef ASTDeclaration INHERITED;
};

} // namespace

#endif