summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-07 16:36:39 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-08 01:36:02 +0000
commitbba2a7cf30da9e84bcc14ef32dbb0bb944229219 (patch)
tree94a74de8d07b3e395bf6e08a62811a3a0d652d19 /xfa/fde
parent55e026b7b6eec17b012c819c4a7d39e63094b5c4 (diff)
downloadpdfium-bba2a7cf30da9e84bcc14ef32dbb0bb944229219.tar.xz
Update to use CFX_Rect{F} and CFX_Matrix constructors.
This Cl updates the code to use the constructors instead of creating an empty object and calling Set(). It also removes the various memsets of the CFX_Rect{F} classes. Change-Id: I6e20cec00866a38372858dcba5a30d31103172e4 Reviewed-on: https://pdfium-review.googlesource.com/2550 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_path.cpp4
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp14
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp4
-rw-r--r--xfa/fde/fde_gedevice.cpp42
-rw-r--r--xfa/fde/tto/fde_textout.cpp54
5 files changed, 69 insertions, 49 deletions
diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp
index cd65d9ee09..15d33339bf 100644
--- a/xfa/fde/cfde_path.cpp
+++ b/xfa/fde/cfde_path.cpp
@@ -255,7 +255,7 @@ void CFDE_Path::AddRectangle(const CFX_RectF& rect) {
void CFDE_Path::GetBBox(CFX_RectF& bbox) const {
CFX_FloatRect rect = m_Path.GetBoundingBox();
- bbox.Set(rect.left, rect.top, rect.Width(), rect.Height());
+ bbox = CFX_RectF(rect.left, rect.top, rect.Width(), rect.Height());
bbox.Normalize();
}
@@ -263,6 +263,6 @@ void CFDE_Path::GetBBox(CFX_RectF& bbox,
FX_FLOAT fLineWidth,
FX_FLOAT fMiterLimit) const {
CFX_FloatRect rect = m_Path.GetBoundingBox(fLineWidth, fMiterLimit);
- bbox.Set(rect.left, rect.top, rect.Width(), rect.Height());
+ bbox = CFX_RectF(rect.left, rect.top, rect.Width(), rect.Height());
bbox.Normalize();
}
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 7ef6b3ff06..a61f6ab4d9 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -69,7 +69,6 @@ CFDE_TxtEdtEngine::CFDE_TxtEdtEngine()
m_nFirstLineEnd(FDE_TXTEDIT_LINEEND_Auto),
m_bAutoLineEnd(true),
m_wLineEnd(kUnicodeParagraphSeparator) {
- FXSYS_memset(&m_rtCaret, 0, sizeof(CFX_RectF));
m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto);
}
@@ -663,14 +662,14 @@ int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) {
void CFDE_TxtEdtEngine::EndLayout() {
UpdatePages();
int32_t nLength = GetTextLength();
- if (m_nCaret > nLength) {
+ if (m_nCaret > nLength)
m_nCaret = nLength;
- }
+
int32_t nIndex = m_nCaret;
- if (!m_bBefore) {
+ if (!m_bBefore)
nIndex--;
- }
- m_rtCaret.Set(0, 0, 1, m_Param.fFontSize);
+
+ m_rtCaret = CFX_RectF(0, 0, 1, m_Param.fFontSize);
Unlock();
}
@@ -1381,12 +1380,11 @@ bool CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
pTextOut->SetLineSpace(m_Param.fLineSpace);
pTextOut->SetFont(m_Param.pFont);
pTextOut->SetFontSize(m_Param.fFontSize);
- CFX_RectF rcText;
- FXSYS_memset(&rcText, 0, sizeof(rcText));
uint32_t dwStyle = 0;
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines))
dwStyle |= FDE_TTOSTYLE_SingleLine;
+ CFX_RectF rcText;
if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) {
dwStyle |= FDE_TTOSTYLE_LineWrap;
rcText.width = m_Param.fPlateWidth;
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index a049548269..cfb7f83b2c 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -39,10 +39,6 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
m_nCharCount(0),
m_nPageIndex(nPageIndex),
m_bLoaded(false) {
- FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF));
- FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF));
- FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF));
- FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF));
}
CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index b5220cdf13..8b5ef1c40e 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -24,29 +24,36 @@ CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice,
ASSERT(pDevice);
FX_RECT rt = m_pDevice->GetClipBox();
- m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(),
- (FX_FLOAT)rt.Height());
+ m_rtClip = CFX_RectF(
+ static_cast<FX_FLOAT>(rt.left), static_cast<FX_FLOAT>(rt.top),
+ static_cast<FX_FLOAT>(rt.Width()), static_cast<FX_FLOAT>(rt.Height()));
}
CFDE_RenderDevice::~CFDE_RenderDevice() {
if (m_bOwnerDevice)
delete m_pDevice;
}
+
int32_t CFDE_RenderDevice::GetWidth() const {
return m_pDevice->GetWidth();
}
+
int32_t CFDE_RenderDevice::GetHeight() const {
return m_pDevice->GetHeight();
}
+
void CFDE_RenderDevice::SaveState() {
m_pDevice->SaveState();
}
+
void CFDE_RenderDevice::RestoreState() {
m_pDevice->RestoreState(false);
const FX_RECT& rt = m_pDevice->GetClipBox();
- m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(),
- (FX_FLOAT)rt.Height());
+ m_rtClip = CFX_RectF(
+ static_cast<FX_FLOAT>(rt.left), static_cast<FX_FLOAT>(rt.top),
+ static_cast<FX_FLOAT>(rt.Width()), static_cast<FX_FLOAT>(rt.Height()));
}
+
bool CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) {
m_rtClip = rtClip;
return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left),
@@ -54,21 +61,27 @@ bool CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) {
(int32_t)FXSYS_ceil(rtClip.right()),
(int32_t)FXSYS_ceil(rtClip.bottom())));
}
+
const CFX_RectF& CFDE_RenderDevice::GetClipRect() {
return m_rtClip;
}
+
bool CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) {
return false;
}
+
CFDE_Path* CFDE_RenderDevice::GetClipPath() const {
return nullptr;
}
+
FX_FLOAT CFDE_RenderDevice::GetDpiX() const {
return 96;
}
+
FX_FLOAT CFDE_RenderDevice::GetDpiY() const {
return 96;
}
+
bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib,
const CFX_RectF* pSrcRect,
const CFX_RectF& dstRect,
@@ -78,11 +91,13 @@ bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib,
if (pSrcRect) {
srcRect = *pSrcRect;
} else {
- srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight());
+ srcRect = CFX_RectF(0, 0, static_cast<FX_FLOAT>(pDib->GetWidth()),
+ static_cast<FX_FLOAT>(pDib->GetHeight()));
}
- if (srcRect.IsEmpty()) {
+
+ if (srcRect.IsEmpty())
return false;
- }
+
CFX_Matrix dib2fxdev;
if (pImgMatrix) {
dib2fxdev = *pImgMatrix;
@@ -104,6 +119,7 @@ bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib,
m_pDevice->CancelDIBits(handle);
return !!handle;
}
+
bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
const CFX_RetainPtr<CFGAS_GEFont>& pFont,
const FXTEXT_CHARPOS* pCharPos,
@@ -207,6 +223,7 @@ bool CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen,
path.AddBezier(points);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
+
bool CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
const std::vector<CFX_PointF>& points,
@@ -217,6 +234,7 @@ bool CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen,
path.AddCurve(points, bClosed, fTension);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
+
bool CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
const CFX_RectF& rect,
@@ -225,6 +243,7 @@ bool CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen,
path.AddEllipse(rect);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
+
bool CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
const std::vector<CFX_PointF>& points,
@@ -233,6 +252,7 @@ bool CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen,
path.AddLines(points);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
+
bool CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
const CFX_PointF& pt1,
@@ -242,6 +262,7 @@ bool CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen,
path.AddLine(pt1, pt2);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
+
bool CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
const CFDE_Path* pPath,
@@ -257,6 +278,7 @@ bool CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen,
return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix,
&graphState, 0, pPen->GetColor(), 0);
}
+
bool CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
const std::vector<CFX_PointF>& points,
@@ -265,6 +287,7 @@ bool CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen,
path.AddPolygon(points);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
+
bool CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
const CFX_RectF& rect,
@@ -273,6 +296,7 @@ bool CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen,
path.AddRectangle(rect);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
+
bool CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush,
const std::vector<CFX_PointF>& points,
FX_FLOAT fTension,
@@ -281,6 +305,7 @@ bool CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush,
path.AddCurve(points, true, fTension);
return FillPath(pBrush, &path, pMatrix);
}
+
bool CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush,
const CFX_RectF& rect,
const CFX_Matrix* pMatrix) {
@@ -288,6 +313,7 @@ bool CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush,
path.AddEllipse(rect);
return FillPath(pBrush, &path, pMatrix);
}
+
bool CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush,
const std::vector<CFX_PointF>& points,
const CFX_Matrix* pMatrix) {
@@ -295,6 +321,7 @@ bool CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush,
path.AddPolygon(points);
return FillPath(pBrush, &path, pMatrix);
}
+
bool CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush,
const CFX_RectF& rect,
const CFX_Matrix* pMatrix) {
@@ -302,6 +329,7 @@ bool CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush,
path.AddRectangle(rect);
return FillPath(pBrush, &path, pMatrix);
}
+
bool CFDE_RenderDevice::CreatePen(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
CFX_GraphStateData& graphState) {
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index ca5aa566e1..b126d4e583 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -138,8 +138,10 @@ void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
}
void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
- m_rtClip.Set((FX_FLOAT)rtClip.left, (FX_FLOAT)rtClip.top,
- (FX_FLOAT)rtClip.Width(), (FX_FLOAT)rtClip.Height());
+ m_rtClip = CFX_RectF(static_cast<FX_FLOAT>(rtClip.left),
+ static_cast<FX_FLOAT>(rtClip.top),
+ static_cast<FX_FLOAT>(rtClip.Width()),
+ static_cast<FX_FLOAT>(rtClip.Height()));
}
void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) {
@@ -166,8 +168,8 @@ int32_t CFDE_TextOut::GetTotalLines() {
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_Size& size) {
- CFX_RectF rtText;
- rtText.Set(0.0f, 0.0f, (FX_FLOAT)size.x, (FX_FLOAT)size.y);
+ CFX_RectF rtText(0.0f, 0.0f, static_cast<FX_FLOAT>(size.x),
+ static_cast<FX_FLOAT>(size.y));
CalcSize(pwsStr, iLength, rtText);
size.x = (int32_t)rtText.Width();
size.y = (int32_t)rtText.Height();
@@ -176,8 +178,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_SizeF& size) {
- CFX_RectF rtText;
- rtText.Set(0.0f, 0.0f, size.x, size.y);
+ CFX_RectF rtText(0.0f, 0.0f, size.x, size.y);
CalcSize(pwsStr, iLength, rtText);
size.x = rtText.Width();
size.y = rtText.Height();
@@ -186,12 +187,15 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_Rect& rect) {
- CFX_RectF rtText;
- rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.Width(),
- (FX_FLOAT)rect.Height());
+ CFX_RectF rtText(static_cast<FX_FLOAT>(rect.left),
+ static_cast<FX_FLOAT>(rect.top),
+ static_cast<FX_FLOAT>(rect.Width()),
+ static_cast<FX_FLOAT>(rect.Height()));
CalcSize(pwsStr, iLength, rtText);
- rect.Set((int32_t)rtText.left, (int32_t)rtText.top, (int32_t)rtText.Width(),
- (int32_t)rtText.Height());
+ rect = CFX_Rect(static_cast<int32_t>(rtText.left),
+ static_cast<int32_t>(rtText.top),
+ static_cast<int32_t>(rtText.Width()),
+ static_cast<int32_t>(rtText.Height()));
}
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
@@ -212,8 +216,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_SizeF& size) {
- CFX_RectF rtText;
- rtText.Set(0.0f, 0.0f, size.x, size.y);
+ CFX_RectF rtText(0.0f, 0.0f, size.x, size.y);
CalcLogicSize(pwsStr, iLength, rtText);
size.x = rtText.Width();
size.y = rtText.Height();
@@ -346,9 +349,8 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
int32_t x,
int32_t y) {
- CFX_RectF rtText;
- rtText.Set((FX_FLOAT)x, (FX_FLOAT)y, m_fFontSize * 1000.0f,
- m_fFontSize * 1000.0f);
+ CFX_RectF rtText(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y),
+ m_fFontSize * 1000.0f, m_fFontSize * 1000.0f);
DrawText(pwsStr, iLength, rtText);
}
@@ -356,25 +358,23 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
FX_FLOAT x,
FX_FLOAT y) {
- CFX_RectF rtText;
- rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f);
+ CFX_RectF rtText(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f);
DrawText(pwsStr, iLength, rtText);
}
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_Rect& rect) {
- CFX_RectF rtText;
- rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.width,
- (FX_FLOAT)rect.height);
+ CFX_RectF rtText(
+ static_cast<FX_FLOAT>(rect.left), static_cast<FX_FLOAT>(rect.top),
+ static_cast<FX_FLOAT>(rect.width), static_cast<FX_FLOAT>(rect.height));
DrawText(pwsStr, iLength, rtText);
}
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_RectF& rect) {
- CFX_RectF rtText;
- rtText.Set(rect.left, rect.top, rect.width, rect.height);
+ CFX_RectF rtText(rect.left, rect.top, rect.width, rect.height);
CFX_Matrix rm;
rm.SetReverse(m_Matrix);
rm.TransformRect(rtText);
@@ -385,17 +385,15 @@ void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr,
int32_t iLength,
FX_FLOAT x,
FX_FLOAT y) {
- CFX_RectF rtText;
- rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f);
+ CFX_RectF rtText(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f);
DrawLogicText(pwsStr, iLength, rtText);
}
void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_RectF& rect) {
- CFX_RectF rtClip;
- rtClip.Set(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width,
- m_rtLogicClip.height);
+ CFX_RectF rtClip(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width,
+ m_rtLogicClip.height);
m_Matrix.TransformRect(rtClip);
DrawText(pwsStr, iLength, rect, rtClip);
}