aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2019-03-25 11:00:39 +1100
committerNeil <nyamatongwe@gmail.com>2019-03-25 11:00:39 +1100
commit1cf755b51cc643240f60131a8fac5e990cfa5e9f (patch)
tree1a1a8d12e390942dc456b6df0d64d51701c1b9af /win32/PlatWin.cxx
parent5344ef2aee7eaca738b0bddab8d9025bf49f1137 (diff)
downloadscintilla-mirror-1cf755b51cc643240f60131a8fac5e990cfa5e9f.tar.gz
Use generic versions of ceil, floor, round, lround, trunc from <cmath>.
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r--win32/PlatWin.cxx30
1 files changed, 15 insertions, 15 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 766c91ef9..229b4d2e6 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -278,7 +278,7 @@ constexpr D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) noexc
void SetLogFont(LOGFONTW &lf, const char *faceName, int characterSet, float size, int weight, bool italic, int extraFontFlag) {
lf = LOGFONTW();
// The negative is to allow for leading
- lf.lfHeight = -(abs(lround(size)));
+ lf.lfHeight = -(abs(std::lround(size)));
lf.lfWeight = weight;
lf.lfItalic = italic ? 1 : 0;
lf.lfCharSet = static_cast<BYTE>(characterSet);
@@ -749,10 +749,10 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig
if (rc.Width() > 0) {
HDC hMemDC = ::CreateCompatibleDC(hdc);
if (rc.Width() > width)
- rc.left += floor((rc.Width() - width) / 2);
+ rc.left += std::floor((rc.Width() - width) / 2);
rc.right = rc.left + width;
if (rc.Height() > height)
- rc.top += floor((rc.Height() - height) / 2);
+ rc.top += std::floor((rc.Height() - height) / 2);
rc.bottom = rc.top + height;
const BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0},
@@ -1282,7 +1282,7 @@ void SurfaceD2D::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesi
void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
if (pRenderTarget) {
- const D2D1_RECT_F rectangle1 = D2D1::RectF(round(rc.left) + 0.5f, rc.top+0.5f, round(rc.right) - 0.5f, rc.bottom-0.5f);
+ const D2D1_RECT_F rectangle1 = D2D1::RectF(std::round(rc.left) + 0.5f, rc.top+0.5f, std::round(rc.right) - 0.5f, rc.bottom-0.5f);
D2DPenColour(back);
pRenderTarget->FillRectangle(&rectangle1, pBrush);
D2DPenColour(fore);
@@ -1293,7 +1293,7 @@ void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired
void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) {
if (pRenderTarget) {
D2DPenColour(back);
- const D2D1_RECT_F rectangle1 = D2D1::RectF(round(rc.left), rc.top, round(rc.right), rc.bottom);
+ const D2D1_RECT_F rectangle1 = D2D1::RectF(std::round(rc.left), rc.top, std::round(rc.right), rc.bottom);
pRenderTarget->FillRectangle(&rectangle1, pBrush);
}
}
@@ -1343,23 +1343,23 @@ void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil
if (pRenderTarget) {
if (cornerSize == 0) {
// When corner size is zero, draw square rectangle to prevent blurry pixels at corners
- const D2D1_RECT_F rectFill = D2D1::RectF(round(rc.left) + 1.0f, rc.top + 1.0f, round(rc.right) - 1.0f, rc.bottom - 1.0f);
+ const D2D1_RECT_F rectFill = D2D1::RectF(std::round(rc.left) + 1.0f, rc.top + 1.0f, std::round(rc.right) - 1.0f, rc.bottom - 1.0f);
D2DPenColour(fill, alphaFill);
pRenderTarget->FillRectangle(rectFill, pBrush);
- const D2D1_RECT_F rectOutline = D2D1::RectF(round(rc.left) + 0.5f, rc.top + 0.5f, round(rc.right) - 0.5f, rc.bottom - 0.5f);
+ const D2D1_RECT_F rectOutline = D2D1::RectF(std::round(rc.left) + 0.5f, rc.top + 0.5f, std::round(rc.right) - 0.5f, rc.bottom - 0.5f);
D2DPenColour(outline, alphaOutline);
pRenderTarget->DrawRectangle(rectOutline, pBrush);
} else {
const float cornerSizeF = static_cast<float>(cornerSize);
D2D1_ROUNDED_RECT roundedRectFill = {
- D2D1::RectF(round(rc.left) + 1.0f, rc.top + 1.0f, round(rc.right) - 1.0f, rc.bottom - 1.0f),
+ D2D1::RectF(std::round(rc.left) + 1.0f, rc.top + 1.0f, std::round(rc.right) - 1.0f, rc.bottom - 1.0f),
cornerSizeF, cornerSizeF};
D2DPenColour(fill, alphaFill);
pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush);
D2D1_ROUNDED_RECT roundedRect = {
- D2D1::RectF(round(rc.left) + 0.5f, rc.top + 0.5f, round(rc.right) - 0.5f, rc.bottom - 0.5f),
+ D2D1::RectF(std::round(rc.left) + 0.5f, rc.top + 0.5f, std::round(rc.right) - 0.5f, rc.bottom - 0.5f),
cornerSizeF, cornerSizeF};
D2DPenColour(outline, alphaOutline);
pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush);
@@ -1408,7 +1408,7 @@ void SurfaceD2D::GradientRectangle(PRectangle rc, const std::vector<ColourStop>
hr = pRenderTarget->CreateLinearGradientBrush(
lgbp, pGradientStops, &pBrushLinear);
if (SUCCEEDED(hr)) {
- const D2D1_RECT_F rectangle = D2D1::RectF(round(rc.left), rc.top, round(rc.right), rc.bottom);
+ const D2D1_RECT_F rectangle = D2D1::RectF(std::round(rc.left), rc.top, std::round(rc.right), rc.bottom);
pRenderTarget->FillRectangle(&rectangle, pBrushLinear);
pBrushLinear->Release();
}
@@ -1419,10 +1419,10 @@ void SurfaceD2D::GradientRectangle(PRectangle rc, const std::vector<ColourStop>
void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {
if (pRenderTarget) {
if (rc.Width() > width)
- rc.left += floor((rc.Width() - width) / 2);
+ rc.left += std::floor((rc.Width() - width) / 2);
rc.right = rc.left + width;
if (rc.Height() > height)
- rc.top += floor((rc.Height() - height) / 2);
+ rc.top += std::floor((rc.Height() - height) / 2);
rc.bottom = rc.top + height;
std::vector<unsigned char> image(height * width * 4);
@@ -2037,17 +2037,17 @@ void SurfaceD2D::MeasureWidths(Font &font_, std::string_view text, XYPOSITION *p
XYPOSITION SurfaceD2D::Ascent(Font &font_) {
SetFont(font_);
- return ceil(yAscent);
+ return std::ceil(yAscent);
}
XYPOSITION SurfaceD2D::Descent(Font &font_) {
SetFont(font_);
- return ceil(yDescent);
+ return std::ceil(yDescent);
}
XYPOSITION SurfaceD2D::InternalLeading(Font &font_) {
SetFont(font_);
- return floor(yInternalLeading);
+ return std::floor(yInternalLeading);
}
XYPOSITION SurfaceD2D::Height(Font &font_) {