From a5c1323ae6a2379fb5fe3ddea4c223fccd0c41b0 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 12 Apr 2016 13:19:36 -0700 Subject: Remove IFDE_Pen and IFDE_Brush. This Cl removes the two interfaces and renames CFDE_SolidBrush to CFDE_Brush. Uncalled methods are removed from both CFDE_Brush and CFDE_Pen and code simplified to match. BUG=pdfium:468 Review URL: https://codereview.chromium.org/1881803003 --- BUILD.gn | 2 - core/fxge/include/fx_ge.h | 3 - xfa.gyp | 2 - xfa/fde/fde_brush.h | 38 ------- xfa/fde/fde_gedevice.cpp | 235 ++++++++++++++++------------------------ xfa/fde/fde_gedevice.h | 37 +++---- xfa/fde/fde_object.h | 102 ++--------------- xfa/fde/fde_pen.h | 65 ----------- xfa/fde/fde_render.cpp | 125 ++++++++++----------- xfa/fde/fde_renderdevice.h | 32 +++--- xfa/fde/fde_visualset.h | 7 +- xfa/fde/tto/fde_textout.cpp | 18 +-- xfa/fxfa/app/xfa_textlayout.cpp | 13 +-- xfa/fxfa/app/xfa_textlayout.h | 5 +- 14 files changed, 219 insertions(+), 465 deletions(-) delete mode 100644 xfa/fde/fde_brush.h delete mode 100644 xfa/fde/fde_pen.h diff --git a/BUILD.gn b/BUILD.gn index 81e43a15e7..49adca56a8 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -917,7 +917,6 @@ if (pdf_enable_xfa) { "xfa/fde/css/fde_cssstylesheet.h", "xfa/fde/css/fde_csssyntax.cpp", "xfa/fde/css/fde_csssyntax.h", - "xfa/fde/fde_brush.h", "xfa/fde/fde_gedevice.cpp", "xfa/fde/fde_gedevice.h", "xfa/fde/fde_geobject.cpp", @@ -927,7 +926,6 @@ if (pdf_enable_xfa) { "xfa/fde/fde_iterator.h", "xfa/fde/fde_object.h", "xfa/fde/fde_path.h", - "xfa/fde/fde_pen.h", "xfa/fde/fde_render.cpp", "xfa/fde/fde_render.h", "xfa/fde/fde_renderdevice.h", diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h index 2a3a0253a3..9818d185ee 100644 --- a/core/fxge/include/fx_ge.h +++ b/core/fxge/include/fx_ge.h @@ -170,13 +170,10 @@ class CFX_PathData { class CFX_GraphStateData { public: CFX_GraphStateData(); - CFX_GraphStateData(const CFX_GraphStateData& src); - ~CFX_GraphStateData(); void Copy(const CFX_GraphStateData& src); - void SetDashCount(int count); typedef enum { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 } LineCap; diff --git a/xfa.gyp b/xfa.gyp index cb3893a854..b15f41cd88 100644 --- a/xfa.gyp +++ b/xfa.gyp @@ -61,7 +61,6 @@ "xfa/fde/css/fde_cssstylesheet.h", "xfa/fde/css/fde_csssyntax.cpp", "xfa/fde/css/fde_csssyntax.h", - "xfa/fde/fde_brush.h", "xfa/fde/fde_renderdevice.h", "xfa/fde/fde_gedevice.cpp", "xfa/fde/fde_gedevice.h", @@ -72,7 +71,6 @@ "xfa/fde/fde_iterator.h", "xfa/fde/fde_object.h", "xfa/fde/fde_path.h", - "xfa/fde/fde_pen.h", "xfa/fde/fde_render.cpp", "xfa/fde/fde_render.h", "xfa/fde/tto/fde_textout.cpp", diff --git a/xfa/fde/fde_brush.h b/xfa/fde/fde_brush.h deleted file mode 100644 index a9e99b0cd6..0000000000 --- a/xfa/fde/fde_brush.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_FDE_BRUSH_H_ -#define XFA_FDE_FDE_BRUSH_H_ - -#include "core/fxcrt/include/fx_system.h" -#include "core/fxge/include/fx_dib.h" - -#define FDE_BRUSHTYPE_Unknown -1 -#define FDE_BRUSHTYPE_Solid 0 -#define FDE_BRUSHTYPE_MAX 0 - -class IFDE_Brush { - public: - static IFDE_Brush* Create(int32_t iType); - virtual ~IFDE_Brush() {} - virtual void Release() = 0; - virtual int32_t GetType() const = 0; -}; - -class IFDE_SolidBrush : public IFDE_Brush { - public: - virtual FX_ARGB GetColor() const = 0; - virtual void SetColor(FX_ARGB color) = 0; - virtual const CFX_Matrix& GetMatrix() const = 0; - virtual void ResetMatrix() = 0; - virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) = 0; - virtual void RotateMatrix(FX_FLOAT fRadian) = 0; - virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) = 0; - virtual void ConcatMatrix(const CFX_Matrix& matrix) = 0; - virtual void SetMatrix(const CFX_Matrix& matrix) = 0; -}; - -#endif // XFA_FDE_FDE_BRUSH_H_ diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp index 28bf889e1f..e289ef9ec2 100644 --- a/xfa/fde/fde_gedevice.cpp +++ b/xfa/fde/fde_gedevice.cpp @@ -8,11 +8,9 @@ #include -#include "xfa/fde/fde_brush.h" #include "xfa/fde/fde_geobject.h" #include "xfa/fde/fde_image.h" #include "xfa/fde/fde_object.h" -#include "xfa/fde/fde_pen.h" IFDE_RenderDevice* IFDE_RenderDevice::Create(CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder) { @@ -116,7 +114,7 @@ FX_BOOL CFDE_FxgeDevice::DrawImage(CFX_DIBSource* pDib, m_pDevice->CancelDIBits(handle); return handle != NULL; } -FX_BOOL CFDE_FxgeDevice::DrawString(IFDE_Brush* pBrush, +FX_BOOL CFDE_FxgeDevice::DrawString(CFDE_Brush* pBrush, IFX_Font* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, @@ -126,89 +124,91 @@ FX_BOOL CFDE_FxgeDevice::DrawString(IFDE_Brush* pBrush, iCount > 0); CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache(); CFX_Font* pFxFont = (CFX_Font*)pFont->GetDevFont(); - switch (pBrush->GetType()) { - case FDE_BRUSHTYPE_Solid: { - FX_ARGB argb = ((IFDE_SolidBrush*)pBrush)->GetColor(); - if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && - !pFxFont->IsItalic()) { - FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; - FX_FLOAT* pAM; - for (int32_t i = 0; i < iCount; ++i) { - static const FX_FLOAT mc = 0.267949f; - pAM = pCP->m_AdjustMatrix; - pAM[2] = mc * pAM[0] + pAM[2]; - pAM[3] = mc * pAM[1] + pAM[3]; - pCP++; - } - } - FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; - IFX_Font* pCurFont = NULL; - IFX_Font* pSTFont = NULL; - FXTEXT_CHARPOS* pCurCP = NULL; - int32_t iCurCount = 0; -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - uint32_t dwFontStyle = pFont->GetFontStyles(); - CFX_Font FxFont; - CFX_SubstFont SubstFxFont; - FxFont.SetSubstFont(&SubstFxFont); - SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400; - SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; - SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0; - SubstFxFont.m_bItlicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic); -#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - for (int32_t i = 0; i < iCount; ++i) { - pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex); - pCP->m_GlyphIndex &= 0x00FFFFFF; - pCP->m_bFontStyle = FALSE; - if (pCurFont != pSTFont) { - if (pCurFont != NULL) { - pFxFont = (CFX_Font*)pCurFont->GetDevFont(); + + FX_ARGB argb = pBrush->GetColor(); + if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && + !pFxFont->IsItalic()) { + FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; + FX_FLOAT* pAM; + for (int32_t i = 0; i < iCount; ++i) { + static const FX_FLOAT mc = 0.267949f; + pAM = pCP->m_AdjustMatrix; + pAM[2] = mc * pAM[0] + pAM[2]; + pAM[3] = mc * pAM[1] + pAM[3]; + pCP++; + } + } + FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; + IFX_Font* pCurFont = NULL; + IFX_Font* pSTFont = NULL; + FXTEXT_CHARPOS* pCurCP = NULL; + int32_t iCurCount = 0; + #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - FxFont.SetFace(pFxFont->GetFace()); - m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache, - -fFontSize, (const CFX_Matrix*)pMatrix, - argb, FXTEXT_CLEARTYPE); -#else - m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, - -fFontSize, (const CFX_Matrix*)pMatrix, - argb, FXTEXT_CLEARTYPE); + uint32_t dwFontStyle = pFont->GetFontStyles(); + CFX_Font FxFont; + CFX_SubstFont SubstFxFont; + FxFont.SetSubstFont(&SubstFxFont); + SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400; + SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; + SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0; + SubstFxFont.m_bItlicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic); #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - } - pCurFont = pSTFont; - pCurCP = pCP; - iCurCount = 1; - } else { - iCurCount++; - } - pCP++; - } - if (pCurFont != NULL && iCurCount) { + + for (int32_t i = 0; i < iCount; ++i) { + pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex); + pCP->m_GlyphIndex &= 0x00FFFFFF; + pCP->m_bFontStyle = FALSE; + if (pCurFont != pSTFont) { + if (pCurFont != NULL) { pFxFont = (CFX_Font*)pCurFont->GetDevFont(); + #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ FxFont.SetFace(pFxFont->GetFace()); - FX_BOOL bRet = m_pDevice->DrawNormalText( - iCurCount, pCurCP, &FxFont, pCache, -fFontSize, - (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE); - FxFont.SetSubstFont(nullptr); - FxFont.SetFace(nullptr); - return bRet; + m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache, + -fFontSize, (const CFX_Matrix*)pMatrix, argb, + FXTEXT_CLEARTYPE); #else - return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, - -fFontSize, (const CFX_Matrix*)pMatrix, - argb, FXTEXT_CLEARTYPE); + m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, + -fFontSize, (const CFX_Matrix*)pMatrix, argb, + FXTEXT_CLEARTYPE); #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ } + pCurFont = pSTFont; + pCurCP = pCP; + iCurCount = 1; + } else { + iCurCount++; + } + pCP++; + } + if (pCurFont != NULL && iCurCount) { + pFxFont = (CFX_Font*)pCurFont->GetDevFont(); + #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - FxFont.SetSubstFont(nullptr); - FxFont.SetFace(nullptr); + FxFont.SetFace(pFxFont->GetFace()); + FX_BOOL bRet = m_pDevice->DrawNormalText( + iCurCount, pCurCP, &FxFont, pCache, -fFontSize, + (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE); + FxFont.SetSubstFont(nullptr); + FxFont.SetFace(nullptr); + return bRet; +#else + return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, + -fFontSize, (const CFX_Matrix*)pMatrix, + argb, FXTEXT_CLEARTYPE); #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - return TRUE; - } break; - default: - return FALSE; } + +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + FxFont.SetSubstFont(nullptr); + FxFont.SetFace(nullptr); +#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + + return TRUE; } -FX_BOOL CFDE_FxgeDevice::DrawBezier(IFDE_Pen* pPen, + +FX_BOOL CFDE_FxgeDevice::DrawBezier(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, @@ -224,7 +224,7 @@ FX_BOOL CFDE_FxgeDevice::DrawBezier(IFDE_Pen* pPen, path.AddBezier(points); return DrawPath(pPen, fPenWidth, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::DrawCurve(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::DrawCurve(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, FX_BOOL bClosed, @@ -234,7 +234,7 @@ FX_BOOL CFDE_FxgeDevice::DrawCurve(IFDE_Pen* pPen, path.AddCurve(points, bClosed, fTension); return DrawPath(pPen, fPenWidth, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::DrawEllipse(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::DrawEllipse(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { @@ -242,7 +242,7 @@ FX_BOOL CFDE_FxgeDevice::DrawEllipse(IFDE_Pen* pPen, path.AddEllipse(rect); return DrawPath(pPen, fPenWidth, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::DrawLines(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::DrawLines(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, const CFX_Matrix* pMatrix) { @@ -250,7 +250,7 @@ FX_BOOL CFDE_FxgeDevice::DrawLines(IFDE_Pen* pPen, path.AddLines(points); return DrawPath(pPen, fPenWidth, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::DrawLine(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::DrawLine(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, @@ -259,7 +259,7 @@ FX_BOOL CFDE_FxgeDevice::DrawLine(IFDE_Pen* pPen, path.AddLine(pt1, pt2); return DrawPath(pPen, fPenWidth, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::DrawPath(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::DrawPath(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const IFDE_Path* pPath, const CFX_Matrix* pMatrix) { @@ -274,7 +274,7 @@ FX_BOOL CFDE_FxgeDevice::DrawPath(IFDE_Pen* pPen, return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix, &graphState, 0, pPen->GetColor(), 0); } -FX_BOOL CFDE_FxgeDevice::DrawPolygon(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::DrawPolygon(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, const CFX_Matrix* pMatrix) { @@ -282,7 +282,7 @@ FX_BOOL CFDE_FxgeDevice::DrawPolygon(IFDE_Pen* pPen, path.AddPolygon(points); return DrawPath(pPen, fPenWidth, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::DrawRectangle(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::DrawRectangle(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { @@ -290,7 +290,7 @@ FX_BOOL CFDE_FxgeDevice::DrawRectangle(IFDE_Pen* pPen, path.AddRectangle(rect); return DrawPath(pPen, fPenWidth, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::FillClosedCurve(IFDE_Brush* pBrush, +FX_BOOL CFDE_FxgeDevice::FillClosedCurve(CFDE_Brush* pBrush, const CFX_PointsF& points, FX_FLOAT fTension, const CFX_Matrix* pMatrix) { @@ -298,95 +298,50 @@ FX_BOOL CFDE_FxgeDevice::FillClosedCurve(IFDE_Brush* pBrush, path.AddCurve(points, TRUE, fTension); return FillPath(pBrush, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::FillEllipse(IFDE_Brush* pBrush, +FX_BOOL CFDE_FxgeDevice::FillEllipse(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddEllipse(rect); return FillPath(pBrush, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::FillPolygon(IFDE_Brush* pBrush, +FX_BOOL CFDE_FxgeDevice::FillPolygon(CFDE_Brush* pBrush, const CFX_PointsF& points, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddPolygon(points); return FillPath(pBrush, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::FillRectangle(IFDE_Brush* pBrush, +FX_BOOL CFDE_FxgeDevice::FillRectangle(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddRectangle(rect); return FillPath(pBrush, &path, pMatrix); } -FX_BOOL CFDE_FxgeDevice::CreatePen(IFDE_Pen* pPen, +FX_BOOL CFDE_FxgeDevice::CreatePen(CFDE_Pen* pPen, FX_FLOAT fPenWidth, CFX_GraphStateData& graphState) { - if (pPen == NULL) { + if (!pPen) return FALSE; - } - graphState.m_LineCap = (CFX_GraphStateData::LineCap)pPen->GetLineCap(); - graphState.m_LineJoin = (CFX_GraphStateData::LineJoin)pPen->GetLineJoin(); + + graphState.m_LineCap = CFX_GraphStateData::LineCapButt; + graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter; graphState.m_LineWidth = fPenWidth; - graphState.m_MiterLimit = pPen->GetMiterLimit(); - graphState.m_DashPhase = pPen->GetDashPhase(); - CFX_FloatArray dashArray; - switch (pPen->GetDashStyle()) { - case FDE_DASHSTYLE_Dash: - dashArray.Add(3); - dashArray.Add(1); - break; - case FDE_DASHSTYLE_Dot: - dashArray.Add(1); - dashArray.Add(1); - break; - case FDE_DASHSTYLE_DashDot: - dashArray.Add(3); - dashArray.Add(1); - dashArray.Add(1); - dashArray.Add(1); - break; - case FDE_DASHSTYLE_DashDotDot: - dashArray.Add(3); - dashArray.Add(1); - dashArray.Add(1); - dashArray.Add(1); - dashArray.Add(1); - dashArray.Add(1); - break; - case FDE_DASHSTYLE_Customized: - pPen->GetDashArray(dashArray); - break; - } - int32_t iDashCount = dashArray.GetSize(); - if (iDashCount > 0) { - graphState.SetDashCount(iDashCount); - for (int32_t i = 0; i < iDashCount; ++i) { - graphState.m_DashArray[i] = dashArray[i] * fPenWidth; - } - } + graphState.m_MiterLimit = 10; + graphState.m_DashPhase = 0; return TRUE; } -FX_BOOL CFDE_FxgeDevice::FillPath(IFDE_Brush* pBrush, +FX_BOOL CFDE_FxgeDevice::FillPath(CFDE_Brush* pBrush, const IFDE_Path* pPath, const CFX_Matrix* pMatrix) { CFDE_Path* pGePath = (CFDE_Path*)pPath; if (!pGePath) return FALSE; - if (!pBrush) return FALSE; - - return FillSolidPath(pBrush, &pGePath->m_Path, pMatrix); + return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, + pBrush->GetColor(), 0, FXFILL_WINDING); } -FX_BOOL CFDE_FxgeDevice::FillSolidPath(IFDE_Brush* pBrush, - const CFX_PathData* pPath, - const CFX_Matrix* pMatrix) { - FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Solid); - - IFDE_SolidBrush* pSolidBrush = static_cast(pBrush); - return m_pDevice->DrawPath(pPath, (const CFX_Matrix*)pMatrix, NULL, - pSolidBrush->GetColor(), 0, FXFILL_WINDING); -} diff --git a/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h index c497b1c3b5..4d43ea0ef5 100644 --- a/xfa/fde/fde_gedevice.h +++ b/xfa/fde/fde_gedevice.h @@ -33,77 +33,74 @@ class CFDE_FxgeDevice : public IFDE_RenderDevice, public CFX_Target { const CFX_RectF& dstRect, const CFX_Matrix* pImgMatrix = NULL, const CFX_Matrix* pDevMatrix = NULL); - virtual FX_BOOL DrawString(IFDE_Brush* pBrush, + virtual FX_BOOL DrawString(CFDE_Brush* pBrush, IFX_Font* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, FX_FLOAT fFontSize, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawBezier(IFDE_Pen* pPen, + virtual FX_BOOL DrawBezier(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, const CFX_PointF& pt3, const CFX_PointF& pt4, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawCurve(IFDE_Pen* pPen, + virtual FX_BOOL DrawCurve(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, FX_BOOL bClosed, FX_FLOAT fTension = 0.5f, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawEllipse(IFDE_Pen* pPen, + virtual FX_BOOL DrawEllipse(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawLines(IFDE_Pen* pPen, + virtual FX_BOOL DrawLines(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawLine(IFDE_Pen* pPen, + virtual FX_BOOL DrawLine(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawPath(IFDE_Pen* pPen, + virtual FX_BOOL DrawPath(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const IFDE_Path* pPath, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawPolygon(IFDE_Pen* pPen, + virtual FX_BOOL DrawPolygon(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL DrawRectangle(IFDE_Pen* pPen, + virtual FX_BOOL DrawRectangle(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL FillClosedCurve(IFDE_Brush* pBrush, + virtual FX_BOOL FillClosedCurve(CFDE_Brush* pBrush, const CFX_PointsF& points, FX_FLOAT fTension = 0.5f, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL FillEllipse(IFDE_Brush* pBrush, + virtual FX_BOOL FillEllipse(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL FillPath(IFDE_Brush* pBrush, + virtual FX_BOOL FillPath(CFDE_Brush* pBrush, const IFDE_Path* pPath, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL FillPolygon(IFDE_Brush* pBrush, + virtual FX_BOOL FillPolygon(CFDE_Brush* pBrush, const CFX_PointsF& points, const CFX_Matrix* pMatrix = NULL); - virtual FX_BOOL FillRectangle(IFDE_Brush* pBrush, + virtual FX_BOOL FillRectangle(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL); - FX_BOOL FillSolidPath(IFDE_Brush* pBrush, - const CFX_PathData* pPath, - const CFX_Matrix* pMatrix); - FX_BOOL DrawSolidString(IFDE_Brush* pBrush, + FX_BOOL DrawSolidString(CFDE_Brush* pBrush, IFX_Font* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, FX_FLOAT fFontSize, const CFX_Matrix* pMatrix); - FX_BOOL DrawStringPath(IFDE_Brush* pBrush, + FX_BOOL DrawStringPath(CFDE_Brush* pBrush, IFX_Font* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, @@ -111,7 +108,7 @@ class CFDE_FxgeDevice : public IFDE_RenderDevice, public CFX_Target { const CFX_Matrix* pMatrix); protected: - FX_BOOL CreatePen(IFDE_Pen* pPen, + FX_BOOL CreatePen(CFDE_Pen* pPen, FX_FLOAT fPenWidth, CFX_GraphStateData& graphState); diff --git a/xfa/fde/fde_object.h b/xfa/fde/fde_object.h index e749778794..7df5de2638 100644 --- a/xfa/fde/fde_object.h +++ b/xfa/fde/fde_object.h @@ -10,109 +10,29 @@ #include #include "core/fxge/include/fx_dib.h" -#include "xfa/fde/fde_brush.h" -#include "xfa/fde/fde_pen.h" #include "xfa/fgas/crt/fgas_memory.h" -class CFDE_Pen : public IFDE_Pen, public CFX_Target { +class CFDE_Brush : public CFX_Target { public: - CFDE_Pen() - : m_Color(0), - m_iLineCap(0), - m_iLineJoin(0), - m_iDashStyle(0), - m_fDashPhase(0), - m_fMiterLimit(10), - m_bAutoRelease(FALSE), - m_pBrush(NULL) {} + CFDE_Brush() : m_Color(0xFF000000) {} - ~CFDE_Pen() { - if (m_pBrush && m_bAutoRelease) { - m_pBrush->Release(); - } - } - virtual void Release() { delete this; } - - virtual int32_t GetType() const { - return m_pBrush ? m_pBrush->GetType() : FDE_PENTYPE_SolidColor; - } - - virtual FX_ARGB GetColor() const { return m_Color; } - virtual void SetColor(FX_ARGB color) { m_Color = color; } - virtual IFDE_Brush* GetBrush() const { return m_pBrush; } - virtual void SetBrush(IFDE_Brush* pBrush, FX_BOOL bAutoRelease) { - m_bAutoRelease = bAutoRelease; - m_pBrush = pBrush; - if (m_pBrush && m_pBrush->GetType() == FDE_BRUSHTYPE_Solid) { - m_Color = ((IFDE_SolidBrush*)m_pBrush)->GetColor(); - } - } - virtual int32_t GetLineCap() const { return m_iLineCap; } - virtual void SetLineCap(int32_t iLineCap) { m_iLineCap = iLineCap; } - virtual int32_t GetDashStyle() const { return m_iDashStyle; } - virtual void SetDashStyle(int32_t iDashStyle) { m_iDashStyle = iDashStyle; } - virtual FX_FLOAT GetDashPhase() const { return m_fDashPhase; } - virtual void SetDashPhase(FX_FLOAT fPhase) { m_fDashPhase = fPhase; } - virtual int32_t CountDashArray() const { return m_DashArray.GetSize(); } - virtual int32_t GetDashArray(CFX_FloatArray& dashArray) const { - dashArray.Copy(m_DashArray); - return dashArray.GetSize(); - } - virtual void SetDashArray(const CFX_FloatArray& dashArray) { - m_DashArray.Copy(dashArray); - } - virtual int32_t GetLineJoin() const { return m_iLineJoin; } - virtual void SetLineJoin(int32_t iLineJoin) { m_iLineJoin = iLineJoin; } - virtual FX_FLOAT GetMiterLimit() const { return m_fMiterLimit; } - virtual void SetMiterLimit(FX_FLOAT fMiterLimit) { - m_fMiterLimit = fMiterLimit; - } - virtual int32_t CountCompoundPatterns() const { - return m_CompoundPatterns.GetSize(); - } - virtual FX_BOOL GetCompoundPatterns( - CFDE_CompoundPatterns& compoundPatterns) const { - return compoundPatterns.Copy(m_CompoundPatterns), TRUE; - } - virtual FX_BOOL SetCompoundPatterns( - const CFDE_CompoundPatterns& compoundPatterns) { - return m_CompoundPatterns.Copy(compoundPatterns), TRUE; - } + FX_ARGB GetColor() const { return m_Color; } + void SetColor(FX_ARGB color) { m_Color = color; } + private: FX_ARGB m_Color; - int32_t m_iLineCap; - int32_t m_iLineJoin; - int32_t m_iDashStyle; - FX_FLOAT m_fDashPhase; - FX_FLOAT m_fMiterLimit; - FX_BOOL m_bAutoRelease; - IFDE_Brush* m_pBrush; - CFX_FloatArray m_DashArray; - CFDE_CompoundPatterns m_CompoundPatterns; }; -class CFDE_SolidBrush : public IFDE_SolidBrush, public CFX_Target { +class CFDE_Pen : public CFX_Target { public: - CFDE_SolidBrush() : m_Color(0xFF000000) { m_Matrix.SetIdentity(); } + CFDE_Pen() : m_Color(0) {} + ~CFDE_Pen() {} - virtual void Release() { delete this; } - virtual int32_t GetType() const { return FDE_BRUSHTYPE_Solid; } - virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; } - virtual void ResetMatrix() { m_Matrix.SetIdentity(); } - virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) { - m_Matrix.Translate(dx, dy); - } - virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); } - virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); } - virtual void ConcatMatrix(const CFX_Matrix& matrix) { - m_Matrix.Concat(matrix); - } - virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; } - virtual FX_ARGB GetColor() const { return m_Color; } - virtual void SetColor(FX_ARGB color) { m_Color = color; } + FX_ARGB GetColor() const { return m_Color; } + void SetColor(FX_ARGB color) { m_Color = color; } + private: FX_ARGB m_Color; - CFX_Matrix m_Matrix; }; #endif // XFA_FDE_FDE_OBJECT_H_ diff --git a/xfa/fde/fde_pen.h b/xfa/fde/fde_pen.h deleted file mode 100644 index 9253726b81..0000000000 --- a/xfa/fde/fde_pen.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_FDE_PEN_H_ -#define XFA_FDE_FDE_PEN_H_ - -class IFDE_Pen; - -#define FDE_PENTYPE_SolidColor FDE_BRUSHTYPE_Solid - -#define FDE_DASHSTYLE_Solid 0 -#define FDE_DASHSTYLE_Dash 1 -#define FDE_DASHSTYLE_Dot 2 -#define FDE_DASHSTYLE_DashDot 3 -#define FDE_DASHSTYLE_DashDotDot 4 -#define FDE_DASHSTYLE_Customized 5 - -#define FDE_LINEJOIN_Miter 0 -#define FDE_LINEJOIN_Round 1 -#define FDE_LINEJOIN_Bevel 2 - -#define FDE_LINECAP_Flat 0 -#define FDE_LINECAP_Round 1 -#define FDE_LINECAP_Square 2 - -struct FDE_COMPOUNDPATTERN { - FX_FLOAT pos; - FX_FLOAT width; -}; -typedef CFX_ArrayTemplate CFDE_CompoundPatterns; - -class IFDE_Pen { - public: - virtual ~IFDE_Pen() {} - - virtual void Release() = 0; - virtual int32_t GetType() const = 0; - virtual FX_ARGB GetColor() const = 0; - virtual void SetColor(FX_ARGB color) = 0; - virtual IFDE_Brush* GetBrush() const = 0; - virtual void SetBrush(IFDE_Brush* pBrush, FX_BOOL bAutoRelease) = 0; - virtual int32_t GetLineCap() const = 0; - virtual void SetLineCap(int32_t iLineCap) = 0; - virtual int32_t GetDashStyle() const = 0; - virtual void SetDashStyle(int32_t iDashStyle) = 0; - virtual FX_FLOAT GetDashPhase() const = 0; - virtual void SetDashPhase(FX_FLOAT fPhase) = 0; - virtual int32_t CountDashArray() const = 0; - virtual int32_t GetDashArray(CFX_FloatArray& dashArray) const = 0; - virtual void SetDashArray(const CFX_FloatArray& dashArray) = 0; - virtual int32_t GetLineJoin() const = 0; - virtual void SetLineJoin(int32_t iLineJoin) = 0; - virtual FX_FLOAT GetMiterLimit() const = 0; - virtual void SetMiterLimit(FX_FLOAT fMiterLimit) = 0; - virtual int32_t CountCompoundPatterns() const = 0; - virtual FX_BOOL GetCompoundPatterns( - CFDE_CompoundPatterns& compoundPatterns) const = 0; - virtual FX_BOOL SetCompoundPatterns( - const CFDE_CompoundPatterns& compoundPatterns) = 0; -}; - -#endif // XFA_FDE_FDE_PEN_H_ diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp index fed831348a..59bb5f1aa2 100644 --- a/xfa/fde/fde_render.cpp +++ b/xfa/fde/fde_render.cpp @@ -24,7 +24,7 @@ class CFDE_RenderContext : public IFDE_RenderContext, public CFX_Target { IFDE_CanvasSet* pCanvasSet, const CFX_Matrix& tmDoc2Device); virtual FDE_RENDERSTATUS GetStatus() const { return m_eStatus; } - virtual FDE_RENDERSTATUS DoRender(IFX_Pause* pPause = NULL); + virtual FDE_RENDERSTATUS DoRender(IFX_Pause* pPause = nullptr); virtual void StopRender(); void RenderPath(IFDE_PathSet* pPathSet, FDE_HVISUALOBJ hPath); void RenderText(IFDE_TextSet* pTextSet, FDE_HVISUALOBJ hText); @@ -36,7 +36,7 @@ class CFDE_RenderContext : public IFDE_RenderContext, public CFX_Target { protected: FDE_RENDERSTATUS m_eStatus; IFDE_RenderDevice* m_pRenderDevice; - IFDE_SolidBrush* m_pSolidBrush; + CFDE_Brush* m_pBrush; CFX_Matrix m_Transform; FXTEXT_CHARPOS* m_pCharPos; int32_t m_iCharPosCount; @@ -93,51 +93,52 @@ void FDE_GetPageMatrix(CFX_Matrix& pageMatrix, } pageMatrix = m; } + IFDE_RenderContext* IFDE_RenderContext::Create() { return new CFDE_RenderContext; } + CFDE_RenderContext::CFDE_RenderContext() : m_eStatus(FDE_RENDERSTATUS_Reset), - m_pRenderDevice(NULL), - m_pSolidBrush(NULL), + m_pRenderDevice(nullptr), + m_pBrush(nullptr), m_Transform(), - m_pCharPos(NULL), + m_pCharPos(nullptr), m_iCharPosCount(0), - m_pIterator(NULL) { + m_pIterator(nullptr) { m_Transform.SetIdentity(); } + CFDE_RenderContext::~CFDE_RenderContext() { StopRender(); } + FX_BOOL CFDE_RenderContext::StartRender(IFDE_RenderDevice* pRenderDevice, IFDE_CanvasSet* pCanvasSet, const CFX_Matrix& tmDoc2Device) { - if (m_pRenderDevice != NULL) { + if (m_pRenderDevice) return FALSE; - } - if (pRenderDevice == NULL) { + if (!pRenderDevice) return FALSE; - } - if (pCanvasSet == NULL) { + if (!pCanvasSet) return FALSE; - } m_eStatus = FDE_RENDERSTATUS_Paused; m_pRenderDevice = pRenderDevice; m_Transform = tmDoc2Device; - if (m_pIterator == NULL) { + if (!m_pIterator) { m_pIterator = IFDE_VisualSetIterator::Create(); - FXSYS_assert(m_pIterator != NULL); + FXSYS_assert(m_pIterator); } return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); } + FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { - if (m_pRenderDevice == NULL) { + if (!m_pRenderDevice) return FDE_RENDERSTATUS_Failed; - } - if (m_pIterator == NULL) { + if (!m_pIterator) return FDE_RENDERSTATUS_Failed; - } + FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused; CFX_Matrix rm; rm.SetReverse(m_Transform); @@ -154,15 +155,15 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { int32_t iCount = 0; while (TRUE) { hVisualObj = m_pIterator->GetNext(pVisualSet); - if (hVisualObj == NULL || pVisualSet == NULL) { + if (!hVisualObj || !pVisualSet) { eStatus = FDE_RENDERSTATUS_Done; break; } rtObj.Empty(); pVisualSet->GetRect(hVisualObj, rtObj); - if (!rtDocClip.IntersectWith(rtObj)) { + if (!rtDocClip.IntersectWith(rtObj)) continue; - } + switch (pVisualSet->GetType()) { case FDE_VISUALOBJ_Text: RenderText((IFDE_TextSet*)pVisualSet, hVisualObj); @@ -181,13 +182,14 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { default: break; } - if (iCount >= 100 && pPause != NULL && pPause->NeedToPauseNow()) { + if (iCount >= 100 && pPause && pPause->NeedToPauseNow()) { eStatus = FDE_RENDERSTATUS_Paused; break; } } return m_eStatus = eStatus; } + void CFDE_RenderContext::StopRender() { m_eStatus = FDE_RENDERSTATUS_Reset; m_pRenderDevice = nullptr; @@ -196,87 +198,85 @@ void CFDE_RenderContext::StopRender() { m_pIterator->Release(); m_pIterator = nullptr; } - if (m_pSolidBrush) { - m_pSolidBrush->Release(); - m_pSolidBrush = nullptr; + if (m_pBrush) { + delete m_pBrush; + m_pBrush = nullptr; } FX_Free(m_pCharPos); m_pCharPos = nullptr; m_iCharPosCount = 0; } + void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, FDE_HVISUALOBJ hText) { - FXSYS_assert(m_pRenderDevice != NULL); - FXSYS_assert(pTextSet != NULL && hText != NULL); + FXSYS_assert(m_pRenderDevice); + FXSYS_assert(pTextSet && hText); + IFX_Font* pFont = pTextSet->GetFont(hText); - if (pFont == NULL) { + if (!pFont) return; - } - int32_t iCount = pTextSet->GetDisplayPos(hText, NULL, FALSE); - if (iCount < 1) { + + int32_t iCount = pTextSet->GetDisplayPos(hText, nullptr, FALSE); + if (iCount < 1) return; - } - if (m_pSolidBrush == NULL) { - m_pSolidBrush = new CFDE_SolidBrush; - if (m_pSolidBrush == NULL) { - return; - } - } - if (m_pCharPos == NULL) { + + if (!m_pBrush) + m_pBrush = new CFDE_Brush; + + if (!m_pCharPos) m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount); - } else if (m_iCharPosCount < iCount) { + else if (m_iCharPosCount < iCount) m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount); - } - if (m_iCharPosCount < iCount) { + + if (m_iCharPosCount < iCount) m_iCharPosCount = iCount; - } + iCount = pTextSet->GetDisplayPos(hText, m_pCharPos, FALSE); FX_FLOAT fFontSize = pTextSet->GetFontSize(hText); FX_ARGB dwColor = pTextSet->GetFontColor(hText); - m_pSolidBrush->SetColor(dwColor); + m_pBrush->SetColor(dwColor); FDE_HDEVICESTATE hState; FX_BOOL bClip = ApplyClip(pTextSet, hText, hState); - m_pRenderDevice->DrawString(m_pSolidBrush, pFont, m_pCharPos, iCount, - fFontSize, &m_Transform); - if (bClip) { + m_pRenderDevice->DrawString(m_pBrush, pFont, m_pCharPos, iCount, fFontSize, + &m_Transform); + if (bClip) RestoreClip(hState); - } } + void CFDE_RenderContext::RenderPath(IFDE_PathSet* pPathSet, FDE_HVISUALOBJ hPath) { - FXSYS_assert(m_pRenderDevice != NULL); - FXSYS_assert(pPathSet != NULL && hPath != NULL); + FXSYS_assert(m_pRenderDevice); + FXSYS_assert(pPathSet && hPath); + IFDE_Path* pPath = pPathSet->GetPath(hPath); - if (pPath == NULL) { + if (!pPath) return; - } + FDE_HDEVICESTATE hState; FX_BOOL bClip = ApplyClip(pPathSet, hPath, hState); int32_t iRenderMode = pPathSet->GetRenderMode(hPath); if (iRenderMode & FDE_PATHRENDER_Stroke) { - IFDE_Pen* pPen = pPathSet->GetPen(hPath); + CFDE_Pen* pPen = pPathSet->GetPen(hPath); FX_FLOAT fWidth = pPathSet->GetPenWidth(hPath); - if (pPen != NULL && fWidth > 0) { + if (pPen && fWidth > 0) m_pRenderDevice->DrawPath(pPen, fWidth, pPath, &m_Transform); - } } if (iRenderMode & FDE_PATHRENDER_Fill) { - IFDE_Brush* pBrush = pPathSet->GetBrush(hPath); - if (pBrush != NULL) { + CFDE_Brush* pBrush = pPathSet->GetBrush(hPath); + if (pBrush) m_pRenderDevice->FillPath(pBrush, pPath, &m_Transform); - } } - if (bClip) { + if (bClip) RestoreClip(hState); - } } + FX_BOOL CFDE_RenderContext::ApplyClip(IFDE_VisualSet* pVisualSet, FDE_HVISUALOBJ hObj, FDE_HDEVICESTATE& hState) { CFX_RectF rtClip; - if (!pVisualSet->GetClip(hObj, rtClip)) { + if (!pVisualSet->GetClip(hObj, rtClip)) return FALSE; - } + CFX_RectF rtObj; pVisualSet->GetRect(hObj, rtObj); rtClip.Offset(rtObj.left, rtObj.top); @@ -286,6 +286,7 @@ FX_BOOL CFDE_RenderContext::ApplyClip(IFDE_VisualSet* pVisualSet, hState = m_pRenderDevice->SaveState(); return m_pRenderDevice->SetClipRect(rtClip); } + void CFDE_RenderContext::RestoreClip(FDE_HDEVICESTATE hState) { m_pRenderDevice->RestoreState(hState); } diff --git a/xfa/fde/fde_renderdevice.h b/xfa/fde/fde_renderdevice.h index 55f6524cff..f0686597c7 100644 --- a/xfa/fde/fde_renderdevice.h +++ b/xfa/fde/fde_renderdevice.h @@ -13,8 +13,8 @@ #include "xfa/fde/fde_path.h" #include "xfa/fgas/font/fgas_font.h" -class IFDE_Pen; -class IFDE_Brush; +class CFDE_Pen; +class CFDE_Brush; class CFX_DIBitmap; class CFX_DIBSource; @@ -45,64 +45,64 @@ class IFDE_RenderDevice { const CFX_RectF& dstRect, const CFX_Matrix* pImgMatrix = NULL, const CFX_Matrix* pDevMatrix = NULL) = 0; - virtual FX_BOOL DrawString(IFDE_Brush* pBrush, + virtual FX_BOOL DrawString(CFDE_Brush* pBrush, IFX_Font* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, FX_FLOAT fFontSize, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawBezier(IFDE_Pen* pPen, + virtual FX_BOOL DrawBezier(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, const CFX_PointF& pt3, const CFX_PointF& pt4, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawCurve(IFDE_Pen* pPen, + virtual FX_BOOL DrawCurve(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, FX_BOOL bClosed, FX_FLOAT fTension = 0.5f, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawEllipse(IFDE_Pen* pPen, + virtual FX_BOOL DrawEllipse(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawLines(IFDE_Pen* pPen, + virtual FX_BOOL DrawLines(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawLine(IFDE_Pen* pPen, + virtual FX_BOOL DrawLine(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawPath(IFDE_Pen* pPen, + virtual FX_BOOL DrawPath(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const IFDE_Path* pPath, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawPolygon(IFDE_Pen* pPen, + virtual FX_BOOL DrawPolygon(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointsF& points, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL DrawRectangle(IFDE_Pen* pPen, + virtual FX_BOOL DrawRectangle(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL FillClosedCurve(IFDE_Brush* pBrush, + virtual FX_BOOL FillClosedCurve(CFDE_Brush* pBrush, const CFX_PointsF& points, FX_FLOAT fTension = 0.5f, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL FillEllipse(IFDE_Brush* pBrush, + virtual FX_BOOL FillEllipse(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL FillPath(IFDE_Brush* pBrush, + virtual FX_BOOL FillPath(CFDE_Brush* pBrush, const IFDE_Path* pPath, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL FillPolygon(IFDE_Brush* pBrush, + virtual FX_BOOL FillPolygon(CFDE_Brush* pBrush, const CFX_PointsF& points, const CFX_Matrix* pMatrix = NULL) = 0; - virtual FX_BOOL FillRectangle(IFDE_Brush* pBrush, + virtual FX_BOOL FillRectangle(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix = NULL) = 0; }; diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h index 6dcb42c296..2c95253315 100644 --- a/xfa/fde/fde_visualset.h +++ b/xfa/fde/fde_visualset.h @@ -11,10 +11,9 @@ #include "core/fxcrt/include/fx_system.h" #include "core/fxge/include/fx_dib.h" #include "core/fxge/include/fx_ge.h" -#include "xfa/fde/fde_brush.h" #include "xfa/fde/fde_image.h" +#include "xfa/fde/fde_object.h" #include "xfa/fde/fde_path.h" -#include "xfa/fde/fde_pen.h" #include "xfa/fgas/font/fgas_font.h" enum FDE_VISUALOBJTYPE { @@ -78,9 +77,9 @@ class IFDE_PathSet : public IFDE_VisualSet { virtual IFDE_Path* GetPath(FDE_HVISUALOBJ hPath) = 0; virtual int32_t GetFillMode(FDE_HVISUALOBJ hPath) = 0; virtual int32_t GetRenderMode(FDE_HVISUALOBJ hPath) = 0; - virtual IFDE_Pen* GetPen(FDE_HVISUALOBJ hPath) = 0; + virtual CFDE_Pen* GetPen(FDE_HVISUALOBJ hPath) = 0; virtual FX_FLOAT GetPenWidth(FDE_HVISUALOBJ hPath) = 0; - virtual IFDE_Brush* GetBrush(FDE_HVISUALOBJ hPath) = 0; + virtual CFDE_Brush* GetBrush(FDE_HVISUALOBJ hPath) = 0; }; enum FDE_WIDGETOBJ { diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index 49d3abb8ab..265db253fc 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -10,9 +10,7 @@ #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_system.h" -#include "xfa/fde/fde_brush.h" #include "xfa/fde/fde_object.h" -#include "xfa/fde/fde_pen.h" #include "xfa/fde/fde_renderdevice.h" #include "xfa/fgas/crt/fgas_memory.h" #include "xfa/fgas/crt/fgas_utils.h" @@ -145,7 +143,7 @@ class CFDE_TextOut : public IFDE_TextOut, public CFX_Target { int32_t GetCharRects(FDE_LPTTOPIECE pPiece); void ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr); - void DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen); + void DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen); IFX_TxtBreak* m_pTxtBreak; IFX_Font* m_pFont; @@ -951,9 +949,9 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { if (iLines < 1) { return; } - IFDE_SolidBrush* pBrush = new CFDE_SolidBrush; + CFDE_Brush* pBrush = new CFDE_Brush; pBrush->SetColor(m_TxtColor); - IFDE_Pen* pPen = NULL; + CFDE_Pen* pPen = NULL; FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState(); if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { m_pRenderDevice->SetClipRect(rtClip); @@ -975,12 +973,8 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { } } m_pRenderDevice->RestoreState(hDev); - if (pBrush) { - pBrush->Release(); - } - if (pPen) { - pPen->Release(); - } + delete pBrush; + delete pPen; } int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { FX_TXTRUN tr; @@ -1008,7 +1002,7 @@ void CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr) { tr.wLineBreakChar = m_wParagraphBkChar; tr.pRect = &pPiece->rtPiece; } -void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen) { +void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen) { FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index a15fb95925..4a20cbb44d 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -11,7 +11,6 @@ #include "core/fxcrt/include/fx_ext.h" #include "xfa/fde/css/fde_csscache.h" #include "xfa/fde/fde_object.h" -#include "xfa/fde/fde_pen.h" #include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_algorithm.h" #include "xfa/fgas/crt/fgas_codepage.h" @@ -1223,8 +1222,8 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, } FDE_HDEVICESTATE state = pDevice->SaveState(); pDevice->SetClipRect(rtClip); - IFDE_SolidBrush* pSolidBrush = new CFDE_SolidBrush; - IFDE_Pen* pPen = new CFDE_Pen; + CFDE_Brush* pSolidBrush = new CFDE_Brush; + CFDE_Pen* pPen = new CFDE_Pen; FXSYS_assert(pDevice); if (m_pieceLines.GetSize() == 0) { @@ -1271,8 +1270,8 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, } pDevice->RestoreState(state); FX_Free(pCharPos); - pSolidBrush->Release(); - pPen->Release(); + delete pSolidBrush; + delete pPen; pDevice->Release(); return iPieceLines; } @@ -1840,7 +1839,7 @@ void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, m_iLines++; } void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, - IFDE_SolidBrush* pBrush, + CFDE_Brush* pBrush, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, @@ -1855,7 +1854,7 @@ void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, pPieceLine->m_charCounts.Add(iCount); } void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, - IFDE_Pen* pPen, + CFDE_Pen* pPen, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h index 5d3ce16a49..a96c537033 100644 --- a/xfa/fxfa/app/xfa_textlayout.h +++ b/xfa/fxfa/app/xfa_textlayout.h @@ -8,7 +8,6 @@ #define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ #include "xfa/fde/css/fde_css.h" -#include "xfa/fde/fde_brush.h" #include "xfa/fde/fde_renderdevice.h" #include "xfa/fgas/layout/fgas_rtfbreak.h" #include "xfa/fxfa/include/xfa_ffdoc.h" @@ -378,13 +377,13 @@ class CXFA_TextLayout { void ProcessText(CFX_WideString& wsText); void UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom); void RenderString(IFDE_RenderDevice* pDevice, - IFDE_SolidBrush* pBrush, + CFDE_Brush* pBrush, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device); void RenderPath(IFDE_RenderDevice* pDevice, - IFDE_Pen* pPen, + CFDE_Pen* pPen, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, -- cgit v1.2.3