[SDK][INCLUDE] Refinement of Gdiplus headers (#2217)

Define getNat helper functions in gdiplusbase.h and use them. CORE-16585
This commit is contained in:
Katayama Hirofumi MZ 2020-01-01 13:53:30 +09:00 committed by GitHub
parent 9ba5594599
commit 84de8c3f25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 105 additions and 100 deletions

View file

@ -47,4 +47,53 @@ class GdiplusBase
} }
}; };
class Brush;
class CachedBitmap;
class CustomLineCap;
class Font;
class FontCollection;
class FontFamily;
class Graphics;
class GraphicsPath;
class Image;
class ImageAttributes;
class Matrix;
class Metafile;
class Pen;
class Region;
// get native
GpBrush *&
getNat(const Brush *brush);
GpCachedBitmap *&
getNat(const CachedBitmap *cb);
GpCustomLineCap *&
getNat(const CustomLineCap *cap);
GpFontCollection *&
getNat(const FontCollection *fc);
GpGraphics *&
getNat(const Graphics *graphics);
GpPath *&
getNat(const GraphicsPath *path);
GpImage *&
getNat(const Image *image);
GpImageAttributes *&
getNat(const ImageAttributes *ia);
GpMatrix *&
getNat(const Matrix *matrix);
GpPen *&
getNat(const Pen *pen);
GpRegion *&
getNat(const Region *region);
#endif /* _GDIPLUSBASE_H */ #endif /* _GDIPLUSBASE_H */

View file

