Skia
2D Graphics Library
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 
23  enum class InvertStyle {
24  kNoInvert,
27 
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.
53  bool fGrayscale;
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 
79 struct SK_API SkHighContrastFilter {
80  // Returns the filter, or nullptr if the config is invalid.
82 };
83 
84 #endif
float SkScalar
Definition: SkScalar.h:14
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:35
Configuration struct for SkHighContrastFilter.
Definition: SkHighContrastFilter.h:22
SkScalar fContrast
Definition: SkHighContrastFilter.h:60
SkHighContrastConfig()
Definition: SkHighContrastFilter.h:31
bool fGrayscale
Definition: SkHighContrastFilter.h:53
bool isValid() const
Definition: SkHighContrastFilter.h:45
InvertStyle fInvertStyle
Definition: SkHighContrastFilter.h:56
InvertStyle
Definition: SkHighContrastFilter.h:23
SkHighContrastConfig(bool grayscale, InvertStyle invertStyle, SkScalar contrast)
Definition: SkHighContrastFilter.h:37
Color filter that provides transformations to improve contrast for users with low vision.
Definition: SkHighContrastFilter.h:79
static sk_sp< SkColorFilter > Make(const SkHighContrastConfig &config)