aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-03-29 18:14:57 +1100
committerNeil <nyamatongwe@gmail.com>2025-03-29 18:14:57 +1100
commitba688f069206dc113d16b97a03dc3ff78497597d (patch)
tree0398bbe861d6bf8d84c93ad96db0106d120c1656
parent9ccbd1eb1fb1c53fc7be721f98b0acb207e56723 (diff)
downloadscintilla-mirror-ba688f069206dc113d16b97a03dc3ff78497597d.tar.gz
Use constant definitions to avoid warnings.
-rw-r--r--win32/SurfaceD2D.cxx9
-rw-r--r--win32/SurfaceGDI.cxx11
2 files changed, 14 insertions, 6 deletions
diff --git a/win32/SurfaceD2D.cxx b/win32/SurfaceD2D.cxx
index 39b02fa7e..b49e5d6f6 100644
--- a/win32/SurfaceD2D.cxx
+++ b/win32/SurfaceD2D.cxx
@@ -165,7 +165,8 @@ struct FontDirectWrite : public FontWin {
ComPtr<IDWriteTextFormat> pTextFormat;
FontQuality extraFontFlag = FontQuality::QualityDefault;
CharacterSet characterSet = CharacterSet::Ansi;
- FLOAT yAscent = 2.0f;
+ static constexpr FLOAT minimalAscent = 2.0f;
+ FLOAT yAscent = minimalAscent;
FLOAT yDescent = 1.0f;
FLOAT yInternalLeading = 0.0f;
@@ -530,6 +531,8 @@ int SurfaceD2D::DeviceHeightFont(int points) {
return ::MulDiv(points, LogPixelsY(), pointsPerInch);
}
+constexpr FLOAT mitreLimit = 4.0f;
+
void SurfaceD2D::LineDraw(Point start, Point end, Stroke stroke) {
D2DPenColourAlpha(stroke.colour);
@@ -538,7 +541,7 @@ void SurfaceD2D::LineDraw(Point start, Point end, Stroke stroke) {
strokeProps.endCap = D2D1_CAP_STYLE_SQUARE;
strokeProps.dashCap = D2D1_CAP_STYLE_FLAT;
strokeProps.lineJoin = D2D1_LINE_JOIN_MITER;
- strokeProps.miterLimit = 4.0f;
+ strokeProps.miterLimit = mitreLimit;
strokeProps.dashStyle = D2D1_DASH_STYLE_SOLID;
strokeProps.dashOffset = 0;
@@ -584,7 +587,7 @@ void SurfaceD2D::PolyLine(const Point *pts, size_t npts, Stroke stroke) {
strokeProps.endCap = D2D1_CAP_STYLE_ROUND;
strokeProps.dashCap = D2D1_CAP_STYLE_FLAT;
strokeProps.lineJoin = D2D1_LINE_JOIN_MITER;
- strokeProps.miterLimit = 4.0f;
+ strokeProps.miterLimit = mitreLimit;
strokeProps.dashStyle = D2D1_DASH_STYLE_SOLID;
strokeProps.dashOffset = 0;
diff --git a/win32/SurfaceGDI.cxx b/win32/SurfaceGDI.cxx
index 9fc1ee50c..9df4deb97 100644
--- a/win32/SurfaceGDI.cxx
+++ b/win32/SurfaceGDI.cxx
@@ -431,10 +431,11 @@ void SurfaceGDI::RoundedRectangle(PRectangle rc, FillStroke fillStroke) {
PenColour(fillStroke.stroke.colour, fillStroke.stroke.width);
BrushColour(fillStroke.fill.colour);
const RECT rcw = RectFromPRectangle(rc);
+ constexpr int cornerSize = 8;
::RoundRect(hdc,
rcw.left + 1, rcw.top,
rcw.right - 1, rcw.bottom,
- 8, 8);
+ cornerSize, cornerSize);
}
// DIBSection is bitmap with some drawing operations used by SurfaceGDI.
@@ -497,11 +498,15 @@ ColourRGBA GradientValue(const std::vector<ColourStop> &stops, XYPOSITION propor
}
constexpr DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) noexcept {
- return (a << 24) | (r << 16) | (g << 8) | b;
+ constexpr int aShift = 24;
+ constexpr int rShift = 16;
+ constexpr int gShift = 8;
+ return (a << aShift) | (r << rShift) | (g << gShift) | b;
}
constexpr byte AlphaScaled(unsigned char component, unsigned int alpha) noexcept {
- return static_cast<byte>(component * alpha / 255);
+ constexpr byte maxByte = 0xFFU;
+ return (component * alpha / maxByte) & maxByte;
}
constexpr DWORD dwordMultiplied(ColourRGBA colour) noexcept {