summaryrefslogtreecommitdiff
path: root/xfa/fde/fde_gedevice.cpp
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/fde_gedevice.cpp
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/fde_gedevice.cpp')
-rw-r--r--xfa/fde/fde_gedevice.cpp42
1 files changed, 35 insertions, 7 deletions
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) {