summaryrefslogtreecommitdiff
path: root/xfa/fwl/cfwl_edit.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-14 15:49:46 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-14 20:05:09 +0000
commit2d883813f969dcb88e240b6bd7bcd5af9e782331 (patch)
treed93ec2713e34712ed137804f1eccc252b592f347 /xfa/fwl/cfwl_edit.cpp
parent2d03e604b3979db45f6f2ea8c00c8d7fe0790790 (diff)
downloadpdfium-2d883813f969dcb88e240b6bd7bcd5af9e782331.tar.xz
Merge CFDE_RenderContext into CFWL_Edit
This CL removes CFDE_RenderContext and moves the ::Render method to be ::RenderText on the CFWL_Edit class which was the only caller. Change-Id: Ic940a3f0d10cfce169f5e491de90803fc8a7940d Reviewed-on: https://pdfium-review.googlesource.com/10950 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fwl/cfwl_edit.cpp')
-rw-r--r--xfa/fwl/cfwl_edit.cpp52
1 files changed, 46 insertions, 6 deletions
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index fe4b9dad0c..042e076ab6 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -13,10 +13,10 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
-#include "xfa/fde/cfde_rendercontext.h"
#include "xfa/fde/cfde_renderdevice.h"
#include "xfa/fde/cfde_txtedtengine.h"
#include "xfa/fde/cfde_txtedtpage.h"
+#include "xfa/fde/cfde_txtedttextset.h"
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fwl/cfwl_app.h"
#include "xfa/fwl/cfwl_caret.h"
@@ -567,11 +567,7 @@ void CFWL_Edit::DrawContent(CXFA_Graphics* pGraphics,
if (!pRenderDev)
return;
- CFDE_RenderDevice renderDevice(pRenderDev);
- renderDevice.SetClipRect(rtClip);
-
- CFDE_RenderContext renderContext(&renderDevice);
- renderContext.Render(pPage, mt);
+ RenderText(pRenderDev, rtClip, *pPage, mt);
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
pGraphics->RestoreGraphState();
@@ -596,6 +592,50 @@ void CFWL_Edit::DrawContent(CXFA_Graphics* pGraphics,
pGraphics->RestoreGraphState();
}
+void CFWL_Edit::RenderText(CFX_RenderDevice* pRenderDev,
+ const CFX_RectF& clipRect,
+ const CFDE_TxtEdtPage& pPage,
+ const CFX_Matrix& mt) {
+ ASSERT(pRenderDev);
+
+ CFDE_TxtEdtTextSet* pTextSet = pPage.GetTextSet();
+ if (!pTextSet)
+ return;
+
+ CFX_RetainPtr<CFGAS_GEFont> pFont = pTextSet->GetFont();
+ if (!pFont)
+ return;
+
+ CFDE_RenderDevice renderDevice(pRenderDev);
+ renderDevice.SetClipRect(clipRect);
+
+ CFX_RectF rtDocClip = renderDevice.GetClipRect();
+ if (rtDocClip.IsEmpty()) {
+ rtDocClip.left = rtDocClip.top = 0;
+ rtDocClip.width = static_cast<float>(renderDevice.GetWidth());
+ rtDocClip.height = static_cast<float>(renderDevice.GetHeight());
+ }
+ mt.GetInverse().TransformRect(rtDocClip);
+
+ std::vector<FXTEXT_CHARPOS> char_pos;
+
+ for (size_t i = 0; i < pPage.GetTextPieceCount(); ++i) {
+ const FDE_TEXTEDITPIECE& pText = pPage.GetTextPiece(i);
+ if (!rtDocClip.IntersectWith(pTextSet->GetRect(pText)))
+ continue;
+
+ int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, false);
+ if (iCount < 1)
+ continue;
+ if (char_pos.size() < static_cast<size_t>(iCount))
+ 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);
+ }
+}
+
void CFWL_Edit::UpdateEditEngine() {
UpdateEditParams();
UpdateEditLayout();