@ -19,8 +19,6 @@
#ifndef _GDIPLUSBRUSH_H #ifndef _GDIPLUSBRUSH_H
#define _GDIPLUSBRUSH_H #define _GDIPLUSBRUSH_H
class Image;
class Brush : public GdiplusBase class Brush : public GdiplusBase
{ {
public: public:
@ -302,7 +300,7 @@ class LinearGradientBrush : public Brush
GetTransform(Matrix *matrix) const GetTransform(Matrix *matrix) const
{ {
GpLineGradient *gradient = GetNativeGradient(); GpLineGradient *gradient = GetNativeGradient();
return SetStatus(DllExports::GdipGetLineTransform(gradient, matrix->nativeMatrix)); return SetStatus(DllExports::GdipGetLineTransform(gradient, getNat(matrix)));
} }
WrapMode WrapMode
@ -319,7 +317,7 @@ class LinearGradientBrush : public Brush
MultiplyTransform(const Matrix *matrix, MatrixOrder order) MultiplyTransform(const Matrix *matrix, MatrixOrder order)
{ {
GpLineGradient *gradient = GetNativeGradient(); GpLineGradient *gradient = GetNativeGradient();
return SetStatus(DllExports::GdipMultiplyLineTransform(gradient, matrix->nativeMatrix, order)); return SetStatus(DllExports::GdipMultiplyLineTransform(gradient, getNat(matrix), order));
} }
Status Status
@ -388,7 +386,7 @@ class LinearGradientBrush : public Brush
SetTransform(const Matrix *matrix) SetTransform(const Matrix *matrix)
{ {
GpLineGradient *gradient = GetNativeGradient(); GpLineGradient *gradient = GetNativeGradient();
return SetStatus(DllExports::GdipSetLineTransform(gradient, matrix->nativeMatrix)); return SetStatus(DllExports::GdipSetLineTransform(gradient, getNat(matrix)));
} }
Status Status
@ -502,10 +500,6 @@ class SolidBrush : Brush
} }
}; };
// get native
GpImage *&
getNat(const Image *image);
class TextureBrush : Brush class TextureBrush : Brush
{ {
public: public:
@ -520,7 +514,7 @@ class TextureBrush : Brush
TextureBrush(Image *image, Rect &dstRect, ImageAttributes *imageAttributes) TextureBrush(Image *image, Rect &dstRect, ImageAttributes *imageAttributes)
{ {
GpTexture *texture = NULL; GpTexture *texture = NULL;
GpImageAttributes *attrs = imageAttributes ? imageAttributes->nativeImageAttr : NULL; GpImageAttributes *attrs = imageAttributes ? getNat(imageAttributes) : NULL;
lastStatus = DllExports::GdipCreateTextureIA( lastStatus = DllExports::GdipCreateTextureIA(
getNat(image), attrs, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, &texture); getNat(image), attrs, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, &texture);
SetNativeBrush(texture); SetNativeBrush(texture);
@ -544,7 +538,7 @@ class TextureBrush : Brush
TextureBrush(Image *image, RectF &dstRect, ImageAttributes *imageAttributes) TextureBrush(Image *image, RectF &dstRect, ImageAttributes *imageAttributes)
{ {
GpTexture *texture = NULL; GpTexture *texture = NULL;
GpImageAttributes *attrs = imageAttributes ? imageAttributes->nativeImageAttr : NULL; GpImageAttributes *attrs = imageAttributes ? getNat(imageAttributes) : NULL;
lastStatus = DllExports::GdipCreateTextureIA( lastStatus = DllExports::GdipCreateTextureIA(
getNat(image), attrs, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, &texture); getNat(image), attrs, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, &texture);
SetNativeBrush(texture); SetNativeBrush(texture);
@ -573,7 +567,7 @@ class TextureBrush : Brush
GetTransform(Matrix *matrix) const GetTransform(Matrix *matrix) const
{ {
GpTexture *texture = GetNativeTexture(); GpTexture *texture = GetNativeTexture();
return SetStatus(DllExports::GdipGetTextureTransform(texture, matrix->nativeMatrix)); return SetStatus(DllExports::GdipGetTextureTransform(texture, getNat(matrix)));
} }
WrapMode WrapMode
@ -589,7 +583,7 @@ class TextureBrush : Brush
MultiplyTransform(Matrix *matrix, MatrixOrder order = MatrixOrderPrepend) MultiplyTransform(Matrix *matrix, MatrixOrder order = MatrixOrderPrepend)
{ {
GpTexture *texture = GetNativeTexture(); GpTexture *texture = GetNativeTexture();
return SetStatus(DllExports::GdipMultiplyTextureTransform(texture, matrix->nativeMatrix, order)); return SetStatus(DllExports::GdipMultiplyTextureTransform(texture, getNat(matrix), order));
} }
Status Status
@ -617,7 +611,7 @@ class TextureBrush : Brush
SetTransform(const Matrix *matrix) SetTransform(const Matrix *matrix)
{ {
GpTexture *texture = GetNativeTexture(); GpTexture *texture = GetNativeTexture();
return SetStatus(DllExports::GdipSetTextureTransform(texture, matrix->nativeMatrix)); return SetStatus(DllExports::GdipSetTextureTransform(texture, getNat(matrix)));
} }
Status Status

View file

@ -19,39 +19,6 @@
#ifndef _GDIPLUSGRAPHICS_H #ifndef _GDIPLUSGRAPHICS_H
#define _GDIPLUSGRAPHICS_H #define _GDIPLUSGRAPHICS_H
class Image;
class ImageAttributes;
class CachedBitmap;
class Region;
class Font;
class GraphicsPath;
class Metafile;
// get native
GpImage *&
getNat(const Image *image);
GpPen *&
getNat(const Pen *pen);
GpBrush *&
getNat(const Brush *brush);
GpCachedBitmap *&
getNat(const CachedBitmap *cb);
GpImageAttributes *&
getNat(const ImageAttributes *ia);
GpRegion *&
getNat(const Region *region);
GpMatrix *&
getNat(const Matrix *matrix);
GpPath *&
getNat(const GraphicsPath *path);
class Graphics : public GdiplusBase class Graphics : public GdiplusBase
{ {
friend class Region; friend class Region;
@ -1401,7 +1368,7 @@ class Graphics : public GdiplusBase
Status Status
SetClip(const Graphics *g, CombineMode combineMode = CombineModeReplace) SetClip(const Graphics *g, CombineMode combineMode = CombineModeReplace)
{ {
return SetStatus(DllExports::GdipSetClipGraphics(nativeGraphics, g ? g->nativeGraphics : NULL, combineMode)); return SetStatus(DllExports::GdipSetClipGraphics(nativeGraphics, g ? getNat(g) : NULL, combineMode));
} }
Status Status
@ -1553,9 +1520,9 @@ class Graphics : public GdiplusBase
// get native // get native
friend inline GpGraphics *& friend inline GpGraphics *&
getNat(const Graphics *graph) getNat(const Graphics *graphics)
{ {
return const_cast<Graphics *>(graph)->nativeGraphics; return const_cast<Graphics *>(graphics)->nativeGraphics;
} }
}; };

View file

@ -310,7 +310,7 @@ class Image : public GdiplusBase
if (!newImage) if (!newImage)
return SetStatus(InvalidParameter); return SetStatus(InvalidParameter);
return SetStatus(DllExports::GdipSaveAddImage(nativeImage, newImage->nativeImage, encoderParams)); return SetStatus(DllExports::GdipSaveAddImage(nativeImage, getNat(newImage), encoderParams));
#endif #endif
} }
@ -386,10 +386,6 @@ class Image : public GdiplusBase
} }
}; };
// get native
GpGraphics *&
getNat(const Graphics *graph);
class Bitmap : public Image class Bitmap : public Image
{ {
friend class CachedBitmap; friend class CachedBitmap;
@ -714,6 +710,13 @@ class FontCollection : public GdiplusBase
FontCollection(const FontCollection &); FontCollection(const FontCollection &);
FontCollection & FontCollection &
operator=(const FontCollection &); operator=(const FontCollection &);
// get native
friend inline GpFontCollection *&
getNat(const FontCollection *fc)
{
return const_cast<FontCollection *>(fc)->nativeFontCollection;
}
}; };
class FontFamily : public GdiplusBase class FontFamily : public GdiplusBase
@ -727,7 +730,7 @@ class FontFamily : public GdiplusBase
FontFamily(const WCHAR *name, const FontCollection *fontCollection) FontFamily(const WCHAR *name, const FontCollection *fontCollection)
{ {
GpFontCollection *theCollection = fontCollection ? fontCollection->nativeFontCollection : NULL; GpFontCollection *theCollection = fontCollection ? getNat(fontCollection) : NULL;
status = DllExports::GdipCreateFontFamilyFromName(name, theCollection, &fontFamily); status = DllExports::GdipCreateFontFamilyFromName(name, theCollection, &fontFamily);
} }
@ -834,6 +837,13 @@ class FontFamily : public GdiplusBase
this->status = status; this->status = status;
return status; return status;
} }
// get native
friend inline GpFontFamily *&
getNat(const FontFamily *ff)
{
return const_cast<FontFamily *>(ff)->fontFamily;
}
}; };
class InstalledFontFamily : public FontFamily class InstalledFontFamily : public FontFamily
@ -1001,6 +1011,13 @@ class Font : public GdiplusBase
this->status = status; this->status = status;
return status; return status;
} }
// get native
friend inline GpFont *&
getNat(const Font *font)
{
return const_cast<Font *>(font)->font;
}
}; };
class Region : public GdiplusBase class Region : public GdiplusBase
@ -1027,7 +1044,7 @@ class Region : public GdiplusBase
Region(const GraphicsPath *path) Region(const GraphicsPath *path)
{ {
lastStatus = DllExports::GdipCreateRegionPath(path->nativePath, &nativeRegion); lastStatus = DllExports::GdipCreateRegionPath(getNat(path), &nativeRegion);
} }
Region(HRGN hRgn) Region(HRGN hRgn)
@ -1052,7 +1069,7 @@ class Region : public GdiplusBase
Status Status
Complement(const GraphicsPath *path) Complement(const GraphicsPath *path)
{ {
GpPath *thePath = path ? path->nativePath : NULL; GpPath *thePath = path ? getNat(path) : NULL;
return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, thePath, CombineModeComplement)); return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, thePath, CombineModeComplement));
} }
@ -1088,7 +1105,7 @@ class Region : public GdiplusBase
Exclude(const GraphicsPath *path) Exclude(const GraphicsPath *path)
{ {
return SetStatus( return SetStatus(
DllExports::GdipCombineRegionPath(nativeRegion, path ? path->nativePath : NULL, CombineModeExclude)); DllExports::GdipCombineRegionPath(nativeRegion, path ? getNat(path) : NULL, CombineModeExclude));
} }
Status Status
@ -1159,22 +1176,20 @@ class Region : public GdiplusBase
Status Status
GetRegionScans(const Matrix *matrix, Rect *rects, INT *count) const GetRegionScans(const Matrix *matrix, Rect *rects, INT *count) const
{ {
return SetStatus( return SetStatus(DllExports::GdipGetRegionScansI(nativeRegion, rects, count, matrix ? getNat(matrix) : NULL));
DllExports::GdipGetRegionScansI(nativeRegion, rects, count, matrix ? matrix->nativeMatrix : NULL));
} }
Status Status
GetRegionScans(const Matrix *matrix, RectF *rects, INT *count) const GetRegionScans(const Matrix *matrix, RectF *rects, INT *count) const
{ {
return SetStatus( return SetStatus(DllExports::GdipGetRegionScans(nativeRegion, rects, count, matrix ? getNat(matrix) : NULL));
DllExports::GdipGetRegionScans(nativeRegion, rects, count, matrix ? matrix->nativeMatrix : NULL));
} }
UINT UINT
GetRegionScansCount(const Matrix *matrix) const GetRegionScansCount(const Matrix *matrix) const
{ {
UINT count; UINT count;
SetStatus(DllExports::GdipGetRegionScansCount(nativeRegion, &count, matrix ? matrix->nativeMatrix : NULL)); SetStatus(DllExports::GdipGetRegionScansCount(nativeRegion, &count, matrix ? getNat(matrix) : NULL));
return count; return count;
} }
@ -1187,7 +1202,7 @@ class Region : public GdiplusBase
Status Status
Intersect(const GraphicsPath *path) Intersect(const GraphicsPath *path)
{ {
GpPath *thePath = path ? path->nativePath : NULL; GpPath *thePath = path ? getNat(path) : NULL;
return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, thePath, CombineModeIntersect)); return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, thePath, CombineModeIntersect));
} }
@ -1303,7 +1318,7 @@ class Region : public GdiplusBase
Status Status
Transform(const Matrix *matrix) Transform(const Matrix *matrix)
{ {
return SetStatus(DllExports::GdipTransformRegion(nativeRegion, matrix ? matrix->nativeMatrix : NULL)); return SetStatus(DllExports::GdipTransformRegion(nativeRegion, matrix ? getNat(matrix) : NULL));
} }
Status Status
@ -1340,15 +1355,13 @@ class Region : public GdiplusBase
Status Status
Union(const GraphicsPath *path) Union(const GraphicsPath *path)
{ {
return SetStatus( return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path ? getNat(path) : NULL, CombineModeUnion));
DllExports::GdipCombineRegionPath(nativeRegion, path ? path->nativePath : NULL, CombineModeUnion));
} }
Status Status
Xor(const GraphicsPath *path) Xor(const GraphicsPath *path)
{ {
return SetStatus( return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path ? getNat(path) : NULL, CombineModeXor));
DllExports::GdipCombineRegionPath(nativeRegion, path ? path->nativePath : NULL, CombineModeXor));
} }
Status Status

