1 // Copyright 2017 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_SETTINGS_H_
6 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_DARK_MODE_SETTINGS_H_
7 
8 namespace blink {
9 
10 enum class DarkModeInversionAlgorithm {
11   // Default, drawing is unfiltered.
12   // TODO(https://crbug.com/1002664): This value is deprecated and in the
13   // process of being removed.
14   kOff,
15   // For testing only, does a simple 8-bit invert of every RGB pixel component.
16   kSimpleInvertForTesting,
17   kInvertBrightness,
18   kInvertLightness,
19   kInvertLightnessLAB,
20 };
21 
22 enum class DarkModeImagePolicy {
23   // Apply dark-mode filter to all images.
24   kFilterAll,
25   // Never apply dark-mode filter to any images.
26   kFilterNone,
27   // Apply dark-mode based on image content.
28   kFilterSmart,
29 };
30 
31 enum class DarkModePagePolicy {
32   // Apply dark-mode filter to all frames, regardless of content.
33   kFilterAll,
34   // Apply dark-mode filter to frames based on background color.
35   kFilterByBackground,
36 };
37 
38 enum class DarkModeClassifierType {
39   kIcon,
40   kGeneric,
41 };
42 
43 // New variables added to this struct should also be added to
44 // BuildDarkModeSettings() in
45 //   //src/third_party/blink/renderer/core/accessibility/apply_dark_mode.h
46 struct DarkModeSettings {
47   DarkModeInversionAlgorithm mode = DarkModeInversionAlgorithm::kOff;
48   bool grayscale = false;
49   float image_grayscale_percent = 0.0;  // Valid range from 0.0 to 1.0
50   float contrast = 0.0;                 // Valid range from -1.0 to 1.0
51   DarkModeImagePolicy image_policy = DarkModeImagePolicy::kFilterNone;
52   DarkModeClassifierType classifier_type = DarkModeClassifierType::kGeneric;
53 
54   // Text colors with brightness below this threshold will be inverted, and
55   // above it will be left as in the original, non-dark-mode page.  Set to 256
56   // to always invert text color or to 0 to never invert text color.
57   int text_brightness_threshold = 256;
58 
59   // Background elements with brightness above this threshold will be inverted,
60   // and below it will be left as in the original, non-dark-mode page.  Set to
61   // 256 to never invert the color or to 0 to always invert it.
62   //
63   // Warning: This behavior is the opposite of text_brightness_threshold!
64   int background_brightness_threshold = 0;
65 };
66 
67 }  // namespace blink
68 
69 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_DARK_MODE_SETTINGS_H_
70