• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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/private/SkSLSampleUsage.h"
9 
10 #include <algorithm>
11 
12 namespace SkSL {
13 
merge(const SampleUsage & other)14 SampleUsage SampleUsage::merge(const SampleUsage& other) {
15     // This function is only used when processing SkSL, to determine the combined SampleUsage for
16     // a child fp/shader/etc. We should never see matrix sampling here.
17     SkASSERT(fKind != Kind::kUniformMatrix && other.fKind != Kind::kUniformMatrix);
18 
19     static_assert(Kind::kExplicit > Kind::kPassThrough);
20     static_assert(Kind::kPassThrough > Kind::kNone);
21     fKind = std::max(fKind, other.fKind);
22 
23     return *this;
24 }
25 
constructor() const26 std::string SampleUsage::constructor() const {
27     // This function is only used when processing SkSL. We should never see matrix sampling here.
28     SkASSERT(fKind != Kind::kUniformMatrix);
29 
30     switch (fKind) {
31         case Kind::kNone:        return "SkSL::SampleUsage()";
32         case Kind::kPassThrough: return "SkSL::SampleUsage::PassThrough()";
33         case Kind::kExplicit:    return "SkSL::SampleUsage::Explicit()";
34         default: SkUNREACHABLE;
35     }
36 }
37 
38 }  // namespace SkSL
39