| 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" |
| 11 #include "xfa/fgas/crt/fgas_memory.h" | 11 #include "xfa/fgas/crt/fgas_memory.h" |
| 12 | 12 |
| 13 #define FDE_PATHRENDER_Stroke 1 | 13 #define FDE_PATHRENDER_Stroke 1 |
| 14 #define FDE_PATHRENDER_Fill 2 | 14 #define FDE_PATHRENDER_Fill 2 |
| 15 | 15 |
| 16 CFDE_RenderContext::CFDE_RenderContext() | 16 CFDE_RenderContext::CFDE_RenderContext() |
| 17 : m_eStatus(FDE_RENDERSTATUS_Reset), | 17 : m_eStatus(FDE_RENDERSTATUS_Reset), |
| 18 m_pRenderDevice(nullptr), | 18 m_pRenderDevice(nullptr), |
| 19 m_Transform(), | 19 m_Transform() { |
| 20 m_pCharPos(nullptr), | |
| 21 m_iCharPosCount(0) { | |
| 22 m_Transform.SetIdentity(); | 20 m_Transform.SetIdentity(); |
| 23 } | 21 } |
| 24 | 22 |
| 25 CFDE_RenderContext::~CFDE_RenderContext() { | 23 CFDE_RenderContext::~CFDE_RenderContext() { |
| 26 StopRender(); | 24 StopRender(); |
| 27 } | 25 } |
| 28 | 26 |
| 29 FX_BOOL CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice, | 27 FX_BOOL CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice, |
| 30 IFDE_CanvasSet* pCanvasSet, | 28 IFDE_CanvasSet* pCanvasSet, |
| 31 const CFX_Matrix& tmDoc2Device) { | 29 const CFX_Matrix& tmDoc2Device) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 92 } |
| 95 return m_eStatus = eStatus; | 93 return m_eStatus = eStatus; |
| 96 } | 94 } |
| 97 | 95 |
| 98 void CFDE_RenderContext::StopRender() { | 96 void CFDE_RenderContext::StopRender() { |
| 99 m_eStatus = FDE_RENDERSTATUS_Reset; | 97 m_eStatus = FDE_RENDERSTATUS_Reset; |
| 100 m_pRenderDevice = nullptr; | 98 m_pRenderDevice = nullptr; |
| 101 m_Transform.SetIdentity(); | 99 m_Transform.SetIdentity(); |
| 102 m_pIterator.reset(); | 100 m_pIterator.reset(); |
| 103 m_pBrush.reset(); | 101 m_pBrush.reset(); |
| 104 FX_Free(m_pCharPos); | 102 m_CharPos.clear(); |
| 105 m_pCharPos = nullptr; | |
| 106 m_iCharPosCount = 0; | |
| 107 } | 103 } |
| 108 | 104 |
| 109 void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, | 105 void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, |
| 110 FDE_TEXTEDITPIECE* pText) { | 106 FDE_TEXTEDITPIECE* pText) { |
| 111 ASSERT(m_pRenderDevice); | 107 ASSERT(m_pRenderDevice); |
| 112 ASSERT(pTextSet && pText); | 108 ASSERT(pTextSet && pText); |
| 113 | 109 |
| 114 CFGAS_GEFont* pFont = pTextSet->GetFont(); | 110 CFGAS_GEFont* pFont = pTextSet->GetFont(); |
| 115 if (!pFont) | 111 if (!pFont) |
| 116 return; | 112 return; |
| 117 | 113 |
| 118 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, FALSE); | 114 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, FALSE); |
| 119 if (iCount < 1) | 115 if (iCount < 1) |
| 120 return; | 116 return; |
| 121 | 117 |
| 122 if (!m_pBrush) | 118 if (!m_pBrush) |
| 123 m_pBrush.reset(new CFDE_Brush); | 119 m_pBrush.reset(new CFDE_Brush); |
| 124 | 120 |
| 125 if (!m_pCharPos) | 121 if (m_CharPos.size() < static_cast<size_t>(iCount)) |
| 126 m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount); | 122 m_CharPos.resize(iCount, FXTEXT_CHARPOS()); |
| 127 else if (m_iCharPosCount < iCount) | |
| 128 m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount); | |
| 129 | 123 |
| 130 if (m_iCharPosCount < iCount) | 124 iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), FALSE); |
| 131 m_iCharPosCount = iCount; | |
| 132 | |
| 133 iCount = pTextSet->GetDisplayPos(pText, m_pCharPos, FALSE); | |
| 134 FX_FLOAT fFontSize = pTextSet->GetFontSize(); | 125 FX_FLOAT fFontSize = pTextSet->GetFontSize(); |
| 135 FX_ARGB dwColor = pTextSet->GetFontColor(); | 126 FX_ARGB dwColor = pTextSet->GetFontColor(); |
| 136 m_pBrush->SetColor(dwColor); | 127 m_pBrush->SetColor(dwColor); |
| 137 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount, | 128 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, |
| 138 fFontSize, &m_Transform); | 129 fFontSize, &m_Transform); |
| 139 } | 130 } |
| 140 | 131 |
| OLD | NEW |