| 1 |
/* |
| 2 |
* Copyright (C) 2020 The Android Open Source Project |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include "CommonWriter.h" |
| 18 |
|
| 19 |
#include <private/filament/EngineEnums.h> |
| 20 |
#include <private/filament/Variant.h> |
| 21 |
|
| 22 |
namespace filament::matdbg { |
| 23 |
|
| 24 |
std::string formatVariantString(uint8_t variant, MaterialDomain domain) noexcept { |
| 25 |
if (domain == MaterialDomain::POST_PROCESS) { |
| 26 |
switch ((PostProcessVariant) variant) { |
| 27 |
case PostProcessVariant::OPAQUE: return "OPA"; |
| 28 |
case PostProcessVariant::TRANSLUCENT: return "TRN"; |
| 29 |
} |
| 30 |
return "UNK"; |
| 31 |
} |
| 32 |
|
| 33 |
std::string variantString = ""; |
| 34 |
|
| 35 |
// NOTE: The 3-character nomenclature used here is consistent with the ASCII art seen in the |
| 36 |
// Variant header file and allows the information to fit in a reasonable amount of space on |
| 37 |
// the page. The HTML file has a legend. |
| 38 |
if (variant) { |
| 39 |
if (variant & Variant::DIRECTIONAL_LIGHTING) variantString += "DIR|"; |
| 40 |
if (variant & Variant::DYNAMIC_LIGHTING) variantString += "DYN|"; |
| 41 |
if (variant & Variant::SHADOW_RECEIVER) variantString += "SRE|"; |
| 42 |
if (variant & Variant::SKINNING_OR_MORPHING) variantString += "SKN|"; |
| 43 |
if (variant & Variant::DEPTH) variantString += "DEP|"; |
| 44 |
if (variant & Variant::FOG) variantString += "FOG|"; |
| 45 |
if (variant & Variant::VSM) variantString += "VSM|"; |
| 46 |
variantString = variantString.substr(0, variantString.length() - 1); |
| 47 |
} |
| 48 |
|
| 49 |
return variantString; |
| 50 |
} |
| 51 |
|
| 52 |
} // namespace filament::matdbg |