summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/sksl/ir/SkSLDiscardStatement.cpp
blob: 2f090219f20147d1a479ad49d22d4791ed3ae316 (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
/*
 * Copyright 2022 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "include/core/SkTypes.h"
#include "include/sksl/SkSLErrorReporter.h"
#include "src/sksl/SkSLContext.h"
#include "src/sksl/SkSLProgramSettings.h"
#include "src/sksl/ir/SkSLDiscardStatement.h"

namespace SkSL {

std::unique_ptr<Statement> DiscardStatement::Convert(const Context& context, Position pos) {
    if (!ProgramConfig::IsFragment(context.fConfig->fKind)) {
        context.fErrors->error(pos, "discard statement is only permitted in fragment shaders");
        return nullptr;
    }
    return DiscardStatement::Make(context, pos);
}

std::unique_ptr<Statement> DiscardStatement::Make(const Context& context, Position pos) {
    SkASSERT(ProgramConfig::IsFragment(context.fConfig->fKind));
    return std::make_unique<DiscardStatement>(pos);
}

std::unique_ptr<Statement> DiscardStatement::clone() const {
    return std::make_unique<DiscardStatement>(fPosition);
}

}  // namespace SkSL