Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 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 | |
Brian Osman | b1e9cb0 | 2021-05-21 12:03:51 -0400 | [diff] [blame] | 10 | #include <algorithm> |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 11 | |
| 12 | namespace SkSL { |
| 13 | |
| 14 | SampleUsage SampleUsage::merge(const SampleUsage& other) { |
Brian Osman | 83dae92 | 2021-04-28 10:44:06 -0400 | [diff] [blame] | 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); |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 18 | |
Brian Osman | 83dae92 | 2021-04-28 10:44:06 -0400 | [diff] [blame] | 19 | static_assert(Kind::kExplicit > Kind::kPassThrough); |
| 20 | static_assert(Kind::kPassThrough > Kind::kNone); |
| 21 | fKind = std::max(fKind, other.fKind); |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 22 | |
| 23 | return *this; |
| 24 | } |
| 25 | |
Brian Osman | 83dae92 | 2021-04-28 10:44:06 -0400 | [diff] [blame] | 26 | 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); |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 29 | |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 30 | switch (fKind) { |
Brian Osman | 83dae92 | 2021-04-28 10:44:06 -0400 | [diff] [blame] | 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; |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 35 | } |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 36 | } |
| 37 | |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 38 | } // namespace SkSL |