https://git.reactos.org/?p=reactos.git;a=commitdiff;h=84de8c3f2563a3fb7f433…
commit 84de8c3f2563a3fb7f433d7a06ebc27d5fb6a7df
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Jan 1 13:53:30 2020 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jan 1 13:53:30 2020 +0900
[SDK][INCLUDE] Refinement of Gdiplus headers (#2217)
Define getNat helper functions in gdiplusbase.h and use them. CORE-16585
---
sdk/include/psdk/gdiplusbase.h | 49 +++++++++++++++++++++++++++++++++++
sdk/include/psdk/gdiplusbrush.h | 22 ++++++----------
sdk/include/psdk/gdiplusgraphics.h | 39 +++-------------------------
sdk/include/psdk/gdiplusheaders.h | 53 ++++++++++++++++++++++++--------------
sdk/include/psdk/gdipluslinecaps.h | 4 +--
sdk/include/psdk/gdiplusmatrix.h | 4 +--
sdk/include/psdk/gdipluspath.h | 18 +++----------
sdk/include/psdk/gdipluspen.h | 16 ++++--------
8 files changed, 105 insertions(+), 100 deletions(-)
diff --git a/sdk/include/psdk/gdiplusbase.h b/sdk/include/psdk/gdiplusbase.h
index 274195c243f..92e3aafc7c5 100644
--- a/sdk/include/psdk/gdiplusbase.h
+++ b/sdk/include/psdk/gdiplusbase.h
@@ -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 */
diff --git a/sdk/include/psdk/gdiplusbrush.h b/sdk/include/psdk/gdiplusbrush.h
index 2416135294e..cb98a7a3e22 100644
--- a/sdk/include/psdk/gdiplusbrush.h
+++ b/sdk/include/psdk/gdiplusbrush.h
@@ -19,8 +19,6 @@
#ifndef _GDIPLUSBRUSH_H
#define _GDIPLUSBRUSH_H
-class Image;
-
class Brush : public GdiplusBase
{
public:
@@ -302,7 +300,7 @@ class LinearGradientBrush : public Brush
GetTransform(Matrix *matrix) const
{
GpLineGradient *gradient = GetNativeGradient();
- return SetStatus(DllExports::GdipGetLineTransform(gradient,
matrix->nativeMatrix));
+ return SetStatus(DllExports::GdipGetLineTransform(gradient, getNat(matrix)));
}
WrapMode
@@ -319,7 +317,7 @@ class LinearGradientBrush : public Brush
MultiplyTransform(const Matrix *matrix, MatrixOrder order)
{
GpLineGradient *gradient = GetNativeGradient();
- return SetStatus(DllExports::GdipMultiplyLineTransform(gradient,
matrix->nativeMatrix, order));
+ return SetStatus(DllExports::GdipMultiplyLineTransform(gradient, getNat(matrix),
order));
}
Status
@@ -388,7 +386,7 @@ class LinearGradientBrush : public Brush
SetTransform(const Matrix *matrix)
{
GpLineGradient *gradient = GetNativeGradient();
- return SetStatus(DllExports::GdipSetLineTransform(gradient,
matrix->nativeMatrix));
+ return SetStatus(DllExports::GdipSetLineTransform(gradient, getNat(matrix)));
}
Status
@@ -502,10 +500,6 @@ class SolidBrush : Brush
}
};
-// get native
-GpImage *&
-getNat(const Image *image);
-
class TextureBrush : Brush
{
public:
@@ -520,7 +514,7 @@ class TextureBrush : Brush
TextureBrush(Image *image, Rect &dstRect, ImageAttributes *imageAttributes)
{
GpTexture *texture = NULL;
- GpImageAttributes *attrs = imageAttributes ? imageAttributes->nativeImageAttr
: NULL;
+ GpImageAttributes *attrs = imageAttributes ? getNat(imageAttributes) : NULL;
lastStatus = DllExports::GdipCreateTextureIA(
getNat(image), attrs, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height,
&texture);
SetNativeBrush(texture);
@@ -544,7 +538,7 @@ class TextureBrush : Brush
TextureBrush(Image *image, RectF &dstRect, ImageAttributes *imageAttributes)
{
GpTexture *texture = NULL;
- GpImageAttributes *attrs = imageAttributes ? imageAttributes->nativeImageAttr
: NULL;
+ GpImageAttributes *attrs = imageAttributes ? getNat(imageAttributes) : NULL;
lastStatus = DllExports::GdipCreateTextureIA(
getNat(image), attrs, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height,
&texture);
SetNativeBrush(texture);
@@ -573,7 +567,7 @@ class TextureBrush : Brush
GetTransform(Matrix *matrix) const
{
GpTexture *texture = GetNativeTexture();
- return SetStatus(DllExports::GdipGetTextureTransform(texture,
matrix->nativeMatrix));
+ return SetStatus(DllExports::GdipGetTextureTransform(texture, getNat(matrix)));
}
WrapMode
@@ -589,7 +583,7 @@ class TextureBrush : Brush
MultiplyTransform(Matrix *matrix, MatrixOrder order = MatrixOrderPrepend)
{
GpTexture *texture = GetNativeTexture();
- return SetStatus(DllExports::GdipMultiplyTextureTransform(texture,
matrix->nativeMatrix, order));
+ return SetStatus(DllExports::GdipMultiplyTextureTransform(texture,
getNat(matrix), order));
}
Status
@@ -617,7 +611,7 @@ class TextureBrush : Brush
SetTransform(const Matrix *matrix)
{
GpTexture *texture = GetNativeTexture();
- return SetStatus(DllExports::GdipSetTextureTransform(texture,
matrix->nativeMatrix));
+ return SetStatus(DllExports::GdipSetTextureTransform(texture, getNat(matrix)));
}
Status
diff --git a/sdk/include/psdk/gdiplusgraphics.h b/sdk/include/psdk/gdiplusgraphics.h
index f34c1093cc5..d93dd542694 100644
--- a/sdk/include/psdk/gdiplusgraphics.h
+++ b/sdk/include/psdk/gdiplusgraphics.h
@@ -19,39 +19,6 @@
#ifndef _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
{
friend class Region;
@@ -1401,7 +1368,7 @@ class Graphics : public GdiplusBase
Status
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
@@ -1553,9 +1520,9 @@ class Graphics : public GdiplusBase
// get native
friend inline GpGraphics *&
- getNat(const Graphics *graph)
+ getNat(const Graphics *graphics)
{
- return const_cast<Graphics *>(graph)->nativeGraphics;
+ return const_cast<Graphics *>(graphics)->nativeGraphics;
}
};
diff --git a/sdk/include/psdk/gdiplusheaders.h b/sdk/include/psdk/gdiplusheaders.h
index 2cd2a35657f..d839ce324ff 100644
--- a/sdk/include/psdk/gdiplusheaders.h
+++ b/sdk/include/psdk/gdiplusheaders.h
@@ -310,7 +310,7 @@ class Image : public GdiplusBase
if (!newImage)
return SetStatus(InvalidParameter);
- return SetStatus(DllExports::GdipSaveAddImage(nativeImage,
newImage->nativeImage, encoderParams));
+ return SetStatus(DllExports::GdipSaveAddImage(nativeImage, getNat(newImage),
encoderParams));
#endif
}
@@ -386,10 +386,6 @@ class Image : public GdiplusBase
}
};
-// get native
-GpGraphics *&
-getNat(const Graphics *graph);
-
class Bitmap : public Image
{
friend class CachedBitmap;
@@ -714,6 +710,13 @@ class FontCollection : public GdiplusBase
FontCollection(const FontCollection &);
FontCollection &
operator=(const FontCollection &);
+
+ // get native
+ friend inline GpFontCollection *&
+ getNat(const FontCollection *fc)
+ {
+ return const_cast<FontCollection *>(fc)->nativeFontCollection;
+ }
};
class FontFamily : public GdiplusBase
@@ -727,7 +730,7 @@ class FontFamily : public GdiplusBase
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);
}
@@ -834,6 +837,13 @@ class FontFamily : public GdiplusBase
this->status = status;
return status;
}
+
+ // get native
+ friend inline GpFontFamily *&
+ getNat(const FontFamily *ff)
+ {
+ return const_cast<FontFamily *>(ff)->fontFamily;
+ }
};
class InstalledFontFamily : public FontFamily
@@ -1001,6 +1011,13 @@ class Font : public GdiplusBase
this->status = status;
return status;
}
+
+ // get native
+ friend inline GpFont *&
+ getNat(const Font *font)
+ {
+ return const_cast<Font *>(font)->font;
+ }
};
class Region : public GdiplusBase
@@ -1027,7 +1044,7 @@ class Region : public GdiplusBase
Region(const GraphicsPath *path)
{
- lastStatus = DllExports::GdipCreateRegionPath(path->nativePath,
&nativeRegion);
+ lastStatus = DllExports::GdipCreateRegionPath(getNat(path), &nativeRegion);
}
Region(HRGN hRgn)
@@ -1052,7 +1069,7 @@ class Region : public GdiplusBase
Status
Complement(const GraphicsPath *path)
{
- GpPath *thePath = path ? path->nativePath : NULL;
+ GpPath *thePath = path ? getNat(path) : NULL;
return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, thePath,
CombineModeComplement));
}
@@ -1088,7 +1105,7 @@ class Region : public GdiplusBase
Exclude(const GraphicsPath *path)
{
return SetStatus(
- DllExports::GdipCombineRegionPath(nativeRegion, path ? path->nativePath :
NULL, CombineModeExclude));
+ DllExports::GdipCombineRegionPath(nativeRegion, path ? getNat(path) : NULL,
CombineModeExclude));
}
Status
@@ -1159,22 +1176,20 @@ class Region : public GdiplusBase
Status
GetRegionScans(const Matrix *matrix, Rect *rects, INT *count) const
{
- return SetStatus(
- DllExports::GdipGetRegionScansI(nativeRegion, rects, count, matrix ?
matrix->nativeMatrix : NULL));
+ return SetStatus(DllExports::GdipGetRegionScansI(nativeRegion, rects, count,
matrix ? getNat(matrix) : NULL));
}
Status
GetRegionScans(const Matrix *matrix, RectF *rects, INT *count) const
{
- return SetStatus(
- DllExports::GdipGetRegionScans(nativeRegion, rects, count, matrix ?
matrix->nativeMatrix : NULL));
+ return SetStatus(DllExports::GdipGetRegionScans(nativeRegion, rects, count,
matrix ? getNat(matrix) : NULL));
}
UINT
GetRegionScansCount(const Matrix *matrix) const
{
UINT count;
- SetStatus(DllExports::GdipGetRegionScansCount(nativeRegion, &count, matrix ?
matrix->nativeMatrix : NULL));
+ SetStatus(DllExports::GdipGetRegionScansCount(nativeRegion, &count, matrix ?
getNat(matrix) : NULL));
return count;
}
@@ -1187,7 +1202,7 @@ class Region : public GdiplusBase
Status
Intersect(const GraphicsPath *path)
{
- GpPath *thePath = path ? path->nativePath : NULL;
+ GpPath *thePath = path ? getNat(path) : NULL;
return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, thePath,
CombineModeIntersect));
}
@@ -1303,7 +1318,7 @@ class Region : public GdiplusBase
Status
Transform(const Matrix *matrix)
{
- return SetStatus(DllExports::GdipTransformRegion(nativeRegion, matrix ?
matrix->nativeMatrix : NULL));
+ return SetStatus(DllExports::GdipTransformRegion(nativeRegion, matrix ?
getNat(matrix) : NULL));
}
Status
@@ -1340,15 +1355,13 @@ class Region : public GdiplusBase
Status
Union(const GraphicsPath *path)
{
- return SetStatus(
- DllExports::GdipCombineRegionPath(nativeRegion, path ? path->nativePath :
NULL, CombineModeUnion));
+ return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path ?
getNat(path) : NULL, CombineModeUnion));
}
Status
Xor(const GraphicsPath *path)
{
- return SetStatus(
- DllExports::GdipCombineRegionPath(nativeRegion, path ? path->nativePath :
NULL, CombineModeXor));
+ return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path ?
getNat(path) : NULL, CombineModeXor));
}
Status
diff --git a/sdk/include/psdk/gdipluslinecaps.h b/sdk/include/psdk/gdipluslinecaps.h
index 0a0d26bada7..d449874b5e7 100644
--- a/sdk/include/psdk/gdipluslinecaps.h
+++ b/sdk/include/psdk/gdipluslinecaps.h
@@ -27,8 +27,8 @@ inline CustomLineCap::CustomLineCap(
: nativeCap(NULL)
{
nativeCap = NULL;
- GpPath *nativeFillPath = fillPath ? fillPath->nativePath : NULL;
- GpPath *nativeStrokePath = strokePath ? strokePath->nativePath : NULL;
+ GpPath *nativeFillPath = fillPath ? getNat(fillPath) : NULL;
+ GpPath *nativeStrokePath = strokePath ? getNat(strokePath) : NULL;
lastStatus = DllExports::GdipCreateCustomLineCap(nativeFillPath, nativeStrokePath,
baseCap, baseInset, &nativeCap);
}
diff --git a/sdk/include/psdk/gdiplusmatrix.h b/sdk/include/psdk/gdiplusmatrix.h
index c822be2cd4d..124b070a9e4 100644
--- a/sdk/include/psdk/gdiplusmatrix.h
+++ b/sdk/include/psdk/gdiplusmatrix.h
@@ -70,7 +70,7 @@ class Matrix : public GdiplusBase
Equals(const Matrix *matrix)
{
BOOL result;
- SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix, matrix ?
matrix->nativeMatrix : NULL, &result));
+ SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix, matrix ? getNat(matrix) :
NULL, &result));
return result;
}
@@ -111,7 +111,7 @@ class Matrix : public GdiplusBase
Status
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)
diff --git a/sdk/include/psdk/gdipluspath.h b/sdk/include/psdk/gdipluspath.h
index a937784628c..2d2b3f3f2af 100644
--- a/sdk/include/psdk/gdipluspath.h
+++ b/sdk/include/psdk/gdipluspath.h
@@ -19,9 +19,6 @@
#ifndef _GDIPLUSPATH_H
#define _GDIPLUSPATH_H
-class FontFamily;
-class Graphics;
-
class GraphicsPath : public GdiplusBase
{
friend class Region;
@@ -233,10 +230,7 @@ class GraphicsPath : public GdiplusBase
Status
AddPath(const GraphicsPath *addingPath, BOOL connect)
{
- GpPath *nativePath2 = NULL;
- if (addingPath)
- nativePath2 = addingPath->nativePath;
-
+ GpPath *nativePath2 = addingPath ? getNat(addingPath) : NULL;
return SetStatus(DllExports::GdipAddPathPath(nativePath, nativePath2, connect));
}
@@ -383,10 +377,7 @@ class GraphicsPath : public GdiplusBase
Status
Flatten(const Matrix *matrix, REAL flatness)
{
- GpMatrix *nativeMatrix = NULL;
- if (matrix)
- nativeMatrix = matrix->nativeMatrix;
-
+ GpMatrix *nativeMatrix = matrix ? getNat(matrix) : NULL;
return SetStatus(DllExports::GdipFlattenPath(nativePath, nativeMatrix,
flatness));
}
@@ -553,10 +544,7 @@ class GraphicsPath : public GdiplusBase
WarpMode warpMode,
REAL flatness)
{
- GpMatrix *nativeMatrix = NULL;
- if (matrix)
- nativeMatrix = matrix->nativeMatrix;
-
+ GpMatrix *nativeMatrix = matrix ? getNat(matrix) : NULL;
return SetStatus(DllExports::GdipWarpPath(
nativePath, nativeMatrix, destPoints, count, srcRect.X, srcRect.Y,
srcRect.Width, srcRect.Height, warpMode,
flatness));
diff --git a/sdk/include/psdk/gdipluspen.h b/sdk/include/psdk/gdipluspen.h
index 76291aea017..58c08a4ed98 100644
--- a/sdk/include/psdk/gdipluspen.h
+++ b/sdk/include/psdk/gdipluspen.h
@@ -19,12 +19,6 @@
#ifndef _GDIPLUSPEN_H
#define _GDIPLUSPEN_H
-class CustomLineCap;
-
-// get native
-GpCustomLineCap *&
-getNat(const CustomLineCap *cap);
-
class Pen : public GdiplusBase
{
public:
@@ -33,7 +27,7 @@ class Pen : public GdiplusBase
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)
@@ -218,7 +212,7 @@ class Pen : public GdiplusBase
Status
GetTransform(Matrix *matrix)
{
- return SetStatus(DllExports::GdipGetPenTransform(nativePen,
matrix->nativeMatrix));
+ return SetStatus(DllExports::GdipGetPenTransform(nativePen, getNat(matrix)));
}
REAL
@@ -235,7 +229,7 @@ class Pen : public GdiplusBase
#if 1
return SetStatus(NotImplemented);
#else
- return SetStatus(DllExports::GdipMultiplyPenTransform(nativePen,
matrix->nativeMatrix, order));
+ return SetStatus(DllExports::GdipMultiplyPenTransform(nativePen, getNat(matrix),
order));
#endif
}
@@ -266,7 +260,7 @@ class Pen : public GdiplusBase
Status
SetBrush(const Brush *brush)
{
- GpBrush *theBrush = brush ? brush->nativeBrush : NULL;
+ GpBrush *theBrush = brush ? getNat(brush) : NULL;
return SetStatus(DllExports::GdipSetPenBrushFill(nativePen, theBrush));
}
@@ -353,7 +347,7 @@ class Pen : public GdiplusBase
Status
SetTransform(const Matrix *matrix)
{
- GpMatrix *mat = matrix ? matrix->nativeMatrix : NULL;
+ GpMatrix *mat = matrix ? getNat(matrix) : NULL;
return SetStatus(DllExports::GdipSetPenTransform(nativePen, mat));
}