forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathcolor_utils_android.cc
32 lines (25 loc) · 928 Bytes
/
color_utils_android.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2021 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.
#include "ui/android/color_utils_android.h"
#include "base/check.h"
#include "base/numerics/safe_math.h"
#include "ui/gfx/color_utils.h"
namespace ui {
std::string OptionalSkColorToString(const absl::optional<SkColor>& color) {
if (!color)
return std::string();
return color_utils::SkColorToRgbaString(*color);
}
int64_t OptionalSkColorToJavaColor(const absl::optional<SkColor>& skcolor) {
if (!skcolor)
return kInvalidJavaColor;
return static_cast<int32_t>(*skcolor);
}
absl::optional<SkColor> JavaColorToOptionalSkColor(int64_t java_color) {
if (java_color == kInvalidJavaColor)
return absl::nullopt;
DCHECK(base::IsValueInRangeForNumericType<int32_t>(java_color));
return static_cast<SkColor>(java_color);
}
} // namespace ui