Flutter Engine
The Flutter Engine
SkHighContrastFilter.h
Go to the documentation of this file.
1/*
2* Copyright 2017 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#ifndef SkHighContrastFilter_DEFINED
9#define SkHighContrastFilter_DEFINED
10
14
15class SkColorFilter;
16
17/**
18 * Configuration struct for SkHighContrastFilter.
19 *
20 * Provides transformations to improve contrast for users with low vision.
21 */
23 enum class InvertStyle {
24 kNoInvert,
25 kInvertBrightness,
26 kInvertLightness,
27
28 kLast = kInvertLightness
29 };
30
32 fGrayscale = false;
34 fContrast = 0.0f;
35 }
36
37 SkHighContrastConfig(bool grayscale,
38 InvertStyle invertStyle,
39 SkScalar contrast)
40 : fGrayscale(grayscale)
41 , fInvertStyle(invertStyle)
42 , fContrast(contrast) {}
43
44 // Returns true if all of the fields are set within the valid range.
45 bool isValid() const {
48 fContrast >= -1.0 &&
49 fContrast <= 1.0;
50 }
51
52 // If true, the color will be converted to grayscale.
54
55 // Whether to invert brightness, lightness, or neither.
57
58 // After grayscale and inverting, the contrast can be adjusted linearly.
59 // The valid range is -1.0 through 1.0, where 0.0 is no adjustment.
61};
62
63/**
64 * Color filter that provides transformations to improve contrast
65 * for users with low vision.
66 *
67 * Applies the following transformations in this order. Each of these
68 * can be configured using SkHighContrastConfig.
69 *
70 * - Conversion to grayscale
71 * - Color inversion (either in RGB or HSL space)
72 * - Increasing the resulting contrast.
73 *
74 * Calling SkHighContrastFilter::Make will return nullptr if the config is
75 * not valid, e.g. if you try to call it with a contrast outside the range of
76 * -1.0 to 1.0.
77 */
78
80 // Returns the filter, or nullptr if the config is invalid.
82};
83
84#endif
#define SK_API
Definition: SkAPI.h:35
float SkScalar
Definition: extension.cpp:12
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
SkHighContrastConfig(bool grayscale, InvertStyle invertStyle, SkScalar contrast)