1 /*
2 * Copyright 2021 Google LLC.
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/sksl/DSLLayout.h"
9
10 #include "src/sksl/SkSLThreadContext.h"
11
12 #include <string>
13
14 namespace SkSL {
15
16 namespace dsl {
17
flag(SkSL::Layout::Flag mask,const char * name,Position pos)18 DSLLayout& DSLLayout::flag(SkSL::Layout::Flag mask, const char* name, Position pos) {
19 if (fSkSLLayout.fFlags & mask) {
20 ThreadContext::ReportError("layout qualifier '" + std::string(name) +
21 "' appears more than once", pos);
22 }
23 fSkSLLayout.fFlags |= mask;
24 return *this;
25 }
26
intValue(int * target,int value,SkSL::Layout::Flag flag,const char * name,Position pos)27 DSLLayout& DSLLayout::intValue(int* target, int value, SkSL::Layout::Flag flag, const char* name,
28 Position pos) {
29 this->flag(flag, name, pos);
30 *target = value;
31 return *this;
32 }
33
34 } // namespace dsl
35
36 } // namespace SkSL
37