diff options
Diffstat (limited to 'xfa/fde')
-rw-r--r-- | xfa/fde/cfde_brush.h | 23 | ||||
-rw-r--r-- | xfa/fde/cfde_pen.h | 24 | ||||
-rw-r--r-- | xfa/fde/cfde_rendercontext.cpp | 10 | ||||
-rw-r--r-- | xfa/fde/cfde_rendercontext.h | 1 | ||||
-rw-r--r-- | xfa/fde/cfde_renderdevice.cpp | 93 | ||||
-rw-r--r-- | xfa/fde/cfde_renderdevice.h | 40 | ||||
-rw-r--r-- | xfa/fde/cfde_textout.cpp | 15 | ||||
-rw-r--r-- | xfa/fde/cfde_textout.h | 3 |
8 files changed, 62 insertions, 147 deletions
diff --git a/xfa/fde/cfde_brush.h b/xfa/fde/cfde_brush.h deleted file mode 100644 index 7a070c8605..0000000000 --- a/xfa/fde/cfde_brush.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 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_CFDE_BRUSH_H_ -#define XFA_FDE_CFDE_BRUSH_H_ - -#include "core/fxge/fx_dib.h" - -class CFDE_Brush { - public: - CFDE_Brush() : m_Color(0xFF000000) {} - - FX_ARGB GetColor() const { return m_Color; } - void SetColor(FX_ARGB color) { m_Color = color; } - - private: - FX_ARGB m_Color; -}; - -#endif // XFA_FDE_CFDE_BRUSH_H_ diff --git a/xfa/fde/cfde_pen.h b/xfa/fde/cfde_pen.h deleted file mode 100644 index ac49571bd0..0000000000 --- a/xfa/fde/cfde_pen.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 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_CFDE_PEN_H_ -#define XFA_FDE_CFDE_PEN_H_ - -#include "core/fxge/fx_dib.h" - -class CFDE_Pen { - public: - CFDE_Pen() : m_Color(0) {} - ~CFDE_Pen() {} - - FX_ARGB GetColor() const { return m_Color; } - void SetColor(FX_ARGB color) { m_Color = color; } - - private: - FX_ARGB m_Color; -}; - -#endif // XFA_FDE_CFDE_PEN_H_ diff --git a/xfa/fde/cfde_rendercontext.cpp b/xfa/fde/cfde_rendercontext.cpp index dc2a628c23..7e7baebee2 100644 --- a/xfa/fde/cfde_rendercontext.cpp +++ b/xfa/fde/cfde_rendercontext.cpp @@ -8,7 +8,6 @@ #include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" -#include "xfa/fde/cfde_brush.h" #include "xfa/fde/cfde_renderdevice.h" #include "xfa/fde/cfde_txtedttextset.h" @@ -83,15 +82,10 @@ void CFDE_RenderContext::RenderText(CFDE_TxtEdtTextSet* pTextSet, int32_t iCount = pTextSet->GetDisplayPos(*pText, nullptr, false); if (iCount < 1) return; - if (!m_pBrush) - m_pBrush = pdfium::MakeUnique<CFDE_Brush>(); if (m_CharPos.size() < static_cast<size_t>(iCount)) m_CharPos.resize(iCount, FXTEXT_CHARPOS()); iCount = pTextSet->GetDisplayPos(*pText, m_CharPos.data(), false); - float fFontSize = pTextSet->GetFontSize(); - FX_ARGB dwColor = pTextSet->GetFontColor(); - m_pBrush->SetColor(dwColor); - m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, - fFontSize, &m_Transform); + m_pRenderDevice->DrawString(pTextSet->GetFontColor(), pFont, m_CharPos.data(), + iCount, pTextSet->GetFontSize(), &m_Transform); } diff --git a/xfa/fde/cfde_rendercontext.h b/xfa/fde/cfde_rendercontext.h index 7f54e28c6d..3823255e95 100644 --- a/xfa/fde/cfde_rendercontext.h +++ b/xfa/fde/cfde_rendercontext.h @@ -34,7 +34,6 @@ class CFDE_RenderContext { CFDE_RenderDevice* m_pRenderDevice; CFX_Matrix m_Transform; std::vector<FXTEXT_CHARPOS> m_CharPos; - std::unique_ptr<CFDE_Brush> m_pBrush; std::unique_ptr<CFDE_VisualSetIterator> m_pIterator; }; diff --git a/xfa/fde/cfde_renderdevice.cpp b/xfa/fde/cfde_renderdevice.cpp index ec1fc2fed1..8a1b980724 100644 --- a/xfa/fde/cfde_renderdevice.cpp +++ b/xfa/fde/cfde_renderdevice.cpp @@ -15,9 +15,7 @@ #include "core/fxge/cfx_substfont.h" #include "core/fxge/dib/cfx_imagerenderer.h" #include "third_party/base/ptr_util.h" -#include "xfa/fde/cfde_brush.h" #include "xfa/fde/cfde_path.h" -#include "xfa/fde/cfde_pen.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fgas/font/cfgas_gefont.h" @@ -117,15 +115,14 @@ bool CFDE_RenderDevice::DrawImage(const CFX_RetainPtr<CFX_DIBSource>& pDib, return !!handle; } -bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, +bool CFDE_RenderDevice::DrawString(FX_ARGB color, const CFX_RetainPtr<CFGAS_GEFont>& pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, float fFontSize, const CFX_Matrix* pMatrix) { - ASSERT(pBrush && pFont && pCharPos && iCount > 0); + ASSERT(pFont && pCharPos && iCount > 0); CFX_Font* pFxFont = pFont->GetDevFont(); - FX_ARGB argb = pBrush->GetColor(); if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && !pFxFont->IsItalic()) { FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; @@ -165,10 +162,10 @@ bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ FxFont.SetFace(pFxFont->GetFace()); m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, -fFontSize, - pMatrix, argb, FXTEXT_CLEARTYPE); + pMatrix, color, FXTEXT_CLEARTYPE); #else m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize, - pMatrix, argb, FXTEXT_CLEARTYPE); + pMatrix, color, FXTEXT_CLEARTYPE); #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ } pCurFont = pSTFont; @@ -185,12 +182,12 @@ bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, FxFont.SetFace(pFxFont->GetFace()); bool bRet = m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, -fFontSize, - pMatrix, argb, FXTEXT_CLEARTYPE); + pMatrix, color, FXTEXT_CLEARTYPE); FxFont.SetFace(nullptr); return bRet; #else return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize, - pMatrix, argb, FXTEXT_CLEARTYPE); + pMatrix, color, FXTEXT_CLEARTYPE); #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ } @@ -201,7 +198,7 @@ bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, return true; } -bool CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawBezier(FX_ARGB color, float fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, @@ -215,10 +212,10 @@ bool CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen, points.push_back(pt4); CFDE_Path path; path.AddBezier(points); - return DrawPath(pPen, fPenWidth, &path, pMatrix); + return DrawPath(color, fPenWidth, &path, pMatrix); } -bool CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawCurve(FX_ARGB color, float fPenWidth, const std::vector<CFX_PointF>& points, bool bClosed, @@ -226,38 +223,38 @@ bool CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddCurve(points, bClosed, fTension); - return DrawPath(pPen, fPenWidth, &path, pMatrix); + return DrawPath(color, fPenWidth, &path, pMatrix); } -bool CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawEllipse(FX_ARGB color, float fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddEllipse(rect); - return DrawPath(pPen, fPenWidth, &path, pMatrix); + return DrawPath(color, fPenWidth, &path, pMatrix); } -bool CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawLines(FX_ARGB color, float fPenWidth, const std::vector<CFX_PointF>& points, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddLines(points); - return DrawPath(pPen, fPenWidth, &path, pMatrix); + return DrawPath(color, fPenWidth, &path, pMatrix); } -bool CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawLine(FX_ARGB color, float fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddLine(pt1, pt2); - return DrawPath(pPen, fPenWidth, &path, pMatrix); + return DrawPath(color, fPenWidth, &path, pMatrix); } -bool CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawPath(FX_ARGB color, float fPenWidth, const CFDE_Path* pPath, const CFX_Matrix* pMatrix) { @@ -266,86 +263,72 @@ bool CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, return false; CFX_GraphStateData graphState; - if (!CreatePen(pPen, fPenWidth, graphState)) { - return false; - } + graphState.m_LineCap = CFX_GraphStateData::LineCapButt; + graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter; + graphState.m_LineWidth = fPenWidth; + graphState.m_MiterLimit = 10; + graphState.m_DashPhase = 0; return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix, - &graphState, 0, pPen->GetColor(), 0); + &graphState, 0, color, 0); } -bool CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawPolygon(FX_ARGB color, float fPenWidth, const std::vector<CFX_PointF>& points, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddPolygon(points); - return DrawPath(pPen, fPenWidth, &path, pMatrix); + return DrawPath(color, fPenWidth, &path, pMatrix); } -bool CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen, +bool CFDE_RenderDevice::DrawRectangle(FX_ARGB color, float fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddRectangle(rect); - return DrawPath(pPen, fPenWidth, &path, pMatrix); + return DrawPath(color, fPenWidth, &path, pMatrix); } -bool CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush, +bool CFDE_RenderDevice::FillClosedCurve(FX_ARGB color, const std::vector<CFX_PointF>& points, float fTension, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddCurve(points, true, fTension); - return FillPath(pBrush, &path, pMatrix); + return FillPath(color, &path, pMatrix); } -bool CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush, +bool CFDE_RenderDevice::FillEllipse(FX_ARGB color, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddEllipse(rect); - return FillPath(pBrush, &path, pMatrix); + return FillPath(color, &path, pMatrix); } -bool CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush, +bool CFDE_RenderDevice::FillPolygon(FX_ARGB color, const std::vector<CFX_PointF>& points, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddPolygon(points); - return FillPath(pBrush, &path, pMatrix); + return FillPath(color, &path, pMatrix); } -bool CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush, +bool CFDE_RenderDevice::FillRectangle(FX_ARGB color, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { CFDE_Path path; path.AddRectangle(rect); - return FillPath(pBrush, &path, pMatrix); + return FillPath(color, &path, pMatrix); } -bool CFDE_RenderDevice::CreatePen(CFDE_Pen* pPen, - float fPenWidth, - CFX_GraphStateData& graphState) { - if (!pPen) - return false; - - graphState.m_LineCap = CFX_GraphStateData::LineCapButt; - graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter; - graphState.m_LineWidth = fPenWidth; - graphState.m_MiterLimit = 10; - graphState.m_DashPhase = 0; - return true; -} - -bool CFDE_RenderDevice::FillPath(CFDE_Brush* pBrush, +bool CFDE_RenderDevice::FillPath(FX_ARGB color, const CFDE_Path* pPath, const CFX_Matrix* pMatrix) { CFDE_Path* pGePath = (CFDE_Path*)pPath; if (!pGePath) return false; - if (!pBrush) - return false; - return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, - pBrush->GetColor(), 0, FXFILL_WINDING); + return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, color, 0, + FXFILL_WINDING); } diff --git a/xfa/fde/cfde_renderdevice.h b/xfa/fde/cfde_renderdevice.h index d9f4ce0d34..a372c23f9d 100644 --- a/xfa/fde/cfde_renderdevice.h +++ b/xfa/fde/cfde_renderdevice.h @@ -12,9 +12,7 @@ #include "core/fxge/cfx_renderdevice.h" #include "xfa/fgas/font/cfgas_gefont.h" -class CFDE_Brush; class CFDE_Path; -class CFDE_Pen; class CFX_GraphStateData; class CFDE_RenderDevice { @@ -39,85 +37,81 @@ class CFDE_RenderDevice { const CFX_RectF& dstRect, const CFX_Matrix* pImgMatrix = nullptr, const CFX_Matrix* pDevMatrix = nullptr); - bool DrawString(CFDE_Brush* pBrush, + bool DrawString(FX_ARGB color, const CFX_RetainPtr<CFGAS_GEFont>& pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, float fFontSize, const CFX_Matrix* pMatrix = nullptr); - bool DrawBezier(CFDE_Pen* pPen, + bool DrawBezier(FX_ARGB color, float fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, const CFX_PointF& pt3, const CFX_PointF& pt4, const CFX_Matrix* pMatrix = nullptr); - bool DrawCurve(CFDE_Pen* pPen, + bool DrawCurve(FX_ARGB color, float fPenWidth, const std::vector<CFX_PointF>& points, bool bClosed, float fTension = 0.5f, const CFX_Matrix* pMatrix = nullptr); - bool DrawEllipse(CFDE_Pen* pPen, + bool DrawEllipse(FX_ARGB color, float fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix = nullptr); - bool DrawLines(CFDE_Pen* pPen, + bool DrawLines(FX_ARGB color, float fPenWidth, const std::vector<CFX_PointF>& points, const CFX_Matrix* pMatrix = nullptr); - bool DrawLine(CFDE_Pen* pPen, + bool DrawLine(FX_ARGB color, float fPenWidth, const CFX_PointF& pt1, const CFX_PointF& pt2, const CFX_Matrix* pMatrix = nullptr); - bool DrawPath(CFDE_Pen* pPen, + bool DrawPath(FX_ARGB color, float fPenWidth, const CFDE_Path* pPath, const CFX_Matrix* pMatrix = nullptr); - bool DrawPolygon(CFDE_Pen* pPen, + bool DrawPolygon(FX_ARGB color, float fPenWidth, const std::vector<CFX_PointF>& points, const CFX_Matrix* pMatrix = nullptr); - bool DrawRectangle(CFDE_Pen* pPen, + bool DrawRectangle(FX_ARGB color, float fPenWidth, const CFX_RectF& rect, const CFX_Matrix* pMatrix = nullptr); - bool FillClosedCurve(CFDE_Brush* pBrush, + bool FillClosedCurve(FX_ARGB color, const std::vector<CFX_PointF>& points, float fTension = 0.5f, const CFX_Matrix* pMatrix = nullptr); - bool FillEllipse(CFDE_Brush* pBrush, + bool FillEllipse(FX_ARGB color, const CFX_RectF& rect, const CFX_Matrix* pMatrix = nullptr); - bool FillPath(CFDE_Brush* pBrush, + bool FillPath(FX_ARGB color, const CFDE_Path* pPath, const CFX_Matrix* pMatrix = nullptr); - bool FillPolygon(CFDE_Brush* pBrush, + bool FillPolygon(FX_ARGB color, const std::vector<CFX_PointF>& points, const CFX_Matrix* pMatrix = nullptr); - bool FillRectangle(CFDE_Brush* pBrush, + bool FillRectangle(FX_ARGB color, const CFX_RectF& rect, const CFX_Matrix* pMatrix = nullptr); - bool DrawSolidString(CFDE_Brush* pBrush, + bool DrawSolidString(FX_ARGB color, const CFX_RetainPtr<CFGAS_GEFont>& pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, float fFontSize, const CFX_Matrix* pMatrix); - bool DrawStringPath(CFDE_Brush* pBrush, + bool DrawStringPath(FX_ARGB color, const CFX_RetainPtr<CFGAS_GEFont>& pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, float fFontSize, const CFX_Matrix* pMatrix); - protected: - bool CreatePen(CFDE_Pen* pPen, - float fPenWidth, - CFX_GraphStateData& graphState); - + private: CFX_RenderDevice* const m_pDevice; CFX_RectF m_rtClip; int32_t m_iCharCount; diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp index 5d84b6d12b..202074bdc4 100644 --- a/xfa/fde/cfde_textout.cpp +++ b/xfa/fde/cfde_textout.cpp @@ -13,9 +13,7 @@ #include "core/fxcrt/fx_system.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fde/cfde_brush.h" #include "xfa/fde/cfde_path.h" -#include "xfa/fde/cfde_pen.h" #include "xfa/fde/cfde_renderdevice.h" #include "xfa/fgas/layout/cfx_txtbreak.h" @@ -651,15 +649,10 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { if (!m_pRenderDevice || m_ttoLines.empty()) return; - auto pBrush = pdfium::MakeUnique<CFDE_Brush>(); - pBrush->SetColor(m_TxtColor); m_pRenderDevice->SaveState(); if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) m_pRenderDevice->SetClipRect(rtClip); - auto pPen = pdfium::MakeUnique<CFDE_Pen>(); - pPen->SetColor(m_TxtColor); - for (auto& line : m_ttoLines) { int32_t iPieces = line.GetSize(); for (int32_t j = 0; j < iPieces; j++) { @@ -669,10 +662,10 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { int32_t iCount = GetDisplayPos(pPiece); if (iCount > 0) { - m_pRenderDevice->DrawString(pBrush.get(), m_pFont, m_CharPos.data(), + m_pRenderDevice->DrawString(m_TxtColor, m_pFont, m_CharPos.data(), iCount, m_fFontSize, &m_Matrix); } - DrawLine(pPiece, pPen.get()); + DrawLine(pPiece, m_TxtColor); } } m_pRenderDevice->RestoreState(); @@ -704,7 +697,7 @@ FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_TTOPIECE* pPiece) { return tr; } -void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen* pPen) { +void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, FX_ARGB color) { bool bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); bool bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); bool bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); @@ -748,7 +741,7 @@ void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen* pPen) { } } if (iLineCount > 0) - m_pRenderDevice->DrawPath(pPen, 1, pPath.get(), &m_Matrix); + m_pRenderDevice->DrawPath(color, 1, pPath.get(), &m_Matrix); } CFDE_TTOLine::CFDE_TTOLine() : m_bNewReload(false) {} diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h index a52814041b..98a7d11cd4 100644 --- a/xfa/fde/cfde_textout.h +++ b/xfa/fde/cfde_textout.h @@ -37,7 +37,6 @@ #define FDE_TTOALIGNMENT_BottomRight 10 #define FDE_TTOALIGNMENT_BottomAuto 11 -class CFDE_Pen; class CFDE_RenderDevice; class CFX_RenderDevice; class CFX_TxtBreak; @@ -139,7 +138,7 @@ class CFDE_TextOut { int32_t GetCharRects(const FDE_TTOPIECE* pPiece); FX_TXTRUN ToTextRun(const FDE_TTOPIECE* pPiece); - void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen* pPen); + void DrawLine(const FDE_TTOPIECE* pPiece, FX_ARGB color); std::unique_ptr<CFX_TxtBreak> m_pTxtBreak; CFX_RetainPtr<CFGAS_GEFont> m_pFont; |