gfx/2d/Types.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef MOZILLA_GFX_TYPES_H_
michael@0 7 #define MOZILLA_GFX_TYPES_H_
michael@0 8
michael@0 9 #include "mozilla/NullPtr.h"
michael@0 10 #include "mozilla/TypedEnum.h"
michael@0 11
michael@0 12 #include <stddef.h>
michael@0 13 #include <stdint.h>
michael@0 14
michael@0 15 namespace mozilla {
michael@0 16 namespace gfx {
michael@0 17
michael@0 18 typedef float Float;
michael@0 19
michael@0 20 MOZ_BEGIN_ENUM_CLASS(SurfaceType, int8_t)
michael@0 21 DATA, /* Data surface - bitmap in memory */
michael@0 22 D2D1_BITMAP, /* Surface wrapping a ID2D1Bitmap */
michael@0 23 D2D1_DRAWTARGET, /* Surface made from a D2D draw target */
michael@0 24 CAIRO, /* Surface wrapping a cairo surface */
michael@0 25 CAIRO_IMAGE, /* Data surface wrapping a cairo image surface */
michael@0 26 COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */
michael@0 27 COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */
michael@0 28 SKIA, /* Surface wrapping a Skia bitmap */
michael@0 29 DUAL_DT, /* Snapshot of a dual drawtarget */
michael@0 30 D2D1_1_IMAGE, /* A D2D 1.1 ID2D1Image SourceSurface */
michael@0 31 RECORDING /* Surface used for recording */
michael@0 32 MOZ_END_ENUM_CLASS(SurfaceType)
michael@0 33
michael@0 34 MOZ_BEGIN_ENUM_CLASS(SurfaceFormat, int8_t)
michael@0 35 B8G8R8A8,
michael@0 36 B8G8R8X8,
michael@0 37 R8G8B8A8,
michael@0 38 R8G8B8X8,
michael@0 39 R5G6B5,
michael@0 40 A8,
michael@0 41 YUV,
michael@0 42 UNKNOWN
michael@0 43 MOZ_END_ENUM_CLASS(SurfaceFormat)
michael@0 44
michael@0 45 MOZ_BEGIN_ENUM_CLASS(FilterType, int8_t)
michael@0 46 BLEND = 0,
michael@0 47 TRANSFORM,
michael@0 48 MORPHOLOGY,
michael@0 49 COLOR_MATRIX,
michael@0 50 FLOOD,
michael@0 51 TILE,
michael@0 52 TABLE_TRANSFER,
michael@0 53 DISCRETE_TRANSFER,
michael@0 54 LINEAR_TRANSFER,
michael@0 55 GAMMA_TRANSFER,
michael@0 56 CONVOLVE_MATRIX,
michael@0 57 DISPLACEMENT_MAP,
michael@0 58 TURBULENCE,
michael@0 59 ARITHMETIC_COMBINE,
michael@0 60 COMPOSITE,
michael@0 61 DIRECTIONAL_BLUR,
michael@0 62 GAUSSIAN_BLUR,
michael@0 63 POINT_DIFFUSE,
michael@0 64 POINT_SPECULAR,
michael@0 65 SPOT_DIFFUSE,
michael@0 66 SPOT_SPECULAR,
michael@0 67 DISTANT_DIFFUSE,
michael@0 68 DISTANT_SPECULAR,
michael@0 69 CROP,
michael@0 70 PREMULTIPLY,
michael@0 71 UNPREMULTIPLY
michael@0 72 MOZ_END_ENUM_CLASS(FilterType)
michael@0 73
michael@0 74 MOZ_BEGIN_ENUM_CLASS(BackendType, int8_t)
michael@0 75 NONE = 0,
michael@0 76 DIRECT2D,
michael@0 77 COREGRAPHICS,
michael@0 78 COREGRAPHICS_ACCELERATED,
michael@0 79 CAIRO,
michael@0 80 SKIA,
michael@0 81 RECORDING,
michael@0 82 DIRECT2D1_1
michael@0 83 MOZ_END_ENUM_CLASS(BackendType)
michael@0 84
michael@0 85 MOZ_BEGIN_ENUM_CLASS(FontType, int8_t)
michael@0 86 DWRITE,
michael@0 87 GDI,
michael@0 88 MAC,
michael@0 89 SKIA,
michael@0 90 CAIRO,
michael@0 91 COREGRAPHICS
michael@0 92 MOZ_END_ENUM_CLASS(FontType)
michael@0 93
michael@0 94 MOZ_BEGIN_ENUM_CLASS(NativeSurfaceType, int8_t)
michael@0 95 D3D10_TEXTURE,
michael@0 96 CAIRO_SURFACE,
michael@0 97 CAIRO_CONTEXT,
michael@0 98 CGCONTEXT,
michael@0 99 CGCONTEXT_ACCELERATED,
michael@0 100 OPENGL_TEXTURE
michael@0 101 MOZ_END_ENUM_CLASS(NativeSurfaceType)
michael@0 102
michael@0 103 MOZ_BEGIN_ENUM_CLASS(NativeFontType, int8_t)
michael@0 104 DWRITE_FONT_FACE,
michael@0 105 GDI_FONT_FACE,
michael@0 106 MAC_FONT_FACE,
michael@0 107 SKIA_FONT_FACE,
michael@0 108 CAIRO_FONT_FACE
michael@0 109 MOZ_END_ENUM_CLASS(NativeFontType)
michael@0 110
michael@0 111 MOZ_BEGIN_ENUM_CLASS(FontStyle, int8_t)
michael@0 112 NORMAL,
michael@0 113 ITALIC,
michael@0 114 BOLD,
michael@0 115 BOLD_ITALIC
michael@0 116 MOZ_END_ENUM_CLASS(FontStyle)
michael@0 117
michael@0 118 MOZ_BEGIN_ENUM_CLASS(FontHinting, int8_t)
michael@0 119 NONE,
michael@0 120 LIGHT,
michael@0 121 NORMAL,
michael@0 122 FULL
michael@0 123 MOZ_END_ENUM_CLASS(FontHinting)
michael@0 124
michael@0 125 MOZ_BEGIN_ENUM_CLASS(CompositionOp, int8_t)
michael@0 126 OP_OVER,
michael@0 127 OP_ADD,
michael@0 128 OP_ATOP,
michael@0 129 OP_OUT,
michael@0 130 OP_IN,
michael@0 131 OP_SOURCE,
michael@0 132 OP_DEST_IN,
michael@0 133 OP_DEST_OUT,
michael@0 134 OP_DEST_OVER,
michael@0 135 OP_DEST_ATOP,
michael@0 136 OP_XOR,
michael@0 137 OP_MULTIPLY,
michael@0 138 OP_SCREEN,
michael@0 139 OP_OVERLAY,
michael@0 140 OP_DARKEN,
michael@0 141 OP_LIGHTEN,
michael@0 142 OP_COLOR_DODGE,
michael@0 143 OP_COLOR_BURN,
michael@0 144 OP_HARD_LIGHT,
michael@0 145 OP_SOFT_LIGHT,
michael@0 146 OP_DIFFERENCE,
michael@0 147 OP_EXCLUSION,
michael@0 148 OP_HUE,
michael@0 149 OP_SATURATION,
michael@0 150 OP_COLOR,
michael@0 151 OP_LUMINOSITY,
michael@0 152 OP_COUNT
michael@0 153 MOZ_END_ENUM_CLASS(CompositionOp)
michael@0 154
michael@0 155 MOZ_BEGIN_ENUM_CLASS(ExtendMode, int8_t)
michael@0 156 CLAMP,
michael@0 157 REPEAT,
michael@0 158 REFLECT
michael@0 159 MOZ_END_ENUM_CLASS(ExtendMode)
michael@0 160
michael@0 161 MOZ_BEGIN_ENUM_CLASS(FillRule, int8_t)
michael@0 162 FILL_WINDING,
michael@0 163 FILL_EVEN_ODD
michael@0 164 MOZ_END_ENUM_CLASS(FillRule)
michael@0 165
michael@0 166 MOZ_BEGIN_ENUM_CLASS(AntialiasMode, int8_t)
michael@0 167 NONE,
michael@0 168 GRAY,
michael@0 169 SUBPIXEL,
michael@0 170 DEFAULT
michael@0 171 MOZ_END_ENUM_CLASS(AntialiasMode)
michael@0 172
michael@0 173 MOZ_BEGIN_ENUM_CLASS(Filter, int8_t)
michael@0 174 GOOD,
michael@0 175 LINEAR,
michael@0 176 POINT
michael@0 177 MOZ_END_ENUM_CLASS(Filter)
michael@0 178
michael@0 179 MOZ_BEGIN_ENUM_CLASS(PatternType, int8_t)
michael@0 180 COLOR,
michael@0 181 SURFACE,
michael@0 182 LINEAR_GRADIENT,
michael@0 183 RADIAL_GRADIENT
michael@0 184 MOZ_END_ENUM_CLASS(PatternType)
michael@0 185
michael@0 186 MOZ_BEGIN_ENUM_CLASS(JoinStyle, int8_t)
michael@0 187 BEVEL,
michael@0 188 ROUND,
michael@0 189 MITER,
michael@0 190 MITER_OR_BEVEL
michael@0 191 MOZ_END_ENUM_CLASS(JoinStyle)
michael@0 192
michael@0 193 MOZ_BEGIN_ENUM_CLASS(CapStyle, int8_t)
michael@0 194 BUTT,
michael@0 195 ROUND,
michael@0 196 SQUARE
michael@0 197 MOZ_END_ENUM_CLASS(CapStyle)
michael@0 198
michael@0 199 MOZ_BEGIN_ENUM_CLASS(SamplingBounds, int8_t)
michael@0 200 UNBOUNDED,
michael@0 201 BOUNDED
michael@0 202 MOZ_END_ENUM_CLASS(SamplingBounds)
michael@0 203
michael@0 204 /* Color is stored in non-premultiplied form */
michael@0 205 struct Color
michael@0 206 {
michael@0 207 public:
michael@0 208 Color()
michael@0 209 : r(0.0f), g(0.0f), b(0.0f), a(0.0f)
michael@0 210 {}
michael@0 211 Color(Float aR, Float aG, Float aB, Float aA)
michael@0 212 : r(aR), g(aG), b(aB), a(aA)
michael@0 213 {}
michael@0 214 Color(Float aR, Float aG, Float aB)
michael@0 215 : r(aR), g(aG), b(aB), a(1.0f)
michael@0 216 {}
michael@0 217
michael@0 218 static Color FromABGR(uint32_t aColor)
michael@0 219 {
michael@0 220 Color newColor(((aColor >> 0) & 0xff) * (1.0f / 255.0f),
michael@0 221 ((aColor >> 8) & 0xff) * (1.0f / 255.0f),
michael@0 222 ((aColor >> 16) & 0xff) * (1.0f / 255.0f),
michael@0 223 ((aColor >> 24) & 0xff) * (1.0f / 255.0f));
michael@0 224
michael@0 225 return newColor;
michael@0 226 }
michael@0 227
michael@0 228 uint32_t ToABGR() const
michael@0 229 {
michael@0 230 return uint32_t(r * 255.0f) | uint32_t(g * 255.0f) << 8 |
michael@0 231 uint32_t(b * 255.0f) << 16 | uint32_t(a * 255.0f) << 24;
michael@0 232 }
michael@0 233
michael@0 234 Float r, g, b, a;
michael@0 235 };
michael@0 236
michael@0 237 struct GradientStop
michael@0 238 {
michael@0 239 bool operator<(const GradientStop& aOther) const {
michael@0 240 return offset < aOther.offset;
michael@0 241 }
michael@0 242
michael@0 243 Float offset;
michael@0 244 Color color;
michael@0 245 };
michael@0 246
michael@0 247 }
michael@0 248 }
michael@0 249
michael@0 250 #if defined(XP_WIN) && defined(MOZ_GFX)
michael@0 251 #ifdef GFX2D_INTERNAL
michael@0 252 #define GFX2D_API __declspec(dllexport)
michael@0 253 #else
michael@0 254 #define GFX2D_API __declspec(dllimport)
michael@0 255 #endif
michael@0 256 #else
michael@0 257 #define GFX2D_API
michael@0 258 #endif
michael@0 259
michael@0 260 // Side constants for use in various places
michael@0 261 namespace mozilla {
michael@0 262 namespace css {
michael@0 263 enum Side {eSideTop, eSideRight, eSideBottom, eSideLeft};
michael@0 264 }
michael@0 265 }
michael@0 266
michael@0 267 // XXX - These don't really belong here. But for now this is where they go.
michael@0 268 #define NS_SIDE_TOP mozilla::css::eSideTop
michael@0 269 #define NS_SIDE_RIGHT mozilla::css::eSideRight
michael@0 270 #define NS_SIDE_BOTTOM mozilla::css::eSideBottom
michael@0 271 #define NS_SIDE_LEFT mozilla::css::eSideLeft
michael@0 272
michael@0 273 #endif /* MOZILLA_GFX_TYPES_H_ */

mercurial