Skia
2D Graphics Library
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 
11 #include "include/core/SkTypes.h"
12 #include "include/private/base/SkTo.h"
13 
25 };
26 
27 // Returns true iff geo is a known geometry and is RGB.
28 static inline bool SkPixelGeometryIsRGB(SkPixelGeometry geo) {
29  return kRGB_H_SkPixelGeometry == geo || kRGB_V_SkPixelGeometry == geo;
30 }
31 
32 // Returns true iff geo is a known geometry and is BGR.
33 static inline bool SkPixelGeometryIsBGR(SkPixelGeometry geo) {
34  return kBGR_H_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
35 }
36 
37 // Returns true iff geo is a known geometry and is horizontal.
38 static inline bool SkPixelGeometryIsH(SkPixelGeometry geo) {
39  return kRGB_H_SkPixelGeometry == geo || kBGR_H_SkPixelGeometry == geo;
40 }
41 
42 // Returns true iff geo is a known geometry and is vertical.
43 static inline bool SkPixelGeometryIsV(SkPixelGeometry geo) {
44  return kRGB_V_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
45 }
46 
52 class SK_API SkSurfaceProps {
53 public:
54  enum Flags {
55  kUseDeviceIndependentFonts_Flag = 1 << 0,
56  // Use internal MSAA to render to non-MSAA GPU surfaces.
57  kDynamicMSAA_Flag = 1 << 1,
58  // If set, all rendering will have dithering enabled
59  // Currently this only impacts GPU backends
60  kAlwaysDither_Flag = 1 << 2,
61  };
62 
65  SkSurfaceProps(uint32_t flags, SkPixelGeometry);
66 
67  SkSurfaceProps(const SkSurfaceProps&) = default;
69 
71  return SkSurfaceProps(fFlags, newPixelGeometry);
72  }
73 
74  uint32_t flags() const { return fFlags; }
75  SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
76 
78  return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag);
79  }
80 
81  bool isAlwaysDither() const {
82  return SkToBool(fFlags & kAlwaysDither_Flag);
83  }
84 
85  bool operator==(const SkSurfaceProps& that) const {
86  return fFlags == that.fFlags && fPixelGeometry == that.fPixelGeometry;
87  }
88 
89  bool operator!=(const SkSurfaceProps& that) const {
90  return !(*this == that);
91  }
92 
93 private:
94  uint32_t fFlags;
95  SkPixelGeometry fPixelGeometry;
96 };
97 
98 #endif
static bool SkPixelGeometryIsH(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:38
SkPixelGeometry
Description of how the LCD strips are arranged for each pixel.
Definition: SkSurfaceProps.h:19
@ kUnknown_SkPixelGeometry
Definition: SkSurfaceProps.h:20
@ kRGB_V_SkPixelGeometry
Definition: SkSurfaceProps.h:23
@ kBGR_H_SkPixelGeometry
Definition: SkSurfaceProps.h:22
@ kRGB_H_SkPixelGeometry
Definition: SkSurfaceProps.h:21
@ kBGR_V_SkPixelGeometry
Definition: SkSurfaceProps.h:24
static bool SkPixelGeometryIsBGR(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:33
static bool SkPixelGeometryIsRGB(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:28
static bool SkPixelGeometryIsV(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:43
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:52
SkSurfaceProps cloneWithPixelGeometry(SkPixelGeometry newPixelGeometry) const
Definition: SkSurfaceProps.h:70
Flags
Definition: SkSurfaceProps.h:54
bool isAlwaysDither() const
Definition: SkSurfaceProps.h:81
bool operator==(const SkSurfaceProps &that) const
Definition: SkSurfaceProps.h:85
uint32_t flags() const
Definition: SkSurfaceProps.h:74
bool isUseDeviceIndependentFonts() const
Definition: SkSurfaceProps.h:77
SkSurfaceProps()
No flags, unknown pixel geometry.
SkSurfaceProps(uint32_t flags, SkPixelGeometry)
bool operator!=(const SkSurfaceProps &that) const
Definition: SkSurfaceProps.h:89
SkPixelGeometry pixelGeometry() const
Definition: SkSurfaceProps.h:75
SkSurfaceProps & operator=(const SkSurfaceProps &)=default
SkSurfaceProps(const SkSurfaceProps &)=default