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_Transform.SetIdentity(); | 20 m_Transform.SetIdentity(); |
21 } | 21 } |
22 | 22 |
23 CFDE_RenderContext::~CFDE_RenderContext() { | 23 CFDE_RenderContext::~CFDE_RenderContext() { |
24 StopRender(); | 24 StopRender(); |
25 } | 25 } |
26 | 26 |
27 FX_BOOL CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice, | 27 bool CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice, |
28 IFDE_CanvasSet* pCanvasSet, | 28 IFDE_CanvasSet* pCanvasSet, |
29 const CFX_Matrix& tmDoc2Device) { | 29 const CFX_Matrix& tmDoc2Device) { |
30 if (m_pRenderDevice) | 30 if (m_pRenderDevice) |
31 return FALSE; | 31 return false; |
32 if (!pRenderDevice) | 32 if (!pRenderDevice) |
33 return FALSE; | 33 return false; |
34 if (!pCanvasSet) | 34 if (!pCanvasSet) |
35 return FALSE; | 35 return false; |
36 | 36 |
37 m_eStatus = FDE_RENDERSTATUS_Paused; | 37 m_eStatus = FDE_RENDERSTATUS_Paused; |
38 m_pRenderDevice = pRenderDevice; | 38 m_pRenderDevice = pRenderDevice; |
39 m_Transform = tmDoc2Device; | 39 m_Transform = tmDoc2Device; |
40 if (!m_pIterator) | 40 if (!m_pIterator) |
41 m_pIterator.reset(new CFDE_VisualSetIterator); | 41 m_pIterator.reset(new CFDE_VisualSetIterator); |
42 | 42 |
43 return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); | 43 return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); |
44 } | 44 } |
45 | 45 |
(...skipping 10 matching lines...) Expand all Loading... |
56 if (rtDocClip.IsEmpty()) { | 56 if (rtDocClip.IsEmpty()) { |
57 rtDocClip.left = rtDocClip.top = 0; | 57 rtDocClip.left = rtDocClip.top = 0; |
58 rtDocClip.width = (FX_FLOAT)m_pRenderDevice->GetWidth(); | 58 rtDocClip.width = (FX_FLOAT)m_pRenderDevice->GetWidth(); |
59 rtDocClip.height = (FX_FLOAT)m_pRenderDevice->GetHeight(); | 59 rtDocClip.height = (FX_FLOAT)m_pRenderDevice->GetHeight(); |
60 } | 60 } |
61 rm.TransformRect(rtDocClip); | 61 rm.TransformRect(rtDocClip); |
62 IFDE_VisualSet* pVisualSet; | 62 IFDE_VisualSet* pVisualSet; |
63 FDE_TEXTEDITPIECE* pPiece; | 63 FDE_TEXTEDITPIECE* pPiece; |
64 CFX_RectF rtObj; | 64 CFX_RectF rtObj; |
65 int32_t iCount = 0; | 65 int32_t iCount = 0; |
66 while (TRUE) { | 66 while (true) { |
67 pPiece = m_pIterator->GetNext(pVisualSet); | 67 pPiece = m_pIterator->GetNext(pVisualSet); |
68 if (!pPiece || !pVisualSet) { | 68 if (!pPiece || !pVisualSet) { |
69 eStatus = FDE_RENDERSTATUS_Done; | 69 eStatus = FDE_RENDERSTATUS_Done; |
70 break; | 70 break; |
71 } | 71 } |
72 rtObj.Empty(); | 72 rtObj.Empty(); |
73 pVisualSet->GetRect(pPiece, rtObj); | 73 pVisualSet->GetRect(pPiece, rtObj); |
74 if (!rtDocClip.IntersectWith(rtObj)) | 74 if (!rtDocClip.IntersectWith(rtObj)) |
75 continue; | 75 continue; |
76 | 76 |
77 switch (pVisualSet->GetType()) { | 77 switch (pVisualSet->GetType()) { |
78 case FDE_VISUALOBJ_Text: | 78 case FDE_VISUALOBJ_Text: |
79 RenderText(static_cast<IFDE_TextSet*>(pVisualSet), pPiece); | 79 RenderText(static_cast<IFDE_TextSet*>(pVisualSet), pPiece); |
80 iCount += 5; | 80 iCount += 5; |
81 break; | 81 break; |
82 case FDE_VISUALOBJ_Canvas: | 82 case FDE_VISUALOBJ_Canvas: |
83 ASSERT(FALSE); | 83 ASSERT(false); |
84 break; | 84 break; |
85 default: | 85 default: |
86 break; | 86 break; |
87 } | 87 } |
88 if (iCount >= 100 && pPause && pPause->NeedToPauseNow()) { | 88 if (iCount >= 100 && pPause && pPause->NeedToPauseNow()) { |
89 eStatus = FDE_RENDERSTATUS_Paused; | 89 eStatus = FDE_RENDERSTATUS_Paused; |
90 break; | 90 break; |
91 } | 91 } |
92 } | 92 } |
93 return m_eStatus = eStatus; | 93 return m_eStatus = eStatus; |
(...skipping 10 matching lines...) Expand all Loading... |
104 | 104 |
105 void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, | 105 void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, |
106 FDE_TEXTEDITPIECE* pText) { | 106 FDE_TEXTEDITPIECE* pText) { |
107 ASSERT(m_pRenderDevice); | 107 ASSERT(m_pRenderDevice); |
108 ASSERT(pTextSet && pText); | 108 ASSERT(pTextSet && pText); |
109 | 109 |
110 CFGAS_GEFont* pFont = pTextSet->GetFont(); | 110 CFGAS_GEFont* pFont = pTextSet->GetFont(); |
111 if (!pFont) | 111 if (!pFont) |
112 return; | 112 return; |
113 | 113 |
114 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, FALSE); | 114 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, false); |
115 if (iCount < 1) | 115 if (iCount < 1) |
116 return; | 116 return; |
117 | 117 |
118 if (!m_pBrush) | 118 if (!m_pBrush) |
119 m_pBrush.reset(new CFDE_Brush); | 119 m_pBrush.reset(new CFDE_Brush); |
120 | 120 |
121 if (m_CharPos.size() < static_cast<size_t>(iCount)) | 121 if (m_CharPos.size() < static_cast<size_t>(iCount)) |
122 m_CharPos.resize(iCount, FXTEXT_CHARPOS()); | 122 m_CharPos.resize(iCount, FXTEXT_CHARPOS()); |
123 | 123 |
124 iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), FALSE); | 124 iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), false); |
125 FX_FLOAT fFontSize = pTextSet->GetFontSize(); | 125 FX_FLOAT fFontSize = pTextSet->GetFontSize(); |
126 FX_ARGB dwColor = pTextSet->GetFontColor(); | 126 FX_ARGB dwColor = pTextSet->GetFontColor(); |
127 m_pBrush->SetColor(dwColor); | 127 m_pBrush->SetColor(dwColor); |
128 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, | 128 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, |
129 fFontSize, &m_Transform); | 129 fFontSize, &m_Transform); |
130 } | 130 } |
131 | 131 |
OLD | NEW |