Flutter Engine
The Flutter Engine
third_party
skia
include
effects
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
11
#include "
include/core/SkRefCnt.h
"
12
#include "
include/core/SkScalar.h
"
13
#include "
include/core/SkTypes.h
"
14
15
class
SkColorFilter
;
16
17
/**
18
* Configuration struct for SkHighContrastFilter.
19
*
20
* Provides transformations to improve contrast for users with low vision.
21
*/
22
struct
SkHighContrastConfig
{
23
enum class
InvertStyle
{
24
kNoInvert,
25
kInvertBrightness,
26
kInvertLightness,
27
28
kLast = kInvertLightness
29
};
30
31
SkHighContrastConfig
() {
32
fGrayscale
=
false
;
33
fInvertStyle
=
InvertStyle::kNoInvert
;
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
{
46
return
fInvertStyle
>=
InvertStyle::kNoInvert
&&
47
fInvertStyle
<=
InvertStyle::kInvertLightness
&&
48
fContrast
>= -1.0 &&
49
fContrast
<= 1.0;
50
}
51
52
// If true, the color will be converted to grayscale.
53
bool
fGrayscale
;
54
55
// Whether to invert brightness, lightness, or neither.
56
InvertStyle
fInvertStyle
;
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.
60
SkScalar
fContrast
;
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
79
struct
SK_API
SkHighContrastFilter
{
80
// Returns the filter, or nullptr if the config is invalid.
81
static
sk_sp<SkColorFilter>
Make
(
const
SkHighContrastConfig
& config);
82
};
83
84
#endif
SK_API
#define SK_API
Definition:
SkAPI.h:35
SkRefCnt.h
SkScalar.h
SkTypes.h
SkColorFilter
Definition:
SkColorFilter.h:35
sk_sp< SkColorFilter >
SkScalar
float SkScalar
Definition:
extension.cpp:12
SkMultiPictureDocument::Make
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
Definition:
SkMultiPictureDocument.cpp:150
SkHighContrastConfig
Definition:
SkHighContrastFilter.h:22
SkHighContrastConfig::fContrast
SkScalar fContrast
Definition:
SkHighContrastFilter.h:60
SkHighContrastConfig::SkHighContrastConfig
SkHighContrastConfig()
Definition:
SkHighContrastFilter.h:31
SkHighContrastConfig::fGrayscale
bool fGrayscale
Definition:
SkHighContrastFilter.h:53
SkHighContrastConfig::isValid
bool isValid() const
Definition:
SkHighContrastFilter.h:45
SkHighContrastConfig::fInvertStyle
InvertStyle fInvertStyle
Definition:
SkHighContrastFilter.h:56
SkHighContrastConfig::InvertStyle
InvertStyle
Definition:
SkHighContrastFilter.h:23
SkHighContrastConfig::InvertStyle::kNoInvert
@ kNoInvert
SkHighContrastConfig::InvertStyle::kInvertLightness
@ kInvertLightness
SkHighContrastConfig::SkHighContrastConfig
SkHighContrastConfig(bool grayscale, InvertStyle invertStyle, SkScalar contrast)
Definition:
SkHighContrastFilter.h:37
SkHighContrastFilter
Definition:
SkHighContrastFilter.h:79
Generated on Sun Jun 23 2024 21:56:02 for Flutter Engine by
1.9.4