• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/sksl/SkSLErrorReporter.h"
10 #include "src/sksl/SkSLContext.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 
clone() const29 std::unique_ptr<Statement> DiscardStatement::clone() const {
30     return std::make_unique<DiscardStatement>(fPosition);
31 }
32 
33 }  // namespace SkSL
34