blob: af2bb719d8dc6599e72ff0aa6b0d1badd884ca41 [file] [log] [blame]
// Copyright 2018 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_helpers.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;
return static_cast<SkColor>(java_color);
} // namespace ui