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

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

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: s/NULL/nullptr/ Created 4 years, 6 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 "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
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
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
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
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
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
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 device.Attach(pBuffer, false, nullptr, false); 879 device.Attach(pBuffer, false, nullptr, false);
880 880
881 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); 881 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight());
882 device.FillRect(&rect, 0xffffffff); 882 device.FillRect(&rect, 0xffffffff);
883 Render(&device, pObj, pOptions, pFinalMatrix); 883 Render(&device, pObj, pOptions, pFinalMatrix);
884 } 884 }
885 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates( 885 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(
886 const CPDF_GraphicStates* pSrcStates, 886 const CPDF_GraphicStates* pSrcStates,
887 FX_BOOL bStroke) { 887 FX_BOOL bStroke) {
888 if (!pSrcStates) { 888 if (!pSrcStates) {
889 return NULL; 889 return nullptr;
890 } 890 }
891 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; 891 CPDF_GraphicStates* pStates = new CPDF_GraphicStates;
892 pStates->CopyStates(*pSrcStates); 892 pStates->CopyStates(*pSrcStates);
893 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor() 893 CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor()
894 : pSrcStates->m_ColorState.GetFillColor(); 894 : pSrcStates->m_ColorState.GetFillColor();
895 if (!pObjColor->IsNull()) { 895 if (!pObjColor->IsNull()) {
896 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify(); 896 CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify();
897 pColorData->m_FillRGB = 897 pColorData->m_FillRGB =
898 bStroke ? pSrcStates->m_ColorState.GetObject()->m_StrokeRGB 898 bStroke ? pSrcStates->m_ColorState.GetObject()->m_StrokeRGB
899 : pSrcStates->m_ColorState.GetObject()->m_FillRGB; 899 : pSrcStates->m_ColorState.GetObject()->m_FillRGB;
(...skipping 23 matching lines...) Expand all
923 pLayer->m_pObjectHolder = pObjectHolder; 923 pLayer->m_pObjectHolder = pObjectHolder;
924 if (pObject2Device) { 924 if (pObject2Device) {
925 pLayer->m_Matrix = *pObject2Device; 925 pLayer->m_Matrix = *pObject2Device;
926 } else { 926 } else {
927 pLayer->m_Matrix.SetIdentity(); 927 pLayer->m_Matrix.SetIdentity();
928 } 928 }
929 } 929 }
930 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, 930 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
931 const CPDF_RenderOptions* pOptions, 931 const CPDF_RenderOptions* pOptions,
932 const CFX_Matrix* pLastMatrix) { 932 const CFX_Matrix* pLastMatrix) {
933 Render(pDevice, NULL, pOptions, pLastMatrix); 933 Render(pDevice, nullptr, pOptions, pLastMatrix);
934 } 934 }
935 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, 935 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
936 const CPDF_PageObject* pStopObj, 936 const CPDF_PageObject* pStopObj,
937 const CPDF_RenderOptions* pOptions, 937 const CPDF_RenderOptions* pOptions,
938 const CFX_Matrix* pLastMatrix) { 938 const CFX_Matrix* pLastMatrix) {
939 int count = m_Layers.GetSize(); 939 int count = m_Layers.GetSize();
940 for (int j = 0; j < count; j++) { 940 for (int j = 0; j < count; j++) {
941 pDevice->SaveState(); 941 pDevice->SaveState();
942 Layer* pLayer = m_Layers.GetDataPtr(j); 942 Layer* pLayer = m_Layers.GetDataPtr(j);
943 if (pLastMatrix) { 943 if (pLastMatrix) {
944 CFX_Matrix FinalMatrix = pLayer->m_Matrix; 944 CFX_Matrix FinalMatrix = pLayer->m_Matrix;
945 FinalMatrix.Concat(*pLastMatrix); 945 FinalMatrix.Concat(*pLastMatrix);
946 CPDF_RenderStatus status; 946 CPDF_RenderStatus status;
947 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, 947 status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr,
948 pOptions, pLayer->m_pObjectHolder->m_Transparency, 948 pOptions, pLayer->m_pObjectHolder->m_Transparency,
949 FALSE, NULL); 949 FALSE, nullptr);
950 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); 950 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix);
951 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { 951 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
952 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); 952 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
953 } 953 }
954 if (status.m_bStopped) { 954 if (status.m_bStopped) {
955 pDevice->RestoreState(false); 955 pDevice->RestoreState(false);
956 break; 956 break;
957 } 957 }
958 } else { 958 } else {
959 CPDF_RenderStatus status; 959 CPDF_RenderStatus status;
960 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, 960 status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr,
961 pLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); 961 pOptions, pLayer->m_pObjectHolder->m_Transparency,
962 FALSE, nullptr);
962 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); 963 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix);
963 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { 964 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
964 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); 965 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
965 } 966 }
966 if (status.m_bStopped) { 967 if (status.m_bStopped) {
967 pDevice->RestoreState(false); 968 pDevice->RestoreState(false);
968 break; 969 break;
969 } 970 }
970 } 971 }
971 pDevice->RestoreState(false); 972 pDevice->RestoreState(false);
(...skipping 30 matching lines...) Expand all
1002 if (!m_pCurrentLayer) { 1003 if (!m_pCurrentLayer) {
1003 if (m_LayerIndex >= m_pContext->CountLayers()) { 1004 if (m_LayerIndex >= m_pContext->CountLayers()) {
1004 m_Status = Done; 1005 m_Status = Done;
1005 return; 1006 return;
1006 } 1007 }
1007 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); 1008 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex);
1008 m_LastObjectRendered = 1009 m_LastObjectRendered =
1009 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); 1010 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
1010 m_pRenderStatus.reset(new CPDF_RenderStatus()); 1011 m_pRenderStatus.reset(new CPDF_RenderStatus());
1011 m_pRenderStatus->Initialize( 1012 m_pRenderStatus->Initialize(
1012 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, 1013 m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions,
1013 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); 1014 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, nullptr);
1014 m_pDevice->SaveState(); 1015 m_pDevice->SaveState();
1015 m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); 1016 m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox());
1016 CFX_Matrix device2object; 1017 CFX_Matrix device2object;
1017 device2object.SetReverse(m_pCurrentLayer->m_Matrix); 1018 device2object.SetReverse(m_pCurrentLayer->m_Matrix);
1018 device2object.TransformRect(m_ClipRect); 1019 device2object.TransformRect(m_ClipRect);
1019 } 1020 }
1020 CPDF_PageObjectList::iterator iter; 1021 CPDF_PageObjectList::iterator iter;
1021 CPDF_PageObjectList::iterator iterEnd = 1022 CPDF_PageObjectList::iterator iterEnd =
1022 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); 1023 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
1023 if (m_LastObjectRendered != iterEnd) { 1024 if (m_LastObjectRendered != iterEnd) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { 1193 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) {
1193 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top); 1194 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top);
1194 } else { 1195 } else {
1195 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top, 1196 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top,
1196 m_Rect.Width(), m_Rect.Height()); 1197 m_Rect.Width(), m_Rect.Height());
1197 } 1198 }
1198 } else { 1199 } else {
1199 CFX_DIBitmap buffer; 1200 CFX_DIBitmap buffer;
1200 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), 1201 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(),
1201 m_pBitmap->GetHeight()); 1202 m_pBitmap->GetHeight());
1202 m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix); 1203 m_pContext->GetBackground(&buffer, m_pObject, nullptr, &m_Matrix);
1203 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), 1204 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(),
1204 m_pBitmap.get(), 0, 0); 1205 m_pBitmap.get(), 0, 0);
1205 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(), 1206 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(),
1206 m_Rect.Height()); 1207 m_Rect.Height());
1207 } 1208 }
1208 } 1209 }
1209 1210
1210 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} 1211 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {}
1211 1212
1212 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} 1213 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {}
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, 1267 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions,
1267 &m_Matrix); 1268 &m_Matrix);
1268 return TRUE; 1269 return TRUE;
1269 } 1270 }
1270 void CPDF_ScaledRenderBuffer::OutputToDevice() { 1271 void CPDF_ScaledRenderBuffer::OutputToDevice() {
1271 if (m_pBitmapDevice) { 1272 if (m_pBitmapDevice) {
1272 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, 1273 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left,
1273 m_Rect.top, m_Rect.Width(), m_Rect.Height()); 1274 m_Rect.top, m_Rect.Width(), m_Rect.Height());
1274 } 1275 }
1275 } 1276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698