1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2021 Google LLC.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#ifndef SKSL_DSL_LAYOUT
9cb93a386Sopenharmony_ci#define SKSL_DSL_LAYOUT
10cb93a386Sopenharmony_ci
11cb93a386Sopenharmony_ci#include "include/sksl/DSLLayout.h"
12cb93a386Sopenharmony_ci
13cb93a386Sopenharmony_ci#include "include/private/SkSLLayout.h"
14cb93a386Sopenharmony_ci#include "include/sksl/SkSLErrorReporter.h"
15cb93a386Sopenharmony_ci
16cb93a386Sopenharmony_cinamespace SkSL {
17cb93a386Sopenharmony_ci
18cb93a386Sopenharmony_cinamespace dsl {
19cb93a386Sopenharmony_ci
20cb93a386Sopenharmony_ciclass DSLLayout {
21cb93a386Sopenharmony_cipublic:
22cb93a386Sopenharmony_ci    DSLLayout() {}
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ci    DSLLayout& originUpperLeft(PositionInfo pos = PositionInfo::Capture()) {
25cb93a386Sopenharmony_ci        return this->flag(SkSL::Layout::kOriginUpperLeft_Flag, "origin_upper_left", pos);
26cb93a386Sopenharmony_ci    }
27cb93a386Sopenharmony_ci
28cb93a386Sopenharmony_ci    DSLLayout& pushConstant(PositionInfo pos = PositionInfo::Capture()) {
29cb93a386Sopenharmony_ci        return this->flag(SkSL::Layout::kPushConstant_Flag, "push_constant", pos);
30cb93a386Sopenharmony_ci    }
31cb93a386Sopenharmony_ci
32cb93a386Sopenharmony_ci    DSLLayout& blendSupportAllEquations(PositionInfo pos = PositionInfo::Capture()) {
33cb93a386Sopenharmony_ci        return this->flag(SkSL::Layout::kBlendSupportAllEquations_Flag,
34cb93a386Sopenharmony_ci                          "blend_support_all_equations", pos);
35cb93a386Sopenharmony_ci    }
36cb93a386Sopenharmony_ci
37cb93a386Sopenharmony_ci    DSLLayout& srgbUnpremul(PositionInfo pos = PositionInfo::Capture()) {
38cb93a386Sopenharmony_ci        return this->flag(SkSL::Layout::kSRGBUnpremul_Flag, "srgb_unpremul", pos);
39cb93a386Sopenharmony_ci    }
40cb93a386Sopenharmony_ci
41cb93a386Sopenharmony_ci    DSLLayout& location(int location, PositionInfo pos = PositionInfo::Capture()) {
42cb93a386Sopenharmony_ci        return this->intValue(&fSkSLLayout.fLocation, location, SkSL::Layout::kLocation_Flag,
43cb93a386Sopenharmony_ci                              "location", pos);
44cb93a386Sopenharmony_ci    }
45cb93a386Sopenharmony_ci
46cb93a386Sopenharmony_ci    DSLLayout& offset(int offset, PositionInfo pos = PositionInfo::Capture()) {
47cb93a386Sopenharmony_ci        return this->intValue(&fSkSLLayout.fOffset, offset, SkSL::Layout::kOffset_Flag, "offset",
48cb93a386Sopenharmony_ci                              pos);
49cb93a386Sopenharmony_ci    }
50cb93a386Sopenharmony_ci
51cb93a386Sopenharmony_ci    DSLLayout& binding(int binding, PositionInfo pos = PositionInfo::Capture()) {
52cb93a386Sopenharmony_ci        return this->intValue(&fSkSLLayout.fBinding, binding, SkSL::Layout::kBinding_Flag,
53cb93a386Sopenharmony_ci                              "binding", pos);
54cb93a386Sopenharmony_ci    }
55cb93a386Sopenharmony_ci
56cb93a386Sopenharmony_ci    DSLLayout& index(int index, PositionInfo pos = PositionInfo::Capture()) {
57cb93a386Sopenharmony_ci        return this->intValue(&fSkSLLayout.fIndex, index, SkSL::Layout::kIndex_Flag, "index", pos);
58cb93a386Sopenharmony_ci    }
59cb93a386Sopenharmony_ci
60cb93a386Sopenharmony_ci    DSLLayout& set(int set, PositionInfo pos = PositionInfo::Capture()) {
61cb93a386Sopenharmony_ci        return this->intValue(&fSkSLLayout.fSet, set, SkSL::Layout::kSet_Flag, "set", pos);
62cb93a386Sopenharmony_ci    }
63cb93a386Sopenharmony_ci
64cb93a386Sopenharmony_ci    DSLLayout& builtin(int builtin, PositionInfo pos = PositionInfo::Capture()) {
65cb93a386Sopenharmony_ci        return this->intValue(&fSkSLLayout.fBuiltin, builtin, SkSL::Layout::kBuiltin_Flag,
66cb93a386Sopenharmony_ci                              "builtin", pos);
67cb93a386Sopenharmony_ci    }
68cb93a386Sopenharmony_ci
69cb93a386Sopenharmony_ci    DSLLayout& inputAttachmentIndex(int inputAttachmentIndex,
70cb93a386Sopenharmony_ci                                    PositionInfo pos = PositionInfo::Capture()) {
71cb93a386Sopenharmony_ci        return this->intValue(&fSkSLLayout.fInputAttachmentIndex, inputAttachmentIndex,
72cb93a386Sopenharmony_ci                              SkSL::Layout::kInputAttachmentIndex_Flag, "input_attachment_index",
73cb93a386Sopenharmony_ci                              pos);
74cb93a386Sopenharmony_ci    }
75cb93a386Sopenharmony_ci
76cb93a386Sopenharmony_ciprivate:
77cb93a386Sopenharmony_ci    explicit DSLLayout(SkSL::Layout skslLayout)
78cb93a386Sopenharmony_ci        : fSkSLLayout(skslLayout) {}
79cb93a386Sopenharmony_ci
80cb93a386Sopenharmony_ci    DSLLayout& flag(SkSL::Layout::Flag mask, const char* name, PositionInfo pos);
81cb93a386Sopenharmony_ci
82cb93a386Sopenharmony_ci    DSLLayout& intValue(int* target, int value, SkSL::Layout::Flag flag, const char* name,
83cb93a386Sopenharmony_ci                        PositionInfo pos);
84cb93a386Sopenharmony_ci
85cb93a386Sopenharmony_ci    SkSL::Layout fSkSLLayout;
86cb93a386Sopenharmony_ci
87cb93a386Sopenharmony_ci    friend class DSLModifiers;
88cb93a386Sopenharmony_ci};
89cb93a386Sopenharmony_ci
90cb93a386Sopenharmony_ci} // namespace dsl
91cb93a386Sopenharmony_ci
92cb93a386Sopenharmony_ci} // namespace SkSL
93cb93a386Sopenharmony_ci
94cb93a386Sopenharmony_ci#endif
95