Files
palemoon27/gfx/2d/Types.h
T
roytam1 5a3b3d60eb import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1173260 - stub out tests that fail when 'cursive' is looked up via fontconfig. r=m_kato (0bb3f03cb8)
- bug 1215657 - make AccessibleWrap::get_accDefaultAction work with proxied accessibles r=davidb (5732eb38eb)
- Bug 1210549 - Allow IServiceProvider::QueryService to work for proxied accessibles r=tbsaunde (7dcd9c2271)
- bug 1215657 - make AccessibleWrap::accSelect work with proxies r=davidb (d52e3d4873)
- Bug 1225682 - Don't use nsAuto{,C}String as class member variables in rdf/. r=Pike (f681938445)
- Bug 1232454 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in security/apps/; r=keeler (e416936ed6)
- Bug 1235796 - Allow allocating YCbCr textures with Cb/Cr planes bigger than the Y plane. r=jrmuizel (8f1dbe137c)
- Bug 1241816 - In CreateSourceSurfaceFromMacIOSurface, unlock the IOSurface even in failure cases. r=mattwoodrow (218e6da6c1)
- Bug 1240190 - Add D3D9 texture upload profiler labels. r=jrmuizel (1e55b77bdf)
- Bug 1213429 - Recycle e10s D3D9 textures and add partial upload support. r=Bas (97aeeefdd2)
- Bug 1213429 - Check the result of LockRect. r=Bas (1c3c981d80)
- Bug 1213429 - GCC compilation fixup. (5449005c99)
- Lazily initialize D3D11 mix-blend shaders. (bug 1246388, r=mattwoodrow) (6fd3226030)
- Bug 1237375: Add some more extensive debugging information. r=milan (aed95e4774)
- Bug 1239861. Part 2 Properly resize DXGI swap chain buffer size. r=bas (e9bf410de4)
- Bug 1247775 - Part 1: Remove D3D10/D2D 1.0 texture integration from layers. r=dvander (74d7e93792)
- Bug 1247775 - Part 2: Remove Direct2D 1.0 code from Thebes. r=dvander (f0a1f53917)
- Bug 1247775 - Part 3: Remove Moz2D code to support Direct2D 1.0. r=dvander (10d27128eb)
- Bug 1221656 - Copy mp4parse.h in update-rust.sh. r=kinetik (96ebce3eb8)
- Bug 868333 - Match more MP4 family file types in media sniffer. r=rillian (cd29bd2a74)
- Bug 1211802 - Recognize 'avc?' as mp4 video. r=jya (b68726705b)
- Bug 1244523: [mp4] P2. Have sniffer recognise ftyp qt subtype. r=cpearce (1770f0862b)
- Bug 1087488: Remove some SPROP macro usages in Omnijar.cpp, to avoid triggering -Wtautological-compare clang warning. r=glandium (697dfa9895)
- Bug 1228437 - Add BHR stats from e10s child process. B2G fix by Ting-Yu Chou. r=nchen (213fbb9f37)
- Bug 1198196 - rework EVENTLOOP_UI_LAG_EXP_MS to record all lag. r=vladan (2807460ce0)
- Bug 1240484 - fixed control flow patch issue by adding brackets. r=mccr8 (d2aac14ee1)
- Bug 1242119 - Remove early exit in WinXP debug content processes. r=froydnj (2c2626a1ea)
- Bug 1245513 - Use _exit(0) to exit in B2G debug content processes. r=froydnj (c37efd34d9)
- some crash and profiler stuff (87547f6d8f)
- bug 1234417 - fix a leak in CreateECPublicKey r=rbarnes (99848f0fae)
- Bug 1204784: Handle cases in nsThreadPool where Gecko doesn't own the thread that we're running on. r=froydnj (3f523fc544)
- Bug 1204784: Do not shut the main thread down before all outstanding asynchronous thread shutdowns complete. r=froydnj (6abfb2562f)
- Bug 1234126 - Add Chaos Mode support for setting thread affinity on OS X and Windows. r=froydnj (8811430596)
- Bug 1245586 - add debugging aids for thread shutdown; r=khuey (28b7ae88c3)
- Bug 1191936 - Implement SPKI/PKCS#8/JWK import/export for RSA-PSS r=rbarnes (212ab7fec5)
- Bug 1241757 - Permit export of JWK with empty key_ops field, r=rbarnes (b19f177a13)
- Bug 1205168 - Part 0: Remove copy-ctor from strong type. r=jgilbert (a6070322a1)
- Bug 1205168 - Part 1 - Sort all the WebGLTexelFormats. r=jgilbert (857cd58641)
- Bug 1205168 - Part 2: Texel Conversion - RG8 format. r=jgilbert (6c241194ed)
- Bug 1205168 - Part 3: Texel Conversion - RG16F format. r=jgilbert (7573635218)
- Bug 1205168 - Part 4: Texel Conversion - RG32F format. r=jgilbert (f54343317e)
- Bug 1205168 - Part 5: Texel Conversion - RGB11F11F10F format. r=jgilbert (500514e025)
- Bug 1205168 - Part 6: Fix TexImage2D and TexSubImage2D with texture conversion. r=jgilbert (b5e2e75276)
- Bug 1205168 - Part 7: Remove unneeded functions. r=jgilbert (9bd24cd813)
- Bug 1234744 - Fix build errors in ImageBitmap.h. r=roc (b4b67e5905)
- missing telemetry bits (28161fd3f9)
- Bug 1237193 - Fix WebGL getActiveUniforms return type. r=jgilbert, r=smaug (f9a37a360e)
- Bug 1233353 - Initialize rb correctly if rb bind to READ_FRAMEBUFFER. r=jgilbert (bbc77437a4)
- Bug 1237637 - Disallow negative levels for framebuffer attachments. -r=jrmuizel (fa65b6ad24)
- Bug 1236395 - [WebGL2] pass getFramebufferAttachmentParameter in gl-object-get-calls.html, r=jgilbert (6f9fde1cd2)
- Bug 1236784 - [WebGL2] pass getRenderbufferParameter in gl-object-get-calls.html, r=jgilbert (e4f20f54ad)
- Bug 1238865 - Part 1: Validate attachments before clearBuffer. r=jgilbert (a6e6e05a0c)
- Bug 1229210. Handle the new formats required by WebGL2 in ReadPixels. r=jgilbert (66e305f97d)
- Bug 1238865 - Part 2: Add more format/type checks for WebGL2. r=jgilbert (af629782b3)
- Bug 1238865 - Part 3: Prevent IMPLEMENTATION_COLOR_READ_FORMAT return SRGB_ALPHA. r=jgilbert (81da93d791)
- Bug 1240673 - Fix WebGL2 framebuffer parameter problem. r=jgilbert (2c957a8294)
- Bug 1240438 - Fix WebGL2 framebuffer attachment related implementation. r=jgilbert (b4339241c8)
- Bug 1239187 - Use the GLFeature instead. - r=jrmuizel (c5f2c57646)
- Bug 1094458 - Implement RenderbufferStorageMultisample. - r=jrmuizel (f20f776597)
- Bug 1246007 - Ignore RENDERBUFFER_SAMPLES outside of webgl2. - r=jrmuizel (6b8f59ae49)
- Bug 1243907 - Don't query _BITS enums on Core profiles. - r=jrmuizel (e722abe45b)
- partial Bug 1242120 - Remove switch fallthrough (0f47fb7a71)
- Bug 1236080. Null check format in GetParameter. r=jgilbert (09fedc2ea8)
- Bug 1240662 - Add max level check for framebufferTextureLayer. r=jgilbert (f6d5eda15c)
- Bug 1236091. Move validate checks inside of null checks. r=jgilbert (4c67e04e87)
- Bug 1237191 - Add check for getQueryParameter to return correct error. r=jgilbert (93345aab7e)
- Bug 1230089 - If sampler is bound, use parameter of sampler. r=jgilbert (e4139a5174)
- Bug 1242336 - Fix WebGL2 return type of GL_UNPACK_SKIP. r=jgilbert (4a2ef1956e)
- Bug 1240262 - Annotate intentional switch fallthrough and suppress -Wimplicit-fallthrough warnings in dom/canvas/. r=jgilbert (eaee57ba8f)
- Bug 1237194 - Fix getSyncParameter return error. r=jgilbert (13119be06e)
- Bug 1239541 - Fix WebGL2 texImage related checking. r=jgilbert (6777244db0)
- Bug 1225291 - IsTransformFeedback doesn't report error when input is null. r=jgilbert (8c67d072b5)
- Bug 1233094. Handle null buffers in GetIndexedParameter. r=jgilbert (ae5d75bd47)
- Bug 1228676 - WebGL2 VertexAttrib funcs should match WebGL 1 patterns. - r=jgilbert (bf96c0e17b)
- Bug 1237420 - "Fix length-checking when setting WebGL 2 vertex attributes with an array". r=jgilbert (d8e9ca7111)
- Bug 1233819 - Fix WebGL on WinXP. - r=jrmuizel (39b15ba9ee)
- Bug 1233046 - Mark non-try platforms. Align some tests. (9d16ce70a4)
- Bug 1201885,1247752,1247753 - Re-mark passing/failing tests. (381c71c0f8)
- Bug 1247764 - Disable STENCIL_TEST on mac+intel when not needed. - r=jrmuizel (0b544d0c36)
- Bug 1243908 - Use DrawBuffers through GLScreenBuffer when operating on fb0. - r=jrmuizel (0ac0fc6047)
- Bug 1229944 - Add glClear for zeroing texture data. - r=kamidphish (51df8cbb50)
- Bug 1220450 - Clear length on cache OOM. r=kamidphish (44431a0d3e)
- Bug 1232346 - Clarify ResolveForDraw's failure checking. - r=kamidphish (542917bb85)
2024-01-11 09:39:33 +08:00

