summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-14 17:23:25 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-15 13:42:32 +0000
commit73b492a5d775c05d8c186c8478d1003edfffd34c (patch)
tree0815bab5627ae27f5eb2f1a45b90bb9dc10b9e1c
parent5f0e64435c97755a7d309e80ea0a4dad83e76e73 (diff)
downloadpdfium-73b492a5d775c05d8c186c8478d1003edfffd34c.tar.xz
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 <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--BUILD.gn1
-rw-r--r--core/fxge/cfx_renderdevice.cpp7
-rw-r--r--core/fxge/cfx_renderdevice.h1
-rw-r--r--xfa/fde/cfde_renderdevice.cpp159
-rw-r--r--xfa/fde/cfde_renderdevice.h48
-rw-r--r--xfa/fde/cfde_textout.cpp105
-rw-r--r--xfa/fde/cfde_textout.h13
-rw-r--r--xfa/fwl/cfwl_edit.cpp16
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp4
-rw-r--r--xfa/fxfa/cxfa_fwltheme.cpp6
-rw-r--r--xfa/fxfa/cxfa_textlayout.cpp34
-rw-r--r--xfa/fxfa/cxfa_textlayout.h4
12 files changed, 144 insertions, 254 deletions
diff --git a/BUILD.gn b/BUILD.gn
index bfe38046a5..e268c50b16 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1459,7 +1459,6 @@ if (pdf_enable_xfa) {
static_library("xfa") {
sources = [
- "xfa/fde/cfde_renderdevice.cpp",
"xfa/fde/cfde_textout.cpp",
"xfa/fde/cfde_textout.h",
"xfa/fde/cfde_txtedtbuf.cpp",
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 310a16512c..cb0e600916 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -471,6 +471,13 @@ bool CFX_RenderDevice::SetClip_PathStroke(
return true;
}
+bool CFX_RenderDevice::SetClip_Rect(const CFX_RectF& rtClip) {
+ return SetClip_Rect(FX_RECT(static_cast<int32_t>(floor(rtClip.left)),
+ static_cast<int32_t>(floor(rtClip.top)),
+ static_cast<int32_t>(ceil(rtClip.right())),
+ static_cast<int32_t>(ceil(rtClip.bottom()))));
+}
+
bool CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) {
CFX_PathData path;
path.AppendRect(rect.left, rect.bottom, rect.right, rect.top);
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index ad8e487749..1a69c42b14 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -123,6 +123,7 @@ class CFX_RenderDevice {
bool SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode);
+ bool SetClip_Rect(const CFX_RectF& pRect);
bool SetClip_Rect(const FX_RECT& pRect);
bool SetClip_PathStroke(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
diff --git a/xfa/fde/cfde_renderdevice.cpp b/xfa/fde/cfde_renderdevice.cpp
deleted file mode 100644
index e9457f4c5e..0000000000
--- a/xfa/fde/cfde_renderdevice.cpp
+++ /dev/null
@@ -1,159 +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
-
-#include "xfa/fde/cfde_renderdevice.h"
-
-#include <algorithm>
-#include <memory>
-#include <utility>
-
-#include "core/fxge/cfx_graphstatedata.h"
-#include "core/fxge/cfx_pathdata.h"
-#include "core/fxge/cfx_renderdevice.h"
-#include "core/fxge/cfx_substfont.h"
-#include "core/fxge/dib/cfx_imagerenderer.h"
-#include "third_party/base/ptr_util.h"
-#include "xfa/fgas/font/cfgas_fontmgr.h"
-#include "xfa/fgas/font/cfgas_gefont.h"
-
-CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice)
- : m_pDevice(pDevice) {
- ASSERT(pDevice);
-
- FX_RECT rt = m_pDevice->GetClipBox();
- m_rtClip = CFX_RectF(static_cast<float>(rt.left), static_cast<float>(rt.top),
- static_cast<float>(rt.Width()),
- static_cast<float>(rt.Height()));
-}
-
-CFDE_RenderDevice::~CFDE_RenderDevice() {}
-
-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 = CFX_RectF(static_cast<float>(rt.left), static_cast<float>(rt.top),
- static_cast<float>(rt.Width()),
- static_cast<float>(rt.Height()));
-}
-
-bool CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) {
- m_rtClip = rtClip;
- return m_pDevice->SetClip_Rect(
- FX_RECT((int32_t)floor(rtClip.left), (int32_t)floor(rtClip.top),
- (int32_t)ceil(rtClip.right()), (int32_t)ceil(rtClip.bottom())));
-}
-
-const CFX_RectF& CFDE_RenderDevice::GetClipRect() {
- return m_rtClip;
-}
-
-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(pFont && pCharPos && iCount > 0);
- CFX_Font* pFxFont = pFont->GetDevFont();
- if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
- !pFxFont->IsItalic()) {
- FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
- float* pAM;
- for (int32_t i = 0; i < iCount; ++i) {
- static const 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;
- CFX_RetainPtr<CFGAS_GEFont> pCurFont;
- CFX_RetainPtr<CFGAS_GEFont> pSTFont;
- FXTEXT_CHARPOS* pCurCP = nullptr;
- int32_t iCurCount = 0;
-
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- uint32_t dwFontStyle = pFont->GetFontStyles();
- CFX_Font FxFont;
- auto SubstFxFont = pdfium::MakeUnique<CFX_SubstFont>();
- SubstFxFont->m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
- SubstFxFont->m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
- SubstFxFont->m_WeightCJK = SubstFxFont->m_Weight;
- SubstFxFont->m_bItalicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic);
- FxFont.SetSubstFont(std::move(SubstFxFont));
-#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) {
- pFxFont = pCurFont->GetDevFont();
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- FxFont.SetFace(pFxFont->GetFace());
- m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, -fFontSize,
- pMatrix, color, FXTEXT_CLEARTYPE);
-#else
- m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize,
- pMatrix, color, FXTEXT_CLEARTYPE);
-#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- }
- pCurFont = pSTFont;
- pCurCP = pCP;
- iCurCount = 1;
- } else {
- iCurCount++;
- }
- pCP++;
- }
- if (pCurFont && iCurCount) {
- pFxFont = pCurFont->GetDevFont();
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- FxFont.SetFace(pFxFont->GetFace());
- bool bRet =
- m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, -fFontSize,
- pMatrix, color, FXTEXT_CLEARTYPE);
- FxFont.SetFace(nullptr);
- return bRet;
-#else
- return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize,
- pMatrix, color, FXTEXT_CLEARTYPE);
-#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- }
-
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- FxFont.SetFace(nullptr);
-#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
-
- return true;
-}
-
-bool CFDE_RenderDevice::DrawPath(FX_ARGB color,
- float fPenWidth,
- const CFX_PathData& pPath,
- const CFX_Matrix* pMatrix) {
- CFX_GraphStateData graphState;
- 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(&pPath, pMatrix, &graphState, 0, color, 0);
-}
diff --git a/xfa/fde/cfde_renderdevice.h b/xfa/fde/cfde_renderdevice.h
deleted file mode 100644
index ccc2ef281e..0000000000
--- a/xfa/fde/cfde_renderdevice.h
+++ /dev/null
@@ -1,48 +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_CFDE_RENDERDEVICE_H_
-#define XFA_FDE_CFDE_RENDERDEVICE_H_
-
-#include <vector>
-
-#include "core/fxge/cfx_renderdevice.h"
-#include "xfa/fgas/font/cfgas_gefont.h"
-
-class CFX_PathData;
-class CFX_GraphStateData;
-
-class CFDE_RenderDevice {
- public:
- explicit CFDE_RenderDevice(CFX_RenderDevice* pDevice);
- ~CFDE_RenderDevice();
-
- int32_t GetWidth() const;
- int32_t GetHeight() const;
-
- void SaveState();
- void RestoreState();
-
- bool SetClipRect(const CFX_RectF& rtClip);
- const CFX_RectF& GetClipRect();
-
- bool DrawString(FX_ARGB color,
- const CFX_RetainPtr<CFGAS_GEFont>& pFont,
- const FXTEXT_CHARPOS* pCharPos,
- int32_t iCount,
- float fFontSize,
- const CFX_Matrix* pMatrix);
- bool DrawPath(FX_ARGB color,
- float fPenWidth,
- const CFX_PathData& pPath,
- const CFX_Matrix* pMatrix);
-
- private:
- CFX_RenderDevice* const m_pDevice;
- CFX_RectF m_rtClip;
-};
-
-#endif // XFA_FDE_CFDE_RENDERDEVICE_H_
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 5f7fe078f1..7a246a8efe 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -14,7 +14,6 @@
#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/fgas/layout/cfx_txtbreak.h"
namespace {
@@ -31,6 +30,90 @@ bool IsTextAlignmentTop(const FDE_TextAlignment align) {
} // namespace
+// static
+bool CFDE_TextOut::DrawString(CFX_RenderDevice* device,
+ FX_ARGB color,
+ const CFX_RetainPtr<CFGAS_GEFont>& pFont,
+ const FXTEXT_CHARPOS* pCharPos,
+ int32_t iCount,
+ float fFontSize,
+ const CFX_Matrix* pMatrix) {
+ ASSERT(pFont && pCharPos && iCount > 0);
+ CFX_Font* pFxFont = pFont->GetDevFont();
+ if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
+ !pFxFont->IsItalic()) {
+ FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
+ float* pAM;
+ for (int32_t i = 0; i < iCount; ++i) {
+ static const 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;
+ CFX_RetainPtr<CFGAS_GEFont> pCurFont;
+ CFX_RetainPtr<CFGAS_GEFont> pSTFont;
+ FXTEXT_CHARPOS* pCurCP = nullptr;
+ int32_t iCurCount = 0;
+
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ uint32_t dwFontStyle = pFont->GetFontStyles();
+ CFX_Font FxFont;
+ auto SubstFxFont = pdfium::MakeUnique<CFX_SubstFont>();
+ SubstFxFont->m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
+ SubstFxFont->m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
+ SubstFxFont->m_WeightCJK = SubstFxFont->m_Weight;
+ SubstFxFont->m_bItalicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic);
+ FxFont.SetSubstFont(std::move(SubstFxFont));
+#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) {
+ pFxFont = pCurFont->GetDevFont();
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ FxFont.SetFace(pFxFont->GetFace());
+ device->DrawNormalText(iCurCount, pCurCP, &FxFont, -fFontSize, pMatrix,
+ color, FXTEXT_CLEARTYPE);
+#else
+ device->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize, pMatrix,
+ color, FXTEXT_CLEARTYPE);
+#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ }
+ pCurFont = pSTFont;
+ pCurCP = pCP;
+ iCurCount = 1;
+ } else {
+ iCurCount++;
+ }
+ pCP++;
+ }
+ if (pCurFont && iCurCount) {
+ pFxFont = pCurFont->GetDevFont();
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ FxFont.SetFace(pFxFont->GetFace());
+ bool bRet = device->DrawNormalText(iCurCount, pCurCP, &FxFont, -fFontSize,
+ pMatrix, color, FXTEXT_CLEARTYPE);
+ FxFont.SetFace(nullptr);
+ return bRet;
+#else
+ return device->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize,
+ pMatrix, color, FXTEXT_CLEARTYPE);
+#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ }
+
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ FxFont.SetFace(nullptr);
+#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+
+ return true;
+}
+
FDE_TTOPIECE::FDE_TTOPIECE() = default;
FDE_TTOPIECE::FDE_TTOPIECE(const FDE_TTOPIECE& that) = default;
@@ -102,11 +185,6 @@ void CFDE_TextOut::SetLineSpace(float fLineSpace) {
m_fLineSpace = fLineSpace;
}
-void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
- ASSERT(pDevice);
- m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pDevice);
-}
-
void CFDE_TextOut::SetLineBreakTolerance(float fTolerance) {
m_fTolerance = fTolerance;
m_pTxtBreak->SetLineBreakTolerance(m_fTolerance);
@@ -208,7 +286,8 @@ bool CFDE_TextOut::RetrieveLineWidth(CFX_BreakType dwBreakStatus,
return true;
}
-void CFDE_TextOut::DrawLogicText(const wchar_t* pwsStr,
+void CFDE_TextOut::DrawLogicText(CFX_RenderDevice* device,
+ const wchar_t* pwsStr,
int32_t iLength,
const CFX_RectF& rect) {
ASSERT(m_pFont && m_fFontSize >= 1.0f);
@@ -226,15 +305,15 @@ void CFDE_TextOut::DrawLogicText(const wchar_t* pwsStr,
Reload(rect);
DoAlignment(rect);
- if (!m_pRenderDevice || m_ttoLines.empty())
+ if (!device || m_ttoLines.empty())
return;
CFX_RectF rtClip;
m_Matrix.TransformRect(rtClip);
- m_pRenderDevice->SaveState();
+ device->SaveState();
if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f)
- m_pRenderDevice->SetClipRect(rtClip);
+ device->SetClip_Rect(rtClip);
for (auto& line : m_ttoLines) {
int32_t iPieces = line.GetSize();
@@ -245,12 +324,12 @@ void CFDE_TextOut::DrawLogicText(const wchar_t* pwsStr,
int32_t iCount = GetDisplayPos(pPiece);
if (iCount > 0) {
- m_pRenderDevice->DrawString(m_TxtColor, m_pFont, m_CharPos.data(),
- iCount, m_fFontSize, &m_Matrix);
+ CFDE_TextOut::DrawString(device, m_TxtColor, m_pFont, m_CharPos.data(),
+ iCount, m_fFontSize, &m_Matrix);
}
}
}
- m_pRenderDevice->RestoreState();
+ device->RestoreState(false);
}
void CFDE_TextOut::LoadText(const wchar_t* pwsStr,
diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h
index f2541bb11b..421987c3fd 100644
--- a/xfa/fde/cfde_textout.h
+++ b/xfa/fde/cfde_textout.h
@@ -76,6 +76,14 @@ class CFDE_TTOLine {
class CFDE_TextOut {
public:
+ static bool DrawString(CFX_RenderDevice* device,
+ FX_ARGB color,
+ const CFX_RetainPtr<CFGAS_GEFont>& pFont,
+ const FXTEXT_CHARPOS* pCharPos,
+ int32_t iCount,
+ float fFontSize,
+ const CFX_Matrix* pMatrix);
+
CFDE_TextOut();
~CFDE_TextOut();
@@ -85,13 +93,13 @@ class CFDE_TextOut {
void SetStyles(const FDE_TextStyle& dwStyles);
void SetAlignment(FDE_TextAlignment iAlignment);
void SetLineSpace(float fLineSpace);
- void SetRenderDevice(CFX_RenderDevice* pDevice);
void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
void SetLineBreakTolerance(float fTolerance);
void CalcLogicSize(const wchar_t* pwsStr, int32_t iLength, CFX_SizeF& size);
void CalcLogicSize(const wchar_t* pwsStr, int32_t iLength, CFX_RectF& rect);
- void DrawLogicText(const wchar_t* pwsStr,
+ void DrawLogicText(CFX_RenderDevice* device,
+ const wchar_t* pwsStr,
int32_t iLength,
const CFX_RectF& rect);
int32_t GetTotalLines() const { return m_iTotalLines; }
@@ -134,7 +142,6 @@ class CFDE_TextOut {
int32_t m_iCurPiece;
int32_t m_iTotalLines;
std::vector<FXTEXT_CHARPOS> m_CharPos;
- std::unique_ptr<CFDE_RenderDevice> m_pRenderDevice;
};
#endif // XFA_FDE_CFDE_TEXTOUT_H_
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 042e076ab6..526275313f 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -13,7 +13,7 @@
#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/fde/cfde_txtedtengine.h"
#include "xfa/fde/cfde_txtedtpage.h"
#include "xfa/fde/cfde_txtedttextset.h"
@@ -606,14 +606,13 @@ void CFWL_Edit::RenderText(CFX_RenderDevice* pRenderDev,
if (!pFont)
return;
- CFDE_RenderDevice renderDevice(pRenderDev);
- renderDevice.SetClipRect(clipRect);
+ pRenderDev->SetClip_Rect(clipRect);
- CFX_RectF rtDocClip = renderDevice.GetClipRect();
+ CFX_RectF rtDocClip = clipRect;
if (rtDocClip.IsEmpty()) {
rtDocClip.left = rtDocClip.top = 0;
- rtDocClip.width = static_cast<float>(renderDevice.GetWidth());
- rtDocClip.height = static_cast<float>(renderDevice.GetHeight());
+ rtDocClip.width = static_cast<float>(pRenderDev->GetWidth());
+ rtDocClip.height = static_cast<float>(pRenderDev->GetHeight());
}
mt.GetInverse().TransformRect(rtDocClip);
@@ -631,8 +630,9 @@ void CFWL_Edit::RenderText(CFX_RenderDevice* pRenderDev,
char_pos.resize(iCount, FXTEXT_CHARPOS());
iCount = pTextSet->GetDisplayPos(pText, char_pos.data(), false);
- renderDevice.DrawString(pTextSet->GetFontColor(), pFont, char_pos.data(),
- iCount, pTextSet->GetFontSize(), &mt);
+ CFDE_TextOut::DrawString(pRenderDev, pTextSet->GetFontColor(), pFont,
+ char_pos.data(), iCount, pTextSet->GetFontSize(),
+ &mt);
}
}
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index bf5fd42736..fe63780c39 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -46,14 +46,14 @@ void CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) {
return;
CXFA_Graphics* pGraphics = pParams->m_pGraphics;
- m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice());
m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
CFX_Matrix* pMatrix = &pParams->m_matrix;
pMatrix->Concat(*pGraphics->GetMatrix());
m_pTextOut->SetMatrix(*pMatrix);
- m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), iLen, pParams->m_rtPart);
+ m_pTextOut->DrawLogicText(pGraphics->GetRenderDevice(),
+ pParams->m_wsText.c_str(), iLen, pParams->m_rtPart);
}
void CFWL_WidgetTP::InitializeArrowColorData() {
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<CFDE_RenderDevice>(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,