• 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/private/SkSLLayout.h"
9 #include "include/private/SkSLString.h"
10 
11 namespace SkSL {
12 
description() const13 std::string Layout::description() const {
14     std::string result;
15     auto separator = SkSL::String::Separator();
16     if (fLocation >= 0) {
17         result += separator() + "location = " + std::to_string(fLocation);
18     }
19     if (fOffset >= 0) {
20         result += separator() + "offset = " + std::to_string(fOffset);
21     }
22     if (fBinding >= 0) {
23         result += separator() + "binding = " + std::to_string(fBinding);
24     }
25     if (fTexture >= 0) {
26         result += separator() + "texture = " + std::to_string(fTexture);
27     }
28     if (fSampler >= 0) {
29         result += separator() + "sampler = " + std::to_string(fSampler);
30     }
31     if (fIndex >= 0) {
32         result += separator() + "index = " + std::to_string(fIndex);
33     }
34     if (fSet >= 0) {
35         result += separator() + "set = " + std::to_string(fSet);
36     }
37     if (fBuiltin >= 0) {
38         result += separator() + "builtin = " + std::to_string(fBuiltin);
39     }
40     if (fInputAttachmentIndex >= 0) {
41         result += separator() + "input_attachment_index = " +
42                   std::to_string(fInputAttachmentIndex);
43     }
44     if (fFlags & kOriginUpperLeft_Flag) {
45         result += separator() + "origin_upper_left";
46     }
47     if (fFlags & kBlendSupportAllEquations_Flag) {
48         result += separator() + "blend_support_all_equations";
49     }
50     if (fFlags & kPushConstant_Flag) {
51         result += separator() + "push_constant";
52     }
53     if (fFlags & kColor_Flag) {
54         result += separator() + "color";
55     }
56     if (result.size() > 0) {
57         result = "layout (" + result + ")";
58     }
59     return result;
60 }
61 
operator ==(const Layout & other) const62 bool Layout::operator==(const Layout& other) const {
63     return fFlags                == other.fFlags &&
64            fLocation             == other.fLocation &&
65            fOffset               == other.fOffset &&
66            fBinding              == other.fBinding &&
67            fTexture              == other.fTexture &&
68            fSampler              == other.fSampler &&
69            fIndex                == other.fIndex &&
70            fSet                  == other.fSet &&
71            fBuiltin              == other.fBuiltin &&
72            fInputAttachmentIndex == other.fInputAttachmentIndex;
73 }
74 
75 }  // namespace SkSL
76