//+-------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Abstract: // Public API definitions shared by DWrite, D2D, and DImage. // //---------------------------------------------------------------------------- #pragma once #ifndef DCOMMON_H_INCLUDED #define DCOMMON_H_INCLUDED #include #ifndef DX_DECLARE_INTERFACE #define DX_DECLARE_INTERFACE(x) DECLSPEC_UUID(x) DECLSPEC_NOVTABLE #endif #ifndef CHECKMETHOD #define CHECKMETHOD(method) virtual DECLSPEC_NOTHROW _Must_inspect_result_ HRESULT STDMETHODCALLTYPE method #endif #pragma warning(push) #pragma warning(disable:4201) // anonymous unions warning // // Forward declarations // struct IDXGISurface; /// /// The measuring method used for text layout. /// typedef enum DWRITE_MEASURING_MODE { /// /// Text is measured using glyph ideal metrics whose values are independent to the current display resolution. /// DWRITE_MEASURING_MODE_NATURAL, /// /// Text is measured using glyph display compatible metrics whose values tuned for the current display resolution. /// DWRITE_MEASURING_MODE_GDI_CLASSIC, /// // Text is measured using the same glyph display metrics as text measured by GDI using a font // created with CLEARTYPE_NATURAL_QUALITY. /// DWRITE_MEASURING_MODE_GDI_NATURAL } DWRITE_MEASURING_MODE; #if NTDDI_VERSION >= NTDDI_WIN10_RS1 /// /// Fonts may contain multiple drawable data formats for glyphs. These flags specify which formats /// are supported in the font, either at a font-wide level or per glyph, and the app may use them /// to tell DWrite which formats to return when splitting a color glyph run. /// enum DWRITE_GLYPH_IMAGE_FORMATS { /// /// Indicates no data is available for this glyph. /// DWRITE_GLYPH_IMAGE_FORMATS_NONE = 0x00000000, /// /// The glyph has TrueType outlines. /// DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE = 0x00000001, /// /// The glyph has CFF outlines. /// DWRITE_GLYPH_IMAGE_FORMATS_CFF = 0x00000002, /// /// The glyph has multilayered COLR data. /// DWRITE_GLYPH_IMAGE_FORMATS_COLR = 0x00000004, /// /// The glyph has SVG outlines as standard XML. /// /// /// Fonts may store the content gzip'd rather than plain text, /// indicated by the first two bytes as gzip header {0x1F 0x8B}. /// DWRITE_GLYPH_IMAGE_FORMATS_SVG = 0x00000008, /// /// The glyph has PNG image data, with standard PNG IHDR. /// DWRITE_GLYPH_IMAGE_FORMATS_PNG = 0x00000010, /// /// The glyph has JPEG image data, with standard JIFF SOI header. /// DWRITE_GLYPH_IMAGE_FORMATS_JPEG = 0x00000020, /// /// The glyph has TIFF image data. /// DWRITE_GLYPH_IMAGE_FORMATS_TIFF = 0x00000040, /// /// The glyph has raw 32-bit premultiplied BGRA data. /// DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8 = 0x00000080, }; #ifdef DEFINE_ENUM_FLAG_OPERATORS DEFINE_ENUM_FLAG_OPERATORS(DWRITE_GLYPH_IMAGE_FORMATS); #endif #endif /// /// Qualifies how alpha is to be treated in a bitmap or render target containing /// alpha. /// typedef enum D2D1_ALPHA_MODE { /// /// Alpha mode should be determined implicitly. Some target surfaces do not supply /// or imply this information in which case alpha must be specified. /// D2D1_ALPHA_MODE_UNKNOWN = 0, /// /// Treat the alpha as premultipled. /// D2D1_ALPHA_MODE_PREMULTIPLIED = 1, /// /// Opacity is in the 'A' component only. /// D2D1_ALPHA_MODE_STRAIGHT = 2, /// /// Ignore any alpha channel information. /// D2D1_ALPHA_MODE_IGNORE = 3, D2D1_ALPHA_MODE_FORCE_DWORD = 0xffffffff } D2D1_ALPHA_MODE; /// /// Description of a pixel format. /// typedef struct D2D1_PIXEL_FORMAT { DXGI_FORMAT format; D2D1_ALPHA_MODE alphaMode; } D2D1_PIXEL_FORMAT; /// /// Represents an x-coordinate and y-coordinate pair in two-dimensional space. /// typedef struct D2D_POINT_2U { UINT32 x; UINT32 y; } D2D_POINT_2U; /// /// Represents an x-coordinate and y-coordinate pair in two-dimensional space. /// typedef struct D2D_POINT_2F { FLOAT x; FLOAT y; } D2D_POINT_2F; typedef POINT D2D_POINT_2L; /// /// A vector of 2 FLOAT values (x, y). /// typedef struct D2D_VECTOR_2F { FLOAT x; FLOAT y; } D2D_VECTOR_2F; /// /// A vector of 3 FLOAT values (x, y, z). /// typedef struct D2D_VECTOR_3F { FLOAT x; FLOAT y; FLOAT z; } D2D_VECTOR_3F; /// /// A vector of 4 FLOAT values (x, y, z, w). /// typedef struct D2D_VECTOR_4F { FLOAT x; FLOAT y; FLOAT z; FLOAT w; } D2D_VECTOR_4F; /// /// Represents a rectangle defined by the coordinates of the upper-left corner /// (left, top) and the coordinates of the lower-right corner (right, bottom). /// typedef struct D2D_RECT_F { FLOAT left; FLOAT top; FLOAT right; FLOAT bottom; } D2D_RECT_F; /// /// Represents a rectangle defined by the coordinates of the upper-left corner /// (left, top) and the coordinates of the lower-right corner (right, bottom). /// typedef struct D2D_RECT_U { UINT32 left; UINT32 top; UINT32 right; UINT32 bottom; } D2D_RECT_U; typedef RECT D2D_RECT_L; /// /// Stores an ordered pair of floats, typically the width and height of a rectangle. /// typedef struct D2D_SIZE_F { FLOAT width; FLOAT height; } D2D_SIZE_F; /// /// Stores an ordered pair of integers, typically the width and height of a /// rectangle. /// typedef struct D2D_SIZE_U { UINT32 width; UINT32 height; } D2D_SIZE_U; /// /// Represents a 3-by-2 matrix. /// typedef struct D2D_MATRIX_3X2_F { union { struct { /// /// Horizontal scaling / cosine of rotation /// FLOAT m11; /// /// Vertical shear / sine of rotation /// FLOAT m12; /// /// Horizontal shear / negative sine of rotation /// FLOAT m21; /// /// Vertical scaling / cosine of rotation /// FLOAT m22; /// /// Horizontal shift (always orthogonal regardless of rotation) /// FLOAT dx; /// /// Vertical shift (always orthogonal regardless of rotation) /// FLOAT dy; }; struct { FLOAT _11, _12; FLOAT _21, _22; FLOAT _31, _32; }; FLOAT m[3][2]; }; } D2D_MATRIX_3X2_F; /// /// Represents a 4-by-3 matrix. /// typedef struct D2D_MATRIX_4X3_F { union { struct { FLOAT _11, _12, _13; FLOAT _21, _22, _23; FLOAT _31, _32, _33; FLOAT _41, _42, _43; }; FLOAT m[4][3]; }; } D2D_MATRIX_4X3_F; /// /// Represents a 4-by-4 matrix. /// typedef struct D2D_MATRIX_4X4_F { union { struct { FLOAT _11, _12, _13, _14; FLOAT _21, _22, _23, _24; FLOAT _31, _32, _33, _34; FLOAT _41, _42, _43, _44; }; FLOAT m[4][4]; }; } D2D_MATRIX_4X4_F; /// /// Represents a 5-by-4 matrix. /// typedef struct D2D_MATRIX_5X4_F { union { struct { FLOAT _11, _12, _13, _14; FLOAT _21, _22, _23, _24; FLOAT _31, _32, _33, _34; FLOAT _41, _42, _43, _44; FLOAT _51, _52, _53, _54; }; FLOAT m[5][4]; }; } D2D_MATRIX_5X4_F; typedef D2D_POINT_2F D2D1_POINT_2F; typedef D2D_POINT_2U D2D1_POINT_2U; typedef D2D_POINT_2L D2D1_POINT_2L; typedef D2D_RECT_F D2D1_RECT_F; typedef D2D_RECT_U D2D1_RECT_U; typedef D2D_RECT_L D2D1_RECT_L; typedef D2D_SIZE_F D2D1_SIZE_F; typedef D2D_SIZE_U D2D1_SIZE_U; typedef D2D_MATRIX_3X2_F D2D1_MATRIX_3X2_F; #pragma warning(pop) #endif /* DCOMMON_H_INCLUDED */