View file

@ -27,8 +27,8 @@ inline CustomLineCap::CustomLineCap(
: nativeCap(NULL) : nativeCap(NULL)
{ {
nativeCap = NULL; nativeCap = NULL;
GpPath *nativeFillPath = fillPath ? fillPath->nativePath : NULL; GpPath *nativeFillPath = fillPath ? getNat(fillPath) : NULL;
GpPath *nativeStrokePath = strokePath ? strokePath->nativePath : NULL; GpPath *nativeStrokePath = strokePath ? getNat(strokePath) : NULL;
lastStatus = DllExports::GdipCreateCustomLineCap(nativeFillPath, nativeStrokePath, baseCap, baseInset, &nativeCap); lastStatus = DllExports::GdipCreateCustomLineCap(nativeFillPath, nativeStrokePath, baseCap, baseInset, &nativeCap);
} }

View file

@ -70,7 +70,7 @@ class Matrix : public GdiplusBase
Equals(const Matrix *matrix) Equals(const Matrix *matrix)
{ {
BOOL result; BOOL result;
SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix, matrix ? matrix->nativeMatrix : NULL, &result)); SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix, matrix ? getNat(matrix) : NULL, &result));
return result; return result;
} }
@ -111,7 +111,7 @@ class Matrix : public GdiplusBase
Status Status
Multiply(const Matrix *matrix, MatrixOrder order) Multiply(const Matrix *matrix, MatrixOrder order)
{ {
return SetStatus(DllExports::GdipMultiplyMatrix(nativeMatrix, matrix ? matrix->nativeMatrix : NULL, order)); return SetStatus(DllExports::GdipMultiplyMatrix(nativeMatrix, matrix ? getNat(matrix) : NULL, order));
} }
REAL OffsetX(VOID) REAL OffsetX(VOID)

