ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 | #ifndef SKSL_PROGRAM |
| 9 | #define SKSL_PROGRAM |
| 10 | |
| 11 | #include <vector> |
| 12 | #include <memory> |
| 13 | |
ethannicholas | dcfe6db | 2016-10-10 10:09:00 -0700 | [diff] [blame^] | 14 | #include "SkSLModifiers.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 15 | #include "SkSLProgramElement.h" |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 16 | #include "SkSLSymbolTable.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 17 | |
| 18 | namespace SkSL { |
| 19 | |
| 20 | /** |
| 21 | * Represents a fully-digested program, ready for code generation. |
| 22 | */ |
| 23 | struct Program { |
| 24 | enum Kind { |
| 25 | kFragment_Kind, |
| 26 | kVertex_Kind |
| 27 | }; |
| 28 | |
ethannicholas | dcfe6db | 2016-10-10 10:09:00 -0700 | [diff] [blame^] | 29 | Program(Kind kind, |
| 30 | Modifiers::Flag defaultPrecision, |
| 31 | std::vector<std::unique_ptr<ProgramElement>> elements, |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 32 | std::shared_ptr<SymbolTable> symbols) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 33 | : fKind(kind) |
ethannicholas | dcfe6db | 2016-10-10 10:09:00 -0700 | [diff] [blame^] | 34 | , fDefaultPrecision(defaultPrecision) |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 35 | , fElements(std::move(elements)) |
| 36 | , fSymbols(symbols) {} |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 37 | |
| 38 | Kind fKind; |
ethannicholas | dcfe6db | 2016-10-10 10:09:00 -0700 | [diff] [blame^] | 39 | // FIXME handle different types; currently it assumes this is for floats |
| 40 | Modifiers::Flag fDefaultPrecision; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 41 | std::vector<std::unique_ptr<ProgramElement>> fElements; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 42 | std::shared_ptr<SymbolTable> fSymbols; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } // namespace |
| 46 | |
| 47 | #endif |