Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: xfa/fde/tto/fde_textout.cpp

Issue 1881803003: Remove IFDE_Pen and IFDE_Brush. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fde/fde_visualset.h ('k') | xfa/fxfa/app/xfa_textlayout.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fde/tto/fde_textout.h" 7 #include "xfa/fde/tto/fde_textout.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "core/fxcrt/include/fx_coordinates.h" 11 #include "core/fxcrt/include/fx_coordinates.h"
12 #include "core/fxcrt/include/fx_system.h" 12 #include "core/fxcrt/include/fx_system.h"
13 #include "xfa/fde/fde_brush.h"
14 #include "xfa/fde/fde_object.h" 13 #include "xfa/fde/fde_object.h"
15 #include "xfa/fde/fde_pen.h"
16 #include "xfa/fde/fde_renderdevice.h" 14 #include "xfa/fde/fde_renderdevice.h"
17 #include "xfa/fgas/crt/fgas_memory.h" 15 #include "xfa/fgas/crt/fgas_memory.h"
18 #include "xfa/fgas/crt/fgas_utils.h" 16 #include "xfa/fgas/crt/fgas_utils.h"
19 #include "xfa/fgas/layout/fgas_textbreak.h" 17 #include "xfa/fgas/layout/fgas_textbreak.h"
20 18
21 namespace { 19 namespace {
22 20
23 struct FDE_TTOPIECE { 21 struct FDE_TTOPIECE {
24 public: 22 public:
25 int32_t iStartChar; 23 int32_t iStartChar;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void AppendPiece(const FDE_TTOPIECE& ttoPiece, 136 void AppendPiece(const FDE_TTOPIECE& ttoPiece,
139 FX_BOOL bNeedReload, 137 FX_BOOL bNeedReload,
140 FX_BOOL bEnd); 138 FX_BOOL bEnd);
141 void ReplaceWidthEllipsis(); 139 void ReplaceWidthEllipsis();
142 void DoAlignment(const CFX_RectF& rect); 140 void DoAlignment(const CFX_RectF& rect);
143 void OnDraw(const CFX_RectF& rtClip); 141 void OnDraw(const CFX_RectF& rtClip);
144 int32_t GetDisplayPos(FDE_LPTTOPIECE pPiece); 142 int32_t GetDisplayPos(FDE_LPTTOPIECE pPiece);
145 int32_t GetCharRects(FDE_LPTTOPIECE pPiece); 143 int32_t GetCharRects(FDE_LPTTOPIECE pPiece);
146 144
147 void ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr); 145 void ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr);
148 void DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen); 146 void DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen);
149 147
150 IFX_TxtBreak* m_pTxtBreak; 148 IFX_TxtBreak* m_pTxtBreak;
151 IFX_Font* m_pFont; 149 IFX_Font* m_pFont;
152 FX_FLOAT m_fFontSize; 150 FX_FLOAT m_fFontSize;
153 FX_FLOAT m_fLineSpace; 151 FX_FLOAT m_fLineSpace;
154 FX_FLOAT m_fLinePos; 152 FX_FLOAT m_fLinePos;
155 FX_FLOAT m_fTolerance; 153 FX_FLOAT m_fTolerance;
156 int32_t m_iAlignment; 154 int32_t m_iAlignment;
157 int32_t m_iTxtBkAlignment; 155 int32_t m_iTxtBkAlignment;
158 int32_t* m_pCharWidths; 156 int32_t* m_pCharWidths;
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 } 942 }
945 } 943 }
946 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { 944 void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
947 if (m_pRenderDevice == NULL) { 945 if (m_pRenderDevice == NULL) {
948 return; 946 return;
949 } 947 }
950 int32_t iLines = m_ttoLines.GetSize(); 948 int32_t iLines = m_ttoLines.GetSize();
951 if (iLines < 1) { 949 if (iLines < 1) {
952 return; 950 return;
953 } 951 }
954 IFDE_SolidBrush* pBrush = new CFDE_SolidBrush; 952 CFDE_Brush* pBrush = new CFDE_Brush;
955 pBrush->SetColor(m_TxtColor); 953 pBrush->SetColor(m_TxtColor);
956 IFDE_Pen* pPen = NULL; 954 CFDE_Pen* pPen = NULL;
957 FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState(); 955 FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState();
958 if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { 956 if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) {
959 m_pRenderDevice->SetClipRect(rtClip); 957 m_pRenderDevice->SetClipRect(rtClip);
960 } 958 }
961 for (int32_t i = 0; i < iLines; i++) { 959 for (int32_t i = 0; i < iLines; i++) {
962 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); 960 CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i);
963 int32_t iPieces = pLine->GetSize(); 961 int32_t iPieces = pLine->GetSize();
964 for (int32_t j = 0; j < iPieces; j++) { 962 for (int32_t j = 0; j < iPieces; j++) {
965 FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(j); 963 FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(j);
966 if (pPiece == NULL) { 964 if (pPiece == NULL) {
967 continue; 965 continue;
968 } 966 }
969 int32_t iCount = GetDisplayPos(pPiece); 967 int32_t iCount = GetDisplayPos(pPiece);
970 if (iCount > 0) { 968 if (iCount > 0) {
971 m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount, 969 m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount,
972 m_fFontSize, &m_Matrix); 970 m_fFontSize, &m_Matrix);
973 } 971 }
974 DrawLine(pPiece, pPen); 972 DrawLine(pPiece, pPen);
975 } 973 }
976 } 974 }
977 m_pRenderDevice->RestoreState(hDev); 975 m_pRenderDevice->RestoreState(hDev);
978 if (pBrush) { 976 delete pBrush;
979 pBrush->Release(); 977 delete pPen;
980 }
981 if (pPen) {
982 pPen->Release();
983 }
984 } 978 }
985 int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { 979 int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) {
986 FX_TXTRUN tr; 980 FX_TXTRUN tr;
987 ToTextRun(pPiece, tr); 981 ToTextRun(pPiece, tr);
988 ExpandBuffer(tr.iLength, 2); 982 ExpandBuffer(tr.iLength, 2);
989 return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos); 983 return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos);
990 } 984 }
991 int32_t CFDE_TextOut::GetCharRects(FDE_LPTTOPIECE pPiece) { 985 int32_t CFDE_TextOut::GetCharRects(FDE_LPTTOPIECE pPiece) {
992 FX_TXTRUN tr; 986 FX_TXTRUN tr;
993 ToTextRun(pPiece, tr); 987 ToTextRun(pPiece, tr);
994 m_rectArray.RemoveAll(); 988 m_rectArray.RemoveAll();
995 return m_pTxtBreak->GetCharRects(&tr, m_rectArray); 989 return m_pTxtBreak->GetCharRects(&tr, m_rectArray);
996 } 990 }
997 void CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr) { 991 void CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr) {
998 tr.pAccess = NULL; 992 tr.pAccess = NULL;
999 tr.pIdentity = NULL; 993 tr.pIdentity = NULL;
1000 tr.pStr = (const FX_WCHAR*)m_wsText + pPiece->iStartChar; 994 tr.pStr = (const FX_WCHAR*)m_wsText + pPiece->iStartChar;
1001 tr.pWidths = m_pCharWidths + pPiece->iStartChar; 995 tr.pWidths = m_pCharWidths + pPiece->iStartChar;
1002 tr.iLength = pPiece->iChars; 996 tr.iLength = pPiece->iChars;
1003 tr.pFont = m_pFont; 997 tr.pFont = m_pFont;
1004 tr.fFontSize = m_fFontSize; 998 tr.fFontSize = m_fFontSize;
1005 tr.dwStyles = m_dwTxtBkStyles; 999 tr.dwStyles = m_dwTxtBkStyles;
1006 tr.iCharRotation = 0; 1000 tr.iCharRotation = 0;
1007 tr.dwCharStyles = pPiece->dwCharStyles; 1001 tr.dwCharStyles = pPiece->dwCharStyles;
1008 tr.wLineBreakChar = m_wParagraphBkChar; 1002 tr.wLineBreakChar = m_wParagraphBkChar;
1009 tr.pRect = &pPiece->rtPiece; 1003 tr.pRect = &pPiece->rtPiece;
1010 } 1004 }
1011 void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen) { 1005 void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen) {
1012 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); 1006 FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline);
1013 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); 1007 FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout);
1014 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); 1008 FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey);
1015 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); 1009 FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
1016 if (!bUnderLine && !bStrikeOut && !bHotKey) { 1010 if (!bUnderLine && !bStrikeOut && !bHotKey) {
1017 return; 1011 return;
1018 } 1012 }
1019 if (pPen == NULL) { 1013 if (pPen == NULL) {
1020 pPen = new CFDE_Pen; 1014 pPen = new CFDE_Pen;
1021 pPen->SetColor(m_TxtColor); 1015 pPen->SetColor(m_TxtColor);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 return NULL; 1105 return NULL;
1112 } 1106 }
1113 return m_pieces.GetPtrAt(index); 1107 return m_pieces.GetPtrAt(index);
1114 } 1108 }
1115 void CFDE_TTOLine::RemoveLast(int32_t iCount) { 1109 void CFDE_TTOLine::RemoveLast(int32_t iCount) {
1116 m_pieces.RemoveLast(iCount); 1110 m_pieces.RemoveLast(iCount);
1117 } 1111 }
1118 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { 1112 void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) {
1119 m_pieces.RemoveAll(bLeaveMemory); 1113 m_pieces.RemoveAll(bLeaveMemory);
1120 } 1114 }
OLDNEW
« no previous file with comments | « xfa/fde/fde_visualset.h ('k') | xfa/fxfa/app/xfa_textlayout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698