OLD | NEW |
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/fde_render.h" | 7 #include "xfa/fde/fde_render.h" |
8 | 8 |
9 #include "xfa/fde/fde_gedevice.h" | 9 #include "xfa/fde/fde_gedevice.h" |
10 #include "xfa/fde/fde_object.h" | 10 #include "xfa/fde/fde_object.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 else if (m_iCharPosCount < iCount) | 127 else if (m_iCharPosCount < iCount) |
128 m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount); | 128 m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount); |
129 | 129 |
130 if (m_iCharPosCount < iCount) | 130 if (m_iCharPosCount < iCount) |
131 m_iCharPosCount = iCount; | 131 m_iCharPosCount = iCount; |
132 | 132 |
133 iCount = pTextSet->GetDisplayPos(hText, m_pCharPos, FALSE); | 133 iCount = pTextSet->GetDisplayPos(hText, m_pCharPos, FALSE); |
134 FX_FLOAT fFontSize = pTextSet->GetFontSize(hText); | 134 FX_FLOAT fFontSize = pTextSet->GetFontSize(hText); |
135 FX_ARGB dwColor = pTextSet->GetFontColor(hText); | 135 FX_ARGB dwColor = pTextSet->GetFontColor(hText); |
136 m_pBrush->SetColor(dwColor); | 136 m_pBrush->SetColor(dwColor); |
137 FDE_HDEVICESTATE hState; | 137 FX_BOOL bClip = ApplyClip(pTextSet, hText); |
138 FX_BOOL bClip = ApplyClip(pTextSet, hText, hState); | |
139 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount, | 138 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount, |
140 fFontSize, &m_Transform); | 139 fFontSize, &m_Transform); |
141 if (bClip) | 140 if (bClip) |
142 RestoreClip(hState); | 141 RestoreClip(); |
143 } | 142 } |
144 | 143 |
145 FX_BOOL CFDE_RenderContext::ApplyClip(IFDE_VisualSet* pVisualSet, | 144 FX_BOOL CFDE_RenderContext::ApplyClip(IFDE_VisualSet* pVisualSet, |
146 FDE_HVISUALOBJ hObj, | 145 FDE_HVISUALOBJ hObj) { |
147 FDE_HDEVICESTATE& hState) { | |
148 CFX_RectF rtClip; | 146 CFX_RectF rtClip; |
149 if (!pVisualSet->GetClip(hObj, rtClip)) | 147 if (!pVisualSet->GetClip(hObj, rtClip)) |
150 return FALSE; | 148 return FALSE; |
151 | 149 |
152 CFX_RectF rtObj; | 150 CFX_RectF rtObj; |
153 pVisualSet->GetRect(hObj, rtObj); | 151 pVisualSet->GetRect(hObj, rtObj); |
154 rtClip.Offset(rtObj.left, rtObj.top); | 152 rtClip.Offset(rtObj.left, rtObj.top); |
155 m_Transform.TransformRect(rtClip); | 153 m_Transform.TransformRect(rtClip); |
156 const CFX_RectF& rtDevClip = m_pRenderDevice->GetClipRect(); | 154 const CFX_RectF& rtDevClip = m_pRenderDevice->GetClipRect(); |
157 rtClip.Intersect(rtDevClip); | 155 rtClip.Intersect(rtDevClip); |
158 hState = m_pRenderDevice->SaveState(); | 156 m_pRenderDevice->SaveState(); |
159 return m_pRenderDevice->SetClipRect(rtClip); | 157 return m_pRenderDevice->SetClipRect(rtClip); |
160 } | 158 } |
161 | 159 |
162 void CFDE_RenderContext::RestoreClip(FDE_HDEVICESTATE hState) { | 160 void CFDE_RenderContext::RestoreClip() { |
163 m_pRenderDevice->RestoreState(hState); | 161 m_pRenderDevice->RestoreState(); |
164 } | 162 } |
OLD | NEW |