Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: xfa/fde/fde_render.cpp

Issue 1896893003: Cleanup FDE interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fde/fde_render.h ('k') | xfa/fde/fde_renderdevice.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_object.h" 10 #include "xfa/fde/fde_object.h"
10 #include "xfa/fde/fde_renderdevice.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 namespace {
17
18 class CFDE_RenderContext : public IFDE_RenderContext, public CFX_Target {
19 public:
20 CFDE_RenderContext();
21 virtual ~CFDE_RenderContext();
22 virtual void Release() { delete this; }
23 virtual FX_BOOL StartRender(IFDE_RenderDevice* pRenderDevice,
24 IFDE_CanvasSet* pCanvasSet,
25 const CFX_Matrix& tmDoc2Device);
26 virtual FDE_RENDERSTATUS GetStatus() const { return m_eStatus; }
27 virtual FDE_RENDERSTATUS DoRender(IFX_Pause* pPause = nullptr);
28 virtual void StopRender();
29 void RenderText(IFDE_TextSet* pTextSet, FDE_HVISUALOBJ hText);
30 FX_BOOL ApplyClip(IFDE_VisualSet* pVisualSet,
31 FDE_HVISUALOBJ hObj,
32 FDE_HDEVICESTATE& hState);
33 void RestoreClip(FDE_HDEVICESTATE hState);
34
35 protected:
36 FDE_RENDERSTATUS m_eStatus;
37 IFDE_RenderDevice* m_pRenderDevice;
38 CFDE_Brush* m_pBrush;
39 CFX_Matrix m_Transform;
40 FXTEXT_CHARPOS* m_pCharPos;
41 int32_t m_iCharPosCount;
42 IFDE_VisualSetIterator* m_pIterator;
43 };
44
45 } // namespace
46
47 void FDE_GetPageMatrix(CFX_Matrix& pageMatrix,
48 const CFX_RectF& docPageRect,
49 const CFX_Rect& devicePageRect,
50 int32_t iRotate,
51 uint32_t dwCoordinatesType) {
52 FXSYS_assert(iRotate >= 0 && iRotate <= 3);
53 FX_BOOL bFlipX = (dwCoordinatesType & 0x01) != 0;
54 FX_BOOL bFlipY = (dwCoordinatesType & 0x02) != 0;
55 CFX_Matrix m;
56 m.Set((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0);
57 if (iRotate == 0 || iRotate == 2) {
58 m.a *= (FX_FLOAT)devicePageRect.width / docPageRect.width;
59 m.d *= (FX_FLOAT)devicePageRect.height / docPageRect.height;
60 } else {
61 m.a *= (FX_FLOAT)devicePageRect.height / docPageRect.width;
62 m.d *= (FX_FLOAT)devicePageRect.width / docPageRect.height;
63 }
64 m.Rotate(iRotate * 1.57079632675f);
65 switch (iRotate) {
66 case 0:
67 m.e = bFlipX ? (FX_FLOAT)devicePageRect.right()
68 : (FX_FLOAT)devicePageRect.left;
69 m.f = bFlipY ? (FX_FLOAT)devicePageRect.bottom()
70 : (FX_FLOAT)devicePageRect.top;
71 break;
72 case 1:
73 m.e = bFlipY ? (FX_FLOAT)devicePageRect.left
74 : (FX_FLOAT)devicePageRect.right();
75 m.f = bFlipX ? (FX_FLOAT)devicePageRect.bottom()
76 : (FX_FLOAT)devicePageRect.top;
77 break;
78 case 2:
79 m.e = bFlipX ? (FX_FLOAT)devicePageRect.left
80 : (FX_FLOAT)devicePageRect.right();
81 m.f = bFlipY ? (FX_FLOAT)devicePageRect.top
82 : (FX_FLOAT)devicePageRect.bottom();
83 break;
84 case 3:
85 m.e = bFlipY ? (FX_FLOAT)devicePageRect.right()
86 : (FX_FLOAT)devicePageRect.left;
87 m.f = bFlipX ? (FX_FLOAT)devicePageRect.top
88 : (FX_FLOAT)devicePageRect.bottom();
89 break;
90 default:
91 break;
92 }
93 pageMatrix = m;
94 }
95
96 IFDE_RenderContext* IFDE_RenderContext::Create() {
97 return new CFDE_RenderContext;
98 }
99
100 CFDE_RenderContext::CFDE_RenderContext() 16 CFDE_RenderContext::CFDE_RenderContext()
101 : m_eStatus(FDE_RENDERSTATUS_Reset), 17 : m_eStatus(FDE_RENDERSTATUS_Reset),
102 m_pRenderDevice(nullptr), 18 m_pRenderDevice(nullptr),
103 m_pBrush(nullptr), 19 m_pBrush(nullptr),
104 m_Transform(), 20 m_Transform(),
105 m_pCharPos(nullptr), 21 m_pCharPos(nullptr),
106 m_iCharPosCount(0), 22 m_iCharPosCount(0),
107 m_pIterator(nullptr) { 23 m_pIterator(nullptr) {
108 m_Transform.SetIdentity(); 24 m_Transform.SetIdentity();
109 } 25 }
110 26
111 CFDE_RenderContext::~CFDE_RenderContext() { 27 CFDE_RenderContext::~CFDE_RenderContext() {
112 StopRender(); 28 StopRender();
113 } 29 }
114 30
115 FX_BOOL CFDE_RenderContext::StartRender(IFDE_RenderDevice* pRenderDevice, 31 FX_BOOL CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice,
116 IFDE_CanvasSet* pCanvasSet, 32 IFDE_CanvasSet* pCanvasSet,
117 const CFX_Matrix& tmDoc2Device) { 33 const CFX_Matrix& tmDoc2Device) {
118 if (m_pRenderDevice) 34 if (m_pRenderDevice)
119 return FALSE; 35 return FALSE;
120 if (!pRenderDevice) 36 if (!pRenderDevice)
121 return FALSE; 37 return FALSE;
122 if (!pCanvasSet) 38 if (!pCanvasSet)
123 return FALSE; 39 return FALSE;
124 40
125 m_eStatus = FDE_RENDERSTATUS_Paused; 41 m_eStatus = FDE_RENDERSTATUS_Paused;
126 m_pRenderDevice = pRenderDevice; 42 m_pRenderDevice = pRenderDevice;
127 m_Transform = tmDoc2Device; 43 m_Transform = tmDoc2Device;
128 if (!m_pIterator) { 44 if (!m_pIterator)
129 m_pIterator = IFDE_VisualSetIterator::Create(); 45 m_pIterator = new CFDE_VisualSetIterator;
130 FXSYS_assert(m_pIterator); 46
131 }
132 return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); 47 return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
133 } 48 }
134 49
135 FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { 50 FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) {
136 if (!m_pRenderDevice) 51 if (!m_pRenderDevice)
137 return FDE_RENDERSTATUS_Failed; 52 return FDE_RENDERSTATUS_Failed;
138 if (!m_pIterator) 53 if (!m_pIterator)
139 return FDE_RENDERSTATUS_Failed; 54 return FDE_RENDERSTATUS_Failed;
140 55
141 FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused; 56 FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 m_Transform.TransformRect(rtClip); 163 m_Transform.TransformRect(rtClip);
249 const CFX_RectF& rtDevClip = m_pRenderDevice->GetClipRect(); 164 const CFX_RectF& rtDevClip = m_pRenderDevice->GetClipRect();
250 rtClip.Intersect(rtDevClip); 165 rtClip.Intersect(rtDevClip);
251 hState = m_pRenderDevice->SaveState(); 166 hState = m_pRenderDevice->SaveState();
252 return m_pRenderDevice->SetClipRect(rtClip); 167 return m_pRenderDevice->SetClipRect(rtClip);
253 } 168 }
254 169
255 void CFDE_RenderContext::RestoreClip(FDE_HDEVICESTATE hState) { 170 void CFDE_RenderContext::RestoreClip(FDE_HDEVICESTATE hState) {
256 m_pRenderDevice->RestoreState(hState); 171 m_pRenderDevice->RestoreState(hState);
257 } 172 }
OLDNEW
« no previous file with comments | « xfa/fde/fde_render.h ('k') | xfa/fde/fde_renderdevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698