Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSurfaceProps.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 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 SkSurfaceProps_DEFINED
9#define SkSurfaceProps_DEFINED
10
14
15/**
16 * Description of how the LCD strips are arranged for each pixel. If this is unknown, or the
17 * pixels are meant to be "portable" and/or transformed before showing (e.g. rotated, scaled)
18 * then use kUnknown_SkPixelGeometry.
19 */
27
28// Returns true iff geo is a known geometry and is RGB.
29static inline bool SkPixelGeometryIsRGB(SkPixelGeometry geo) {
30 return kRGB_H_SkPixelGeometry == geo || kRGB_V_SkPixelGeometry == geo;
31}
32
33// Returns true iff geo is a known geometry and is BGR.
34static inline bool SkPixelGeometryIsBGR(SkPixelGeometry geo) {
35 return kBGR_H_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
36}
37
38// Returns true iff geo is a known geometry and is horizontal.
39static inline bool SkPixelGeometryIsH(SkPixelGeometry geo) {
40 return kRGB_H_SkPixelGeometry == geo || kBGR_H_SkPixelGeometry == geo;
41}
42
43// Returns true iff geo is a known geometry and is vertical.
44static inline bool SkPixelGeometryIsV(SkPixelGeometry geo) {
45 return kRGB_V_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
46}
47
48/**
49 * Describes properties and constraints of a given SkSurface. The rendering engine can parse these
50 * during drawing, and can sometimes optimize its performance (e.g. disabling an expensive
51 * feature).
52 */
54public:
55 enum Flags {
56 kDefault_Flag = 0,
57 kUseDeviceIndependentFonts_Flag = 1 << 0,
58 // Use internal MSAA to render to non-MSAA GPU surfaces.
59 kDynamicMSAA_Flag = 1 << 1,
60 // If set, all rendering will have dithering enabled
61 // Currently this only impacts GPU backends
62 kAlwaysDither_Flag = 1 << 2,
63 };
64
65 /** No flags, unknown pixel geometry, platform-default contrast/gamma. */
67 /** TODO(kschmi): Remove this constructor and replace with the one below. **/
69 /** Specified pixel geometry, text contrast, and gamma **/
70 SkSurfaceProps(uint32_t flags, SkPixelGeometry, SkScalar textContrast, SkScalar textGamma);
71
72 SkSurfaceProps(const SkSurfaceProps&) = default;
74
76 return SkSurfaceProps(fFlags, newPixelGeometry, fTextContrast, fTextGamma);
77 }
78
79 static constexpr SkScalar kMaxContrastInclusive = 1;
80 static constexpr SkScalar kMinContrastInclusive = 0;
81 static constexpr SkScalar kMaxGammaExclusive = 4;
82 static constexpr SkScalar kMinGammaInclusive = 0;
83
84 uint32_t flags() const { return fFlags; }
85 SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
86 SkScalar textContrast() const { return fTextContrast; }
87 SkScalar textGamma() const { return fTextGamma; }
88
90 return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag);
91 }
92
93 bool isAlwaysDither() const {
94 return SkToBool(fFlags & kAlwaysDither_Flag);
95 }
96
97 bool operator==(const SkSurfaceProps& that) const {
98 return fFlags == that.fFlags && fPixelGeometry == that.fPixelGeometry &&
99 fTextContrast == that.fTextContrast && fTextGamma == that.fTextGamma;
100 }
101
102 bool operator!=(const SkSurfaceProps& that) const {
103 return !(*this == that);
104 }
105
106private:
107 uint32_t fFlags;
108 SkPixelGeometry fPixelGeometry;
109
110 // This gamma value is specifically about blending of mask coverage.
111 // The surface also has a color space, but that applies to the colors.
112 SkScalar fTextContrast;
113 SkScalar fTextGamma;
114};
115
116#endif
uint16_t fFlags
#define SK_API
Definition SkAPI.h:35
static bool SkPixelGeometryIsH(SkPixelGeometry geo)
SkPixelGeometry
@ kUnknown_SkPixelGeometry
@ kRGB_V_SkPixelGeometry
@ kBGR_H_SkPixelGeometry
@ kRGB_H_SkPixelGeometry
@ kBGR_V_SkPixelGeometry
static bool SkPixelGeometryIsBGR(SkPixelGeometry geo)
static bool SkPixelGeometryIsRGB(SkPixelGeometry geo)
static bool SkPixelGeometryIsV(SkPixelGeometry geo)
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
SkSurfaceProps cloneWithPixelGeometry(SkPixelGeometry newPixelGeometry) const
SkScalar textGamma() const
SkSurfaceProps & operator=(const SkSurfaceProps &)=default
bool isAlwaysDither() const
bool operator==(const SkSurfaceProps &that) const
uint32_t flags() const
bool isUseDeviceIndependentFonts() const
bool operator!=(const SkSurfaceProps &that) const
SkPixelGeometry pixelGeometry() const
SkScalar textContrast() const
SkSurfaceProps(const SkSurfaceProps &)=default
float SkScalar
Definition extension.cpp:12
FlutterSemanticsFlag flags