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 "core/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" | 9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" |
10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" | 10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 if (bRelease || value->use_count() < 2) { | 54 if (bRelease || value->use_count() < 2) { |
55 delete value->get(); | 55 delete value->get(); |
56 delete value; | 56 delete value; |
57 m_TransferFuncMap.erase(curr_it); | 57 m_TransferFuncMap.erase(curr_it); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 if (m_pFontCache) { | 61 if (m_pFontCache) { |
62 if (bRelease) { | 62 if (bRelease) { |
63 delete m_pFontCache; | 63 delete m_pFontCache; |
64 m_pFontCache = NULL; | 64 m_pFontCache = nullptr; |
65 } else { | 65 } else { |
66 m_pFontCache->FreeCache(FALSE); | 66 m_pFontCache->FreeCache(FALSE); |
67 } | 67 } |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) { | 71 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) { |
72 CPDF_CountedObject<CPDF_Type3Cache>* pCache; | 72 CPDF_CountedObject<CPDF_Type3Cache>* pCache; |
73 auto it = m_Type3FaceMap.find(pFont); | 73 auto it = m_Type3FaceMap.find(pFont); |
74 if (it == m_Type3FaceMap.end()) { | 74 if (it == m_Type3FaceMap.end()) { |
(...skipping 10 matching lines...) Expand all Loading... |
85 auto it = m_Type3FaceMap.find(pFont); | 85 auto it = m_Type3FaceMap.find(pFont); |
86 if (it != m_Type3FaceMap.end()) | 86 if (it != m_Type3FaceMap.end()) |
87 it->second->RemoveRef(); | 87 it->second->RemoveRef(); |
88 } | 88 } |
89 | 89 |
90 CPDF_RenderOptions::CPDF_RenderOptions() | 90 CPDF_RenderOptions::CPDF_RenderOptions() |
91 : m_ColorMode(RENDER_COLOR_NORMAL), | 91 : m_ColorMode(RENDER_COLOR_NORMAL), |
92 m_Flags(RENDER_CLEARTYPE), | 92 m_Flags(RENDER_CLEARTYPE), |
93 m_Interpolation(0), | 93 m_Interpolation(0), |
94 m_AddFlags(0), | 94 m_AddFlags(0), |
95 m_pOCContext(NULL), | 95 m_pOCContext(nullptr), |
96 m_dwLimitCacheSize(1024 * 1024 * 100), | 96 m_dwLimitCacheSize(1024 * 1024 * 100), |
97 m_HalftoneLimit(-1) {} | 97 m_HalftoneLimit(-1) {} |
98 FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const { | 98 FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const { |
99 if (m_ColorMode == RENDER_COLOR_NORMAL) { | 99 if (m_ColorMode == RENDER_COLOR_NORMAL) { |
100 return argb; | 100 return argb; |
101 } | 101 } |
102 if (m_ColorMode == RENDER_COLOR_ALPHA) { | 102 if (m_ColorMode == RENDER_COLOR_ALPHA) { |
103 return argb; | 103 return argb; |
104 } | 104 } |
105 int a, r, g, b; | 105 int a, r, g, b; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 317 } |
318 rect.Intersect(rtClip); | 318 rect.Intersect(rtClip); |
319 return rect.IsEmpty(); | 319 return rect.IsEmpty(); |
320 } | 320 } |
321 | 321 |
322 void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, | 322 void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, |
323 const CFX_Matrix* pObj2Device) { | 323 const CFX_Matrix* pObj2Device) { |
324 FX_BOOL bRet = FALSE; | 324 FX_BOOL bRet = FALSE; |
325 switch (pObj->GetType()) { | 325 switch (pObj->GetType()) { |
326 case CPDF_PageObject::TEXT: | 326 case CPDF_PageObject::TEXT: |
327 bRet = ProcessText(pObj->AsText(), pObj2Device, NULL); | 327 bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr); |
328 break; | 328 break; |
329 case CPDF_PageObject::PATH: | 329 case CPDF_PageObject::PATH: |
330 bRet = ProcessPath(pObj->AsPath(), pObj2Device); | 330 bRet = ProcessPath(pObj->AsPath(), pObj2Device); |
331 break; | 331 break; |
332 case CPDF_PageObject::IMAGE: | 332 case CPDF_PageObject::IMAGE: |
333 bRet = ProcessImage(pObj->AsImage(), pObj2Device); | 333 bRet = ProcessImage(pObj->AsImage(), pObj2Device); |
334 break; | 334 break; |
335 case CPDF_PageObject::SHADING: | 335 case CPDF_PageObject::SHADING: |
336 ProcessShading(pObj->AsShading(), pObj2Device); | 336 ProcessShading(pObj->AsShading(), pObj2Device); |
337 return; | 337 return; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { | 377 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { |
378 res = 0; | 378 res = 0; |
379 } | 379 } |
380 CPDF_ScaledRenderBuffer buffer; | 380 CPDF_ScaledRenderBuffer buffer; |
381 if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) { | 381 if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) { |
382 return; | 382 return; |
383 } | 383 } |
384 CFX_Matrix matrix = *pObj2Device; | 384 CFX_Matrix matrix = *pObj2Device; |
385 matrix.Concat(*buffer.GetMatrix()); | 385 matrix.Concat(*buffer.GetMatrix()); |
386 GetScaledMatrix(matrix); | 386 GetScaledMatrix(matrix); |
387 CPDF_Dictionary* pFormResource = NULL; | 387 CPDF_Dictionary* pFormResource = nullptr; |
388 if (pObj->IsForm()) { | 388 if (pObj->IsForm()) { |
389 const CPDF_FormObject* pFormObj = pObj->AsForm(); | 389 const CPDF_FormObject* pFormObj = pObj->AsForm(); |
390 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { | 390 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { |
391 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); | 391 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); |
392 } | 392 } |
393 } | 393 } |
394 CPDF_RenderStatus status; | 394 CPDF_RenderStatus status; |
395 status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), NULL, | 395 status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), nullptr, |
396 NULL, NULL, &m_Options, m_Transparency, m_bDropObjects, | 396 nullptr, nullptr, &m_Options, m_Transparency, |
397 pFormResource); | 397 m_bDropObjects, pFormResource); |
398 status.RenderSingleObject(pObj, &matrix); | 398 status.RenderSingleObject(pObj, &matrix); |
399 buffer.OutputToDevice(); | 399 buffer.OutputToDevice(); |
400 } | 400 } |
401 FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, | 401 FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, |
402 const CFX_Matrix* pObj2Device) { | 402 const CFX_Matrix* pObj2Device) { |
403 CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictBy("OC"); | 403 CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictBy("OC"); |
404 if (pOC && m_Options.m_pOCContext && | 404 if (pOC && m_Options.m_pOCContext && |
405 !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { | 405 !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { |
406 return TRUE; | 406 return TRUE; |
407 } | 407 } |
408 CFX_Matrix matrix = pFormObj->m_FormMatrix; | 408 CFX_Matrix matrix = pFormObj->m_FormMatrix; |
409 matrix.Concat(*pObj2Device); | 409 matrix.Concat(*pObj2Device); |
410 CPDF_Dictionary* pResources = NULL; | 410 CPDF_Dictionary* pResources = nullptr; |
411 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { | 411 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { |
412 pResources = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); | 412 pResources = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); |
413 } | 413 } |
414 CPDF_RenderStatus status; | 414 CPDF_RenderStatus status; |
415 status.Initialize(m_pContext, m_pDevice, NULL, m_pStopObj, this, pFormObj, | 415 status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, |
416 &m_Options, m_Transparency, m_bDropObjects, pResources, | 416 &m_Options, m_Transparency, m_bDropObjects, pResources, |
417 FALSE); | 417 FALSE); |
418 status.m_curBlend = m_curBlend; | 418 status.m_curBlend = m_curBlend; |
419 m_pDevice->SaveState(); | 419 m_pDevice->SaveState(); |
420 status.RenderObjectList(pFormObj->m_pForm, &matrix); | 420 status.RenderObjectList(pFormObj->m_pForm, &matrix); |
421 m_bStopped = status.m_bStopped; | 421 m_bStopped = status.m_bStopped; |
422 m_pDevice->RestoreState(false); | 422 m_pDevice->RestoreState(false); |
423 return TRUE; | 423 return TRUE; |
424 } | 424 } |
425 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) { | 425 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } | 662 } |
663 FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, | 663 FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, |
664 const CFX_Matrix* pObj2Device) { | 664 const CFX_Matrix* pObj2Device) { |
665 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; | 665 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; |
666 int blend_type = | 666 int blend_type = |
667 pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL; | 667 pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL; |
668 if (blend_type == FXDIB_BLEND_UNSUPPORTED) { | 668 if (blend_type == FXDIB_BLEND_UNSUPPORTED) { |
669 return TRUE; | 669 return TRUE; |
670 } | 670 } |
671 CPDF_Dictionary* pSMaskDict = | 671 CPDF_Dictionary* pSMaskDict = |
672 pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : NULL; | 672 pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : nullptr; |
673 if (pSMaskDict) { | 673 if (pSMaskDict) { |
674 if (pPageObj->IsImage() && | 674 if (pPageObj->IsImage() && |
675 pPageObj->AsImage()->m_pImage->GetDict()->KeyExist("SMask")) { | 675 pPageObj->AsImage()->m_pImage->GetDict()->KeyExist("SMask")) { |
676 pSMaskDict = NULL; | 676 pSMaskDict = nullptr; |
677 } | 677 } |
678 } | 678 } |
679 CPDF_Dictionary* pFormResource = NULL; | 679 CPDF_Dictionary* pFormResource = nullptr; |
680 FX_FLOAT group_alpha = 1.0f; | 680 FX_FLOAT group_alpha = 1.0f; |
681 int Transparency = m_Transparency; | 681 int Transparency = m_Transparency; |
682 FX_BOOL bGroupTransparent = FALSE; | 682 FX_BOOL bGroupTransparent = FALSE; |
683 if (pPageObj->IsForm()) { | 683 if (pPageObj->IsForm()) { |
684 const CPDF_FormObject* pFormObj = pPageObj->AsForm(); | 684 const CPDF_FormObject* pFormObj = pPageObj->AsForm(); |
685 const CPDF_GeneralStateData* pStateData = | 685 const CPDF_GeneralStateData* pStateData = |
686 pFormObj->m_GeneralState.GetObject(); | 686 pFormObj->m_GeneralState.GetObject(); |
687 if (pStateData) { | 687 if (pStateData) { |
688 group_alpha = pStateData->m_FillAlpha; | 688 group_alpha = pStateData->m_FillAlpha; |
689 } | 689 } |
690 Transparency = pFormObj->m_pForm->m_Transparency; | 690 Transparency = pFormObj->m_pForm->m_Transparency; |
691 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); | 691 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); |
692 if (pFormObj->m_pForm->m_pFormDict) { | 692 if (pFormObj->m_pForm->m_pFormDict) { |
693 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); | 693 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); |
694 } | 694 } |
695 } | 695 } |
696 FX_BOOL bTextClip = FALSE; | 696 FX_BOOL bTextClip = FALSE; |
697 if (pPageObj->m_ClipPath.NotNull() && pPageObj->m_ClipPath.GetTextCount() && | 697 if (pPageObj->m_ClipPath.NotNull() && pPageObj->m_ClipPath.GetTextCount() && |
698 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && | 698 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && |
699 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { | 699 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { |
700 bTextClip = TRUE; | 700 bTextClip = TRUE; |
701 } | 701 } |
702 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && | 702 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && |
703 pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { | 703 pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { |
704 CPDF_Document* pDocument = NULL; | 704 CPDF_Document* pDocument = nullptr; |
705 CPDF_Page* pPage = NULL; | 705 CPDF_Page* pPage = nullptr; |
706 if (m_pContext->GetPageCache()) { | 706 if (m_pContext->GetPageCache()) { |
707 pPage = m_pContext->GetPageCache()->GetPage(); | 707 pPage = m_pContext->GetPageCache()->GetPage(); |
708 pDocument = pPage->m_pDocument; | 708 pDocument = pPage->m_pDocument; |
709 } else { | 709 } else { |
710 pDocument = pPageObj->AsImage()->m_pImage->GetDocument(); | 710 pDocument = pPageObj->AsImage()->m_pImage->GetDocument(); |
711 } | 711 } |
712 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; | 712 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; |
713 CPDF_Object* pCSObj = pPageObj->AsImage() | 713 CPDF_Object* pCSObj = pPageObj->AsImage() |
714 ->m_pImage->GetStream() | 714 ->m_pImage->GetStream() |
715 ->GetDict() | 715 ->GetDict() |
716 ->GetDirectObjectBy("ColorSpace"); | 716 ->GetDirectObjectBy("ColorSpace"); |
717 CPDF_ColorSpace* pColorSpace = | 717 CPDF_ColorSpace* pColorSpace = |
718 pDocument->LoadColorSpace(pCSObj, pPageResources); | 718 pDocument->LoadColorSpace(pCSObj, pPageResources); |
719 if (pColorSpace) { | 719 if (pColorSpace) { |
720 int format = pColorSpace->GetFamily(); | 720 int format = pColorSpace->GetFamily(); |
721 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || | 721 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || |
722 format == PDFCS_DEVICEN) { | 722 format == PDFCS_DEVICEN) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 CFX_Matrix text_matrix; | 789 CFX_Matrix text_matrix; |
790 textobj->GetTextMatrix(&text_matrix); | 790 textobj->GetTextMatrix(&text_matrix); |
791 CPDF_TextRenderer::DrawTextPath( | 791 CPDF_TextRenderer::DrawTextPath( |
792 &text_device, textobj->m_nChars, textobj->m_pCharCodes, | 792 &text_device, textobj->m_nChars, textobj->m_pCharCodes, |
793 textobj->m_pCharPos, textobj->m_TextState.GetFont(), | 793 textobj->m_pCharPos, textobj->m_TextState.GetFont(), |
794 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, | 794 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, |
795 textobj->m_GraphState, (FX_ARGB)-1, 0, nullptr, 0); | 795 textobj->m_GraphState, (FX_ARGB)-1, 0, nullptr, 0); |
796 } | 796 } |
797 } | 797 } |
798 CPDF_RenderStatus bitmap_render; | 798 CPDF_RenderStatus bitmap_render; |
799 bitmap_render.Initialize(m_pContext, &bitmap_device, NULL, m_pStopObj, NULL, | 799 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, |
800 NULL, &m_Options, 0, m_bDropObjects, pFormResource, | 800 nullptr, nullptr, &m_Options, 0, m_bDropObjects, |
801 TRUE); | 801 pFormResource, TRUE); |
802 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); | 802 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); |
803 m_bStopped = bitmap_render.m_bStopped; | 803 m_bStopped = bitmap_render.m_bStopped; |
804 if (pSMaskDict) { | 804 if (pSMaskDict) { |
805 CFX_Matrix smask_matrix; | 805 CFX_Matrix smask_matrix; |
806 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, | 806 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, |
807 sizeof smask_matrix); | 807 sizeof smask_matrix); |
808 smask_matrix.Concat(*pObj2Device); | 808 smask_matrix.Concat(*pObj2Device); |
809 std::unique_ptr<CFX_DIBSource> pSMaskSource( | 809 std::unique_ptr<CFX_DIBSource> pSMaskSource( |
810 LoadSMask(pSMaskDict, &rect, &smask_matrix)); | 810 LoadSMask(pSMaskDict, &rect, &smask_matrix)); |
811 if (pSMaskSource) | 811 if (pSMaskSource) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 device.Attach(pBuffer, false, nullptr, false); | 884 device.Attach(pBuffer, false, nullptr, false); |
885 | 885 |
886 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); | 886 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); |
887 device.FillRect(&rect, 0xffffffff); | 887 device.FillRect(&rect, 0xffffffff); |
888 Render(&device, pObj, pOptions, pFinalMatrix); | 888 Render(&device, pObj, pOptions, pFinalMatrix); |
889 } | 889 } |
890 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates( | 890 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates( |
891 const CPDF_GraphicStates* pSrcStates, | 891 const CPDF_GraphicStates* pSrcStates, |
892 FX_BOOL bStroke) { | 892 FX_BOOL bStroke) { |
893 if (!pSrcStates) { | 893 if (!pSrcStates) { |
894 return NULL; | 894 return nullptr; |
895 } | 895 } |
896 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; | 896 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; |
897 pStates->CopyStates(*pSrcStates); | 897 pStates->CopyStates(*pSrcStates); |
898 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor() | 898 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor() |
899 : pSrcStates->m_ColorState.GetFillColor(); | 899 : pSrcStates->m_ColorState.GetFillColor(); |
900 if (!pObjColor->IsNull()) { | 900 if (!pObjColor->IsNull()) { |
901 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify(); | 901 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify(); |
902 pColorData->m_FillRGB = | 902 pColorData->m_FillRGB = |
903 bStroke ? pSrcStates->m_ColorState.GetObject()->m_StrokeRGB | 903 bStroke ? pSrcStates->m_ColorState.GetObject()->m_StrokeRGB |
904 : pSrcStates->m_ColorState.GetObject()->m_FillRGB; | 904 : pSrcStates->m_ColorState.GetObject()->m_FillRGB; |
(...skipping 23 matching lines...) Expand all Loading... |
928 pLayer->m_pObjectHolder = pObjectHolder; | 928 pLayer->m_pObjectHolder = pObjectHolder; |
929 if (pObject2Device) { | 929 if (pObject2Device) { |
930 pLayer->m_Matrix = *pObject2Device; | 930 pLayer->m_Matrix = *pObject2Device; |
931 } else { | 931 } else { |
932 pLayer->m_Matrix.SetIdentity(); | 932 pLayer->m_Matrix.SetIdentity(); |
933 } | 933 } |
934 } | 934 } |
935 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, | 935 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, |
936 const CPDF_RenderOptions* pOptions, | 936 const CPDF_RenderOptions* pOptions, |
937 const CFX_Matrix* pLastMatrix) { | 937 const CFX_Matrix* pLastMatrix) { |
938 Render(pDevice, NULL, pOptions, pLastMatrix); | 938 Render(pDevice, nullptr, pOptions, pLastMatrix); |
939 } | 939 } |
940 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, | 940 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, |
941 const CPDF_PageObject* pStopObj, | 941 const CPDF_PageObject* pStopObj, |
942 const CPDF_RenderOptions* pOptions, | 942 const CPDF_RenderOptions* pOptions, |
943 const CFX_Matrix* pLastMatrix) { | 943 const CFX_Matrix* pLastMatrix) { |
944 int count = m_Layers.GetSize(); | 944 int count = m_Layers.GetSize(); |
945 for (int j = 0; j < count; j++) { | 945 for (int j = 0; j < count; j++) { |
946 pDevice->SaveState(); | 946 pDevice->SaveState(); |
947 Layer* pLayer = m_Layers.GetDataPtr(j); | 947 Layer* pLayer = m_Layers.GetDataPtr(j); |
948 if (pLastMatrix) { | 948 if (pLastMatrix) { |
949 CFX_Matrix FinalMatrix = pLayer->m_Matrix; | 949 CFX_Matrix FinalMatrix = pLayer->m_Matrix; |
950 FinalMatrix.Concat(*pLastMatrix); | 950 FinalMatrix.Concat(*pLastMatrix); |
951 CPDF_RenderStatus status; | 951 CPDF_RenderStatus status; |
952 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, | 952 status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, |
953 pOptions, pLayer->m_pObjectHolder->m_Transparency, | 953 pOptions, pLayer->m_pObjectHolder->m_Transparency, |
954 FALSE, NULL); | 954 FALSE, nullptr); |
955 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); | 955 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); |
956 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 956 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
957 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 957 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
958 } | 958 } |
959 if (status.m_bStopped) { | 959 if (status.m_bStopped) { |
960 pDevice->RestoreState(false); | 960 pDevice->RestoreState(false); |
961 break; | 961 break; |
962 } | 962 } |
963 } else { | 963 } else { |
964 CPDF_RenderStatus status; | 964 CPDF_RenderStatus status; |
965 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, | 965 status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, |
966 pLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); | 966 pOptions, pLayer->m_pObjectHolder->m_Transparency, |
| 967 FALSE, nullptr); |
967 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); | 968 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); |
968 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 969 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
969 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 970 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
970 } | 971 } |
971 if (status.m_bStopped) { | 972 if (status.m_bStopped) { |
972 pDevice->RestoreState(false); | 973 pDevice->RestoreState(false); |
973 break; | 974 break; |
974 } | 975 } |
975 } | 976 } |
976 pDevice->RestoreState(false); | 977 pDevice->RestoreState(false); |
(...skipping 30 matching lines...) Expand all Loading... |
1007 if (!m_pCurrentLayer) { | 1008 if (!m_pCurrentLayer) { |
1008 if (m_LayerIndex >= m_pContext->CountLayers()) { | 1009 if (m_LayerIndex >= m_pContext->CountLayers()) { |
1009 m_Status = Done; | 1010 m_Status = Done; |
1010 return; | 1011 return; |
1011 } | 1012 } |
1012 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); | 1013 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); |
1013 m_LastObjectRendered = | 1014 m_LastObjectRendered = |
1014 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); | 1015 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); |
1015 m_pRenderStatus.reset(new CPDF_RenderStatus()); | 1016 m_pRenderStatus.reset(new CPDF_RenderStatus()); |
1016 m_pRenderStatus->Initialize( | 1017 m_pRenderStatus->Initialize( |
1017 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, | 1018 m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions, |
1018 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); | 1019 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, nullptr); |
1019 m_pDevice->SaveState(); | 1020 m_pDevice->SaveState(); |
1020 m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); | 1021 m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); |
1021 CFX_Matrix device2object; | 1022 CFX_Matrix device2object; |
1022 device2object.SetReverse(m_pCurrentLayer->m_Matrix); | 1023 device2object.SetReverse(m_pCurrentLayer->m_Matrix); |
1023 device2object.TransformRect(m_ClipRect); | 1024 device2object.TransformRect(m_ClipRect); |
1024 } | 1025 } |
1025 CPDF_PageObjectList::iterator iter; | 1026 CPDF_PageObjectList::iterator iter; |
1026 CPDF_PageObjectList::iterator iterEnd = | 1027 CPDF_PageObjectList::iterator iterEnd = |
1027 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); | 1028 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); |
1028 if (m_LastObjectRendered != iterEnd) { | 1029 if (m_LastObjectRendered != iterEnd) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { | 1198 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { |
1198 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top); | 1199 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top); |
1199 } else { | 1200 } else { |
1200 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top, | 1201 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top, |
1201 m_Rect.Width(), m_Rect.Height()); | 1202 m_Rect.Width(), m_Rect.Height()); |
1202 } | 1203 } |
1203 } else { | 1204 } else { |
1204 CFX_DIBitmap buffer; | 1205 CFX_DIBitmap buffer; |
1205 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), | 1206 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), |
1206 m_pBitmap->GetHeight()); | 1207 m_pBitmap->GetHeight()); |
1207 m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix); | 1208 m_pContext->GetBackground(&buffer, m_pObject, nullptr, &m_Matrix); |
1208 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), | 1209 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), |
1209 m_pBitmap.get(), 0, 0); | 1210 m_pBitmap.get(), 0, 0); |
1210 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(), | 1211 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(), |
1211 m_Rect.Height()); | 1212 m_Rect.Height()); |
1212 } | 1213 } |
1213 } | 1214 } |
1214 | 1215 |
1215 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} | 1216 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} |
1216 | 1217 |
1217 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} | 1218 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, | 1272 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, |
1272 &m_Matrix); | 1273 &m_Matrix); |
1273 return TRUE; | 1274 return TRUE; |
1274 } | 1275 } |
1275 void CPDF_ScaledRenderBuffer::OutputToDevice() { | 1276 void CPDF_ScaledRenderBuffer::OutputToDevice() { |
1276 if (m_pBitmapDevice) { | 1277 if (m_pBitmapDevice) { |
1277 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1278 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
1278 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1279 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
1279 } | 1280 } |
1280 } | 1281 } |
OLD | NEW |