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_gedevice.h" | 7 #include "xfa/fde/fde_gedevice.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "xfa/fde/cfde_path.h" | 11 #include "xfa/fde/cfde_path.h" |
12 #include "xfa/fde/fde_object.h" | 12 #include "xfa/fde/fde_object.h" |
13 #include "xfa/fgas/font/fgas_font.h" | 13 #include "xfa/fgas/font/fgas_font.h" |
| 14 #include "xfa/fgas/font/fgas_gefont.h" |
14 | 15 |
15 CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, | 16 CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, |
16 FX_BOOL bOwnerDevice) | 17 FX_BOOL bOwnerDevice) |
17 : m_pDevice(pDevice), | 18 : m_pDevice(pDevice), |
18 m_bOwnerDevice(bOwnerDevice), | 19 m_bOwnerDevice(bOwnerDevice), |
19 m_pCharPos(nullptr), | 20 m_pCharPos(nullptr), |
20 m_iCharCount(0) { | 21 m_iCharCount(0) { |
21 ASSERT(pDevice); | 22 ASSERT(pDevice); |
22 | 23 |
23 FX_RECT rt = m_pDevice->GetClipBox(); | 24 FX_RECT rt = m_pDevice->GetClipBox(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 99 } |
99 void* handle = NULL; | 100 void* handle = NULL; |
100 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, | 101 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, |
101 handle); | 102 handle); |
102 while (m_pDevice->ContinueDIBits(handle, NULL)) { | 103 while (m_pDevice->ContinueDIBits(handle, NULL)) { |
103 } | 104 } |
104 m_pDevice->CancelDIBits(handle); | 105 m_pDevice->CancelDIBits(handle); |
105 return handle != NULL; | 106 return handle != NULL; |
106 } | 107 } |
107 FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, | 108 FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, |
108 IFX_Font* pFont, | 109 CFX_GEFont* pFont, |
109 const FXTEXT_CHARPOS* pCharPos, | 110 const FXTEXT_CHARPOS* pCharPos, |
110 int32_t iCount, | 111 int32_t iCount, |
111 FX_FLOAT fFontSize, | 112 FX_FLOAT fFontSize, |
112 const CFX_Matrix* pMatrix) { | 113 const CFX_Matrix* pMatrix) { |
113 ASSERT(pBrush != NULL && pFont != NULL && pCharPos != NULL && iCount > 0); | 114 ASSERT(pBrush != NULL && pFont != NULL && pCharPos != NULL && iCount > 0); |
114 CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache(); | 115 CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache(); |
115 CFX_Font* pFxFont = (CFX_Font*)pFont->GetDevFont(); | 116 CFX_Font* pFxFont = (CFX_Font*)pFont->GetDevFont(); |
116 | 117 |
117 FX_ARGB argb = pBrush->GetColor(); | 118 FX_ARGB argb = pBrush->GetColor(); |
118 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && | 119 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && |
119 !pFxFont->IsItalic()) { | 120 !pFxFont->IsItalic()) { |
120 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; | 121 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; |
121 FX_FLOAT* pAM; | 122 FX_FLOAT* pAM; |
122 for (int32_t i = 0; i < iCount; ++i) { | 123 for (int32_t i = 0; i < iCount; ++i) { |
123 static const FX_FLOAT mc = 0.267949f; | 124 static const FX_FLOAT mc = 0.267949f; |
124 pAM = pCP->m_AdjustMatrix; | 125 pAM = pCP->m_AdjustMatrix; |
125 pAM[2] = mc * pAM[0] + pAM[2]; | 126 pAM[2] = mc * pAM[0] + pAM[2]; |
126 pAM[3] = mc * pAM[1] + pAM[3]; | 127 pAM[3] = mc * pAM[1] + pAM[3]; |
127 pCP++; | 128 pCP++; |
128 } | 129 } |
129 } | 130 } |
130 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; | 131 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; |
131 IFX_Font* pCurFont = NULL; | 132 CFX_GEFont* pCurFont = NULL; |
132 IFX_Font* pSTFont = NULL; | 133 CFX_GEFont* pSTFont = NULL; |
133 FXTEXT_CHARPOS* pCurCP = NULL; | 134 FXTEXT_CHARPOS* pCurCP = NULL; |
134 int32_t iCurCount = 0; | 135 int32_t iCurCount = 0; |
135 | 136 |
136 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 137 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
137 uint32_t dwFontStyle = pFont->GetFontStyles(); | 138 uint32_t dwFontStyle = pFont->GetFontStyles(); |
138 CFX_Font FxFont; | 139 CFX_Font FxFont; |
139 CFX_SubstFont SubstFxFont; | 140 CFX_SubstFont SubstFxFont; |
140 FxFont.SetSubstFont(&SubstFxFont); | 141 FxFont.SetSubstFont(&SubstFxFont); |
141 SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400; | 142 SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400; |
142 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; | 143 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 const CFX_Matrix* pMatrix) { | 328 const CFX_Matrix* pMatrix) { |
328 CFDE_Path* pGePath = (CFDE_Path*)pPath; | 329 CFDE_Path* pGePath = (CFDE_Path*)pPath; |
329 if (!pGePath) | 330 if (!pGePath) |
330 return FALSE; | 331 return FALSE; |
331 if (!pBrush) | 332 if (!pBrush) |
332 return FALSE; | 333 return FALSE; |
333 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, | 334 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, |
334 pBrush->GetColor(), 0, FXFILL_WINDING); | 335 pBrush->GetColor(), 0, FXFILL_WINDING); |
335 } | 336 } |
336 | 337 |
OLD | NEW |