aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-07-15 09:07:18 +1000
committerNeil <nyamatongwe@gmail.com>2020-07-15 09:07:18 +1000
commitb46f4cdda3df7c26dc6cc1c55173c3a1559b20f2 (patch)
treebc3eeb9f2d3772d352536ed7ccddf69cd1e915f4
parent33b62f1dba553b5c5c528fe9088d96a5c2341cdd (diff)
downloadscintilla-mirror-b46f4cdda3df7c26dc6cc1c55173c3a1559b20f2.tar.gz
Backport: Hoist common conversion code into RectangleFromPRectangle.
Backport of changeset 8405:004e2fe0cc50.
-rw-r--r--win32/PlatWin.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index a292b6728..560fa3435 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1139,6 +1139,14 @@ void SurfaceGDI::SetDBCSMode(int codePage_) {
#if defined(USE_D2D)
+namespace {
+
+constexpr D2D1_RECT_F RectangleFromPRectangle(PRectangle rc) noexcept {
+ return { rc.left, rc.top, rc.right, rc.bottom };
+}
+
+}
+
class SurfaceD2D : public Surface {
bool unicodeMode;
int x, y;
@@ -1600,7 +1608,7 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig
const HRESULT hr = pRenderTarget->CreateBitmap(size, image.data(),
width * 4, &props, &bitmap);
if (SUCCEEDED(hr)) {
- D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom};
+ const D2D1_RECT_F rcDestination = RectangleFromPRectangle(rc);
pRenderTarget->DrawBitmap(bitmap, rcDestination);
ReleaseUnknown(bitmap);
}
@@ -1630,7 +1638,7 @@ void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
ID2D1Bitmap *pBitmap = nullptr;
HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap);
if (SUCCEEDED(hr)) {
- D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom};
+ const D2D1_RECT_F rcDestination = RectangleFromPRectangle(rc);
D2D1_RECT_F rcSource = {from.x, from.y, from.x + rc.Width(), from.y + rc.Height()};
pRenderTarget->DrawBitmap(pBitmap, rcDestination, 1.0f,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, rcSource);
@@ -1649,7 +1657,7 @@ void SurfaceD2D::DrawTextCommon(PRectangle rc, const Font &font_, XYPOSITION yba
const TextWide tbuf(s, len, unicodeMode, codePageText);
if (pRenderTarget && pTextFormat && pBrush) {
if (fuOptions & ETO_CLIPPED) {
- D2D1_RECT_F rcClip = {rc.left, rc.top, rc.right, rc.bottom};
+ const D2D1_RECT_F rcClip = RectangleFromPRectangle(rc);
pRenderTarget->PushAxisAlignedClip(rcClip, D2D1_ANTIALIAS_MODE_ALIASED);
}
@@ -1841,7 +1849,7 @@ XYPOSITION SurfaceD2D::AverageCharWidth(Font &font_) {
void SurfaceD2D::SetClip(PRectangle rc) {
if (pRenderTarget) {
- D2D1_RECT_F rcClip = {rc.left, rc.top, rc.right, rc.bottom};
+ const D2D1_RECT_F rcClip = RectangleFromPRectangle(rc);
pRenderTarget->PushAxisAlignedClip(rcClip, D2D1_ANTIALIAS_MODE_ALIASED);
clipsActive++;
}