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 "../../../include/fpdfapi/fpdf_module.h" | 7 #include "../../../include/fpdfapi/fpdf_module.h" |
8 #include "../../../include/fpdfapi/fpdf_render.h" | 8 #include "../../../include/fpdfapi/fpdf_render.h" |
9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
11 #include "render_int.h" | 11 #include "render_int.h" |
12 | 12 |
13 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) | 13 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) |
14 : m_pPDFDoc(pPDFDoc), | 14 : m_pPDFDoc(pPDFDoc), |
15 m_pFontCache(new CFX_FontCache) | 15 m_pFontCache(new CFX_FontCache) |
16 { | 16 { |
17 } | 17 } |
18 | 18 |
19 CPDF_DocRenderData::~CPDF_DocRenderData() | 19 CPDF_DocRenderData::~CPDF_DocRenderData() |
20 { | 20 { |
21 Clear(TRUE); | 21 Clear(true); |
22 } | 22 } |
23 | 23 |
24 void CPDF_DocRenderData::Clear(FX_BOOL bRelease) | 24 void CPDF_DocRenderData::Clear(bool bRelease) |
25 { | 25 { |
26 for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) { | 26 for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) { |
27 auto curr_it = it++; | 27 auto curr_it = it++; |
28 CPDF_CountedObject<CPDF_Type3Cache>* cache = curr_it->second; | 28 CPDF_CountedObject<CPDF_Type3Cache>* cache = curr_it->second; |
29 if (bRelease || cache->use_count() < 2) { | 29 if (bRelease || cache->use_count() < 2) { |
30 delete cache->get(); | 30 delete cache->get(); |
31 delete cache; | 31 delete cache; |
32 m_Type3FaceMap.erase(curr_it); | 32 m_Type3FaceMap.erase(curr_it); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 for (auto it = m_TransferFuncMap.begin(); it != m_TransferFuncMap.end();) { | 36 for (auto it = m_TransferFuncMap.begin(); it != m_TransferFuncMap.end();) { |
37 auto curr_it = it++; | 37 auto curr_it = it++; |
38 CPDF_CountedObject<CPDF_TransferFunc>* value = curr_it->second; | 38 CPDF_CountedObject<CPDF_TransferFunc>* value = curr_it->second; |
39 if (bRelease || value->use_count() < 2) { | 39 if (bRelease || value->use_count() < 2) { |
40 delete value->get(); | 40 delete value->get(); |
41 delete value; | 41 delete value; |
42 m_TransferFuncMap.erase(curr_it); | 42 m_TransferFuncMap.erase(curr_it); |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 if (m_pFontCache) { | 46 if (m_pFontCache) { |
47 if (bRelease) { | 47 if (bRelease) { |
48 delete m_pFontCache; | 48 delete m_pFontCache; |
49 m_pFontCache = NULL; | 49 m_pFontCache = NULL; |
50 } else { | 50 } else { |
51 m_pFontCache->FreeCache(FALSE); | 51 m_pFontCache->FreeCache(false); |
52 } | 52 } |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) | 56 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) |
57 { | 57 { |
58 CPDF_CountedObject<CPDF_Type3Cache>* pCache; | 58 CPDF_CountedObject<CPDF_Type3Cache>* pCache; |
59 auto it = m_Type3FaceMap.find(pFont); | 59 auto it = m_Type3FaceMap.find(pFont); |
60 if (it == m_Type3FaceMap.end()) { | 60 if (it == m_Type3FaceMap.end()) { |
61 CPDF_Type3Cache* pType3 = new CPDF_Type3Cache(pFont); | 61 CPDF_Type3Cache* pType3 = new CPDF_Type3Cache(pFont); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 { | 111 { |
112 return new CPDF_DocRenderData(pDoc); | 112 return new CPDF_DocRenderData(pDoc); |
113 } | 113 } |
114 void CPDF_RenderModule::DestroyDocData(CPDF_DocRenderData* pDocData) | 114 void CPDF_RenderModule::DestroyDocData(CPDF_DocRenderData* pDocData) |
115 { | 115 { |
116 delete pDocData; | 116 delete pDocData; |
117 } | 117 } |
118 void CPDF_RenderModule::ClearDocData(CPDF_DocRenderData* p) | 118 void CPDF_RenderModule::ClearDocData(CPDF_DocRenderData* p) |
119 { | 119 { |
120 if (p) { | 120 if (p) { |
121 p->Clear(FALSE); | 121 p->Clear(false); |
122 } | 122 } |
123 } | 123 } |
124 void CPDF_RenderModule::DestroyPageCache(CPDF_PageRenderCache* pCache) | 124 void CPDF_RenderModule::DestroyPageCache(CPDF_PageRenderCache* pCache) |
125 { | 125 { |
126 delete pCache; | 126 delete pCache; |
127 } | 127 } |
128 | 128 |
129 void CPDF_ModuleMgr::InitRenderModule() | 129 void CPDF_ModuleMgr::InitRenderModule() |
130 { | 130 { |
131 m_pRenderModule.reset(new CPDF_RenderModule); | 131 m_pRenderModule.reset(new CPDF_RenderModule); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 b = (bb - fb) * gray / 255 + fb; | 173 b = (bb - fb) * gray / 255 + fb; |
174 return ArgbEncode(a, r, g, b); | 174 return ArgbEncode(a, r, g, b); |
175 } | 175 } |
176 | 176 |
177 // static | 177 // static |
178 int CPDF_RenderStatus::s_CurrentRecursionDepth = 0; | 178 int CPDF_RenderStatus::s_CurrentRecursionDepth = 0; |
179 | 179 |
180 CPDF_RenderStatus::CPDF_RenderStatus() | 180 CPDF_RenderStatus::CPDF_RenderStatus() |
181 { | 181 { |
182 m_pContext = NULL; | 182 m_pContext = NULL; |
183 m_bStopped = FALSE; | 183 m_bStopped = false; |
184 m_pDevice = NULL; | 184 m_pDevice = NULL; |
185 m_pCurObj = NULL; | 185 m_pCurObj = NULL; |
186 m_pStopObj = NULL; | 186 m_pStopObj = NULL; |
187 m_HalftoneLimit = 0; | 187 m_HalftoneLimit = 0; |
188 m_pObjectRenderer = NULL; | 188 m_pObjectRenderer = NULL; |
189 m_bPrint = FALSE; | 189 m_bPrint = false; |
190 m_Transparency = 0; | 190 m_Transparency = 0; |
191 m_DitherBits = 0; | 191 m_DitherBits = 0; |
192 m_bDropObjects = FALSE; | 192 m_bDropObjects = false; |
193 m_bStdCS = FALSE; | 193 m_bStdCS = false; |
194 m_GroupFamily = 0; | 194 m_GroupFamily = 0; |
195 m_bLoadMask = FALSE; | 195 m_bLoadMask = false; |
196 m_pType3Char = NULL; | 196 m_pType3Char = NULL; |
197 m_T3FillColor = 0; | 197 m_T3FillColor = 0; |
198 m_pFormResource = NULL; | 198 m_pFormResource = NULL; |
199 m_pPageResource = NULL; | 199 m_pPageResource = NULL; |
200 m_curBlend = FXDIB_BLEND_NORMAL; | 200 m_curBlend = FXDIB_BLEND_NORMAL; |
201 } | 201 } |
202 | 202 |
203 CPDF_RenderStatus::~CPDF_RenderStatus() | 203 CPDF_RenderStatus::~CPDF_RenderStatus() |
204 { | 204 { |
205 delete m_pObjectRenderer; | 205 delete m_pObjectRenderer; |
206 } | 206 } |
207 | 207 |
208 FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe
vice* pDevice, | 208 bool CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevic
e* pDevice, |
209 const CFX_AffineMatrix* pDeviceMatrix, con
st CPDF_PageObject* pStopObj, | 209 const CFX_AffineMatrix* pDeviceMatrix, con
st CPDF_PageObject* pStopObj, |
210 const CPDF_RenderStatus* pParentState, con
st CPDF_GraphicStates* pInitialStates, | 210 const CPDF_RenderStatus* pParentState, con
st CPDF_GraphicStates* pInitialStates, |
211 const CPDF_RenderOptions* pOptions, int tr
ansparency, FX_BOOL bDropObjects, | 211 const CPDF_RenderOptions* pOptions, int tr
ansparency, bool bDropObjects, |
212 CPDF_Dictionary* pFormResource, FX_BOOL bS
tdCS, CPDF_Type3Char* pType3Char, | 212 CPDF_Dictionary* pFormResource, bool bStdC
S, CPDF_Type3Char* pType3Char, |
213 FX_ARGB fill_color, FX_DWORD GroupFamily, | 213 FX_ARGB fill_color, FX_DWORD GroupFamily, |
214 FX_BOOL bLoadMask) | 214 bool bLoadMask) |
215 { | 215 { |
216 m_pContext = pContext; | 216 m_pContext = pContext; |
217 m_pDevice = pDevice; | 217 m_pDevice = pDevice; |
218 m_DitherBits = pDevice->GetDeviceCaps(FXDC_DITHER_BITS); | 218 m_DitherBits = pDevice->GetDeviceCaps(FXDC_DITHER_BITS); |
219 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; | 219 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; |
220 if (pDeviceMatrix) { | 220 if (pDeviceMatrix) { |
221 m_DeviceMatrix = *pDeviceMatrix; | 221 m_DeviceMatrix = *pDeviceMatrix; |
222 } | 222 } |
223 m_pStopObj = pStopObj; | 223 m_pStopObj = pStopObj; |
224 if (pOptions) { | 224 if (pOptions) { |
(...skipping 21 matching lines...) Expand all Loading... |
246 CPDF_ColorStateData* pData = m_InitialStates.m_ColorState.GetMod
ify(); | 246 CPDF_ColorStateData* pData = m_InitialStates.m_ColorState.GetMod
ify(); |
247 pData->m_StrokeRGB = pParentData->m_FillRGB; | 247 pData->m_StrokeRGB = pParentData->m_FillRGB; |
248 pData->m_StrokeColor.Copy(&pParentData->m_StrokeColor); | 248 pData->m_StrokeColor.Copy(&pParentData->m_StrokeColor); |
249 } | 249 } |
250 } | 250 } |
251 } else { | 251 } else { |
252 m_InitialStates.DefaultStates(); | 252 m_InitialStates.DefaultStates(); |
253 } | 253 } |
254 m_pObjectRenderer = NULL; | 254 m_pObjectRenderer = NULL; |
255 m_Transparency = transparency; | 255 m_Transparency = transparency; |
256 return TRUE; | 256 return true; |
257 } | 257 } |
258 void CPDF_RenderStatus::RenderObjectList(const CPDF_PageObjects* pObjs, const CF
X_AffineMatrix* pObj2Device) | 258 void CPDF_RenderStatus::RenderObjectList(const CPDF_PageObjects* pObjs, const CF
X_AffineMatrix* pObj2Device) |
259 { | 259 { |
260 CFX_FloatRect clip_rect = m_pDevice->GetClipBox(); | 260 CFX_FloatRect clip_rect = m_pDevice->GetClipBox(); |
261 CFX_AffineMatrix device2object; | 261 CFX_AffineMatrix device2object; |
262 device2object.SetReverse(*pObj2Device); | 262 device2object.SetReverse(*pObj2Device); |
263 device2object.TransformRect(clip_rect); | 263 device2object.TransformRect(clip_rect); |
264 int index = 0; | 264 int index = 0; |
265 FX_POSITION pos = pObjs->GetFirstObjectPosition(); | 265 FX_POSITION pos = pObjs->GetFirstObjectPosition(); |
266 while(pos) { | 266 while(pos) { |
267 index ++; | 267 index ++; |
268 CPDF_PageObject* pCurObj = pObjs->GetNextObject(pos); | 268 CPDF_PageObject* pCurObj = pObjs->GetNextObject(pos); |
269 if (pCurObj == m_pStopObj) { | 269 if (pCurObj == m_pStopObj) { |
270 m_bStopped = TRUE; | 270 m_bStopped = true; |
271 return; | 271 return; |
272 } | 272 } |
273 if (!pCurObj) { | 273 if (!pCurObj) { |
274 continue; | 274 continue; |
275 } | 275 } |
276 if(pCurObj == NULL || pCurObj->m_Left > clip_rect.right || pCurObj->m_Ri
ght < clip_rect.left || | 276 if(pCurObj == NULL || pCurObj->m_Left > clip_rect.right || pCurObj->m_Ri
ght < clip_rect.left || |
277 pCurObj->m_Bottom > clip_rect.top || pCurObj->m_Top < clip_rect.
bottom) { | 277 pCurObj->m_Bottom > clip_rect.top || pCurObj->m_Top < clip_rect.
bottom) { |
278 continue; | 278 continue; |
279 } | 279 } |
280 RenderSingleObject(pCurObj, pObj2Device); | 280 RenderSingleObject(pCurObj, pObj2Device); |
(...skipping 13 matching lines...) Expand all Loading... |
294 if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) { | 294 if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) { |
295 return; | 295 return; |
296 } | 296 } |
297 } | 297 } |
298 ProcessClipPath(pObj->m_ClipPath, pObj2Device); | 298 ProcessClipPath(pObj->m_ClipPath, pObj2Device); |
299 if (ProcessTransparency(pObj, pObj2Device)) { | 299 if (ProcessTransparency(pObj, pObj2Device)) { |
300 return; | 300 return; |
301 } | 301 } |
302 ProcessObjectNoClip(pObj, pObj2Device); | 302 ProcessObjectNoClip(pObj, pObj2Device); |
303 } | 303 } |
304 FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, con
st CFX_AffineMatrix* pObj2Device, IFX_Pause* pPause) | 304 bool CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, const
CFX_AffineMatrix* pObj2Device, IFX_Pause* pPause) |
305 { | 305 { |
306 if (m_pObjectRenderer) { | 306 if (m_pObjectRenderer) { |
307 if (m_pObjectRenderer->Continue(pPause)) { | 307 if (m_pObjectRenderer->Continue(pPause)) { |
308 return TRUE; | 308 return true; |
309 } | 309 } |
310 if (!m_pObjectRenderer->m_Result) { | 310 if (!m_pObjectRenderer->m_Result) { |
311 DrawObjWithBackground(pObj, pObj2Device); | 311 DrawObjWithBackground(pObj, pObj2Device); |
312 } | 312 } |
313 delete m_pObjectRenderer; | 313 delete m_pObjectRenderer; |
314 m_pObjectRenderer = NULL; | 314 m_pObjectRenderer = NULL; |
315 return FALSE; | 315 return false; |
316 } | 316 } |
317 m_pCurObj = pObj; | 317 m_pCurObj = pObj; |
318 if (m_Options.m_pOCContext && pObj->m_ContentMark.NotNull()) | 318 if (m_Options.m_pOCContext && pObj->m_ContentMark.NotNull()) |
319 if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) { | 319 if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) { |
320 return FALSE; | 320 return false; |
321 } | 321 } |
322 ProcessClipPath(pObj->m_ClipPath, pObj2Device); | 322 ProcessClipPath(pObj->m_ClipPath, pObj2Device); |
323 if (ProcessTransparency(pObj, pObj2Device)) { | 323 if (ProcessTransparency(pObj, pObj2Device)) { |
324 return FALSE; | 324 return false; |
325 } | 325 } |
326 if (pObj->m_Type == PDFPAGE_IMAGE) { | 326 if (pObj->m_Type == PDFPAGE_IMAGE) { |
327 m_pObjectRenderer = IPDF_ObjectRenderer::Create(pObj->m_Type); | 327 m_pObjectRenderer = IPDF_ObjectRenderer::Create(pObj->m_Type); |
328 if (!m_pObjectRenderer->Start(this, pObj, pObj2Device, FALSE)) { | 328 if (!m_pObjectRenderer->Start(this, pObj, pObj2Device, false)) { |
329 if (!m_pObjectRenderer->m_Result) { | 329 if (!m_pObjectRenderer->m_Result) { |
330 DrawObjWithBackground(pObj, pObj2Device); | 330 DrawObjWithBackground(pObj, pObj2Device); |
331 } | 331 } |
332 delete m_pObjectRenderer; | 332 delete m_pObjectRenderer; |
333 m_pObjectRenderer = NULL; | 333 m_pObjectRenderer = NULL; |
334 return FALSE; | 334 return false; |
335 } | 335 } |
336 return ContinueSingleObject(pObj, pObj2Device, pPause); | 336 return ContinueSingleObject(pObj, pObj2Device, pPause); |
337 } | 337 } |
338 ProcessObjectNoClip(pObj, pObj2Device); | 338 ProcessObjectNoClip(pObj, pObj2Device); |
339 return FALSE; | 339 return false; |
340 } | 340 } |
341 IPDF_ObjectRenderer* IPDF_ObjectRenderer::Create(int type) | 341 IPDF_ObjectRenderer* IPDF_ObjectRenderer::Create(int type) |
342 { | 342 { |
343 if (type != PDFPAGE_IMAGE) { | 343 if (type != PDFPAGE_IMAGE) { |
344 return NULL; | 344 return NULL; |
345 } | 345 } |
346 return new CPDF_ImageRenderer; | 346 return new CPDF_ImageRenderer; |
347 } | 347 } |
348 FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, con
st CFX_AffineMatrix* pObj2Device, FX_BOOL bLogical, FX_RECT &rect) const | 348 bool CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, const
CFX_AffineMatrix* pObj2Device, bool bLogical, FX_RECT &rect) const |
349 { | 349 { |
350 rect = pObj->GetBBox(pObj2Device); | 350 rect = pObj->GetBBox(pObj2Device); |
351 FX_RECT rtClip = m_pDevice->GetClipBox(); | 351 FX_RECT rtClip = m_pDevice->GetClipBox(); |
352 if (!bLogical) { | 352 if (!bLogical) { |
353 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 353 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
354 FX_FLOAT a = FXSYS_fabs(dCTM.a); | 354 FX_FLOAT a = FXSYS_fabs(dCTM.a); |
355 FX_FLOAT d = FXSYS_fabs(dCTM.d); | 355 FX_FLOAT d = FXSYS_fabs(dCTM.d); |
356 if (a != 1.0f || d != 1.0f) { | 356 if (a != 1.0f || d != 1.0f) { |
357 rect.right = rect.left + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Width()
* a); | 357 rect.right = rect.left + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Width()
* a); |
358 rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height()
* d); | 358 rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height()
* d); |
359 rtClip.right = rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Wi
dth() * a); | 359 rtClip.right = rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Wi
dth() * a); |
360 rtClip.bottom = rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.He
ight() * d); | 360 rtClip.bottom = rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.He
ight() * d); |
361 } | 361 } |
362 } | 362 } |
363 rect.Intersect(rtClip); | 363 rect.Intersect(rtClip); |
364 return rect.IsEmpty(); | 364 return rect.IsEmpty(); |
365 } | 365 } |
366 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, const CFX_
AffineMatrix* pObj2Device) | 366 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, const CFX_
AffineMatrix* pObj2Device) |
367 { | 367 { |
368 CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); | 368 CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); |
369 if (pBitmap == NULL) { | 369 if (pBitmap == NULL) { |
370 return; | 370 return; |
371 } | 371 } |
372 FX_RECT rect; | 372 FX_RECT rect; |
373 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { | 373 if (GetObjectClippedRect(pObj, pObj2Device, false, rect)) { |
374 return; | 374 return; |
375 } | 375 } |
376 if (m_DitherBits == 2) { | 376 if (m_DitherBits == 2) { |
377 static FX_ARGB pal[4] = {0, 85, 170, 255}; | 377 static FX_ARGB pal[4] = {0, 85, 170, 255}; |
378 pBitmap->DitherFS(pal, 4, &rect); | 378 pBitmap->DitherFS(pal, 4, &rect); |
379 } else if (m_DitherBits == 3) { | 379 } else if (m_DitherBits == 3) { |
380 static FX_ARGB pal[8] = {0, 36, 73, 109, 146, 182, 219, 255}; | 380 static FX_ARGB pal[8] = {0, 36, 73, 109, 146, 182, 219, 255}; |
381 pBitmap->DitherFS(pal, 8, &rect); | 381 pBitmap->DitherFS(pal, 8, &rect); |
382 } else if (m_DitherBits == 4) { | 382 } else if (m_DitherBits == 4) { |
383 static FX_ARGB pal[16] = {0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170
, 187, 204, 221, 238, 255}; | 383 static FX_ARGB pal[16] = {0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170
, 187, 204, 221, 238, 255}; |
384 pBitmap->DitherFS(pal, 16, &rect); | 384 pBitmap->DitherFS(pal, 16, &rect); |
385 } | 385 } |
386 } | 386 } |
387 void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, const C
FX_AffineMatrix* pObj2Device) | 387 void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, const C
FX_AffineMatrix* pObj2Device) |
388 { | 388 { |
389 FX_BOOL bRet = FALSE; | 389 bool bRet = false; |
390 switch (pObj->m_Type) { | 390 switch (pObj->m_Type) { |
391 case PDFPAGE_TEXT: | 391 case PDFPAGE_TEXT: |
392 bRet = ProcessText((CPDF_TextObject*)pObj, pObj2Device, NULL); | 392 bRet = ProcessText((CPDF_TextObject*)pObj, pObj2Device, NULL); |
393 break; | 393 break; |
394 case PDFPAGE_PATH: | 394 case PDFPAGE_PATH: |
395 bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device); | 395 bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device); |
396 break; | 396 break; |
397 case PDFPAGE_IMAGE: | 397 case PDFPAGE_IMAGE: |
398 bRet = ProcessImage((CPDF_ImageObject*)pObj, pObj2Device); | 398 bRet = ProcessImage((CPDF_ImageObject*)pObj, pObj2Device); |
399 break; | 399 break; |
400 case PDFPAGE_SHADING: | 400 case PDFPAGE_SHADING: |
401 bRet = ProcessShading((CPDF_ShadingObject*)pObj, pObj2Device); | 401 bRet = ProcessShading((CPDF_ShadingObject*)pObj, pObj2Device); |
402 break; | 402 break; |
403 case PDFPAGE_FORM: | 403 case PDFPAGE_FORM: |
404 bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device); | 404 bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device); |
405 break; | 405 break; |
406 } | 406 } |
407 if (!bRet) { | 407 if (!bRet) { |
408 DrawObjWithBackground(pObj, pObj2Device); | 408 DrawObjWithBackground(pObj, pObj2Device); |
409 } | 409 } |
410 } | 410 } |
411 FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(const CPDF_PageObject* pObj, const C
FX_AffineMatrix* pObj2Device) | 411 bool CPDF_RenderStatus::DrawObjWithBlend(const CPDF_PageObject* pObj, const CFX_
AffineMatrix* pObj2Device) |
412 { | 412 { |
413 FX_BOOL bRet = FALSE; | 413 bool bRet = false; |
414 switch (pObj->m_Type) { | 414 switch (pObj->m_Type) { |
415 case PDFPAGE_PATH: | 415 case PDFPAGE_PATH: |
416 bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device); | 416 bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device); |
417 break; | 417 break; |
418 case PDFPAGE_IMAGE: | 418 case PDFPAGE_IMAGE: |
419 bRet = ProcessImage((CPDF_ImageObject *)pObj, pObj2Device); | 419 bRet = ProcessImage((CPDF_ImageObject *)pObj, pObj2Device); |
420 break; | 420 break; |
421 case PDFPAGE_FORM: | 421 case PDFPAGE_FORM: |
422 bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device); | 422 bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device); |
423 break; | 423 break; |
424 } | 424 } |
425 return bRet; | 425 return bRet; |
426 } | 426 } |
427 void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix &matrix) const | 427 void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix &matrix) const |
428 { | 428 { |
429 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 429 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
430 matrix.a *= FXSYS_fabs(dCTM.a); | 430 matrix.a *= FXSYS_fabs(dCTM.a); |
431 matrix.d *= FXSYS_fabs(dCTM.d); | 431 matrix.d *= FXSYS_fabs(dCTM.d); |
432 } | 432 } |
433 void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, const
CFX_AffineMatrix* pObj2Device) | 433 void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, const
CFX_AffineMatrix* pObj2Device) |
434 { | 434 { |
435 FX_RECT rect; | 435 FX_RECT rect; |
436 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { | 436 if (GetObjectClippedRect(pObj, pObj2Device, false, rect)) { |
437 return; | 437 return; |
438 } | 438 } |
439 int res = 300; | 439 int res = 300; |
440 if (pObj->m_Type == PDFPAGE_IMAGE && m_pDevice->GetDeviceCaps(FXDC_DEVICE_CL
ASS) == FXDC_PRINTER) { | 440 if (pObj->m_Type == PDFPAGE_IMAGE && m_pDevice->GetDeviceCaps(FXDC_DEVICE_CL
ASS) == FXDC_PRINTER) { |
441 res = 0; | 441 res = 0; |
442 } | 442 } |
443 CPDF_ScaledRenderBuffer buffer; | 443 CPDF_ScaledRenderBuffer buffer; |
444 if (!buffer.Initialize(m_pContext, m_pDevice, &rect, pObj, &m_Options, res))
{ | 444 if (!buffer.Initialize(m_pContext, m_pDevice, &rect, pObj, &m_Options, res))
{ |
445 return; | 445 return; |
446 } | 446 } |
447 CFX_AffineMatrix matrix = *pObj2Device; | 447 CFX_AffineMatrix matrix = *pObj2Device; |
448 matrix.Concat(*buffer.GetMatrix()); | 448 matrix.Concat(*buffer.GetMatrix()); |
449 GetScaledMatrix(matrix); | 449 GetScaledMatrix(matrix); |
450 CPDF_Dictionary* pFormResource = NULL; | 450 CPDF_Dictionary* pFormResource = NULL; |
451 if (pObj->m_Type == PDFPAGE_FORM) { | 451 if (pObj->m_Type == PDFPAGE_FORM) { |
452 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pObj; | 452 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pObj; |
453 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { | 453 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { |
454 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict(FX_BSTRC("Re
sources")); | 454 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict(FX_BSTRC("Re
sources")); |
455 } | 455 } |
456 } | 456 } |
457 CPDF_RenderStatus status; | 457 CPDF_RenderStatus status; |
458 status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), NULL,
NULL, NULL, &m_Options, m_Transparency, m_bDropObjects, pFormResource); | 458 status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), NULL,
NULL, NULL, &m_Options, m_Transparency, m_bDropObjects, pFormResource); |
459 status.RenderSingleObject(pObj, &matrix); | 459 status.RenderSingleObject(pObj, &matrix); |
460 buffer.OutputToDevice(); | 460 buffer.OutputToDevice(); |
461 } | 461 } |
462 FX_BOOL CPDF_RenderStatus::ProcessForm(CPDF_FormObject* pFormObj, const CFX_Affi
neMatrix* pObj2Device) | 462 bool CPDF_RenderStatus::ProcessForm(CPDF_FormObject* pFormObj, const CFX_AffineM
atrix* pObj2Device) |
463 { | 463 { |
464 CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDict(FX_BSTRC("OC"
)); | 464 CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDict(FX_BSTRC("OC"
)); |
465 if (pOC && m_Options.m_pOCContext && !m_Options.m_pOCContext->CheckOCGVisibl
e(pOC)) { | 465 if (pOC && m_Options.m_pOCContext && !m_Options.m_pOCContext->CheckOCGVisibl
e(pOC)) { |
466 return TRUE; | 466 return true; |
467 } | 467 } |
468 CFX_AffineMatrix matrix = pFormObj->m_FormMatrix; | 468 CFX_AffineMatrix matrix = pFormObj->m_FormMatrix; |
469 matrix.Concat(*pObj2Device); | 469 matrix.Concat(*pObj2Device); |
470 CPDF_Dictionary* pResources = NULL; | 470 CPDF_Dictionary* pResources = NULL; |
471 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { | 471 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { |
472 pResources = pFormObj->m_pForm->m_pFormDict->GetDict(FX_BSTRC("Resources
")); | 472 pResources = pFormObj->m_pForm->m_pFormDict->GetDict(FX_BSTRC("Resources
")); |
473 } | 473 } |
474 CPDF_RenderStatus status; | 474 CPDF_RenderStatus status; |
475 status.Initialize(m_pContext, m_pDevice, NULL, m_pStopObj, | 475 status.Initialize(m_pContext, m_pDevice, NULL, m_pStopObj, |
476 this, pFormObj, &m_Options, m_Transparency, m_bDropObjects
, pResources, FALSE); | 476 this, pFormObj, &m_Options, m_Transparency, m_bDropObjects
, pResources, false); |
477 status.m_curBlend = m_curBlend; | 477 status.m_curBlend = m_curBlend; |
478 m_pDevice->SaveState(); | 478 m_pDevice->SaveState(); |
479 status.RenderObjectList(pFormObj->m_pForm, &matrix); | 479 status.RenderObjectList(pFormObj->m_pForm, &matrix); |
480 m_bStopped = status.m_bStopped; | 480 m_bStopped = status.m_bStopped; |
481 m_pDevice->RestoreState(); | 481 m_pDevice->RestoreState(); |
482 return TRUE; | 482 return true; |
483 } | 483 } |
484 FX_BOOL IsAvailableMatrix(const CFX_AffineMatrix& matrix) | 484 bool IsAvailableMatrix(const CFX_AffineMatrix& matrix) |
485 { | 485 { |
486 if (matrix.a == 0 || matrix.d == 0) { | 486 if (matrix.a == 0 || matrix.d == 0) { |
487 return matrix.b != 0 && matrix.c != 0; | 487 return matrix.b != 0 && matrix.c != 0; |
488 } | 488 } |
489 if (matrix.b == 0 || matrix.c == 0) { | 489 if (matrix.b == 0 || matrix.c == 0) { |
490 return matrix.a != 0 && matrix.d != 0; | 490 return matrix.a != 0 && matrix.d != 0; |
491 } | 491 } |
492 return TRUE; | 492 return true; |
493 } | 493 } |
494 FX_BOOL CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, const CFX_Affi
neMatrix* pObj2Device) | 494 bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, const CFX_AffineM
atrix* pObj2Device) |
495 { | 495 { |
496 int FillType = pPathObj->m_FillType; | 496 int FillType = pPathObj->m_FillType; |
497 FX_BOOL bStroke = pPathObj->m_bStroke; | 497 bool bStroke = pPathObj->m_bStroke; |
498 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); | 498 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); |
499 if (FillType == 0 && !bStroke) { | 499 if (FillType == 0 && !bStroke) { |
500 return TRUE; | 500 return true; |
501 } | 501 } |
502 FX_DWORD fill_argb = 0; | 502 FX_DWORD fill_argb = 0; |
503 if (FillType) { | 503 if (FillType) { |
504 fill_argb = GetFillArgb(pPathObj); | 504 fill_argb = GetFillArgb(pPathObj); |
505 } | 505 } |
506 FX_DWORD stroke_argb = 0; | 506 FX_DWORD stroke_argb = 0; |
507 if (bStroke) { | 507 if (bStroke) { |
508 stroke_argb = GetStrokeArgb(pPathObj); | 508 stroke_argb = GetStrokeArgb(pPathObj); |
509 } | 509 } |
510 CFX_AffineMatrix path_matrix = pPathObj->m_Matrix; | 510 CFX_AffineMatrix path_matrix = pPathObj->m_Matrix; |
511 path_matrix.Concat(*pObj2Device); | 511 path_matrix.Concat(*pObj2Device); |
512 if (!IsAvailableMatrix(path_matrix)) { | 512 if (!IsAvailableMatrix(path_matrix)) { |
513 return TRUE; | 513 return true; |
514 } | 514 } |
515 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) { | 515 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) { |
516 FillType |= FXFILL_RECT_AA; | 516 FillType |= FXFILL_RECT_AA; |
517 } | 517 } |
518 if (m_Options.m_Flags & RENDER_FILL_FULLCOVER) { | 518 if (m_Options.m_Flags & RENDER_FILL_FULLCOVER) { |
519 FillType |= FXFILL_FULLCOVER; | 519 FillType |= FXFILL_FULLCOVER; |
520 } | 520 } |
521 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { | 521 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { |
522 FillType |= FXFILL_NOPATHSMOOTH; | 522 FillType |= FXFILL_NOPATHSMOOTH; |
523 } | 523 } |
(...skipping 15 matching lines...) Expand all Loading... |
539 } | 539 } |
540 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const | 540 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const |
541 { | 541 { |
542 ASSERT(pObj != NULL); | 542 ASSERT(pObj != NULL); |
543 CPDF_DocRenderData* pDocCache = m_pContext->m_pDocument->GetRenderData(); | 543 CPDF_DocRenderData* pDocCache = m_pContext->m_pDocument->GetRenderData(); |
544 if (!pDocCache) { | 544 if (!pDocCache) { |
545 return NULL; | 545 return NULL; |
546 } | 546 } |
547 return pDocCache->GetTransferFunc(pObj); | 547 return pDocCache->GetTransferFunc(pObj); |
548 } | 548 } |
549 FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bTyp
e3) const | 549 FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, bool bType3)
const |
550 { | 550 { |
551 CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorSta
teData*)pObj->m_ColorState; | 551 CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorSta
teData*)pObj->m_ColorState; |
552 if (m_pType3Char && !bType3 && (!m_pType3Char->m_bColored || (m_pType3Char->
m_bColored && (!pColorData || pColorData->m_FillColor.IsNull())))) { | 552 if (m_pType3Char && !bType3 && (!m_pType3Char->m_bColored || (m_pType3Char->
m_bColored && (!pColorData || pColorData->m_FillColor.IsNull())))) { |
553 return m_T3FillColor; | 553 return m_T3FillColor; |
554 } else if (!pColorData || pColorData->m_FillColor.IsNull()) { | 554 } else if (!pColorData || pColorData->m_FillColor.IsNull()) { |
555 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial
States.m_ColorState; | 555 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial
States.m_ColorState; |
556 } | 556 } |
557 FX_COLORREF rgb = pColorData->m_FillRGB; | 557 FX_COLORREF rgb = pColorData->m_FillRGB; |
558 if (rgb == (FX_DWORD) - 1) { | 558 if (rgb == (FX_DWORD) - 1) { |
559 return 0; | 559 return 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 alpha = 255; | 603 alpha = 255; |
604 } | 604 } |
605 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); | 605 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); |
606 } | 606 } |
607 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Affine
Matrix* pObj2Device) | 607 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Affine
Matrix* pObj2Device) |
608 { | 608 { |
609 if (ClipPath.IsNull()) { | 609 if (ClipPath.IsNull()) { |
610 if (m_LastClipPath.IsNull()) { | 610 if (m_LastClipPath.IsNull()) { |
611 return; | 611 return; |
612 } | 612 } |
613 m_pDevice->RestoreState(TRUE); | 613 m_pDevice->RestoreState(true); |
614 m_LastClipPath.SetNull(); | 614 m_LastClipPath.SetNull(); |
615 return; | 615 return; |
616 } | 616 } |
617 if (m_LastClipPath == ClipPath) { | 617 if (m_LastClipPath == ClipPath) { |
618 return; | 618 return; |
619 } | 619 } |
620 m_LastClipPath = ClipPath; | 620 m_LastClipPath = ClipPath; |
621 m_pDevice->RestoreState(TRUE); | 621 m_pDevice->RestoreState(true); |
622 int nClipPath = ClipPath.GetPathCount(); | 622 int nClipPath = ClipPath.GetPathCount(); |
623 int i; | 623 int i; |
624 for (i = 0; i < nClipPath; i++) { | 624 for (i = 0; i < nClipPath; i++) { |
625 const CFX_PathData* pPathData = ClipPath.GetPath(i); | 625 const CFX_PathData* pPathData = ClipPath.GetPath(i); |
626 if (pPathData == NULL) { | 626 if (pPathData == NULL) { |
627 continue; | 627 continue; |
628 } | 628 } |
629 if (pPathData->GetPointCount() == 0) { | 629 if (pPathData->GetPointCount() == 0) { |
630 CFX_PathData EmptyPath; | 630 CFX_PathData EmptyPath; |
631 EmptyPath.AppendRect(-1, -1, 0, 0); | 631 EmptyPath.AppendRect(-1, -1, 0, 0); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 if (pPathData == NULL) { | 681 if (pPathData == NULL) { |
682 continue; | 682 continue; |
683 } | 683 } |
684 CFX_GraphStateData stroke_state; | 684 CFX_GraphStateData stroke_state; |
685 if (m_Options.m_Flags & RENDER_THINLINE) { | 685 if (m_Options.m_Flags & RENDER_THINLINE) { |
686 stroke_state.m_LineWidth = 0; | 686 stroke_state.m_LineWidth = 0; |
687 } | 687 } |
688 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000
, fill_mode); | 688 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000
, fill_mode); |
689 } | 689 } |
690 } | 690 } |
691 FX_BOOL CPDF_RenderStatus::SelectClipPath(CPDF_PathObject* pPathObj, const CFX_A
ffineMatrix* pObj2Device, FX_BOOL bStroke) | 691 bool CPDF_RenderStatus::SelectClipPath(CPDF_PathObject* pPathObj, const CFX_Affi
neMatrix* pObj2Device, bool bStroke) |
692 { | 692 { |
693 CFX_AffineMatrix path_matrix = pPathObj->m_Matrix; | 693 CFX_AffineMatrix path_matrix = pPathObj->m_Matrix; |
694 path_matrix.Concat(*pObj2Device); | 694 path_matrix.Concat(*pObj2Device); |
695 if (bStroke) { | 695 if (bStroke) { |
696 CFX_GraphStateData graphState(*pPathObj->m_GraphState); | 696 CFX_GraphStateData graphState(*pPathObj->m_GraphState); |
697 if (m_Options.m_Flags & RENDER_THINLINE) { | 697 if (m_Options.m_Flags & RENDER_THINLINE) { |
698 graphState.m_LineWidth = 0; | 698 graphState.m_LineWidth = 0; |
699 } | 699 } |
700 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path, &path_matrix, &gr
aphState); | 700 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path, &path_matrix, &gr
aphState); |
701 } | 701 } |
702 int fill_mode = pPathObj->m_FillType; | 702 int fill_mode = pPathObj->m_FillType; |
703 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { | 703 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { |
704 fill_mode |= FXFILL_NOPATHSMOOTH; | 704 fill_mode |= FXFILL_NOPATHSMOOTH; |
705 } | 705 } |
706 return m_pDevice->SetClip_PathFill(pPathObj->m_Path, &path_matrix, fill_mode
); | 706 return m_pDevice->SetClip_PathFill(pPathObj->m_Path, &path_matrix, fill_mode
); |
707 } | 707 } |
708 FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
const CFX_AffineMatrix* pObj2Device) | 708 bool CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, con
st CFX_AffineMatrix* pObj2Device) |
709 { | 709 { |
710 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; | 710 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; |
711 int blend_type = pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NO
RMAL; | 711 int blend_type = pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NO
RMAL; |
712 if (blend_type == FXDIB_BLEND_UNSUPPORTED) { | 712 if (blend_type == FXDIB_BLEND_UNSUPPORTED) { |
713 return TRUE; | 713 return true; |
714 } | 714 } |
715 CPDF_Dictionary* pSMaskDict = pGeneralState ? (CPDF_Dictionary*)pGeneralStat
e->m_pSoftMask : NULL; | 715 CPDF_Dictionary* pSMaskDict = pGeneralState ? (CPDF_Dictionary*)pGeneralStat
e->m_pSoftMask : NULL; |
716 if (pSMaskDict) { | 716 if (pSMaskDict) { |
717 if (pPageObj->m_Type == PDFPAGE_IMAGE && | 717 if (pPageObj->m_Type == PDFPAGE_IMAGE && |
718 ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDict()->KeyExist(FX_
BSTRC("SMask"))) { | 718 ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDict()->KeyExist(FX_
BSTRC("SMask"))) { |
719 pSMaskDict = NULL; | 719 pSMaskDict = NULL; |
720 } | 720 } |
721 } | 721 } |
722 CPDF_Dictionary* pFormResource = NULL; | 722 CPDF_Dictionary* pFormResource = NULL; |
723 FX_FLOAT group_alpha = 1.0f; | 723 FX_FLOAT group_alpha = 1.0f; |
724 int Transparency = m_Transparency; | 724 int Transparency = m_Transparency; |
725 FX_BOOL bGroupTransparent = FALSE; | 725 bool bGroupTransparent = false; |
726 if (pPageObj->m_Type == PDFPAGE_FORM) { | 726 if (pPageObj->m_Type == PDFPAGE_FORM) { |
727 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; | 727 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; |
728 const CPDF_GeneralStateData *pStateData = pFormObj->m_GeneralState.GetOb
ject(); | 728 const CPDF_GeneralStateData *pStateData = pFormObj->m_GeneralState.GetOb
ject(); |
729 if (pStateData) { | 729 if (pStateData) { |
730 group_alpha = pStateData->m_FillAlpha; | 730 group_alpha = pStateData->m_FillAlpha; |
731 } | 731 } |
732 Transparency = pFormObj->m_pForm->m_Transparency; | 732 Transparency = pFormObj->m_pForm->m_Transparency; |
733 bGroupTransparent = Transparency & PDFTRANS_ISOLATED ? TRUE : FALSE; | 733 bGroupTransparent = Transparency & PDFTRANS_ISOLATED ? true : false; |
734 if (pFormObj->m_pForm->m_pFormDict) { | 734 if (pFormObj->m_pForm->m_pFormDict) { |
735 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources")
; | 735 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources")
; |
736 } | 736 } |
737 } | 737 } |
738 FX_BOOL bTextClip = FALSE; | 738 bool bTextClip = false; |
739 if (pPageObj->m_ClipPath.NotNull() && pPageObj->m_ClipPath.GetTextCount() && | 739 if (pPageObj->m_ClipPath.NotNull() && pPageObj->m_ClipPath.GetTextCount() && |
740 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && !(m_pDevice->GetDevic
eCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { | 740 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && !(m_pDevice->GetDevic
eCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { |
741 bTextClip = TRUE; | 741 bTextClip = true; |
742 } | 742 } |
743 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->m_Type == PDFPAGE_IM
AGE && pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { | 743 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->m_Type == PDFPAGE_IM
AGE && pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { |
744 CPDF_Document* pDocument = NULL; | 744 CPDF_Document* pDocument = NULL; |
745 CPDF_Page* pPage = NULL; | 745 CPDF_Page* pPage = NULL; |
746 if (m_pContext->m_pPageCache) { | 746 if (m_pContext->m_pPageCache) { |
747 pPage = m_pContext->m_pPageCache->GetPage(); | 747 pPage = m_pContext->m_pPageCache->GetPage(); |
748 pDocument = pPage->m_pDocument; | 748 pDocument = pPage->m_pDocument; |
749 } else { | 749 } else { |
750 pDocument = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDocument(); | 750 pDocument = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDocument(); |
751 } | 751 } |
752 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL
; | 752 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL
; |
753 CPDF_Object* pCSObj = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetStream
()->GetDict()->GetElementValue(FX_BSTRC("ColorSpace")); | 753 CPDF_Object* pCSObj = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetStream
()->GetDict()->GetElementValue(FX_BSTRC("ColorSpace")); |
754 CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageRe
sources); | 754 CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageRe
sources); |
755 if (pColorSpace) { | 755 if (pColorSpace) { |
756 int format = pColorSpace->GetFamily(); | 756 int format = pColorSpace->GetFamily(); |
757 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form
at == PDFCS_DEVICEN) { | 757 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form
at == PDFCS_DEVICEN) { |
758 blend_type = FXDIB_BLEND_DARKEN; | 758 blend_type = FXDIB_BLEND_DARKEN; |
759 } | 759 } |
760 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 760 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); |
761 } | 761 } |
762 } | 762 } |
763 if (pSMaskDict == NULL && group_alpha == 1.0f && blend_type == FXDIB_BLEND_N
ORMAL && !bTextClip && !bGroupTransparent) { | 763 if (pSMaskDict == NULL && group_alpha == 1.0f && blend_type == FXDIB_BLEND_N
ORMAL && !bTextClip && !bGroupTransparent) { |
764 return FALSE; | 764 return false; |
765 } | 765 } |
766 FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED; | 766 bool isolated = Transparency & PDFTRANS_ISOLATED; |
767 if (m_bPrint) { | 767 if (m_bPrint) { |
768 FX_BOOL bRet = FALSE; | 768 bool bRet = false; |
769 int rendCaps = m_pDevice->GetRenderCaps(); | 769 int rendCaps = m_pDevice->GetRenderCaps(); |
770 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) &&
(rendCaps & FXRC_BLEND_MODE)) { | 770 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) &&
(rendCaps & FXRC_BLEND_MODE)) { |
771 int oldBlend = m_curBlend; | 771 int oldBlend = m_curBlend; |
772 m_curBlend = blend_type; | 772 m_curBlend = blend_type; |
773 bRet = DrawObjWithBlend(pPageObj, pObj2Device); | 773 bRet = DrawObjWithBlend(pPageObj, pObj2Device); |
774 m_curBlend = oldBlend; | 774 m_curBlend = oldBlend; |
775 } | 775 } |
776 if (!bRet) { | 776 if (!bRet) { |
777 DrawObjWithBackground(pPageObj, pObj2Device); | 777 DrawObjWithBackground(pPageObj, pObj2Device); |
778 } | 778 } |
779 return TRUE; | 779 return true; |
780 } | 780 } |
781 FX_RECT rect = pPageObj->GetBBox(pObj2Device); | 781 FX_RECT rect = pPageObj->GetBBox(pObj2Device); |
782 rect.Intersect(m_pDevice->GetClipBox()); | 782 rect.Intersect(m_pDevice->GetClipBox()); |
783 if (rect.IsEmpty()) { | 783 if (rect.IsEmpty()) { |
784 return TRUE; | 784 return true; |
785 } | 785 } |
786 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); | 786 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); |
787 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); | 787 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); |
788 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); | 788 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); |
789 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); | 789 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); |
790 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); | 790 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); |
791 CFX_FxgeDevice bitmap_device; | 791 CFX_FxgeDevice bitmap_device; |
792 CFX_DIBitmap* oriDevice = NULL; | 792 CFX_DIBitmap* oriDevice = NULL; |
793 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { | 793 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { |
794 oriDevice = new CFX_DIBitmap; | 794 oriDevice = new CFX_DIBitmap; |
795 if (!m_pDevice->CreateCompatibleBitmap(oriDevice, width, height)) { | 795 if (!m_pDevice->CreateCompatibleBitmap(oriDevice, width, height)) { |
796 return TRUE; | 796 return true; |
797 } | 797 } |
798 m_pDevice->GetDIBits(oriDevice, rect.left, rect.top); | 798 m_pDevice->GetDIBits(oriDevice, rect.left, rect.top); |
799 } | 799 } |
800 if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice)) { | 800 if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice)) { |
801 return TRUE; | 801 return true; |
802 } | 802 } |
803 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); | 803 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); |
804 bitmap->Clear(0); | 804 bitmap->Clear(0); |
805 CFX_AffineMatrix new_matrix = *pObj2Device; | 805 CFX_AffineMatrix new_matrix = *pObj2Device; |
806 new_matrix.TranslateI(-rect.left, -rect.top); | 806 new_matrix.TranslateI(-rect.left, -rect.top); |
807 new_matrix.Scale(scaleX, scaleY); | 807 new_matrix.Scale(scaleX, scaleY); |
808 CFX_DIBitmap* pTextMask = NULL; | 808 CFX_DIBitmap* pTextMask = NULL; |
809 if (bTextClip) { | 809 if (bTextClip) { |
810 pTextMask = new CFX_DIBitmap; | 810 pTextMask = new CFX_DIBitmap; |
811 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) { | 811 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) { |
812 delete pTextMask; | 812 delete pTextMask; |
813 return TRUE; | 813 return true; |
814 } | 814 } |
815 pTextMask->Clear(0); | 815 pTextMask->Clear(0); |
816 CFX_FxgeDevice text_device; | 816 CFX_FxgeDevice text_device; |
817 text_device.Attach(pTextMask); | 817 text_device.Attach(pTextMask); |
818 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i ++) { | 818 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i ++) { |
819 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); | 819 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); |
820 if (textobj == NULL) { | 820 if (textobj == NULL) { |
821 break; | 821 break; |
822 } | 822 } |
823 CFX_AffineMatrix text_matrix; | 823 CFX_AffineMatrix text_matrix; |
824 textobj->GetTextMatrix(&text_matrix); | 824 textobj->GetTextMatrix(&text_matrix); |
825 CPDF_TextRenderer::DrawTextPath(&text_device, textobj->m_nChars, tex
tobj->m_pCharCodes, textobj->m_pCharPos, | 825 CPDF_TextRenderer::DrawTextPath(&text_device, textobj->m_nChars, tex
tobj->m_pCharCodes, textobj->m_pCharPos, |
826 textobj->m_TextState.GetFont(), text
obj->m_TextState.GetFontSize(), | 826 textobj->m_TextState.GetFont(), text
obj->m_TextState.GetFontSize(), |
827 &text_matrix, &new_matrix, textobj->
m_GraphState, (FX_ARGB) - 1, 0, NULL); | 827 &text_matrix, &new_matrix, textobj->
m_GraphState, (FX_ARGB) - 1, 0, NULL); |
828 } | 828 } |
829 } | 829 } |
830 CPDF_RenderStatus bitmap_render; | 830 CPDF_RenderStatus bitmap_render; |
831 bitmap_render.Initialize(m_pContext, &bitmap_device, NULL, | 831 bitmap_render.Initialize(m_pContext, &bitmap_device, NULL, |
832 m_pStopObj, NULL, NULL, &m_Options, 0, m_bDropObjec
ts, pFormResource, TRUE); | 832 m_pStopObj, NULL, NULL, &m_Options, 0, m_bDropObjec
ts, pFormResource, true); |
833 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); | 833 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); |
834 m_bStopped = bitmap_render.m_bStopped; | 834 m_bStopped = bitmap_render.m_bStopped; |
835 if (pSMaskDict) { | 835 if (pSMaskDict) { |
836 CFX_AffineMatrix smask_matrix; | 836 CFX_AffineMatrix smask_matrix; |
837 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, sizeof smask_m
atrix); | 837 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, sizeof smask_m
atrix); |
838 smask_matrix.Concat(*pObj2Device); | 838 smask_matrix.Concat(*pObj2Device); |
839 CFX_DIBSource* pSMaskSource = LoadSMask(pSMaskDict, &rect, &smask_matrix
); | 839 CFX_DIBSource* pSMaskSource = LoadSMask(pSMaskDict, &rect, &smask_matrix
); |
840 if (pSMaskSource) { | 840 if (pSMaskSource) { |
841 bitmap->MultiplyAlpha(pSMaskSource); | 841 bitmap->MultiplyAlpha(pSMaskSource); |
842 delete pSMaskSource; | 842 delete pSMaskSource; |
843 } | 843 } |
844 } | 844 } |
845 if (pTextMask) { | 845 if (pTextMask) { |
846 bitmap->MultiplyAlpha(pTextMask); | 846 bitmap->MultiplyAlpha(pTextMask); |
847 delete pTextMask; | 847 delete pTextMask; |
848 pTextMask = NULL; | 848 pTextMask = NULL; |
849 } | 849 } |
850 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { | 850 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { |
851 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); | 851 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); |
852 } | 852 } |
853 Transparency = m_Transparency; | 853 Transparency = m_Transparency; |
854 if (pPageObj->m_Type == PDFPAGE_FORM) { | 854 if (pPageObj->m_Type == PDFPAGE_FORM) { |
855 Transparency |= PDFTRANS_GROUP; | 855 Transparency |= PDFTRANS_GROUP; |
856 } | 856 } |
857 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare
ncy); | 857 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare
ncy); |
858 delete oriDevice; | 858 delete oriDevice; |
859 return TRUE; | 859 return true; |
860 } | 860 } |
861 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const
FX_RECT& rect, int& left, int& top, | 861 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const
FX_RECT& rect, int& left, int& top, |
862 FX_BOOL bBackAlphaRequired) | 862 bool bBackAlphaRequired) |
863 { | 863 { |
864 FX_RECT bbox = rect; | 864 FX_RECT bbox = rect; |
865 bbox.Intersect(m_pDevice->GetClipBox()); | 865 bbox.Intersect(m_pDevice->GetClipBox()); |
866 left = bbox.left; | 866 left = bbox.left; |
867 top = bbox.top; | 867 top = bbox.top; |
868 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); | 868 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); |
869 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); | 869 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); |
870 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); | 870 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); |
871 int width = FXSYS_round(bbox.Width() * scaleX); | 871 int width = FXSYS_round(bbox.Width() * scaleX); |
872 int height = FXSYS_round(bbox.Height() * scaleY); | 872 int height = FXSYS_round(bbox.Height() * scaleY); |
873 CFX_DIBitmap* pBackdrop = new CFX_DIBitmap; | 873 CFX_DIBitmap* pBackdrop = new CFX_DIBitmap; |
874 if (bBackAlphaRequired && !m_bDropObjects) { | 874 if (bBackAlphaRequired && !m_bDropObjects) { |
875 pBackdrop->Create(width, height, FXDIB_Argb); | 875 pBackdrop->Create(width, height, FXDIB_Argb); |
876 } else { | 876 } else { |
877 m_pDevice->CreateCompatibleBitmap(pBackdrop, width, height); | 877 m_pDevice->CreateCompatibleBitmap(pBackdrop, width, height); |
878 } | 878 } |
879 if (pBackdrop->GetBuffer() == NULL) { | 879 if (pBackdrop->GetBuffer() == NULL) { |
880 delete pBackdrop; | 880 delete pBackdrop; |
881 return NULL; | 881 return NULL; |
882 } | 882 } |
883 FX_BOOL bNeedDraw; | 883 bool bNeedDraw; |
884 if (pBackdrop->HasAlpha()) { | 884 if (pBackdrop->HasAlpha()) { |
885 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT); | 885 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT); |
886 } else { | 886 } else { |
887 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS); | 887 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS); |
888 } | 888 } |
889 if (!bNeedDraw) { | 889 if (!bNeedDraw) { |
890 m_pDevice->GetDIBits(pBackdrop, left, top); | 890 m_pDevice->GetDIBits(pBackdrop, left, top); |
891 return pBackdrop; | 891 return pBackdrop; |
892 } | 892 } |
893 CFX_AffineMatrix FinalMatrix = m_DeviceMatrix; | 893 CFX_AffineMatrix FinalMatrix = m_DeviceMatrix; |
894 FinalMatrix.TranslateI(-left, -top); | 894 FinalMatrix.TranslateI(-left, -top); |
895 FinalMatrix.Scale(scaleX, scaleY); | 895 FinalMatrix.Scale(scaleX, scaleY); |
896 pBackdrop->Clear(pBackdrop->HasAlpha() ? 0 : 0xffffffff); | 896 pBackdrop->Clear(pBackdrop->HasAlpha() ? 0 : 0xffffffff); |
897 CFX_FxgeDevice device; | 897 CFX_FxgeDevice device; |
898 device.Attach(pBackdrop); | 898 device.Attach(pBackdrop); |
899 m_pContext->Render(&device, pObj, &m_Options, &FinalMatrix); | 899 m_pContext->Render(&device, pObj, &m_Options, &FinalMatrix); |
900 return pBackdrop; | 900 return pBackdrop; |
901 } | 901 } |
902 void CPDF_RenderContext::GetBackground(CFX_DIBitmap* pBuffer, const CPDF_PageObj
ect* pObj, | 902 void CPDF_RenderContext::GetBackground(CFX_DIBitmap* pBuffer, const CPDF_PageObj
ect* pObj, |
903 const CPDF_RenderOptions* pOptions, CFX_A
ffineMatrix* pFinalMatrix) | 903 const CPDF_RenderOptions* pOptions, CFX_A
ffineMatrix* pFinalMatrix) |
904 { | 904 { |
905 CFX_FxgeDevice device; | 905 CFX_FxgeDevice device; |
906 device.Attach(pBuffer); | 906 device.Attach(pBuffer); |
907 | 907 |
908 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); | 908 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); |
909 device.FillRect(&rect, 0xffffffff); | 909 device.FillRect(&rect, 0xffffffff); |
910 Render(&device, pObj, pOptions, pFinalMatrix); | 910 Render(&device, pObj, pOptions, pFinalMatrix); |
911 } | 911 } |
912 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(const CPDF_GraphicStates*
pSrcStates, FX_BOOL bStroke) | 912 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(const CPDF_GraphicStates*
pSrcStates, bool bStroke) |
913 { | 913 { |
914 if (!pSrcStates) { | 914 if (!pSrcStates) { |
915 return NULL; | 915 return NULL; |
916 } | 916 } |
917 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; | 917 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; |
918 pStates->CopyStates(*pSrcStates); | 918 pStates->CopyStates(*pSrcStates); |
919 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor()
: | 919 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor()
: |
920 pSrcStates->m_ColorState.GetFillColor(); | 920 pSrcStates->m_ColorState.GetFillColor(); |
921 if (!pObjColor->IsNull()) { | 921 if (!pObjColor->IsNull()) { |
922 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify(); | 922 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify(); |
923 pColorData->m_FillRGB = bStroke ? pSrcStates->m_ColorState.GetObject()->
m_StrokeRGB : | 923 pColorData->m_FillRGB = bStroke ? pSrcStates->m_ColorState.GetObject()->
m_StrokeRGB : |
924 pSrcStates->m_ColorState.GetObject()->m_FillRGB; | 924 pSrcStates->m_ColorState.GetObject()->m_FillRGB; |
925 pColorData->m_StrokeRGB = pColorData->m_FillRGB; | 925 pColorData->m_StrokeRGB = pColorData->m_FillRGB; |
926 } | 926 } |
927 return pStates; | 927 return pStates; |
928 } | 928 } |
929 CPDF_RenderContext::CPDF_RenderContext() | 929 CPDF_RenderContext::CPDF_RenderContext() |
930 { | 930 { |
931 } | 931 } |
932 void CPDF_RenderContext::Create(CPDF_Document* pDoc, CPDF_PageRenderCache* pPage
Cache, | 932 void CPDF_RenderContext::Create(CPDF_Document* pDoc, CPDF_PageRenderCache* pPage
Cache, |
933 CPDF_Dictionary* pPageResources, FX_BOOL bFirstL
ayer) | 933 CPDF_Dictionary* pPageResources, bool bFirstLaye
r) |
934 { | 934 { |
935 m_pDocument = pDoc; | 935 m_pDocument = pDoc; |
936 m_pPageResources = pPageResources; | 936 m_pPageResources = pPageResources; |
937 m_pPageCache = pPageCache; | 937 m_pPageCache = pPageCache; |
938 m_bFirstLayer = bFirstLayer; | 938 m_bFirstLayer = bFirstLayer; |
939 } | 939 } |
940 void CPDF_RenderContext::Create(CPDF_Page* pPage, FX_BOOL bFirstLayer) | 940 void CPDF_RenderContext::Create(CPDF_Page* pPage, bool bFirstLayer) |
941 { | 941 { |
942 m_pDocument = pPage->m_pDocument; | 942 m_pDocument = pPage->m_pDocument; |
943 m_pPageResources = pPage->m_pPageResources; | 943 m_pPageResources = pPage->m_pPageResources; |
944 m_pPageCache = pPage->GetRenderCache(); | 944 m_pPageCache = pPage->GetRenderCache(); |
945 m_bFirstLayer = bFirstLayer; | 945 m_bFirstLayer = bFirstLayer; |
946 } | 946 } |
947 CPDF_RenderContext::~CPDF_RenderContext() | 947 CPDF_RenderContext::~CPDF_RenderContext() |
948 { | 948 { |
949 } | 949 } |
950 void CPDF_RenderContext::Clear() | 950 void CPDF_RenderContext::Clear() |
951 { | 951 { |
952 m_pDocument = NULL; | 952 m_pDocument = NULL; |
953 m_pPageResources = NULL; | 953 m_pPageResources = NULL; |
954 m_pPageCache = NULL; | 954 m_pPageCache = NULL; |
955 m_bFirstLayer = TRUE; | 955 m_bFirstLayer = true; |
956 m_ContentList.RemoveAll(); | 956 m_ContentList.RemoveAll(); |
957 } | 957 } |
958 void CPDF_RenderContext::AppendObjectList(CPDF_PageObjects* pObjs, const CFX_Aff
ineMatrix* pObject2Device) | 958 void CPDF_RenderContext::AppendObjectList(CPDF_PageObjects* pObjs, const CFX_Aff
ineMatrix* pObject2Device) |
959 { | 959 { |
960 _PDF_RenderItem* pItem = m_ContentList.AddSpace(); | 960 _PDF_RenderItem* pItem = m_ContentList.AddSpace(); |
961 pItem->m_pObjectList = pObjs; | 961 pItem->m_pObjectList = pObjs; |
962 if (pObject2Device) { | 962 if (pObject2Device) { |
963 pItem->m_Matrix = *pObject2Device; | 963 pItem->m_Matrix = *pObject2Device; |
964 } else { | 964 } else { |
965 pItem->m_Matrix.SetIdentity(); | 965 pItem->m_Matrix.SetIdentity(); |
966 } | 966 } |
967 } | 967 } |
968 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_RenderOpti
ons* pOptions, | 968 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_RenderOpti
ons* pOptions, |
969 const CFX_AffineMatrix* pLastMatrix) | 969 const CFX_AffineMatrix* pLastMatrix) |
970 { | 970 { |
971 Render(pDevice, NULL, pOptions, pLastMatrix); | 971 Render(pDevice, NULL, pOptions, pLastMatrix); |
972 } | 972 } |
973 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_PageObject
* pStopObj, | 973 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_PageObject
* pStopObj, |
974 const CPDF_RenderOptions* pOptions, const CFX_Af
fineMatrix* pLastMatrix) | 974 const CPDF_RenderOptions* pOptions, const CFX_Af
fineMatrix* pLastMatrix) |
975 { | 975 { |
976 int count = m_ContentList.GetSize(); | 976 int count = m_ContentList.GetSize(); |
977 for (int j = 0; j < count; j ++) { | 977 for (int j = 0; j < count; j ++) { |
978 pDevice->SaveState(); | 978 pDevice->SaveState(); |
979 _PDF_RenderItem* pItem = m_ContentList.GetDataPtr(j); | 979 _PDF_RenderItem* pItem = m_ContentList.GetDataPtr(j); |
980 if (pLastMatrix) { | 980 if (pLastMatrix) { |
981 CFX_AffineMatrix FinalMatrix = pItem->m_Matrix; | 981 CFX_AffineMatrix FinalMatrix = pItem->m_Matrix; |
982 FinalMatrix.Concat(*pLastMatrix); | 982 FinalMatrix.Concat(*pLastMatrix); |
983 CPDF_RenderStatus status; | 983 CPDF_RenderStatus status; |
984 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL,
pOptions, | 984 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL,
pOptions, |
985 pItem->m_pObjectList->m_Transparency, FALSE, NULL)
; | 985 pItem->m_pObjectList->m_Transparency, false, NULL)
; |
986 status.RenderObjectList(pItem->m_pObjectList, &FinalMatrix); | 986 status.RenderObjectList(pItem->m_pObjectList, &FinalMatrix); |
987 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 987 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
988 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS
ize); | 988 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS
ize); |
989 } | 989 } |
990 if (status.m_bStopped) { | 990 if (status.m_bStopped) { |
991 pDevice->RestoreState(); | 991 pDevice->RestoreState(); |
992 break; | 992 break; |
993 } | 993 } |
994 } else { | 994 } else { |
995 CPDF_RenderStatus status; | 995 CPDF_RenderStatus status; |
996 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOption
s, | 996 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOption
s, |
997 pItem->m_pObjectList->m_Transparency, FALSE, NULL)
; | 997 pItem->m_pObjectList->m_Transparency, false, NULL)
; |
998 status.RenderObjectList(pItem->m_pObjectList, &pItem->m_Matrix); | 998 status.RenderObjectList(pItem->m_pObjectList, &pItem->m_Matrix); |
999 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 999 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
1000 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS
ize); | 1000 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS
ize); |
1001 } | 1001 } |
1002 if (status.m_bStopped) { | 1002 if (status.m_bStopped) { |
1003 pDevice->RestoreState(); | 1003 pDevice->RestoreState(); |
1004 break; | 1004 break; |
1005 } | 1005 } |
1006 } | 1006 } |
1007 pDevice->RestoreState(); | 1007 pDevice->RestoreState(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); | 1081 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); |
1082 } | 1082 } |
1083 m_PrevLastPos = LastPos; | 1083 m_PrevLastPos = LastPos; |
1084 } | 1084 } |
1085 if (!m_pRenderStatus) { | 1085 if (!m_pRenderStatus) { |
1086 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); | 1086 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); |
1087 m_ObjectIndex = 0; | 1087 m_ObjectIndex = 0; |
1088 m_pRenderStatus.reset(new CPDF_RenderStatus()); | 1088 m_pRenderStatus.reset(new CPDF_RenderStatus()); |
1089 m_pRenderStatus->Initialize( | 1089 m_pRenderStatus->Initialize( |
1090 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, | 1090 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, |
1091 pItem->m_pObjectList->m_Transparency, FALSE, NULL); | 1091 pItem->m_pObjectList->m_Transparency, false, NULL); |
1092 m_pDevice->SaveState(); | 1092 m_pDevice->SaveState(); |
1093 m_ClipRect = m_pDevice->GetClipBox(); | 1093 m_ClipRect = m_pDevice->GetClipBox(); |
1094 CFX_AffineMatrix device2object; | 1094 CFX_AffineMatrix device2object; |
1095 device2object.SetReverse(pItem->m_Matrix); | 1095 device2object.SetReverse(pItem->m_Matrix); |
1096 device2object.TransformRect(m_ClipRect); | 1096 device2object.TransformRect(m_ClipRect); |
1097 } | 1097 } |
1098 int objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()->
m_RenderStepLimit; | 1098 int objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()->
m_RenderStepLimit; |
1099 while (m_ObjectPos) { | 1099 while (m_ObjectPos) { |
1100 CPDF_PageObject* pCurObj = pItem->m_pObjectList->GetObjectAt(m_Objec
tPos); | 1100 CPDF_PageObject* pCurObj = pItem->m_pObjectList->GetObjectAt(m_Objec
tPos); |
1101 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && pCurObj->m_Rig
ht >= m_ClipRect.left && | 1101 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && pCurObj->m_Rig
ht >= m_ClipRect.left && |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 if (!pObj) | 1162 if (!pObj) |
1163 return nullptr; | 1163 return nullptr; |
1164 | 1164 |
1165 auto it = m_TransferFuncMap.find(pObj); | 1165 auto it = m_TransferFuncMap.find(pObj); |
1166 if (it != m_TransferFuncMap.end()) { | 1166 if (it != m_TransferFuncMap.end()) { |
1167 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; | 1167 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; |
1168 return pTransferCounter->AddRef(); | 1168 return pTransferCounter->AddRef(); |
1169 } | 1169 } |
1170 | 1170 |
1171 CPDF_Function* pFuncs[3] = { nullptr, nullptr, nullptr }; | 1171 CPDF_Function* pFuncs[3] = { nullptr, nullptr, nullptr }; |
1172 FX_BOOL bUniTransfer = TRUE; | 1172 bool bUniTransfer = true; |
1173 FX_BOOL bIdentity = TRUE; | 1173 bool bIdentity = true; |
1174 if (pObj->GetType() == PDFOBJ_ARRAY) { | 1174 if (pObj->GetType() == PDFOBJ_ARRAY) { |
1175 bUniTransfer = FALSE; | 1175 bUniTransfer = false; |
1176 CPDF_Array* pArray = (CPDF_Array*)pObj; | 1176 CPDF_Array* pArray = (CPDF_Array*)pObj; |
1177 if (pArray->GetCount() < 3) | 1177 if (pArray->GetCount() < 3) |
1178 return nullptr; | 1178 return nullptr; |
1179 | 1179 |
1180 for (FX_DWORD i = 0; i < 3; ++i) { | 1180 for (FX_DWORD i = 0; i < 3; ++i) { |
1181 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetElementValue(i)); | 1181 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetElementValue(i)); |
1182 if (!pFuncs[2 - i]) { | 1182 if (!pFuncs[2 - i]) { |
1183 return nullptr; | 1183 return nullptr; |
1184 } | 1184 } |
1185 } | 1185 } |
(...skipping 13 matching lines...) Expand all Loading... |
1199 FXSYS_memset(output, 0, sizeof(output)); | 1199 FXSYS_memset(output, 0, sizeof(output)); |
1200 FX_FLOAT input; | 1200 FX_FLOAT input; |
1201 int noutput; | 1201 int noutput; |
1202 for (int v = 0; v < 256; ++v) { | 1202 for (int v = 0; v < 256; ++v) { |
1203 input = (FX_FLOAT)v / 255.0f; | 1203 input = (FX_FLOAT)v / 255.0f; |
1204 if (bUniTransfer) { | 1204 if (bUniTransfer) { |
1205 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) | 1205 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) |
1206 pFuncs[0]->Call(&input, 1, output, noutput); | 1206 pFuncs[0]->Call(&input, 1, output, noutput); |
1207 int o = FXSYS_round(output[0] * 255); | 1207 int o = FXSYS_round(output[0] * 255); |
1208 if (o != v) | 1208 if (o != v) |
1209 bIdentity = FALSE; | 1209 bIdentity = false; |
1210 for (int i = 0; i < 3; ++i) { | 1210 for (int i = 0; i < 3; ++i) { |
1211 pTransfer->m_Samples[i * 256 + v] = o; | 1211 pTransfer->m_Samples[i * 256 + v] = o; |
1212 } | 1212 } |
1213 } else { | 1213 } else { |
1214 for (int i = 0; i < 3; ++i) { | 1214 for (int i = 0; i < 3; ++i) { |
1215 if (pFuncs[i] && pFuncs[i]->CountOutputs() <= kMaxOutputs) { | 1215 if (pFuncs[i] && pFuncs[i]->CountOutputs() <= kMaxOutputs) { |
1216 pFuncs[i]->Call(&input, 1, output, noutput); | 1216 pFuncs[i]->Call(&input, 1, output, noutput); |
1217 int o = FXSYS_round(output[0] * 255); | 1217 int o = FXSYS_round(output[0] * 255); |
1218 if (o != v) | 1218 if (o != v) |
1219 bIdentity = FALSE; | 1219 bIdentity = false; |
1220 pTransfer->m_Samples[i * 256 + v] = o; | 1220 pTransfer->m_Samples[i * 256 + v] = o; |
1221 } else { | 1221 } else { |
1222 pTransfer->m_Samples[i * 256 + v] = v; | 1222 pTransfer->m_Samples[i * 256 + v] = v; |
1223 } | 1223 } |
1224 } | 1224 } |
1225 } | 1225 } |
1226 } | 1226 } |
1227 for (int i = 0; i < 3; ++i) | 1227 for (int i = 0; i < 3; ++i) |
1228 delete pFuncs[i]; | 1228 delete pFuncs[i]; |
1229 | 1229 |
(...skipping 19 matching lines...) Expand all Loading... |
1249 { | 1249 { |
1250 m_pBitmap = NULL; | 1250 m_pBitmap = NULL; |
1251 m_pDevice = NULL; | 1251 m_pDevice = NULL; |
1252 m_pContext = NULL; | 1252 m_pContext = NULL; |
1253 m_pObject = NULL; | 1253 m_pObject = NULL; |
1254 } | 1254 } |
1255 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() | 1255 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() |
1256 { | 1256 { |
1257 delete m_pBitmap; | 1257 delete m_pBitmap; |
1258 } | 1258 } |
1259 FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe
vice* pDevice, FX_RECT* pRect, | 1259 bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevic
e* pDevice, FX_RECT* pRect, |
1260 const CPDF_PageObject* pObj, int max_dpi) | 1260 const CPDF_PageObject* pObj, int max_dpi) |
1261 { | 1261 { |
1262 m_pDevice = pDevice; | 1262 m_pDevice = pDevice; |
1263 m_pContext = pContext; | 1263 m_pContext = pContext; |
1264 m_Rect = *pRect; | 1264 m_Rect = *pRect; |
1265 m_pObject = pObj; | 1265 m_pObject = pObj; |
1266 m_Matrix.TranslateI(-pRect->left, -pRect->top); | 1266 m_Matrix.TranslateI(-pRect->left, -pRect->top); |
1267 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1267 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
1268 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); | 1268 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); |
1269 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); | 1269 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); |
(...skipping 10 matching lines...) Expand all Loading... |
1280 #endif | 1280 #endif |
1281 CFX_Matrix ctm = m_pDevice->GetCTM(); | 1281 CFX_Matrix ctm = m_pDevice->GetCTM(); |
1282 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); | 1282 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); |
1283 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); | 1283 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); |
1284 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); | 1284 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); |
1285 CFX_FloatRect rect(*pRect); | 1285 CFX_FloatRect rect(*pRect); |
1286 m_Matrix.TransformRect(rect); | 1286 m_Matrix.TransformRect(rect); |
1287 FX_RECT bitmap_rect = rect.GetOutterRect(); | 1287 FX_RECT bitmap_rect = rect.GetOutterRect(); |
1288 m_pBitmap = new CFX_DIBitmap; | 1288 m_pBitmap = new CFX_DIBitmap; |
1289 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); | 1289 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); |
1290 return TRUE; | 1290 return true; |
1291 } | 1291 } |
1292 void CPDF_DeviceBuffer::OutputToDevice() | 1292 void CPDF_DeviceBuffer::OutputToDevice() |
1293 { | 1293 { |
1294 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { | 1294 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { |
1295 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { | 1295 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { |
1296 m_pDevice->SetDIBits(m_pBitmap, m_Rect.left, m_Rect.top); | 1296 m_pDevice->SetDIBits(m_pBitmap, m_Rect.left, m_Rect.top); |
1297 } else { | 1297 } else { |
1298 m_pDevice->StretchDIBits(m_pBitmap, m_Rect.left, m_Rect.top, m_Rect.
Width(), m_Rect.Height()); | 1298 m_pDevice->StretchDIBits(m_pBitmap, m_Rect.left, m_Rect.top, m_Rect.
Width(), m_Rect.Height()); |
1299 } | 1299 } |
1300 } else { | 1300 } else { |
1301 CFX_DIBitmap buffer; | 1301 CFX_DIBitmap buffer; |
1302 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), m_pBit
map->GetHeight()); | 1302 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), m_pBit
map->GetHeight()); |
1303 m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix); | 1303 m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix); |
1304 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pB
itmap, 0, 0); | 1304 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pB
itmap, 0, 0); |
1305 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(
), m_Rect.Height()); | 1305 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(
), m_Rect.Height()); |
1306 } | 1306 } |
1307 } | 1307 } |
1308 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() | 1308 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() |
1309 { | 1309 { |
1310 m_pBitmapDevice = NULL; | 1310 m_pBitmapDevice = NULL; |
1311 } | 1311 } |
1312 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() | 1312 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() |
1313 { | 1313 { |
1314 delete m_pBitmapDevice; | 1314 delete m_pBitmapDevice; |
1315 } | 1315 } |
1316 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) | 1316 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) |
1317 FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Re
nderDevice* pDevice, FX_RECT* pRect, | 1317 bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Rende
rDevice* pDevice, FX_RECT* pRect, |
1318 const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions, int max
_dpi) | 1318 const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions, int max
_dpi) |
1319 { | 1319 { |
1320 FXSYS_assert(pRect != NULL); | 1320 FXSYS_assert(pRect != NULL); |
1321 m_pDevice = pDevice; | 1321 m_pDevice = pDevice; |
1322 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { | 1322 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { |
1323 return TRUE; | 1323 return true; |
1324 } | 1324 } |
1325 m_pContext = pContext; | 1325 m_pContext = pContext; |
1326 m_Rect = *pRect; | 1326 m_Rect = *pRect; |
1327 m_pObject = pObj; | 1327 m_pObject = pObj; |
1328 m_Matrix.TranslateI(-pRect->left, -pRect->top); | 1328 m_Matrix.TranslateI(-pRect->left, -pRect->top); |
1329 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); | 1329 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); |
1330 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); | 1330 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); |
1331 if (horz_size && vert_size && max_dpi) { | 1331 if (horz_size && vert_size && max_dpi) { |
1332 int dpih = pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size *
10); | 1332 int dpih = pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size *
10); |
1333 int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size
* 10); | 1333 int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size
* 10); |
(...skipping 14 matching lines...) Expand all Loading... |
1348 CFX_FloatRect rect; | 1348 CFX_FloatRect rect; |
1349 int32_t iWidth, iHeight, iPitch; | 1349 int32_t iWidth, iHeight, iPitch; |
1350 while (1) { | 1350 while (1) { |
1351 rect = *pRect; | 1351 rect = *pRect; |
1352 m_Matrix.TransformRect(rect); | 1352 m_Matrix.TransformRect(rect); |
1353 FX_RECT bitmap_rect = rect.GetOutterRect(); | 1353 FX_RECT bitmap_rect = rect.GetOutterRect(); |
1354 iWidth = bitmap_rect.Width(); | 1354 iWidth = bitmap_rect.Width(); |
1355 iHeight = bitmap_rect.Height(); | 1355 iHeight = bitmap_rect.Height(); |
1356 iPitch = (iWidth * bpp + 31) / 32 * 4; | 1356 iPitch = (iWidth * bpp + 31) / 32 * 4; |
1357 if (iWidth * iHeight < 1) { | 1357 if (iWidth * iHeight < 1) { |
1358 return FALSE; | 1358 return false; |
1359 } | 1359 } |
1360 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && | 1360 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && |
1361 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) { | 1361 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) { |
1362 break; | 1362 break; |
1363 } | 1363 } |
1364 m_Matrix.Scale(0.5f, 0.5f); | 1364 m_Matrix.Scale(0.5f, 0.5f); |
1365 } | 1365 } |
1366 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions,
&m_Matrix); | 1366 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions,
&m_Matrix); |
1367 return TRUE; | 1367 return true; |
1368 } | 1368 } |
1369 void CPDF_ScaledRenderBuffer::OutputToDevice() | 1369 void CPDF_ScaledRenderBuffer::OutputToDevice() |
1370 { | 1370 { |
1371 if (m_pBitmapDevice) { | 1371 if (m_pBitmapDevice) { |
1372 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, m_Re
ct.top, m_Rect.Width(), m_Rect.Height()); | 1372 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, m_Re
ct.top, m_Rect.Width(), m_Rect.Height()); |
1373 } | 1373 } |
1374 } | 1374 } |
1375 FX_BOOL IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) | 1375 bool IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) |
1376 { | 1376 { |
1377 const CPDF_ContentMarkData* pData = pObj->m_ContentMark; | 1377 const CPDF_ContentMarkData* pData = pObj->m_ContentMark; |
1378 int nItems = pData->CountItems(); | 1378 int nItems = pData->CountItems(); |
1379 for (int i = 0; i < nItems; i ++) { | 1379 for (int i = 0; i < nItems; i ++) { |
1380 CPDF_ContentMarkItem& item = pData->GetItem(i); | 1380 CPDF_ContentMarkItem& item = pData->GetItem(i); |
1381 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont
entMarkItem::PropertiesDict) { | 1381 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont
entMarkItem::PropertiesDict) { |
1382 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); | 1382 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); |
1383 if (!CheckOCGVisible(pOCG)) { | 1383 if (!CheckOCGVisible(pOCG)) { |
1384 return FALSE; | 1384 return false; |
1385 } | 1385 } |
1386 } | 1386 } |
1387 } | 1387 } |
1388 return TRUE; | 1388 return true; |
1389 } | 1389 } |
OLD | NEW |