gfxTypes.h (4810B)
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef GFX_TYPES_H 7 #define GFX_TYPES_H 8 9 #include <stdint.h> 10 #include "mozilla/Attributes.h" 11 #include "mozilla/TypedEnumBits.h" 12 13 namespace mozilla { 14 enum class StyleGenericFontFamily : uint32_t; 15 } 16 17 typedef struct _cairo_surface cairo_surface_t; 18 typedef struct _cairo_user_data_key cairo_user_data_key_t; 19 20 typedef void (*thebes_destroy_func_t)(void* data); 21 22 /** 23 * Currently needs to be 'double' for Cairo compatibility. Could 24 * become 'float', perhaps, in some configurations. 25 */ 26 typedef double gfxFloat; 27 28 /** 29 * Priority of a line break opportunity. 30 * 31 * eNoBreak The line has no break opportunities 32 * eWordWrapBreak The line has a break opportunity only within a word. With 33 * overflow-wrap|word-wrap: break-word we will break at this 34 * point only if there are no other break opportunities in the 35 * line. 36 * eNormalBreak The line has a break opportunity determined by the standard 37 * line-breaking algorithm. 38 * 39 * Future expansion: split eNormalBreak into multiple priorities, e.g. 40 * punctuation break and whitespace break (bug 389710). 41 * As and when we implement it, text-wrap: unrestricted will 42 * mean that priorities are ignored and all line-break 43 * opportunities are equal. 44 * 45 * @see gfxTextRun::BreakAndMeasureText 46 * @see nsLineLayout::NotifyOptionalBreakPosition 47 */ 48 enum class gfxBreakPriority { eNoBreak = 0, eWordWrapBreak, eNormalBreak }; 49 50 enum class gfxSurfaceType { 51 Image, 52 PDF, 53 PS, 54 Xlib, 55 Xcb, 56 Glitz, // unused, but needed for cairo parity 57 Quartz, 58 Win32, 59 BeOS, 60 DirectFB, // unused, but needed for cairo parity 61 SVG, 62 OS2, 63 Win32Printing, 64 QuartzImage, 65 Script, 66 QPainter, 67 Recording, 68 VG, 69 GL, 70 DRM, 71 Tee, 72 XML, 73 Skia, 74 Subsurface, 75 Max 76 }; 77 78 enum class gfxContentType { 79 COLOR = 0x1000, 80 ALPHA = 0x2000, 81 COLOR_ALPHA = 0x3000, 82 SENTINEL = 0xffff 83 }; 84 85 enum class gfxAlphaType { 86 Opaque, 87 Premult, 88 NonPremult, 89 }; 90 91 /** 92 * Type used to record how a particular font is selected during the font- 93 * matching process, so that this can be exposed to the Inspector. 94 */ 95 struct FontMatchType { 96 enum class Kind : uint8_t { 97 kUnspecified = 0, 98 kFontGroup = 1, 99 kPrefsFallback = 1 << 1, 100 kSystemFallback = 1 << 2, 101 }; 102 103 inline FontMatchType& operator|=(const FontMatchType& aOther); 104 105 bool operator==(const FontMatchType& aOther) const { 106 return kind == aOther.kind && generic == aOther.generic; 107 } 108 109 bool operator!=(const FontMatchType& aOther) const { 110 return !(*this == aOther); 111 } 112 113 MOZ_IMPLICIT FontMatchType() = default; 114 MOZ_IMPLICIT FontMatchType(Kind aKind) : kind(aKind) {} 115 FontMatchType(Kind aKind, mozilla::StyleGenericFontFamily aGeneric) 116 : kind(aKind), generic(aGeneric) {} 117 118 Kind kind = static_cast<Kind>(0); 119 // Using 0 to avoid pulling ServoStyleConsts.h everywhere. 120 mozilla::StyleGenericFontFamily generic = mozilla::StyleGenericFontFamily(0); 121 }; 122 123 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(FontMatchType::Kind) 124 125 FontMatchType& FontMatchType::operator|=(const FontMatchType& aOther) { 126 kind |= aOther.kind; 127 // We only keep track of one generic. 128 if (generic != aOther.generic) { 129 generic = mozilla::StyleGenericFontFamily(0); 130 } 131 return *this; 132 } 133 134 // Installation status (base system / langpack / user-installed) may determine 135 // whether the font is visible to CSS font-family or src:local() lookups. 136 // (Exactly what these mean and how accurate they are may be vary across 137 // platforms -- e.g. on Linux there is no clear "base" set of fonts.) 138 enum class FontVisibility : uint8_t { 139 Unknown = 0, // No categorization of families available on this system 140 Base = 1, // Standard part of the base OS installation 141 LangPack = 2, // From an optional OS component such as language support 142 User = 3, // User-installed font (or installed by another app, etc) 143 Hidden = 4, // Internal system font, should never exposed to users 144 Webfont = 5, // Webfont defined by @font-face 145 Count = 6, // Count of values, for IPC serialization 146 }; 147 148 struct HwStretchingSupport { 149 uint32_t mBoth; 150 uint32_t mWindowOnly; 151 uint32_t mFullScreenOnly; 152 uint32_t mNone; 153 uint32_t mError; 154 155 HwStretchingSupport() 156 : mBoth(0), mWindowOnly(0), mFullScreenOnly(0), mNone(0), mError(0) {} 157 158 bool IsFullySupported() const { 159 return mBoth > 0 && mWindowOnly == 0 && mFullScreenOnly == 0 && 160 mNone == 0 && mError == 0; 161 } 162 }; 163 164 #endif /* GFX_TYPES_H */