2011-06-24 21:41:16 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-06-24 21:41:16 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_TYPES_H_
|
|
|
|
#define MOZILLA_GFX_TYPES_H_
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2013-07-30 18:25:31 +04:00
|
|
|
#include <stdint.h>
|
2011-06-24 21:41:16 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
typedef float Float;
|
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class SurfaceType : int8_t {
|
2014-01-10 22:55:24 +04:00
|
|
|
DATA, /* Data surface - bitmap in memory */
|
|
|
|
D2D1_BITMAP, /* Surface wrapping a ID2D1Bitmap */
|
|
|
|
D2D1_DRAWTARGET, /* Surface made from a D2D draw target */
|
|
|
|
CAIRO, /* Surface wrapping a cairo surface */
|
|
|
|
CAIRO_IMAGE, /* Data surface wrapping a cairo image surface */
|
|
|
|
COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */
|
|
|
|
COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */
|
|
|
|
SKIA, /* Surface wrapping a Skia bitmap */
|
|
|
|
DUAL_DT, /* Snapshot of a dual drawtarget */
|
|
|
|
D2D1_1_IMAGE, /* A D2D 1.1 ID2D1Image SourceSurface */
|
2014-06-11 23:53:02 +04:00
|
|
|
RECORDING, /* Surface used for recording */
|
|
|
|
TILED /* Surface from a tiled DrawTarget */
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class SurfaceFormat : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
B8G8R8A8,
|
|
|
|
B8G8R8X8,
|
|
|
|
R8G8B8A8,
|
|
|
|
R8G8B8X8,
|
|
|
|
R5G6B5,
|
|
|
|
A8,
|
|
|
|
YUV,
|
|
|
|
UNKNOWN
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2014-10-30 05:31:54 +03:00
|
|
|
inline bool IsOpaque(SurfaceFormat aFormat)
|
|
|
|
{
|
|
|
|
switch (aFormat) {
|
|
|
|
case SurfaceFormat::B8G8R8X8:
|
|
|
|
case SurfaceFormat::R8G8B8X8:
|
|
|
|
case SurfaceFormat::R5G6B5:
|
|
|
|
case SurfaceFormat::YUV:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class FilterType : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
BLEND = 0,
|
|
|
|
TRANSFORM,
|
|
|
|
MORPHOLOGY,
|
|
|
|
COLOR_MATRIX,
|
|
|
|
FLOOD,
|
|
|
|
TILE,
|
|
|
|
TABLE_TRANSFER,
|
|
|
|
DISCRETE_TRANSFER,
|
|
|
|
LINEAR_TRANSFER,
|
|
|
|
GAMMA_TRANSFER,
|
|
|
|
CONVOLVE_MATRIX,
|
|
|
|
DISPLACEMENT_MAP,
|
|
|
|
TURBULENCE,
|
|
|
|
ARITHMETIC_COMBINE,
|
|
|
|
COMPOSITE,
|
|
|
|
DIRECTIONAL_BLUR,
|
|
|
|
GAUSSIAN_BLUR,
|
|
|
|
POINT_DIFFUSE,
|
|
|
|
POINT_SPECULAR,
|
|
|
|
SPOT_DIFFUSE,
|
|
|
|
SPOT_SPECULAR,
|
|
|
|
DISTANT_DIFFUSE,
|
|
|
|
DISTANT_SPECULAR,
|
|
|
|
CROP,
|
|
|
|
PREMULTIPLY,
|
|
|
|
UNPREMULTIPLY
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2013-11-27 15:22:07 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class DrawTargetType : int8_t {
|
2014-06-27 13:17:49 +04:00
|
|
|
SOFTWARE_RASTER = 0,
|
|
|
|
HARDWARE_RASTER,
|
|
|
|
VECTOR
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-06-27 13:17:49 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class BackendType : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
NONE = 0,
|
|
|
|
DIRECT2D,
|
|
|
|
COREGRAPHICS,
|
|
|
|
COREGRAPHICS_ACCELERATED,
|
|
|
|
CAIRO,
|
|
|
|
SKIA,
|
|
|
|
RECORDING,
|
|
|
|
DIRECT2D1_1
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class FontType : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
DWRITE,
|
|
|
|
GDI,
|
|
|
|
MAC,
|
|
|
|
SKIA,
|
|
|
|
CAIRO,
|
|
|
|
COREGRAPHICS
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class NativeSurfaceType : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
D3D10_TEXTURE,
|
|
|
|
CAIRO_SURFACE,
|
|
|
|
CAIRO_CONTEXT,
|
|
|
|
CGCONTEXT,
|
2014-03-06 01:49:37 +04:00
|
|
|
CGCONTEXT_ACCELERATED,
|
|
|
|
OPENGL_TEXTURE
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class NativeFontType : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
DWRITE_FONT_FACE,
|
|
|
|
GDI_FONT_FACE,
|
|
|
|
MAC_FONT_FACE,
|
|
|
|
SKIA_FONT_FACE,
|
|
|
|
CAIRO_FONT_FACE
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class FontStyle : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
NORMAL,
|
|
|
|
ITALIC,
|
|
|
|
BOLD,
|
|
|
|
BOLD_ITALIC
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2012-05-17 02:30:10 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class FontHinting : int8_t {
|
2014-01-10 23:06:16 +04:00
|
|
|
NONE,
|
|
|
|
LIGHT,
|
|
|
|
NORMAL,
|
|
|
|
FULL
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2013-06-05 21:48:59 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class CompositionOp : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
OP_OVER,
|
|
|
|
OP_ADD,
|
|
|
|
OP_ATOP,
|
|
|
|
OP_OUT,
|
|
|
|
OP_IN,
|
|
|
|
OP_SOURCE,
|
|
|
|
OP_DEST_IN,
|
|
|
|
OP_DEST_OUT,
|
|
|
|
OP_DEST_OVER,
|
|
|
|
OP_DEST_ATOP,
|
|
|
|
OP_XOR,
|
|
|
|
OP_MULTIPLY,
|
|
|
|
OP_SCREEN,
|
|
|
|
OP_OVERLAY,
|
|
|
|
OP_DARKEN,
|
|
|
|
OP_LIGHTEN,
|
|
|
|
OP_COLOR_DODGE,
|
|
|
|
OP_COLOR_BURN,
|
|
|
|
OP_HARD_LIGHT,
|
|
|
|
OP_SOFT_LIGHT,
|
|
|
|
OP_DIFFERENCE,
|
|
|
|
OP_EXCLUSION,
|
|
|
|
OP_HUE,
|
|
|
|
OP_SATURATION,
|
|
|
|
OP_COLOR,
|
|
|
|
OP_LUMINOSITY,
|
|
|
|
OP_COUNT
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class ExtendMode : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
CLAMP,
|
|
|
|
REPEAT,
|
|
|
|
REFLECT
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class FillRule : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
FILL_WINDING,
|
|
|
|
FILL_EVEN_ODD
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class AntialiasMode : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
NONE,
|
|
|
|
GRAY,
|
|
|
|
SUBPIXEL,
|
|
|
|
DEFAULT
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class Filter : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
GOOD,
|
|
|
|
LINEAR,
|
|
|
|
POINT
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class PatternType : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
COLOR,
|
|
|
|
SURFACE,
|
|
|
|
LINEAR_GRADIENT,
|
|
|
|
RADIAL_GRADIENT
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class JoinStyle : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
BEVEL,
|
|
|
|
ROUND,
|
2014-12-16 18:40:59 +03:00
|
|
|
MITER, //!< Mitered if within the miter limit, else, if the backed supports
|
|
|
|
//!< it (D2D), the miter is clamped. If the backend does not support
|
|
|
|
//!< miter clamping the behavior is as for MITER_OR_BEVEL.
|
|
|
|
MITER_OR_BEVEL //!< Mitered if within the miter limit, else beveled.
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class CapStyle : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
BUTT,
|
|
|
|
ROUND,
|
|
|
|
SQUARE
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-01-10 23:06:17 +04:00
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class SamplingBounds : int8_t {
|
2014-01-10 23:06:17 +04:00
|
|
|
UNBOUNDED,
|
|
|
|
BOUNDED
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2011-09-24 19:51:29 +04:00
|
|
|
/* Color is stored in non-premultiplied form */
|
2011-06-24 21:41:16 +04:00
|
|
|
struct Color
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Color()
|
|
|
|
: r(0.0f), g(0.0f), b(0.0f), a(0.0f)
|
|
|
|
{}
|
|
|
|
Color(Float aR, Float aG, Float aB, Float aA)
|
|
|
|
: r(aR), g(aG), b(aB), a(aA)
|
|
|
|
{}
|
|
|
|
Color(Float aR, Float aG, Float aB)
|
|
|
|
: r(aR), g(aG), b(aB), a(1.0f)
|
|
|
|
{}
|
|
|
|
|
|
|
|
static Color FromABGR(uint32_t aColor)
|
|
|
|
{
|
|
|
|
Color newColor(((aColor >> 0) & 0xff) * (1.0f / 255.0f),
|
|
|
|
((aColor >> 8) & 0xff) * (1.0f / 255.0f),
|
|
|
|
((aColor >> 16) & 0xff) * (1.0f / 255.0f),
|
|
|
|
((aColor >> 24) & 0xff) * (1.0f / 255.0f));
|
|
|
|
|
|
|
|
return newColor;
|
|
|
|
}
|
|
|
|
|
2014-10-17 15:53:15 +04:00
|
|
|
static Color FromARGB(uint32_t aColor)
|
|
|
|
{
|
|
|
|
Color newColor(((aColor >> 16) & 0xff) * (1.0f / 255.0f),
|
|
|
|
((aColor >> 8) & 0xff) * (1.0f / 255.0f),
|
|
|
|
((aColor >> 0) & 0xff) * (1.0f / 255.0f),
|
|
|
|
((aColor >> 24) & 0xff) * (1.0f / 255.0f));
|
|
|
|
|
|
|
|
return newColor;
|
|
|
|
}
|
|
|
|
|
2012-10-27 08:32:52 +04:00
|
|
|
uint32_t ToABGR() const
|
|
|
|
{
|
|
|
|
return uint32_t(r * 255.0f) | uint32_t(g * 255.0f) << 8 |
|
|
|
|
uint32_t(b * 255.0f) << 16 | uint32_t(a * 255.0f) << 24;
|
|
|
|
}
|
|
|
|
|
2014-10-17 15:53:15 +04:00
|
|
|
uint32_t ToARGB() const
|
|
|
|
{
|
|
|
|
return uint32_t(b * 255.0f) | uint32_t(g * 255.0f) << 8 |
|
|
|
|
uint32_t(r * 255.0f) << 16 | uint32_t(a * 255.0f) << 24;
|
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
Float r, g, b, a;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GradientStop
|
|
|
|
{
|
2011-11-02 23:55:03 +04:00
|
|
|
bool operator<(const GradientStop& aOther) const {
|
|
|
|
return offset < aOther.offset;
|
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
Float offset;
|
|
|
|
Color color;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2014-03-04 03:24:04 +04:00
|
|
|
#if defined(XP_WIN) && defined(MOZ_GFX)
|
2012-05-03 23:21:52 +04:00
|
|
|
#ifdef GFX2D_INTERNAL
|
|
|
|
#define GFX2D_API __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define GFX2D_API __declspec(dllimport)
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define GFX2D_API
|
|
|
|
#endif
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
namespace mozilla {
|
2014-11-03 13:01:58 +03:00
|
|
|
|
|
|
|
// We can't use MOZ_BEGIN_ENUM_CLASS here because that prevents the enum
|
|
|
|
// values from being used for indexing. Wrapping the enum in a struct does at
|
|
|
|
// least gives us name scoping.
|
|
|
|
struct RectCorner {
|
|
|
|
enum {
|
|
|
|
// This order is important since Rect::AtCorner, AppendRoundedRectToPath
|
|
|
|
// and other code depends on it!
|
|
|
|
TopLeft = 0,
|
|
|
|
TopRight = 1,
|
|
|
|
BottomRight = 2,
|
|
|
|
BottomLeft = 3,
|
|
|
|
Count = 4
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
// Side constants for use in various places.
|
|
|
|
enum Side { eSideTop, eSideRight, eSideBottom, eSideLeft };
|
|
|
|
|
|
|
|
enum SideBits {
|
|
|
|
eSideBitsNone = 0,
|
|
|
|
eSideBitsTop = 1 << eSideTop,
|
|
|
|
eSideBitsRight = 1 << eSideRight,
|
|
|
|
eSideBitsBottom = 1 << eSideBottom,
|
|
|
|
eSideBitsLeft = 1 << eSideLeft,
|
|
|
|
eSideBitsTopBottom = eSideBitsTop | eSideBitsBottom,
|
|
|
|
eSideBitsLeftRight = eSideBitsLeft | eSideBitsRight,
|
|
|
|
eSideBitsAll = eSideBitsTopBottom | eSideBitsLeftRight
|
|
|
|
};
|
2015-07-13 18:25:42 +03:00
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
} // namespace mozilla
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
#define NS_SIDE_TOP mozilla::eSideTop
|
|
|
|
#define NS_SIDE_RIGHT mozilla::eSideRight
|
|
|
|
#define NS_SIDE_BOTTOM mozilla::eSideBottom
|
|
|
|
#define NS_SIDE_LEFT mozilla::eSideLeft
|
2011-06-24 21:41:16 +04:00
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_TYPES_H_ */
|