michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_GFX_TYPES_H_ michael@0: #define MOZILLA_GFX_TYPES_H_ michael@0: michael@0: #include "mozilla/NullPtr.h" michael@0: #include "mozilla/TypedEnum.h" michael@0: michael@0: #include michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: typedef float Float; michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(SurfaceType, int8_t) michael@0: DATA, /* Data surface - bitmap in memory */ michael@0: D2D1_BITMAP, /* Surface wrapping a ID2D1Bitmap */ michael@0: D2D1_DRAWTARGET, /* Surface made from a D2D draw target */ michael@0: CAIRO, /* Surface wrapping a cairo surface */ michael@0: CAIRO_IMAGE, /* Data surface wrapping a cairo image surface */ michael@0: COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */ michael@0: COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */ michael@0: SKIA, /* Surface wrapping a Skia bitmap */ michael@0: DUAL_DT, /* Snapshot of a dual drawtarget */ michael@0: D2D1_1_IMAGE, /* A D2D 1.1 ID2D1Image SourceSurface */ michael@0: RECORDING /* Surface used for recording */ michael@0: MOZ_END_ENUM_CLASS(SurfaceType) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(SurfaceFormat, int8_t) michael@0: B8G8R8A8, michael@0: B8G8R8X8, michael@0: R8G8B8A8, michael@0: R8G8B8X8, michael@0: R5G6B5, michael@0: A8, michael@0: YUV, michael@0: UNKNOWN michael@0: MOZ_END_ENUM_CLASS(SurfaceFormat) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(FilterType, int8_t) michael@0: BLEND = 0, michael@0: TRANSFORM, michael@0: MORPHOLOGY, michael@0: COLOR_MATRIX, michael@0: FLOOD, michael@0: TILE, michael@0: TABLE_TRANSFER, michael@0: DISCRETE_TRANSFER, michael@0: LINEAR_TRANSFER, michael@0: GAMMA_TRANSFER, michael@0: CONVOLVE_MATRIX, michael@0: DISPLACEMENT_MAP, michael@0: TURBULENCE, michael@0: ARITHMETIC_COMBINE, michael@0: COMPOSITE, michael@0: DIRECTIONAL_BLUR, michael@0: GAUSSIAN_BLUR, michael@0: POINT_DIFFUSE, michael@0: POINT_SPECULAR, michael@0: SPOT_DIFFUSE, michael@0: SPOT_SPECULAR, michael@0: DISTANT_DIFFUSE, michael@0: DISTANT_SPECULAR, michael@0: CROP, michael@0: PREMULTIPLY, michael@0: UNPREMULTIPLY michael@0: MOZ_END_ENUM_CLASS(FilterType) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(BackendType, int8_t) michael@0: NONE = 0, michael@0: DIRECT2D, michael@0: COREGRAPHICS, michael@0: COREGRAPHICS_ACCELERATED, michael@0: CAIRO, michael@0: SKIA, michael@0: RECORDING, michael@0: DIRECT2D1_1 michael@0: MOZ_END_ENUM_CLASS(BackendType) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(FontType, int8_t) michael@0: DWRITE, michael@0: GDI, michael@0: MAC, michael@0: SKIA, michael@0: CAIRO, michael@0: COREGRAPHICS michael@0: MOZ_END_ENUM_CLASS(FontType) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(NativeSurfaceType, int8_t) michael@0: D3D10_TEXTURE, michael@0: CAIRO_SURFACE, michael@0: CAIRO_CONTEXT, michael@0: CGCONTEXT, michael@0: CGCONTEXT_ACCELERATED, michael@0: OPENGL_TEXTURE michael@0: MOZ_END_ENUM_CLASS(NativeSurfaceType) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(NativeFontType, int8_t) michael@0: DWRITE_FONT_FACE, michael@0: GDI_FONT_FACE, michael@0: MAC_FONT_FACE, michael@0: SKIA_FONT_FACE, michael@0: CAIRO_FONT_FACE michael@0: MOZ_END_ENUM_CLASS(NativeFontType) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(FontStyle, int8_t) michael@0: NORMAL, michael@0: ITALIC, michael@0: BOLD, michael@0: BOLD_ITALIC michael@0: MOZ_END_ENUM_CLASS(FontStyle) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(FontHinting, int8_t) michael@0: NONE, michael@0: LIGHT, michael@0: NORMAL, michael@0: FULL michael@0: MOZ_END_ENUM_CLASS(FontHinting) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(CompositionOp, int8_t) michael@0: OP_OVER, michael@0: OP_ADD, michael@0: OP_ATOP, michael@0: OP_OUT, michael@0: OP_IN, michael@0: OP_SOURCE, michael@0: OP_DEST_IN, michael@0: OP_DEST_OUT, michael@0: OP_DEST_OVER, michael@0: OP_DEST_ATOP, michael@0: OP_XOR, michael@0: OP_MULTIPLY, michael@0: OP_SCREEN, michael@0: OP_OVERLAY, michael@0: OP_DARKEN, michael@0: OP_LIGHTEN, michael@0: OP_COLOR_DODGE, michael@0: OP_COLOR_BURN, michael@0: OP_HARD_LIGHT, michael@0: OP_SOFT_LIGHT, michael@0: OP_DIFFERENCE, michael@0: OP_EXCLUSION, michael@0: OP_HUE, michael@0: OP_SATURATION, michael@0: OP_COLOR, michael@0: OP_LUMINOSITY, michael@0: OP_COUNT michael@0: MOZ_END_ENUM_CLASS(CompositionOp) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(ExtendMode, int8_t) michael@0: CLAMP, michael@0: REPEAT, michael@0: REFLECT michael@0: MOZ_END_ENUM_CLASS(ExtendMode) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(FillRule, int8_t) michael@0: FILL_WINDING, michael@0: FILL_EVEN_ODD michael@0: MOZ_END_ENUM_CLASS(FillRule) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(AntialiasMode, int8_t) michael@0: NONE, michael@0: GRAY, michael@0: SUBPIXEL, michael@0: DEFAULT michael@0: MOZ_END_ENUM_CLASS(AntialiasMode) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(Filter, int8_t) michael@0: GOOD, michael@0: LINEAR, michael@0: POINT michael@0: MOZ_END_ENUM_CLASS(Filter) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(PatternType, int8_t) michael@0: COLOR, michael@0: SURFACE, michael@0: LINEAR_GRADIENT, michael@0: RADIAL_GRADIENT michael@0: MOZ_END_ENUM_CLASS(PatternType) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(JoinStyle, int8_t) michael@0: BEVEL, michael@0: ROUND, michael@0: MITER, michael@0: MITER_OR_BEVEL michael@0: MOZ_END_ENUM_CLASS(JoinStyle) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(CapStyle, int8_t) michael@0: BUTT, michael@0: ROUND, michael@0: SQUARE michael@0: MOZ_END_ENUM_CLASS(CapStyle) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(SamplingBounds, int8_t) michael@0: UNBOUNDED, michael@0: BOUNDED michael@0: MOZ_END_ENUM_CLASS(SamplingBounds) michael@0: michael@0: /* Color is stored in non-premultiplied form */ michael@0: struct Color michael@0: { michael@0: public: michael@0: Color() michael@0: : r(0.0f), g(0.0f), b(0.0f), a(0.0f) michael@0: {} michael@0: Color(Float aR, Float aG, Float aB, Float aA) michael@0: : r(aR), g(aG), b(aB), a(aA) michael@0: {} michael@0: Color(Float aR, Float aG, Float aB) michael@0: : r(aR), g(aG), b(aB), a(1.0f) michael@0: {} michael@0: michael@0: static Color FromABGR(uint32_t aColor) michael@0: { michael@0: Color newColor(((aColor >> 0) & 0xff) * (1.0f / 255.0f), michael@0: ((aColor >> 8) & 0xff) * (1.0f / 255.0f), michael@0: ((aColor >> 16) & 0xff) * (1.0f / 255.0f), michael@0: ((aColor >> 24) & 0xff) * (1.0f / 255.0f)); michael@0: michael@0: return newColor; michael@0: } michael@0: michael@0: uint32_t ToABGR() const michael@0: { michael@0: return uint32_t(r * 255.0f) | uint32_t(g * 255.0f) << 8 | michael@0: uint32_t(b * 255.0f) << 16 | uint32_t(a * 255.0f) << 24; michael@0: } michael@0: michael@0: Float r, g, b, a; michael@0: }; michael@0: michael@0: struct GradientStop michael@0: { michael@0: bool operator<(const GradientStop& aOther) const { michael@0: return offset < aOther.offset; michael@0: } michael@0: michael@0: Float offset; michael@0: Color color; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #if defined(XP_WIN) && defined(MOZ_GFX) michael@0: #ifdef GFX2D_INTERNAL michael@0: #define GFX2D_API __declspec(dllexport) michael@0: #else michael@0: #define GFX2D_API __declspec(dllimport) michael@0: #endif michael@0: #else michael@0: #define GFX2D_API michael@0: #endif michael@0: michael@0: // Side constants for use in various places michael@0: namespace mozilla { michael@0: namespace css { michael@0: enum Side {eSideTop, eSideRight, eSideBottom, eSideLeft}; michael@0: } michael@0: } michael@0: michael@0: // XXX - These don't really belong here. But for now this is where they go. michael@0: #define NS_SIDE_TOP mozilla::css::eSideTop michael@0: #define NS_SIDE_RIGHT mozilla::css::eSideRight michael@0: #define NS_SIDE_BOTTOM mozilla::css::eSideBottom michael@0: #define NS_SIDE_LEFT mozilla::css::eSideLeft michael@0: michael@0: #endif /* MOZILLA_GFX_TYPES_H_ */