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

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render.cpp

Issue 1254703002: FX_BOOL considered harmful, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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
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 "../../../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
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
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
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
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
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 } 554 }
555 if (!pColorData || pColorData->m_FillColor.IsNull()) { 555 if (!pColorData || pColorData->m_FillColor.IsNull()) {
556 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial States.m_ColorState; 556 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial States.m_ColorState;
557 } 557 }
558 FX_COLORREF rgb = pColorData->m_FillRGB; 558 FX_COLORREF rgb = pColorData->m_FillRGB;
559 if (rgb == (FX_DWORD) - 1) { 559 if (rgb == (FX_DWORD) - 1) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 alpha = 255; 605 alpha = 255;
606 } 606 }
607 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); 607 return m_Options.TranslateColor(ArgbEncode(alpha, rgb));
608 } 608 }
609 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Affine Matrix* pObj2Device) 609 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Affine Matrix* pObj2Device)
610 { 610 {
611 if (ClipPath.IsNull()) { 611 if (ClipPath.IsNull()) {
612 if (m_LastClipPath.IsNull()) { 612 if (m_LastClipPath.IsNull()) {
613 return; 613 return;
614 } 614 }
615 m_pDevice->RestoreState(TRUE); 615 m_pDevice->RestoreState(true);
616 m_LastClipPath.SetNull(); 616 m_LastClipPath.SetNull();
617 return; 617 return;
618 } 618 }
619 if (m_LastClipPath == ClipPath) { 619 if (m_LastClipPath == ClipPath) {
620 return; 620 return;
621 } 621 }
622 m_LastClipPath = ClipPath; 622 m_LastClipPath = ClipPath;
623 m_pDevice->RestoreState(TRUE); 623 m_pDevice->RestoreState(true);
624 int nClipPath = ClipPath.GetPathCount(); 624 int nClipPath = ClipPath.GetPathCount();
625 int i; 625 int i;
626 for (i = 0; i < nClipPath; i++) { 626 for (i = 0; i < nClipPath; i++) {
627 const CFX_PathData* pPathData = ClipPath.GetPath(i); 627 const CFX_PathData* pPathData = ClipPath.GetPath(i);
628 if (pPathData == NULL) { 628 if (pPathData == NULL) {
629 continue; 629 continue;
630 } 630 }
631 if (pPathData->GetPointCount() == 0) { 631 if (pPathData->GetPointCount() == 0) {
632 CFX_PathData EmptyPath; 632 CFX_PathData EmptyPath;
633 EmptyPath.AppendRect(-1, -1, 0, 0); 633 EmptyPath.AppendRect(-1, -1, 0, 0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (pPathData == NULL) { 683 if (pPathData == NULL) {
684 continue; 684 continue;
685 } 685 }
686 CFX_GraphStateData stroke_state; 686 CFX_GraphStateData stroke_state;
687 if (m_Options.m_Flags & RENDER_THINLINE) { 687 if (m_Options.m_Flags & RENDER_THINLINE) {
688 stroke_state.m_LineWidth = 0; 688 stroke_state.m_LineWidth = 0;
689 } 689 }
690 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000 , fill_mode); 690 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000 , fill_mode);
691 } 691 }
692 } 692 }
693 FX_BOOL CPDF_RenderStatus::SelectClipPath(CPDF_PathObject* pPathObj, const CFX_A ffineMatrix* pObj2Device, FX_BOOL bStroke) 693 bool CPDF_RenderStatus::SelectClipPath(CPDF_PathObject* pPathObj, const CFX_Affi neMatrix* pObj2Device, bool bStroke)
694 { 694 {
695 CFX_AffineMatrix path_matrix = pPathObj->m_Matrix; 695 CFX_AffineMatrix path_matrix = pPathObj->m_Matrix;
696 path_matrix.Concat(*pObj2Device); 696 path_matrix.Concat(*pObj2Device);
697 if (bStroke) { 697 if (bStroke) {
698 CFX_GraphStateData graphState(*pPathObj->m_GraphState); 698 CFX_GraphStateData graphState(*pPathObj->m_GraphState);
699 if (m_Options.m_Flags & RENDER_THINLINE) { 699 if (m_Options.m_Flags & RENDER_THINLINE) {
700 graphState.m_LineWidth = 0; 700 graphState.m_LineWidth = 0;
701 } 701 }
702 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path, &path_matrix, &gr aphState); 702 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path, &path_matrix, &gr aphState);
703 } 703 }
704 int fill_mode = pPathObj->m_FillType; 704 int fill_mode = pPathObj->m_FillType;
705 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { 705 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) {
706 fill_mode |= FXFILL_NOPATHSMOOTH; 706 fill_mode |= FXFILL_NOPATHSMOOTH;
707 } 707 }
708 return m_pDevice->SetClip_PathFill(pPathObj->m_Path, &path_matrix, fill_mode ); 708 return m_pDevice->SetClip_PathFill(pPathObj->m_Path, &path_matrix, fill_mode );
709 } 709 }
710 FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, const CFX_AffineMatrix* pObj2Device) 710 bool CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, con st CFX_AffineMatrix* pObj2Device)
711 { 711 {
712 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; 712 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;
713 int blend_type = pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NO RMAL; 713 int blend_type = pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NO RMAL;
714 if (blend_type == FXDIB_BLEND_UNSUPPORTED) { 714 if (blend_type == FXDIB_BLEND_UNSUPPORTED) {
715 return TRUE; 715 return true;
716 } 716 }
717 CPDF_Dictionary* pSMaskDict = pGeneralState ? (CPDF_Dictionary*)pGeneralStat e->m_pSoftMask : NULL; 717 CPDF_Dictionary* pSMaskDict = pGeneralState ? (CPDF_Dictionary*)pGeneralStat e->m_pSoftMask : NULL;
718 if (pSMaskDict) { 718 if (pSMaskDict) {
719 if (pPageObj->m_Type == PDFPAGE_IMAGE && 719 if (pPageObj->m_Type == PDFPAGE_IMAGE &&
720 ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDict()->KeyExist(FX_ BSTRC("SMask"))) { 720 ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDict()->KeyExist(FX_ BSTRC("SMask"))) {
721 pSMaskDict = NULL; 721 pSMaskDict = NULL;
722 } 722 }
723 } 723 }
724 CPDF_Dictionary* pFormResource = NULL; 724 CPDF_Dictionary* pFormResource = NULL;
725 FX_FLOAT group_alpha = 1.0f; 725 FX_FLOAT group_alpha = 1.0f;
726 int Transparency = m_Transparency; 726 int Transparency = m_Transparency;
727 FX_BOOL bGroupTransparent = FALSE; 727 bool bGroupTransparent = false;
728 if (pPageObj->m_Type == PDFPAGE_FORM) { 728 if (pPageObj->m_Type == PDFPAGE_FORM) {
729 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; 729 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
730 const CPDF_GeneralStateData *pStateData = pFormObj->m_GeneralState.GetOb ject(); 730 const CPDF_GeneralStateData *pStateData = pFormObj->m_GeneralState.GetOb ject();
731 if (pStateData) { 731 if (pStateData) {
732 group_alpha = pStateData->m_FillAlpha; 732 group_alpha = pStateData->m_FillAlpha;
733 } 733 }
734 Transparency = pFormObj->m_pForm->m_Transparency; 734 Transparency = pFormObj->m_pForm->m_Transparency;
735 bGroupTransparent = Transparency & PDFTRANS_ISOLATED ? TRUE : FALSE; 735 bGroupTransparent = Transparency & PDFTRANS_ISOLATED ? true : false;
736 if (pFormObj->m_pForm->m_pFormDict) { 736 if (pFormObj->m_pForm->m_pFormDict) {
737 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources") ; 737 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources") ;
738 } 738 }
739 } 739 }
740 FX_BOOL bTextClip = FALSE; 740 bool bTextClip = false;
741 if (pPageObj->m_ClipPath.NotNull() && pPageObj->m_ClipPath.GetTextCount() && 741 if (pPageObj->m_ClipPath.NotNull() && pPageObj->m_ClipPath.GetTextCount() &&
742 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && !(m_pDevice->GetDevic eCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { 742 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && !(m_pDevice->GetDevic eCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) {
743 bTextClip = TRUE; 743 bTextClip = true;
744 } 744 }
745 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->m_Type == PDFPAGE_IM AGE && pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { 745 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->m_Type == PDFPAGE_IM AGE && pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) {
746 CPDF_Document* pDocument = NULL; 746 CPDF_Document* pDocument = NULL;
747 CPDF_Page* pPage = NULL; 747 CPDF_Page* pPage = NULL;
748 if (m_pContext->m_pPageCache) { 748 if (m_pContext->m_pPageCache) {
749 pPage = m_pContext->m_pPageCache->GetPage(); 749 pPage = m_pContext->m_pPageCache->GetPage();
750 pDocument = pPage->m_pDocument; 750 pDocument = pPage->m_pDocument;
751 } else { 751 } else {
752 pDocument = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDocument(); 752 pDocument = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDocument();
753 } 753 }
754 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL ; 754 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL ;
755 CPDF_Object* pCSObj = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetStream ()->GetDict()->GetElementValue(FX_BSTRC("ColorSpace")); 755 CPDF_Object* pCSObj = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetStream ()->GetDict()->GetElementValue(FX_BSTRC("ColorSpace"));
756 CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageRe sources); 756 CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageRe sources);
757 if (pColorSpace) { 757 if (pColorSpace) {
758 int format = pColorSpace->GetFamily(); 758 int format = pColorSpace->GetFamily();
759 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form at == PDFCS_DEVICEN) { 759 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form at == PDFCS_DEVICEN) {
760 blend_type = FXDIB_BLEND_DARKEN; 760 blend_type = FXDIB_BLEND_DARKEN;
761 } 761 }
762 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); 762 pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
763 } 763 }
764 } 764 }
765 if (pSMaskDict == NULL && group_alpha == 1.0f && blend_type == FXDIB_BLEND_N ORMAL && !bTextClip && !bGroupTransparent) { 765 if (pSMaskDict == NULL && group_alpha == 1.0f && blend_type == FXDIB_BLEND_N ORMAL && !bTextClip && !bGroupTransparent) {
766 return FALSE; 766 return false;
767 } 767 }
768 FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED; 768 bool isolated = Transparency & PDFTRANS_ISOLATED;
769 if (m_bPrint) { 769 if (m_bPrint) {
770 FX_BOOL bRet = FALSE; 770 bool bRet = false;
771 int rendCaps = m_pDevice->GetRenderCaps(); 771 int rendCaps = m_pDevice->GetRenderCaps();
772 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) && (rendCaps & FXRC_BLEND_MODE)) { 772 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) && (rendCaps & FXRC_BLEND_MODE)) {
773 int oldBlend = m_curBlend; 773 int oldBlend = m_curBlend;
774 m_curBlend = blend_type; 774 m_curBlend = blend_type;
775 bRet = DrawObjWithBlend(pPageObj, pObj2Device); 775 bRet = DrawObjWithBlend(pPageObj, pObj2Device);
776 m_curBlend = oldBlend; 776 m_curBlend = oldBlend;
777 } 777 }
778 if (!bRet) { 778 if (!bRet) {
779 DrawObjWithBackground(pPageObj, pObj2Device); 779 DrawObjWithBackground(pPageObj, pObj2Device);
780 } 780 }
781 return TRUE; 781 return true;
782 } 782 }
783 FX_RECT rect = pPageObj->GetBBox(pObj2Device); 783 FX_RECT rect = pPageObj->GetBBox(pObj2Device);
784 rect.Intersect(m_pDevice->GetClipBox()); 784 rect.Intersect(m_pDevice->GetClipBox());
785 if (rect.IsEmpty()) { 785 if (rect.IsEmpty()) {
786 return TRUE; 786 return true;
787 } 787 }
788 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); 788 CFX_Matrix deviceCTM = m_pDevice->GetCTM();
789 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); 789 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a);
790 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); 790 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d);
791 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); 791 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX);
792 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); 792 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY);
793 CFX_FxgeDevice bitmap_device; 793 CFX_FxgeDevice bitmap_device;
794 CFX_DIBitmap* oriDevice = NULL; 794 CFX_DIBitmap* oriDevice = NULL;
795 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { 795 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
796 oriDevice = new CFX_DIBitmap; 796 oriDevice = new CFX_DIBitmap;
797 if (!m_pDevice->CreateCompatibleBitmap(oriDevice, width, height)) { 797 if (!m_pDevice->CreateCompatibleBitmap(oriDevice, width, height)) {
798 return TRUE; 798 return true;
799 } 799 }
800 m_pDevice->GetDIBits(oriDevice, rect.left, rect.top); 800 m_pDevice->GetDIBits(oriDevice, rect.left, rect.top);
801 } 801 }
802 if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice)) { 802 if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice)) {
803 return TRUE; 803 return true;
804 } 804 }
805 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); 805 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap();
806 bitmap->Clear(0); 806 bitmap->Clear(0);
807 CFX_AffineMatrix new_matrix = *pObj2Device; 807 CFX_AffineMatrix new_matrix = *pObj2Device;
808 new_matrix.TranslateI(-rect.left, -rect.top); 808 new_matrix.TranslateI(-rect.left, -rect.top);
809 new_matrix.Scale(scaleX, scaleY); 809 new_matrix.Scale(scaleX, scaleY);
810 CFX_DIBitmap* pTextMask = NULL; 810 CFX_DIBitmap* pTextMask = NULL;
811 if (bTextClip) { 811 if (bTextClip) {
812 pTextMask = new CFX_DIBitmap; 812 pTextMask = new CFX_DIBitmap;
813 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) { 813 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) {
814 delete pTextMask; 814 delete pTextMask;
815 return TRUE; 815 return true;
816 } 816 }
817 pTextMask->Clear(0); 817 pTextMask->Clear(0);
818 CFX_FxgeDevice text_device; 818 CFX_FxgeDevice text_device;
819 text_device.Attach(pTextMask); 819 text_device.Attach(pTextMask);
820 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i ++) { 820 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i ++) {
821 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); 821 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i);
822 if (textobj == NULL) { 822 if (textobj == NULL) {
823 break; 823 break;
824 } 824 }
825 CFX_AffineMatrix text_matrix; 825 CFX_AffineMatrix text_matrix;
826 textobj->GetTextMatrix(&text_matrix); 826 textobj->GetTextMatrix(&text_matrix);
827 CPDF_TextRenderer::DrawTextPath(&text_device, textobj->m_nChars, tex tobj->m_pCharCodes, textobj->m_pCharPos, 827 CPDF_TextRenderer::DrawTextPath(&text_device, textobj->m_nChars, tex tobj->m_pCharCodes, textobj->m_pCharPos,
828 textobj->m_TextState.GetFont(), text obj->m_TextState.GetFontSize(), 828 textobj->m_TextState.GetFont(), text obj->m_TextState.GetFontSize(),
829 &text_matrix, &new_matrix, textobj-> m_GraphState, (FX_ARGB) - 1, 0, NULL); 829 &text_matrix, &new_matrix, textobj-> m_GraphState, (FX_ARGB) - 1, 0, NULL);
830 } 830 }
831 } 831 }
832 CPDF_RenderStatus bitmap_render; 832 CPDF_RenderStatus bitmap_render;
833 bitmap_render.Initialize(m_pContext, &bitmap_device, NULL, 833 bitmap_render.Initialize(m_pContext, &bitmap_device, NULL,
834 m_pStopObj, NULL, NULL, &m_Options, 0, m_bDropObjec ts, pFormResource, TRUE); 834 m_pStopObj, NULL, NULL, &m_Options, 0, m_bDropObjec ts, pFormResource, true);
835 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); 835 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix);
836 m_bStopped = bitmap_render.m_bStopped; 836 m_bStopped = bitmap_render.m_bStopped;
837 if (pSMaskDict) { 837 if (pSMaskDict) {
838 CFX_AffineMatrix smask_matrix; 838 CFX_AffineMatrix smask_matrix;
839 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, sizeof smask_m atrix); 839 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, sizeof smask_m atrix);
840 smask_matrix.Concat(*pObj2Device); 840 smask_matrix.Concat(*pObj2Device);
841 CFX_DIBSource* pSMaskSource = LoadSMask(pSMaskDict, &rect, &smask_matrix ); 841 CFX_DIBSource* pSMaskSource = LoadSMask(pSMaskDict, &rect, &smask_matrix );
842 if (pSMaskSource) { 842 if (pSMaskSource) {
843 bitmap->MultiplyAlpha(pSMaskSource); 843 bitmap->MultiplyAlpha(pSMaskSource);
844 delete pSMaskSource; 844 delete pSMaskSource;
845 } 845 }
846 } 846 }
847 if (pTextMask) { 847 if (pTextMask) {
848 bitmap->MultiplyAlpha(pTextMask); 848 bitmap->MultiplyAlpha(pTextMask);
849 delete pTextMask; 849 delete pTextMask;
850 pTextMask = NULL; 850 pTextMask = NULL;
851 } 851 }
852 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { 852 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) {
853 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); 853 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255));
854 } 854 }
855 Transparency = m_Transparency; 855 Transparency = m_Transparency;
856 if (pPageObj->m_Type == PDFPAGE_FORM) { 856 if (pPageObj->m_Type == PDFPAGE_FORM) {
857 Transparency |= PDFTRANS_GROUP; 857 Transparency |= PDFTRANS_GROUP;
858 } 858 }
859 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare ncy); 859 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare ncy);
860 delete oriDevice; 860 delete oriDevice;
861 return TRUE; 861 return true;
862 } 862 }
863 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, int& top, 863 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, int& top,
864 FX_BOOL bBackAlphaRequired) 864 bool bBackAlphaRequired)
865 { 865 {
866 FX_RECT bbox = rect; 866 FX_RECT bbox = rect;
867 bbox.Intersect(m_pDevice->GetClipBox()); 867 bbox.Intersect(m_pDevice->GetClipBox());
868 left = bbox.left; 868 left = bbox.left;
869 top = bbox.top; 869 top = bbox.top;
870 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); 870 CFX_Matrix deviceCTM = m_pDevice->GetCTM();
871 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); 871 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a);
872 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); 872 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d);
873 int width = FXSYS_round(bbox.Width() * scaleX); 873 int width = FXSYS_round(bbox.Width() * scaleX);
874 int height = FXSYS_round(bbox.Height() * scaleY); 874 int height = FXSYS_round(bbox.Height() * scaleY);
875 CFX_DIBitmap* pBackdrop = new CFX_DIBitmap; 875 CFX_DIBitmap* pBackdrop = new CFX_DIBitmap;
876 if (bBackAlphaRequired && !m_bDropObjects) { 876 if (bBackAlphaRequired && !m_bDropObjects) {
877 pBackdrop->Create(width, height, FXDIB_Argb); 877 pBackdrop->Create(width, height, FXDIB_Argb);
878 } else { 878 } else {
879 m_pDevice->CreateCompatibleBitmap(pBackdrop, width, height); 879 m_pDevice->CreateCompatibleBitmap(pBackdrop, width, height);
880 } 880 }
881 if (pBackdrop->GetBuffer() == NULL) { 881 if (pBackdrop->GetBuffer() == NULL) {
882 delete pBackdrop; 882 delete pBackdrop;
883 return NULL; 883 return NULL;
884 } 884 }
885 FX_BOOL bNeedDraw; 885 bool bNeedDraw;
886 if (pBackdrop->HasAlpha()) { 886 if (pBackdrop->HasAlpha()) {
887 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT); 887 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT);
888 } else { 888 } else {
889 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS); 889 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS);
890 } 890 }
891 if (!bNeedDraw) { 891 if (!bNeedDraw) {
892 m_pDevice->GetDIBits(pBackdrop, left, top); 892 m_pDevice->GetDIBits(pBackdrop, left, top);
893 return pBackdrop; 893 return pBackdrop;
894 } 894 }
895 CFX_AffineMatrix FinalMatrix = m_DeviceMatrix; 895 CFX_AffineMatrix FinalMatrix = m_DeviceMatrix;
896 FinalMatrix.TranslateI(-left, -top); 896 FinalMatrix.TranslateI(-left, -top);
897 FinalMatrix.Scale(scaleX, scaleY); 897 FinalMatrix.Scale(scaleX, scaleY);
898 pBackdrop->Clear(pBackdrop->HasAlpha() ? 0 : 0xffffffff); 898 pBackdrop->Clear(pBackdrop->HasAlpha() ? 0 : 0xffffffff);
899 CFX_FxgeDevice device; 899 CFX_FxgeDevice device;
900 device.Attach(pBackdrop); 900 device.Attach(pBackdrop);
901 m_pContext->Render(&device, pObj, &m_Options, &FinalMatrix); 901 m_pContext->Render(&device, pObj, &m_Options, &FinalMatrix);
902 return pBackdrop; 902 return pBackdrop;
903 } 903 }
904 void CPDF_RenderContext::GetBackground(CFX_DIBitmap* pBuffer, const CPDF_PageObj ect* pObj, 904 void CPDF_RenderContext::GetBackground(CFX_DIBitmap* pBuffer, const CPDF_PageObj ect* pObj,
905 const CPDF_RenderOptions* pOptions, CFX_A ffineMatrix* pFinalMatrix) 905 const CPDF_RenderOptions* pOptions, CFX_A ffineMatrix* pFinalMatrix)
906 { 906 {
907 CFX_FxgeDevice device; 907 CFX_FxgeDevice device;
908 device.Attach(pBuffer); 908 device.Attach(pBuffer);
909 909
910 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); 910 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight());
911 device.FillRect(&rect, 0xffffffff); 911 device.FillRect(&rect, 0xffffffff);
912 Render(&device, pObj, pOptions, pFinalMatrix); 912 Render(&device, pObj, pOptions, pFinalMatrix);
913 } 913 }
914 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(const CPDF_GraphicStates* pSrcStates, FX_BOOL bStroke) 914 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(const CPDF_GraphicStates* pSrcStates, bool bStroke)
915 { 915 {
916 if (!pSrcStates) { 916 if (!pSrcStates) {
917 return NULL; 917 return NULL;
918 } 918 }
919 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; 919 CPDF_GraphicStates* pStates = new CPDF_GraphicStates;
920 pStates->CopyStates(*pSrcStates); 920 pStates->CopyStates(*pSrcStates);
921 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor() : 921 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor() :
922 pSrcStates->m_ColorState.GetFillColor(); 922 pSrcStates->m_ColorState.GetFillColor();
923 if (!pObjColor->IsNull()) { 923 if (!pObjColor->IsNull()) {
924 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify(); 924 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify();
925 pColorData->m_FillRGB = bStroke ? pSrcStates->m_ColorState.GetObject()-> m_StrokeRGB : 925 pColorData->m_FillRGB = bStroke ? pSrcStates->m_ColorState.GetObject()-> m_StrokeRGB :
926 pSrcStates->m_ColorState.GetObject()->m_FillRGB; 926 pSrcStates->m_ColorState.GetObject()->m_FillRGB;
927 pColorData->m_StrokeRGB = pColorData->m_FillRGB; 927 pColorData->m_StrokeRGB = pColorData->m_FillRGB;
928 } 928 }
929 return pStates; 929 return pStates;
930 } 930 }
931 CPDF_RenderContext::CPDF_RenderContext() 931 CPDF_RenderContext::CPDF_RenderContext()
932 { 932 {
933 } 933 }
934 void CPDF_RenderContext::Create(CPDF_Document* pDoc, CPDF_PageRenderCache* pPage Cache, 934 void CPDF_RenderContext::Create(CPDF_Document* pDoc, CPDF_PageRenderCache* pPage Cache,
935 CPDF_Dictionary* pPageResources, FX_BOOL bFirstL ayer) 935 CPDF_Dictionary* pPageResources, bool bFirstLaye r)
936 { 936 {
937 m_pDocument = pDoc; 937 m_pDocument = pDoc;
938 m_pPageResources = pPageResources; 938 m_pPageResources = pPageResources;
939 m_pPageCache = pPageCache; 939 m_pPageCache = pPageCache;
940 m_bFirstLayer = bFirstLayer; 940 m_bFirstLayer = bFirstLayer;
941 } 941 }
942 void CPDF_RenderContext::Create(CPDF_Page* pPage, FX_BOOL bFirstLayer) 942 void CPDF_RenderContext::Create(CPDF_Page* pPage, bool bFirstLayer)
943 { 943 {
944 m_pDocument = pPage->m_pDocument; 944 m_pDocument = pPage->m_pDocument;
945 m_pPageResources = pPage->m_pPageResources; 945 m_pPageResources = pPage->m_pPageResources;
946 m_pPageCache = pPage->GetRenderCache(); 946 m_pPageCache = pPage->GetRenderCache();
947 m_bFirstLayer = bFirstLayer; 947 m_bFirstLayer = bFirstLayer;
948 } 948 }
949 CPDF_RenderContext::~CPDF_RenderContext() 949 CPDF_RenderContext::~CPDF_RenderContext()
950 { 950 {
951 } 951 }
952 void CPDF_RenderContext::Clear() 952 void CPDF_RenderContext::Clear()
953 { 953 {
954 m_pDocument = NULL; 954 m_pDocument = NULL;
955 m_pPageResources = NULL; 955 m_pPageResources = NULL;
956 m_pPageCache = NULL; 956 m_pPageCache = NULL;
957 m_bFirstLayer = TRUE; 957 m_bFirstLayer = true;
958 m_ContentList.RemoveAll(); 958 m_ContentList.RemoveAll();
959 } 959 }
960 void CPDF_RenderContext::AppendObjectList(CPDF_PageObjects* pObjs, const CFX_Aff ineMatrix* pObject2Device) 960 void CPDF_RenderContext::AppendObjectList(CPDF_PageObjects* pObjs, const CFX_Aff ineMatrix* pObject2Device)
961 { 961 {
962 _PDF_RenderItem* pItem = m_ContentList.AddSpace(); 962 _PDF_RenderItem* pItem = m_ContentList.AddSpace();
963 pItem->m_pObjectList = pObjs; 963 pItem->m_pObjectList = pObjs;
964 if (pObject2Device) { 964 if (pObject2Device) {
965 pItem->m_Matrix = *pObject2Device; 965 pItem->m_Matrix = *pObject2Device;
966 } else { 966 } else {
967 pItem->m_Matrix.SetIdentity(); 967 pItem->m_Matrix.SetIdentity();
968 } 968 }
969 } 969 }
970 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_RenderOpti ons* pOptions, 970 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_RenderOpti ons* pOptions,
971 const CFX_AffineMatrix* pLastMatrix) 971 const CFX_AffineMatrix* pLastMatrix)
972 { 972 {
973 Render(pDevice, NULL, pOptions, pLastMatrix); 973 Render(pDevice, NULL, pOptions, pLastMatrix);
974 } 974 }
975 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_PageObject * pStopObj, 975 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_PageObject * pStopObj,
976 const CPDF_RenderOptions* pOptions, const CFX_Af fineMatrix* pLastMatrix) 976 const CPDF_RenderOptions* pOptions, const CFX_Af fineMatrix* pLastMatrix)
977 { 977 {
978 int count = m_ContentList.GetSize(); 978 int count = m_ContentList.GetSize();
979 for (int j = 0; j < count; j ++) { 979 for (int j = 0; j < count; j ++) {
980 pDevice->SaveState(); 980 pDevice->SaveState();
981 _PDF_RenderItem* pItem = m_ContentList.GetDataPtr(j); 981 _PDF_RenderItem* pItem = m_ContentList.GetDataPtr(j);
982 if (pLastMatrix) { 982 if (pLastMatrix) {
983 CFX_AffineMatrix FinalMatrix = pItem->m_Matrix; 983 CFX_AffineMatrix FinalMatrix = pItem->m_Matrix;
984 FinalMatrix.Concat(*pLastMatrix); 984 FinalMatrix.Concat(*pLastMatrix);
985 CPDF_RenderStatus status; 985 CPDF_RenderStatus status;
986 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, pOptions, 986 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, pOptions,
987 pItem->m_pObjectList->m_Transparency, FALSE, NULL) ; 987 pItem->m_pObjectList->m_Transparency, false, NULL) ;
988 status.RenderObjectList(pItem->m_pObjectList, &FinalMatrix); 988 status.RenderObjectList(pItem->m_pObjectList, &FinalMatrix);
989 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { 989 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
990 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS ize); 990 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS ize);
991 } 991 }
992 if (status.m_bStopped) { 992 if (status.m_bStopped) {
993 pDevice->RestoreState(); 993 pDevice->RestoreState();
994 break; 994 break;
995 } 995 }
996 } else { 996 } else {
997 CPDF_RenderStatus status; 997 CPDF_RenderStatus status;
998 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOption s, 998 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOption s,
999 pItem->m_pObjectList->m_Transparency, FALSE, NULL) ; 999 pItem->m_pObjectList->m_Transparency, false, NULL) ;
1000 status.RenderObjectList(pItem->m_pObjectList, &pItem->m_Matrix); 1000 status.RenderObjectList(pItem->m_pObjectList, &pItem->m_Matrix);
1001 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { 1001 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
1002 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS ize); 1002 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheS ize);
1003 } 1003 }
1004 if (status.m_bStopped) { 1004 if (status.m_bStopped) {
1005 pDevice->RestoreState(); 1005 pDevice->RestoreState();
1006 break; 1006 break;
1007 } 1007 }
1008 } 1008 }
1009 pDevice->RestoreState(); 1009 pDevice->RestoreState();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); 1083 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition();
1084 } 1084 }
1085 m_PrevLastPos = LastPos; 1085 m_PrevLastPos = LastPos;
1086 } 1086 }
1087 if (!m_pRenderStatus) { 1087 if (!m_pRenderStatus) {
1088 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); 1088 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition();
1089 m_ObjectIndex = 0; 1089 m_ObjectIndex = 0;
1090 m_pRenderStatus.reset(new CPDF_RenderStatus()); 1090 m_pRenderStatus.reset(new CPDF_RenderStatus());
1091 m_pRenderStatus->Initialize( 1091 m_pRenderStatus->Initialize(
1092 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, 1092 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions,
1093 pItem->m_pObjectList->m_Transparency, FALSE, NULL); 1093 pItem->m_pObjectList->m_Transparency, false, NULL);
1094 m_pDevice->SaveState(); 1094 m_pDevice->SaveState();
1095 m_ClipRect = m_pDevice->GetClipBox(); 1095 m_ClipRect = m_pDevice->GetClipBox();
1096 CFX_AffineMatrix device2object; 1096 CFX_AffineMatrix device2object;
1097 device2object.SetReverse(pItem->m_Matrix); 1097 device2object.SetReverse(pItem->m_Matrix);
1098 device2object.TransformRect(m_ClipRect); 1098 device2object.TransformRect(m_ClipRect);
1099 } 1099 }
1100 int objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()-> m_RenderStepLimit; 1100 int objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()-> m_RenderStepLimit;
1101 while (m_ObjectPos) { 1101 while (m_ObjectPos) {
1102 CPDF_PageObject* pCurObj = pItem->m_pObjectList->GetObjectAt(m_Objec tPos); 1102 CPDF_PageObject* pCurObj = pItem->m_pObjectList->GetObjectAt(m_Objec tPos);
1103 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && pCurObj->m_Rig ht >= m_ClipRect.left && 1103 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
1164 if (!pObj) 1164 if (!pObj)
1165 return nullptr; 1165 return nullptr;
1166 1166
1167 auto it = m_TransferFuncMap.find(pObj); 1167 auto it = m_TransferFuncMap.find(pObj);
1168 if (it != m_TransferFuncMap.end()) { 1168 if (it != m_TransferFuncMap.end()) {
1169 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; 1169 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second;
1170 return pTransferCounter->AddRef(); 1170 return pTransferCounter->AddRef();
1171 } 1171 }
1172 1172
1173 CPDF_Function* pFuncs[3] = { nullptr, nullptr, nullptr }; 1173 CPDF_Function* pFuncs[3] = { nullptr, nullptr, nullptr };
1174 FX_BOOL bUniTransfer = TRUE; 1174 bool bUniTransfer = true;
1175 FX_BOOL bIdentity = TRUE; 1175 bool bIdentity = true;
1176 if (pObj->GetType() == PDFOBJ_ARRAY) { 1176 if (pObj->GetType() == PDFOBJ_ARRAY) {
1177 bUniTransfer = FALSE; 1177 bUniTransfer = false;
1178 CPDF_Array* pArray = (CPDF_Array*)pObj; 1178 CPDF_Array* pArray = (CPDF_Array*)pObj;
1179 if (pArray->GetCount() < 3) 1179 if (pArray->GetCount() < 3)
1180 return nullptr; 1180 return nullptr;
1181 1181
1182 for (FX_DWORD i = 0; i < 3; ++i) { 1182 for (FX_DWORD i = 0; i < 3; ++i) {
1183 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetElementValue(i)); 1183 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetElementValue(i));
1184 if (!pFuncs[2 - i]) { 1184 if (!pFuncs[2 - i]) {
1185 return nullptr; 1185 return nullptr;
1186 } 1186 }
1187 } 1187 }
(...skipping 13 matching lines...) Expand all
1201 FXSYS_memset(output, 0, sizeof(output)); 1201 FXSYS_memset(output, 0, sizeof(output));
1202 FX_FLOAT input; 1202 FX_FLOAT input;
1203 int noutput; 1203 int noutput;
1204 for (int v = 0; v < 256; ++v) { 1204 for (int v = 0; v < 256; ++v) {
1205 input = (FX_FLOAT)v / 255.0f; 1205 input = (FX_FLOAT)v / 255.0f;
1206 if (bUniTransfer) { 1206 if (bUniTransfer) {
1207 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) 1207 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs)
1208 pFuncs[0]->Call(&input, 1, output, noutput); 1208 pFuncs[0]->Call(&input, 1, output, noutput);
1209 int o = FXSYS_round(output[0] * 255); 1209 int o = FXSYS_round(output[0] * 255);
1210 if (o != v) 1210 if (o != v)
1211 bIdentity = FALSE; 1211 bIdentity = false;
1212 for (int i = 0; i < 3; ++i) { 1212 for (int i = 0; i < 3; ++i) {
1213 pTransfer->m_Samples[i * 256 + v] = o; 1213 pTransfer->m_Samples[i * 256 + v] = o;
1214 } 1214 }
1215 } else { 1215 } else {
1216 for (int i = 0; i < 3; ++i) { 1216 for (int i = 0; i < 3; ++i) {
1217 if (pFuncs[i] && pFuncs[i]->CountOutputs() <= kMaxOutputs) { 1217 if (pFuncs[i] && pFuncs[i]->CountOutputs() <= kMaxOutputs) {
1218 pFuncs[i]->Call(&input, 1, output, noutput); 1218 pFuncs[i]->Call(&input, 1, output, noutput);
1219 int o = FXSYS_round(output[0] * 255); 1219 int o = FXSYS_round(output[0] * 255);
1220 if (o != v) 1220 if (o != v)
1221 bIdentity = FALSE; 1221 bIdentity = false;
1222 pTransfer->m_Samples[i * 256 + v] = o; 1222 pTransfer->m_Samples[i * 256 + v] = o;
1223 } else { 1223 } else {
1224 pTransfer->m_Samples[i * 256 + v] = v; 1224 pTransfer->m_Samples[i * 256 + v] = v;
1225 } 1225 }
1226 } 1226 }
1227 } 1227 }
1228 } 1228 }
1229 for (int i = 0; i < 3; ++i) 1229 for (int i = 0; i < 3; ++i)
1230 delete pFuncs[i]; 1230 delete pFuncs[i];
1231 1231
(...skipping 19 matching lines...) Expand all
1251 { 1251 {
1252 m_pBitmap = NULL; 1252 m_pBitmap = NULL;
1253 m_pDevice = NULL; 1253 m_pDevice = NULL;
1254 m_pContext = NULL; 1254 m_pContext = NULL;
1255 m_pObject = NULL; 1255 m_pObject = NULL;
1256 } 1256 }
1257 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() 1257 CPDF_DeviceBuffer::~CPDF_DeviceBuffer()
1258 { 1258 {
1259 delete m_pBitmap; 1259 delete m_pBitmap;
1260 } 1260 }
1261 FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe vice* pDevice, FX_RECT* pRect, 1261 bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevic e* pDevice, FX_RECT* pRect,
1262 const CPDF_PageObject* pObj, int max_dpi) 1262 const CPDF_PageObject* pObj, int max_dpi)
1263 { 1263 {
1264 m_pDevice = pDevice; 1264 m_pDevice = pDevice;
1265 m_pContext = pContext; 1265 m_pContext = pContext;
1266 m_Rect = *pRect; 1266 m_Rect = *pRect;
1267 m_pObject = pObj; 1267 m_pObject = pObj;
1268 m_Matrix.TranslateI(-pRect->left, -pRect->top); 1268 m_Matrix.TranslateI(-pRect->left, -pRect->top);
1269 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1269 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
1270 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); 1270 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE);
1271 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); 1271 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE);
(...skipping 10 matching lines...) Expand all
1282 #endif 1282 #endif
1283 CFX_Matrix ctm = m_pDevice->GetCTM(); 1283 CFX_Matrix ctm = m_pDevice->GetCTM();
1284 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); 1284 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a);
1285 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); 1285 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d);
1286 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); 1286 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0);
1287 CFX_FloatRect rect(*pRect); 1287 CFX_FloatRect rect(*pRect);
1288 m_Matrix.TransformRect(rect); 1288 m_Matrix.TransformRect(rect);
1289 FX_RECT bitmap_rect = rect.GetOutterRect(); 1289 FX_RECT bitmap_rect = rect.GetOutterRect();
1290 m_pBitmap = new CFX_DIBitmap; 1290 m_pBitmap = new CFX_DIBitmap;
1291 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); 1291 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb);
1292 return TRUE; 1292 return true;
1293 } 1293 }
1294 void CPDF_DeviceBuffer::OutputToDevice() 1294 void CPDF_DeviceBuffer::OutputToDevice()
1295 { 1295 {
1296 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { 1296 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) {
1297 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { 1297 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) {
1298 m_pDevice->SetDIBits(m_pBitmap, m_Rect.left, m_Rect.top); 1298 m_pDevice->SetDIBits(m_pBitmap, m_Rect.left, m_Rect.top);
1299 } else { 1299 } else {
1300 m_pDevice->StretchDIBits(m_pBitmap, m_Rect.left, m_Rect.top, m_Rect. Width(), m_Rect.Height()); 1300 m_pDevice->StretchDIBits(m_pBitmap, m_Rect.left, m_Rect.top, m_Rect. Width(), m_Rect.Height());
1301 } 1301 }
1302 } else { 1302 } else {
1303 CFX_DIBitmap buffer; 1303 CFX_DIBitmap buffer;
1304 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), m_pBit map->GetHeight()); 1304 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), m_pBit map->GetHeight());
1305 m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix); 1305 m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix);
1306 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pB itmap, 0, 0); 1306 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pB itmap, 0, 0);
1307 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width( ), m_Rect.Height()); 1307 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width( ), m_Rect.Height());
1308 } 1308 }
1309 } 1309 }
1310 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() 1310 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer()
1311 { 1311 {
1312 m_pBitmapDevice = NULL; 1312 m_pBitmapDevice = NULL;
1313 } 1313 }
1314 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() 1314 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer()
1315 { 1315 {
1316 delete m_pBitmapDevice; 1316 delete m_pBitmapDevice;
1317 } 1317 }
1318 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) 1318 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
1319 FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Re nderDevice* pDevice, FX_RECT* pRect, 1319 bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Rende rDevice* pDevice, FX_RECT* pRect,
1320 const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions, int max _dpi) 1320 const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions, int max _dpi)
1321 { 1321 {
1322 FXSYS_assert(pRect != NULL); 1322 FXSYS_assert(pRect != NULL);
1323 m_pDevice = pDevice; 1323 m_pDevice = pDevice;
1324 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { 1324 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) {
1325 return TRUE; 1325 return true;
1326 } 1326 }
1327 m_pContext = pContext; 1327 m_pContext = pContext;
1328 m_Rect = *pRect; 1328 m_Rect = *pRect;
1329 m_pObject = pObj; 1329 m_pObject = pObj;
1330 m_Matrix.TranslateI(-pRect->left, -pRect->top); 1330 m_Matrix.TranslateI(-pRect->left, -pRect->top);
1331 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); 1331 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE);
1332 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); 1332 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE);
1333 if (horz_size && vert_size && max_dpi) { 1333 if (horz_size && vert_size && max_dpi) {
1334 int dpih = pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10); 1334 int dpih = pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10);
1335 int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10); 1335 int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10);
(...skipping 14 matching lines...) Expand all
1350 CFX_FloatRect rect; 1350 CFX_FloatRect rect;
1351 int32_t iWidth, iHeight, iPitch; 1351 int32_t iWidth, iHeight, iPitch;
1352 while (1) { 1352 while (1) {
1353 rect = *pRect; 1353 rect = *pRect;
1354 m_Matrix.TransformRect(rect); 1354 m_Matrix.TransformRect(rect);
1355 FX_RECT bitmap_rect = rect.GetOutterRect(); 1355 FX_RECT bitmap_rect = rect.GetOutterRect();
1356 iWidth = bitmap_rect.Width(); 1356 iWidth = bitmap_rect.Width();
1357 iHeight = bitmap_rect.Height(); 1357 iHeight = bitmap_rect.Height();
1358 iPitch = (iWidth * bpp + 31) / 32 * 4; 1358 iPitch = (iWidth * bpp + 31) / 32 * 4;
1359 if (iWidth * iHeight < 1) { 1359 if (iWidth * iHeight < 1) {
1360 return FALSE; 1360 return false;
1361 } 1361 }
1362 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && 1362 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ &&
1363 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) { 1363 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) {
1364 break; 1364 break;
1365 } 1365 }
1366 m_Matrix.Scale(0.5f, 0.5f); 1366 m_Matrix.Scale(0.5f, 0.5f);
1367 } 1367 }
1368 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, &m_Matrix); 1368 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, &m_Matrix);
1369 return TRUE; 1369 return true;
1370 } 1370 }
1371 void CPDF_ScaledRenderBuffer::OutputToDevice() 1371 void CPDF_ScaledRenderBuffer::OutputToDevice()
1372 { 1372 {
1373 if (m_pBitmapDevice) { 1373 if (m_pBitmapDevice) {
1374 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, m_Re ct.top, m_Rect.Width(), m_Rect.Height()); 1374 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, m_Re ct.top, m_Rect.Width(), m_Rect.Height());
1375 } 1375 }
1376 } 1376 }
1377 FX_BOOL IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) 1377 bool IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj)
1378 { 1378 {
1379 const CPDF_ContentMarkData* pData = pObj->m_ContentMark; 1379 const CPDF_ContentMarkData* pData = pObj->m_ContentMark;
1380 int nItems = pData->CountItems(); 1380 int nItems = pData->CountItems();
1381 for (int i = 0; i < nItems; i ++) { 1381 for (int i = 0; i < nItems; i ++) {
1382 CPDF_ContentMarkItem& item = pData->GetItem(i); 1382 CPDF_ContentMarkItem& item = pData->GetItem(i);
1383 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont entMarkItem::PropertiesDict) { 1383 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont entMarkItem::PropertiesDict) {
1384 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); 1384 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam();
1385 if (!CheckOCGVisible(pOCG)) { 1385 if (!CheckOCGVisible(pOCG)) {
1386 return FALSE; 1386 return false;
1387 } 1387 }
1388 } 1388 }
1389 } 1389 }
1390 return TRUE; 1390 return true;
1391 } 1391 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698