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 
24 };
25 
26 // Returns true iff geo is a known geometry and is RGB.
27 static inline bool SkPixelGeometryIsRGB(SkPixelGeometry geo) {
28  return kRGB_H_SkPixelGeometry == geo || kRGB_V_SkPixelGeometry == geo;
29 }
30 
31 // Returns true iff geo is a known geometry and is BGR.
32 static inline bool SkPixelGeometryIsBGR(SkPixelGeometry geo) {
33  return kBGR_H_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
34 }
35 
36 // Returns true iff geo is a known geometry and is horizontal.
37 static inline bool SkPixelGeometryIsH(SkPixelGeometry geo) {
38  return kRGB_H_SkPixelGeometry == geo || kBGR_H_SkPixelGeometry == geo;
39 }
40 
41 // Returns true iff geo is a known geometry and is vertical.
42 static inline bool SkPixelGeometryIsV(SkPixelGeometry geo) {
43  return kRGB_V_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
44 }
45 
52 public:
53  enum Flags {
54  kUseDeviceIndependentFonts_Flag = 1 << 0,
55  };
57  static const Flags kUseDistanceFieldFonts_Flag = kUseDeviceIndependentFonts_Flag;
58 
61  SkSurfaceProps(uint32_t flags, SkPixelGeometry);
62 
65 
66  uint32_t flags() const { return fFlags; }
67  SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
68 
70  return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag);
71  }
72 
73  bool operator==(const SkSurfaceProps& that) const {
74  return fFlags == that.fFlags && fPixelGeometry == that.fPixelGeometry;
75  }
76 
77  bool operator!=(const SkSurfaceProps& that) const {
78  return !(*this == that);
79  }
80 
81 private:
82  uint32_t fFlags;
83  SkPixelGeometry fPixelGeometry;
84 };
85 
86 #endif
SkSurfaceProps::SkSurfaceProps
SkSurfaceProps()
No flags, unknown pixel geometry.
kBGR_H_SkPixelGeometry
@ kBGR_H_SkPixelGeometry
Definition: SkSurfaceProps.h:21
SkTypes.h
SkSurfaceProps::operator!=
bool operator!=(const SkSurfaceProps &that) const
Definition: SkSurfaceProps.h:77
kBGR_V_SkPixelGeometry
@ kBGR_V_SkPixelGeometry
Definition: SkSurfaceProps.h:23
SkPixelGeometryIsRGB
static bool SkPixelGeometryIsRGB(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:27
kRGB_H_SkPixelGeometry
@ kRGB_H_SkPixelGeometry
Definition: SkSurfaceProps.h:20
kUnknown_SkPixelGeometry
@ kUnknown_SkPixelGeometry
Definition: SkSurfaceProps.h:19
kRGB_V_SkPixelGeometry
@ kRGB_V_SkPixelGeometry
Definition: SkSurfaceProps.h:22
SkSurfaceProps::flags
uint32_t flags() const
Definition: SkSurfaceProps.h:66
SkSurfaceProps::isUseDeviceIndependentFonts
bool isUseDeviceIndependentFonts() const
Definition: SkSurfaceProps.h:69
SkSurfaceProps::pixelGeometry
SkPixelGeometry pixelGeometry() const
Definition: SkSurfaceProps.h:67
SkPixelGeometryIsH
static bool SkPixelGeometryIsH(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:37
SkToBool
static constexpr bool SkToBool(const T &x)
Definition: SkTypes.h:497
SK_API
#define SK_API
Definition: SkTypes.h:181
SkSurfaceProps::SkSurfaceProps
SkSurfaceProps(const SkSurfaceProps &)
SkSurfaceProps
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:51
SkSurfaceProps::SkSurfaceProps
SkSurfaceProps(uint32_t flags, SkPixelGeometry)
SkSurfaceProps::operator=
SkSurfaceProps & operator=(const SkSurfaceProps &)
SkPixelGeometry
SkPixelGeometry
Description of how the LCD strips are arranged for each pixel.
Definition: SkSurfaceProps.h:18
SkPixelGeometryIsV
static bool SkPixelGeometryIsV(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:42
SkPixelGeometryIsBGR
static bool SkPixelGeometryIsBGR(SkPixelGeometry geo)
Definition: SkSurfaceProps.h:32
SkSurfaceProps::operator==
bool operator==(const SkSurfaceProps &that) const
Definition: SkSurfaceProps.h:73
SkSurfaceProps::Flags
Flags
Definition: SkSurfaceProps.h:53