| 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 "render_int.h" | 7 #include "render_int.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_module.h" | 9 #include "core/include/fpdfapi/fpdf_module.h" |
| 10 #include "core/include/fpdfapi/fpdf_render.h" | 10 #include "core/include/fpdfapi/fpdf_render.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 while (pos) { | 251 while (pos) { |
| 252 index++; | 252 index++; |
| 253 CPDF_PageObject* pCurObj = pObjs->GetNextObject(pos); | 253 CPDF_PageObject* pCurObj = pObjs->GetNextObject(pos); |
| 254 if (pCurObj == m_pStopObj) { | 254 if (pCurObj == m_pStopObj) { |
| 255 m_bStopped = TRUE; | 255 m_bStopped = TRUE; |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 if (!pCurObj) { | 258 if (!pCurObj) { |
| 259 continue; | 259 continue; |
| 260 } | 260 } |
| 261 if (pCurObj == NULL || pCurObj->m_Left > clip_rect.right || | 261 if (!pCurObj || pCurObj->m_Left > clip_rect.right || |
| 262 pCurObj->m_Right < clip_rect.left || | 262 pCurObj->m_Right < clip_rect.left || |
| 263 pCurObj->m_Bottom > clip_rect.top || | 263 pCurObj->m_Bottom > clip_rect.top || |
| 264 pCurObj->m_Top < clip_rect.bottom) { | 264 pCurObj->m_Top < clip_rect.bottom) { |
| 265 continue; | 265 continue; |
| 266 } | 266 } |
| 267 RenderSingleObject(pCurObj, pObj2Device); | 267 RenderSingleObject(pCurObj, pObj2Device); |
| 268 if (m_bStopped) { | 268 if (m_bStopped) { |
| 269 return; | 269 return; |
| 270 } | 270 } |
| 271 } | 271 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 rtClip.bottom = | 351 rtClip.bottom = |
| 352 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); | 352 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 rect.Intersect(rtClip); | 355 rect.Intersect(rtClip); |
| 356 return rect.IsEmpty(); | 356 return rect.IsEmpty(); |
| 357 } | 357 } |
| 358 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, | 358 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, |
| 359 const CFX_Matrix* pObj2Device) { | 359 const CFX_Matrix* pObj2Device) { |
| 360 CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); | 360 CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); |
| 361 if (pBitmap == NULL) { | 361 if (!pBitmap) { |
| 362 return; | 362 return; |
| 363 } | 363 } |
| 364 FX_RECT rect; | 364 FX_RECT rect; |
| 365 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { | 365 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 if (m_DitherBits == 2) { | 368 if (m_DitherBits == 2) { |
| 369 static FX_ARGB pal[4] = {0, 85, 170, 255}; | 369 static FX_ARGB pal[4] = {0, 85, 170, 255}; |
| 370 pBitmap->DitherFS(pal, 4, &rect); | 370 pBitmap->DitherFS(pal, 4, &rect); |
| 371 } else if (m_DitherBits == 3) { | 371 } else if (m_DitherBits == 3) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 return; | 677 return; |
| 678 } | 678 } |
| 679 int fill_mode = 0; | 679 int fill_mode = 0; |
| 680 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { | 680 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { |
| 681 fill_mode |= FXFILL_NOPATHSMOOTH; | 681 fill_mode |= FXFILL_NOPATHSMOOTH; |
| 682 } | 682 } |
| 683 int nClipPath = ClipPath.GetPathCount(); | 683 int nClipPath = ClipPath.GetPathCount(); |
| 684 int i; | 684 int i; |
| 685 for (i = 0; i < nClipPath; i++) { | 685 for (i = 0; i < nClipPath; i++) { |
| 686 const CFX_PathData* pPathData = ClipPath.GetPath(i); | 686 const CFX_PathData* pPathData = ClipPath.GetPath(i); |
| 687 if (pPathData == NULL) { | 687 if (!pPathData) { |
| 688 continue; | 688 continue; |
| 689 } | 689 } |
| 690 CFX_GraphStateData stroke_state; | 690 CFX_GraphStateData stroke_state; |
| 691 if (m_Options.m_Flags & RENDER_THINLINE) { | 691 if (m_Options.m_Flags & RENDER_THINLINE) { |
| 692 stroke_state.m_LineWidth = 0; | 692 stroke_state.m_LineWidth = 0; |
| 693 } | 693 } |
| 694 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000, | 694 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000, |
| 695 fill_mode); | 695 fill_mode); |
| 696 } | 696 } |
| 697 } | 697 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 pDocument->LoadColorSpace(pCSObj, pPageResources); | 773 pDocument->LoadColorSpace(pCSObj, pPageResources); |
| 774 if (pColorSpace) { | 774 if (pColorSpace) { |
| 775 int format = pColorSpace->GetFamily(); | 775 int format = pColorSpace->GetFamily(); |
| 776 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || | 776 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || |
| 777 format == PDFCS_DEVICEN) { | 777 format == PDFCS_DEVICEN) { |
| 778 blend_type = FXDIB_BLEND_DARKEN; | 778 blend_type = FXDIB_BLEND_DARKEN; |
| 779 } | 779 } |
| 780 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 780 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); |
| 781 } | 781 } |
| 782 } | 782 } |
| 783 if (pSMaskDict == NULL && group_alpha == 1.0f && | 783 if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL && |
| 784 blend_type == FXDIB_BLEND_NORMAL && !bTextClip && !bGroupTransparent) { | 784 !bTextClip && !bGroupTransparent) { |
| 785 return FALSE; | 785 return FALSE; |
| 786 } | 786 } |
| 787 FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED; | 787 FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED; |
| 788 if (m_bPrint) { | 788 if (m_bPrint) { |
| 789 FX_BOOL bRet = FALSE; | 789 FX_BOOL bRet = FALSE; |
| 790 int rendCaps = m_pDevice->GetRenderCaps(); | 790 int rendCaps = m_pDevice->GetRenderCaps(); |
| 791 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) && | 791 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) && |
| 792 (rendCaps & FXRC_BLEND_MODE)) { | 792 (rendCaps & FXRC_BLEND_MODE)) { |
| 793 int oldBlend = m_curBlend; | 793 int oldBlend = m_curBlend; |
| 794 m_curBlend = blend_type; | 794 m_curBlend = blend_type; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 if (bTextClip) { | 831 if (bTextClip) { |
| 832 pTextMask.reset(new CFX_DIBitmap); | 832 pTextMask.reset(new CFX_DIBitmap); |
| 833 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) | 833 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) |
| 834 return TRUE; | 834 return TRUE; |
| 835 | 835 |
| 836 pTextMask->Clear(0); | 836 pTextMask->Clear(0); |
| 837 CFX_FxgeDevice text_device; | 837 CFX_FxgeDevice text_device; |
| 838 text_device.Attach(pTextMask.get()); | 838 text_device.Attach(pTextMask.get()); |
| 839 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { | 839 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { |
| 840 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); | 840 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); |
| 841 if (textobj == NULL) { | 841 if (!textobj) { |
| 842 break; | 842 break; |
| 843 } | 843 } |
| 844 CFX_Matrix text_matrix; | 844 CFX_Matrix text_matrix; |
| 845 textobj->GetTextMatrix(&text_matrix); | 845 textobj->GetTextMatrix(&text_matrix); |
| 846 CPDF_TextRenderer::DrawTextPath( | 846 CPDF_TextRenderer::DrawTextPath( |
| 847 &text_device, textobj->m_nChars, textobj->m_pCharCodes, | 847 &text_device, textobj->m_nChars, textobj->m_pCharCodes, |
| 848 textobj->m_pCharPos, textobj->m_TextState.GetFont(), | 848 textobj->m_pCharPos, textobj->m_TextState.GetFont(), |
| 849 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, | 849 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, |
| 850 textobj->m_GraphState, (FX_ARGB)-1, 0, NULL); | 850 textobj->m_GraphState, (FX_ARGB)-1, 0, NULL); |
| 851 } | 851 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 | 1072 |
| 1073 #define RENDER_STEP_LIMIT 100 | 1073 #define RENDER_STEP_LIMIT 100 |
| 1074 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { | 1074 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { |
| 1075 if (m_Status != ToBeContinued) { | 1075 if (m_Status != ToBeContinued) { |
| 1076 return; | 1076 return; |
| 1077 } | 1077 } |
| 1078 FX_DWORD nLayers = m_pContext->m_ContentList.GetSize(); | 1078 FX_DWORD nLayers = m_pContext->m_ContentList.GetSize(); |
| 1079 for (; m_LayerIndex < nLayers; m_LayerIndex++) { | 1079 for (; m_LayerIndex < nLayers; m_LayerIndex++) { |
| 1080 _PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(m_LayerIndex); | 1080 _PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(m_LayerIndex); |
| 1081 FX_POSITION LastPos = pItem->m_pObjectList->GetLastObjectPosition(); | 1081 FX_POSITION LastPos = pItem->m_pObjectList->GetLastObjectPosition(); |
| 1082 if (m_ObjectPos == NULL) { | 1082 if (!m_ObjectPos) { |
| 1083 if (LastPos == m_PrevLastPos) { | 1083 if (LastPos == m_PrevLastPos) { |
| 1084 if (!pItem->m_pObjectList->IsParsed()) { | 1084 if (!pItem->m_pObjectList->IsParsed()) { |
| 1085 pItem->m_pObjectList->ContinueParse(pPause); | 1085 pItem->m_pObjectList->ContinueParse(pPause); |
| 1086 if (!pItem->m_pObjectList->IsParsed()) { | 1086 if (!pItem->m_pObjectList->IsParsed()) { |
| 1087 return; | 1087 return; |
| 1088 } | 1088 } |
| 1089 LastPos = pItem->m_pObjectList->GetLastObjectPosition(); | 1089 LastPos = pItem->m_pObjectList->GetLastObjectPosition(); |
| 1090 } | 1090 } |
| 1091 } | 1091 } |
| 1092 if (LastPos == m_PrevLastPos) { | 1092 if (LastPos == m_PrevLastPos) { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { | 1410 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { |
| 1411 CPDF_Dictionary* pOCG = | 1411 CPDF_Dictionary* pOCG = |
| 1412 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); | 1412 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); |
| 1413 if (!CheckOCGVisible(pOCG)) { | 1413 if (!CheckOCGVisible(pOCG)) { |
| 1414 return FALSE; | 1414 return FALSE; |
| 1415 } | 1415 } |
| 1416 } | 1416 } |
| 1417 } | 1417 } |
| 1418 return TRUE; | 1418 return TRUE; |
| 1419 } | 1419 } |
| OLD | NEW |