1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_DARK_MODE_COLOR_CLASSIFIER_H_
6 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_DARK_MODE_COLOR_CLASSIFIER_H_
7 
8 #include <memory>
9 
10 #include "third_party/blink/renderer/platform/graphics/color.h"
11 #include "third_party/blink/renderer/platform/graphics/dark_mode_settings.h"
12 #include "third_party/blink/renderer/platform/graphics/graphics_types.h"
13 #include "third_party/blink/renderer/platform/platform_export.h"
14 
15 namespace blink {
16 
17 class PLATFORM_EXPORT DarkModeColorClassifier {
18  public:
19   // Determine perceived brightness of a color.
20   static int CalculateColorBrightness(const Color& color);
21 
22   static std::unique_ptr<DarkModeColorClassifier> MakeTextColorClassifier(
23       const DarkModeSettings& settings);
24   static std::unique_ptr<DarkModeColorClassifier> MakeBackgroundColorClassifier(
25       const DarkModeSettings& settings);
26 
27   virtual ~DarkModeColorClassifier();
28 
29   // TODO(https://crbug.com/968340): Include element opacity when determining
30   // whether to invert a color. The background is likely to be dark, so a lower
31   // opacity will usually decrease the effective brightness of both the original
32   // and the inverted colors.
33   virtual DarkModeClassification ShouldInvertColor(const Color& color) = 0;
34 };
35 
36 }  // namespace blink
37 
38 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_DARK_MODE_COLOR_CLASSIFIER_H_
39