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 "third_party/base/ptr_util.h" |
9 #include "xfa/fde/fde_gedevice.h" | 10 #include "xfa/fde/fde_gedevice.h" |
10 #include "xfa/fde/fde_object.h" | 11 #include "xfa/fde/fde_object.h" |
11 #include "xfa/fgas/crt/fgas_memory.h" | 12 #include "xfa/fgas/crt/fgas_memory.h" |
12 | 13 |
13 #define FDE_PATHRENDER_Stroke 1 | 14 #define FDE_PATHRENDER_Stroke 1 |
14 #define FDE_PATHRENDER_Fill 2 | 15 #define FDE_PATHRENDER_Fill 2 |
15 | 16 |
16 CFDE_RenderContext::CFDE_RenderContext() | 17 CFDE_RenderContext::CFDE_RenderContext() |
17 : m_eStatus(FDE_RENDERSTATUS_Reset), | 18 : m_eStatus(FDE_RENDERSTATUS_Reset), |
18 m_pRenderDevice(nullptr), | 19 m_pRenderDevice(nullptr), |
(...skipping 12 matching lines...) Expand all Loading... |
31 return false; | 32 return false; |
32 if (!pRenderDevice) | 33 if (!pRenderDevice) |
33 return false; | 34 return false; |
34 if (!pCanvasSet) | 35 if (!pCanvasSet) |
35 return false; | 36 return false; |
36 | 37 |
37 m_eStatus = FDE_RENDERSTATUS_Paused; | 38 m_eStatus = FDE_RENDERSTATUS_Paused; |
38 m_pRenderDevice = pRenderDevice; | 39 m_pRenderDevice = pRenderDevice; |
39 m_Transform = tmDoc2Device; | 40 m_Transform = tmDoc2Device; |
40 if (!m_pIterator) | 41 if (!m_pIterator) |
41 m_pIterator.reset(new CFDE_VisualSetIterator); | 42 m_pIterator = pdfium::MakeUnique<CFDE_VisualSetIterator>(); |
42 | 43 |
43 return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); | 44 return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); |
44 } | 45 } |
45 | 46 |
46 FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { | 47 FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { |
47 if (!m_pRenderDevice) | 48 if (!m_pRenderDevice) |
48 return FDE_RENDERSTATUS_Failed; | 49 return FDE_RENDERSTATUS_Failed; |
49 if (!m_pIterator) | 50 if (!m_pIterator) |
50 return FDE_RENDERSTATUS_Failed; | 51 return FDE_RENDERSTATUS_Failed; |
51 | 52 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 110 |
110 CFGAS_GEFont* pFont = pTextSet->GetFont(); | 111 CFGAS_GEFont* pFont = pTextSet->GetFont(); |
111 if (!pFont) | 112 if (!pFont) |
112 return; | 113 return; |
113 | 114 |
114 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, false); | 115 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, false); |
115 if (iCount < 1) | 116 if (iCount < 1) |
116 return; | 117 return; |
117 | 118 |
118 if (!m_pBrush) | 119 if (!m_pBrush) |
119 m_pBrush.reset(new CFDE_Brush); | 120 m_pBrush = pdfium::MakeUnique<CFDE_Brush>(); |
120 | 121 |
121 if (m_CharPos.size() < static_cast<size_t>(iCount)) | 122 if (m_CharPos.size() < static_cast<size_t>(iCount)) |
122 m_CharPos.resize(iCount, FXTEXT_CHARPOS()); | 123 m_CharPos.resize(iCount, FXTEXT_CHARPOS()); |
123 | 124 |
124 iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), false); | 125 iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), false); |
125 FX_FLOAT fFontSize = pTextSet->GetFontSize(); | 126 FX_FLOAT fFontSize = pTextSet->GetFontSize(); |
126 FX_ARGB dwColor = pTextSet->GetFontColor(); | 127 FX_ARGB dwColor = pTextSet->GetFontColor(); |
127 m_pBrush->SetColor(dwColor); | 128 m_pBrush->SetColor(dwColor); |
128 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, | 129 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, |
129 fFontSize, &m_Transform); | 130 fFontSize, &m_Transform); |
130 } | 131 } |
131 | 132 |
OLD | NEW |