xref: /aosp_15_r20/external/skia/src/sksl/ir/SkSLDiscardStatement.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2022 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 #include "include/core/SkTypes.h"
9 #include "src/sksl/SkSLContext.h"
10 #include "src/sksl/SkSLErrorReporter.h"
11 #include "src/sksl/SkSLProgramSettings.h"
12 #include "src/sksl/ir/SkSLDiscardStatement.h"
13 
14 namespace SkSL {
15 
Convert(const Context & context,Position pos)16 std::unique_ptr<Statement> DiscardStatement::Convert(const Context& context, Position pos) {
17     if (!ProgramConfig::IsFragment(context.fConfig->fKind)) {
18         context.fErrors->error(pos, "discard statement is only permitted in fragment shaders");
19         return nullptr;
20     }
21     return DiscardStatement::Make(context, pos);
22 }
23 
Make(const Context & context,Position pos)24 std::unique_ptr<Statement> DiscardStatement::Make(const Context& context, Position pos) {
25     SkASSERT(ProgramConfig::IsFragment(context.fConfig->fKind));
26     return std::make_unique<DiscardStatement>(pos);
27 }
28 
29 }  // namespace SkSL
30