397 lines
9.0 KiB
C++

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
#ifndef MOZILLA_GFX_TYPES_H_
#define MOZILLA_GFX_TYPES_H_
#include "mozilla/Endian.h"
#include <stddef.h>
#include <stdint.h>
namespace mozilla {
namespace gfx {
typedef float Float;
enum class SurfaceType : int8_t {
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 */
RECORDING, /* Surface used for recording */
TILED /* Surface from a tiled DrawTarget */
};
enum class SurfaceFormat : int8_t {
// The following values are named to reflect layout of colors in memory, from
// lowest byte to highest byte. The 32-bit value layout depends on machine
// endianness.
// in-memory 32-bit LE value 32-bit BE value
B8G8R8A8, // [BB, GG, RR, AA] 0xAARRGGBB 0xBBGGRRAA
B8G8R8X8, // [BB, GG, RR, 00] 0x00RRGGBB 0xBBGGRR00
R8G8B8A8, // [RR, GG, BB, AA] 0xAABBGGRR 0xRRGGBBAA
R8G8B8X8, // [RR, GG, BB, 00] 0x00BBGGRR 0xRRGGBB00
A8R8G8B8, // [AA, RR, GG, BB] 0xBBGGRRAA 0xAARRGGBB
X8R8G8B8, // [00, RR, GG, BB] 0xBBGGRR00 0x00RRGGBB
// The _UINT16 suffix here indicates that the name reflects the layout when
// viewed as a uint16_t value. In memory these values are stored using native
// endianness.
R5G6B5_UINT16, // 0bRRRRRGGGGGGBBBBB
// This one is a single-byte, so endianness isn't an issue.
A8,
// These ones are their own special cases.
YUV,
NV12,
// This represents the unknown format.
UNKNOWN,
// The following values are endian-independent synonyms. The _UINT32 suffix
// indicates that the name reflects the layout when viewed as a uint32_t
// value.
//#if MOZ_LITTLE_ENDIAN
A8R8G8B8_UINT32 = B8G8R8A8, // 0xAARRGGBB
X8R8G8B8_UINT32 = B8G8R8X8 // 0x00RRGGBB
//#elif MOZ_BIG_ENDIAN
// A8R8G8B8_UINT32 = A8R8G8B8, // 0xAARRGGBB
// X8R8G8B8_UINT32 = X8R8G8B8 // 0x00RRGGBB
//#else
//# error "bad endianness"
//#endif
};
inline bool IsOpaque(SurfaceFormat aFormat)
{
switch (aFormat) {
case SurfaceFormat::B8G8R8X8:
case SurfaceFormat::R8G8B8X8:
case SurfaceFormat::R5G6B5_UINT16:
case SurfaceFormat::YUV:
case SurfaceFormat::NV12:
return true;
default:
return false;
}
}
enum class FilterType : int8_t {
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
};
enum class DrawTargetType : int8_t {
SOFTWARE_RASTER = 0,
HARDWARE_RASTER,
VECTOR
};
enum class BackendType : int8_t {
NONE = 0,
DIRECT2D, // Used for version independent D2D objects.
COREGRAPHICS,
COREGRAPHICS_ACCELERATED,
CAIRO,
SKIA,
RECORDING,
DIRECT2D1_1
};
enum class FontType : int8_t {
DWRITE,
GDI,
MAC,
SKIA,
CAIRO,
COREGRAPHICS
};
enum class NativeSurfaceType : int8_t {
D3D10_TEXTURE,
CAIRO_CONTEXT,
CGCONTEXT,
CGCONTEXT_ACCELERATED,
OPENGL_TEXTURE
};
enum class NativeFontType : int8_t {
DWRITE_FONT_FACE,
GDI_FONT_FACE,
MAC_FONT_FACE,
SKIA_FONT_FACE,
CAIRO_FONT_FACE
};
enum class FontStyle : int8_t {
NORMAL,
ITALIC,
BOLD,
BOLD_ITALIC
};
enum class FontHinting : int8_t {
NONE,
LIGHT,
NORMAL,
FULL
};
enum class CompositionOp : int8_t {
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
};
enum class Axis : int8_t {
X_AXIS,
Y_AXIS,
BOTH
};
enum class ExtendMode : int8_t {
CLAMP, // Do not repeat
REPEAT, // Repeat in both axis
REPEAT_X, // Only X axis
REPEAT_Y, // Only Y axis
REFLECT // Mirror the image
};
enum class FillRule : int8_t {
FILL_WINDING,
FILL_EVEN_ODD
};
enum class AntialiasMode : int8_t {
NONE,
GRAY,
SUBPIXEL,
DEFAULT
};
enum class Filter : int8_t {
GOOD,
LINEAR,
POINT,
SENTINEL // one past the last valid value
};
enum class PatternType : int8_t {
COLOR,
SURFACE,
LINEAR_GRADIENT,
RADIAL_GRADIENT
};
enum class JoinStyle : int8_t {
BEVEL,
ROUND,
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.
};
enum class CapStyle : int8_t {
BUTT,
ROUND,
SQUARE
};
enum class SamplingBounds : int8_t {
UNBOUNDED,
BOUNDED
};
/* Color is stored in non-premultiplied form */
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;
}
// The "Unusual" prefix is to avoid unintentionally using this function when
// FromABGR(), which is much more common, is needed.
static Color UnusualFromARGB(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;
}
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;
}
// The "Unusual" prefix is to avoid unintentionally using this function when
// ToABGR(), which is much more common, is needed.
uint32_t UnusualToARGB() 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;
}
bool operator==(const Color& aColor) const {
return r == aColor.r && g == aColor.g && b == aColor.b && a == aColor.a;
}
bool operator!=(const Color& aColor) const {
return !(*this == aColor);
}
Float r, g, b, a;
};
struct GradientStop
{
bool operator<(const GradientStop& aOther) const {
return offset < aOther.offset;
}
Float offset;
Color color;
};
enum class JobStatus {
Complete,
Wait,
Yield,
Error
};
} // namespace gfx
} // namespace mozilla
// XXX: temporary
typedef mozilla::gfx::SurfaceFormat gfxImageFormat;
#if defined(XP_WIN) && defined(MOZ_GFX)
#ifdef GFX2D_INTERNAL
#define GFX2D_API __declspec(dllexport)
#else
#define GFX2D_API __declspec(dllimport)
#endif
#else
#define GFX2D_API
#endif
namespace mozilla {
// 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
};
};
// 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
};
} // namespace mozilla
#define NS_SIDE_TOP mozilla::eSideTop
#define NS_SIDE_RIGHT mozilla::eSideRight
#define NS_SIDE_BOTTOM mozilla::eSideBottom
#define NS_SIDE_LEFT mozilla::eSideLeft
#endif /* MOZILLA_GFX_TYPES_H_ */