From 73b492a5d775c05d8c186c8478d1003edfffd34c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 14 Aug 2017 17:23:25 -0400 Subject: Remove CFDE_RenderDevice This CL removes CFDE_RenderDevice. For most of the proxy'd calls we call the CFX_RenderDevice directly now. To set the clip rect an overload was added to accept a CFX_RectF and handle the casting to FX_RECT. The one needed method, DrawString, is move to a static on CFDE_TextOut. Change-Id: I95ea7e1fa1fd4702074b797c06423c9c9cb51db9 Reviewed-on: https://pdfium-review.googlesource.com/10951 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- xfa/fxfa/cxfa_fwltheme.cpp | 6 ++---- xfa/fxfa/cxfa_textlayout.cpp | 34 ++++++++++++++++++++-------------- xfa/fxfa/cxfa_textlayout.h | 4 ++-- 3 files changed, 24 insertions(+), 20 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp index 89ce0dbfbc..85e48a5123 100644 --- a/xfa/fxfa/cxfa_fwltheme.cpp +++ b/xfa/fxfa/cxfa_fwltheme.cpp @@ -110,14 +110,13 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { if (!pRenderDevice) return; - m_pTextOut->SetRenderDevice(pRenderDevice); CFX_Matrix mtPart = pParams->m_matrix; CFX_Matrix* pMatrix = pGraphics->GetMatrix(); if (pMatrix) { mtPart.Concat(*pMatrix); } m_pTextOut->SetMatrix(mtPart); - m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), + m_pTextOut->DrawLogicText(pRenderDevice, pParams->m_wsText.c_str(), pParams->m_wsText.GetLength(), pParams->m_rtPart); return; } @@ -131,7 +130,6 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { if (!pRenderDevice) return; - m_pTextOut->SetRenderDevice(pRenderDevice); m_pTextOut->SetStyles(pParams->m_dwTTOStyles); m_pTextOut->SetAlignment(pParams->m_iTTOAlign); m_pTextOut->SetFont(pAcc->GetFDEFont()); @@ -143,7 +141,7 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { mtPart.Concat(*pMatrix); m_pTextOut->SetMatrix(mtPart); - m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), + m_pTextOut->DrawLogicText(pRenderDevice, pParams->m_wsText.c_str(), pParams->m_wsText.GetLength(), pParams->m_rtPart); } diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index d22bee2a79..25bbe45e1b 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -14,10 +14,11 @@ #include "core/fxcrt/xml/cfx_xmlelement.h" #include "core/fxcrt/xml/cfx_xmlnode.h" #include "core/fxcrt/xml/cfx_xmltext.h" +#include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fde/cfde_renderdevice.h" +#include "xfa/fde/cfde_textout.h" #include "xfa/fxfa/cxfa_linkuserdata.h" #include "xfa/fxfa/cxfa_loadercontext.h" #include "xfa/fxfa/cxfa_pieceline.h" @@ -557,9 +558,8 @@ bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, if (!pFxDevice) return false; - auto pDevice = pdfium::MakeUnique(pFxDevice); - pDevice->SaveState(); - pDevice->SetClipRect(rtClip); + pFxDevice->SaveState(); + pFxDevice->SetClip_Rect(rtClip); if (m_pieceLines.empty()) { int32_t iBlockCount = CountBlocks(); @@ -598,13 +598,12 @@ bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, iCharCount = iChars; } memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); - RenderString(pDevice.get(), pPieceLine, j, pCharPos, tmDoc2Device); - } - for (j = 0; j < iPieces; j++) { - RenderPath(pDevice.get(), pPieceLine, j, pCharPos, tmDoc2Device); + RenderString(pFxDevice, pPieceLine, j, pCharPos, tmDoc2Device); } + for (j = 0; j < iPieces; j++) + RenderPath(pFxDevice, pPieceLine, j, pCharPos, tmDoc2Device); } - pDevice->RestoreState(); + pFxDevice->RestoreState(false); FX_Free(pCharPos); return iPieceLines > 0; } @@ -1137,7 +1136,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, m_iLines++; } -void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice, +void CXFA_TextLayout::RenderString(CFX_RenderDevice* pDevice, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, @@ -1145,13 +1144,13 @@ void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice, const CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); int32_t iCount = GetDisplayPos(pPiece, pCharPos); if (iCount > 0) { - pDevice->DrawString(pPiece->dwColor, pPiece->pFont, pCharPos, iCount, - pPiece->fFontSize, &tmDoc2Device); + CFDE_TextOut::DrawString(pDevice, pPiece->dwColor, pPiece->pFont, pCharPos, + iCount, pPiece->fFontSize, &tmDoc2Device); } pPieceLine->m_charCounts.push_back(iCount); } -void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, +void CXFA_TextLayout::RenderPath(CFX_RenderDevice* pDevice, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, @@ -1260,7 +1259,14 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, fEndY += 2.0f; } } - pDevice->DrawPath(pPiece->dwColor, 1, path, &tmDoc2Device); + + CFX_GraphStateData graphState; + graphState.m_LineCap = CFX_GraphStateData::LineCapButt; + graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter; + graphState.m_LineWidth = 1; + graphState.m_MiterLimit = 10; + graphState.m_DashPhase = 0; + pDevice->DrawPath(&path, &tmDoc2Device, &graphState, 0, pPiece->dwColor, 0); } int32_t CXFA_TextLayout::GetDisplayPos(const CXFA_TextPiece* pPiece, diff --git a/xfa/fxfa/cxfa_textlayout.h b/xfa/fxfa/cxfa_textlayout.h index d2ff0d21ea..e4bfa1a0bb 100644 --- a/xfa/fxfa/cxfa_textlayout.h +++ b/xfa/fxfa/cxfa_textlayout.h @@ -98,12 +98,12 @@ class CXFA_TextLayout { bool IsEnd(bool bSavePieces); void ProcessText(CFX_WideString& wsText); void UpdateAlign(float fHeight, float fBottom); - void RenderString(CFDE_RenderDevice* pDevice, + void RenderString(CFX_RenderDevice* pDevice, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device); - void RenderPath(CFDE_RenderDevice* pDevice, + void RenderPath(CFX_RenderDevice* pDevice, CXFA_PieceLine* pPieceLine, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, -- cgit v1.2.3