View file

@ -19,9 +19,6 @@
#ifndef _GDIPLUSPATH_H #ifndef _GDIPLUSPATH_H
#define _GDIPLUSPATH_H #define _GDIPLUSPATH_H
class FontFamily;
class Graphics;
class GraphicsPath : public GdiplusBase class GraphicsPath : public GdiplusBase
{ {
friend class Region; friend class Region;
@ -233,10 +230,7 @@ class GraphicsPath : public GdiplusBase
Status Status
AddPath(const GraphicsPath *addingPath, BOOL connect) AddPath(const GraphicsPath *addingPath, BOOL connect)
{ {
GpPath *nativePath2 = NULL; GpPath *nativePath2 = addingPath ? getNat(addingPath) : NULL;
if (addingPath)
nativePath2 = addingPath->nativePath;
return SetStatus(DllExports::GdipAddPathPath(nativePath, nativePath2, connect)); return SetStatus(DllExports::GdipAddPathPath(nativePath, nativePath2, connect));
} }
@ -383,10 +377,7 @@ class GraphicsPath : public GdiplusBase
Status Status
Flatten(const Matrix *matrix, REAL flatness) Flatten(const Matrix *matrix, REAL flatness)
{ {
GpMatrix *nativeMatrix = NULL; GpMatrix *nativeMatrix = matrix ? getNat(matrix) : NULL;
if (matrix)
nativeMatrix = matrix->nativeMatrix;
return SetStatus(DllExports::GdipFlattenPath(nativePath, nativeMatrix, flatness)); return SetStatus(DllExports::GdipFlattenPath(nativePath, nativeMatrix, flatness));
} }
@ -553,10 +544,7 @@ class GraphicsPath : public GdiplusBase
WarpMode warpMode, WarpMode warpMode,
REAL flatness) REAL flatness)
{ {
GpMatrix *nativeMatrix = NULL; GpMatrix *nativeMatrix = matrix ? getNat(matrix) : NULL;
if (matrix)
nativeMatrix = matrix->nativeMatrix;
return SetStatus(DllExports::GdipWarpPath( return SetStatus(DllExports::GdipWarpPath(
nativePath, nativeMatrix, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, warpMode, nativePath, nativeMatrix, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, warpMode,
flatness)); flatness));

View file

@ -19,12 +19,6 @@
#ifndef _GDIPLUSPEN_H #ifndef _GDIPLUSPEN_H
#define _GDIPLUSPEN_H #define _GDIPLUSPEN_H
class CustomLineCap;
// get native
GpCustomLineCap *&
getNat(const CustomLineCap *cap);
class Pen : public GdiplusBase class Pen : public GdiplusBase
{ {
public: public:
@ -33,7 +27,7 @@ class Pen : public GdiplusBase
Pen(const Brush *brush, REAL width = 1.0f) : nativePen(NULL) Pen(const Brush *brush, REAL width = 1.0f) : nativePen(NULL)
{ {
lastStatus = DllExports::GdipCreatePen2(brush->nativeBrush, width, UnitWorld, &nativePen); lastStatus = DllExports::GdipCreatePen2(getNat(brush), width, UnitWorld, &nativePen);
} }
Pen(const Color &color, REAL width = 1.0f) : nativePen(NULL) Pen(const Color &color, REAL width = 1.0f) : nativePen(NULL)
@ -218,7 +212,7 @@ class Pen : public GdiplusBase
Status Status
GetTransform(Matrix *matrix) GetTransform(Matrix *matrix)
{ {
return SetStatus(DllExports::GdipGetPenTransform(nativePen, matrix->nativeMatrix)); return SetStatus(DllExports::GdipGetPenTransform(nativePen, getNat(matrix)));
} }
REAL REAL
@ -235,7 +229,7 @@ class Pen : public GdiplusBase
#if 1 #if 1
return SetStatus(NotImplemented); return SetStatus(NotImplemented);
#else #else
return SetStatus(DllExports::GdipMultiplyPenTransform(nativePen, matrix->nativeMatrix, order)); return SetStatus(DllExports::GdipMultiplyPenTransform(nativePen, getNat(matrix), order));
#endif #endif
} }
@ -266,7 +260,7 @@ class Pen : public GdiplusBase
Status Status
SetBrush(const Brush *brush) SetBrush(const Brush *brush)
{ {
GpBrush *theBrush = brush ? brush->nativeBrush : NULL; GpBrush *theBrush = brush ? getNat(brush) : NULL;
return SetStatus(DllExports::GdipSetPenBrushFill(nativePen, theBrush)); return SetStatus(DllExports::GdipSetPenBrushFill(nativePen, theBrush));
} }
@ -353,7 +347,7 @@ class Pen : public GdiplusBase
Status Status
SetTransform(const Matrix *matrix) SetTransform(const Matrix *matrix)
{ {
GpMatrix *mat = matrix ? matrix->nativeMatrix : NULL; GpMatrix *mat = matrix ? getNat(matrix) : NULL;
return SetStatus(DllExports::GdipSetPenTransform(nativePen, mat)); return SetStatus(DllExports::GdipSetPenTransform(nativePen, mat));
} }