blob: d765443c1e629925ba5ee9b0f7865c05ff9fe97d [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{%- set header_guard = "%s_"|format(
out_file_path|upper|replace("/","_")|replace(".","_")|
replace("-", "_")) %}
// This file is generated from:
{%- for path in in_files %}
// {{path}}
{%- endfor %}
#ifndef {{header_guard}}
#define {{header_guard}}
namespace {{namespace_name}} {
enum class ColorName {
{%- for obj in colors %}
{{obj.name | to_const_name}},
{%- endfor %}
};
{%- if opacities %}
enum class OpacityName {
{%- for name in opacities %}
{{name | to_const_name}},
{%- endfor %}
};
constexpr SkAlpha GetOpacity(OpacityName opacity_name) {
switch (opacity_name) {
{%- for name, value in opacities.items() %}
case OpacityName::{{name | to_const_name}}:
return {{value | alpha_to_hex}};
{%- endfor %}
}
}
{%- endif %}
constexpr SkColor ResolveColor(ColorName color_name, bool is_dark_mode) {
switch (color_name) {
{%- for obj in colors %}
case ColorName::{{obj.name | to_const_name}}:
{%- if obj.mode_values[Modes.DARK] %}
if (is_dark_mode) {
return {{obj.mode_values[Modes.DARK] | cpp_color}};
} else {
return {{obj.mode_values[Modes.LIGHT] | cpp_color}};
}
{%- else %}
return {{obj.mode_values[Modes.LIGHT] | cpp_color}};
{%- endif %}
{%- endfor %}
}
}
} // namespace {{namespace_name}}
#endif // {{header_guard}}