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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "../../../../third_party/base/nonstd_unique_ptr.h" | 9 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
10 #include "../../../include/fpdfapi/fpdf_module.h" | 10 #include "../../../include/fpdfapi/fpdf_module.h" |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 } | 758 } |
759 } | 759 } |
760 } | 760 } |
761 m_bpc = 8; | 761 m_bpc = 8; |
762 } | 762 } |
763 CPDF_DIBSource* CPDF_DIBSource::LoadMask(FX_DWORD& MatteColor) { | 763 CPDF_DIBSource* CPDF_DIBSource::LoadMask(FX_DWORD& MatteColor) { |
764 MatteColor = 0xFFFFFFFF; | 764 MatteColor = 0xFFFFFFFF; |
765 CPDF_Stream* pSoftMask = m_pDict->GetStream(FX_BSTRC("SMask")); | 765 CPDF_Stream* pSoftMask = m_pDict->GetStream(FX_BSTRC("SMask")); |
766 if (pSoftMask) { | 766 if (pSoftMask) { |
767 CPDF_Array* pMatte = pSoftMask->GetDict()->GetArray(FX_BSTRC("Matte")); | 767 CPDF_Array* pMatte = pSoftMask->GetDict()->GetArray(FX_BSTRC("Matte")); |
768 if (pMatte != NULL && m_pColorSpace && | 768 if (pMatte && m_pColorSpace && |
769 (FX_DWORD)m_pColorSpace->CountComponents() <= m_nComponents) { | 769 (FX_DWORD)m_pColorSpace->CountComponents() <= m_nComponents) { |
770 FX_FLOAT* pColor = FX_Alloc(FX_FLOAT, m_nComponents); | 770 FX_FLOAT* pColor = FX_Alloc(FX_FLOAT, m_nComponents); |
771 for (FX_DWORD i = 0; i < m_nComponents; i++) { | 771 for (FX_DWORD i = 0; i < m_nComponents; i++) { |
772 pColor[i] = pMatte->GetFloat(i); | 772 pColor[i] = pMatte->GetFloat(i); |
773 } | 773 } |
774 FX_FLOAT R, G, B; | 774 FX_FLOAT R, G, B; |
775 m_pColorSpace->GetRGB(pColor, R, G, B); | 775 m_pColorSpace->GetRGB(pColor, R, G, B); |
776 FX_Free(pColor); | 776 FX_Free(pColor); |
777 MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), | 777 MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), |
778 FXSYS_round(B * 255)); | 778 FXSYS_round(B * 255)); |
779 } | 779 } |
780 return LoadMaskDIB(pSoftMask); | 780 return LoadMaskDIB(pSoftMask); |
781 } | 781 } |
782 CPDF_Object* pMask = m_pDict->GetElementValue(FX_BSTRC("Mask")); | 782 |
783 if (pMask == NULL) { | 783 if (CPDF_Stream* pStream = |
784 return NULL; | 784 ToStream(m_pDict->GetElementValue(FX_BSTRC("Mask")))) |
785 } | 785 return LoadMaskDIB(pStream); |
786 if (pMask->GetType() == PDFOBJ_STREAM) { | 786 |
787 return LoadMaskDIB((CPDF_Stream*)pMask); | 787 return nullptr; |
788 } | |
789 return NULL; | |
790 } | 788 } |
791 int CPDF_DIBSource::StratLoadMask() { | 789 int CPDF_DIBSource::StratLoadMask() { |
792 m_MatteColor = 0XFFFFFFFF; | 790 m_MatteColor = 0XFFFFFFFF; |
793 m_pMaskStream = m_pDict->GetStream(FX_BSTRC("SMask")); | 791 m_pMaskStream = m_pDict->GetStream(FX_BSTRC("SMask")); |
794 if (m_pMaskStream) { | 792 if (m_pMaskStream) { |
795 CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArray(FX_BSTRC("Matte")); | 793 CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArray(FX_BSTRC("Matte")); |
796 if (pMatte != NULL && m_pColorSpace && | 794 if (pMatte != NULL && m_pColorSpace && |
797 (FX_DWORD)m_pColorSpace->CountComponents() <= m_nComponents) { | 795 (FX_DWORD)m_pColorSpace->CountComponents() <= m_nComponents) { |
798 FX_FLOAT R, G, B; | 796 FX_FLOAT R, G, B; |
799 FX_FLOAT* pColor = FX_Alloc(FX_FLOAT, m_nComponents); | 797 FX_FLOAT* pColor = FX_Alloc(FX_FLOAT, m_nComponents); |
800 for (FX_DWORD i = 0; i < m_nComponents; i++) { | 798 for (FX_DWORD i = 0; i < m_nComponents; i++) { |
801 pColor[i] = pMatte->GetFloat(i); | 799 pColor[i] = pMatte->GetFloat(i); |
802 } | 800 } |
803 m_pColorSpace->GetRGB(pColor, R, G, B); | 801 m_pColorSpace->GetRGB(pColor, R, G, B); |
804 FX_Free(pColor); | 802 FX_Free(pColor); |
805 m_MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), | 803 m_MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), |
806 FXSYS_round(B * 255)); | 804 FXSYS_round(B * 255)); |
807 } | 805 } |
808 return StartLoadMaskDIB(); | 806 return StartLoadMaskDIB(); |
809 } | 807 } |
810 m_pMaskStream = m_pDict->GetElementValue(FX_BSTRC("Mask")); | 808 |
811 if (m_pMaskStream == NULL) { | 809 m_pMaskStream = ToStream(m_pDict->GetElementValue(FX_BSTRC("Mask"))); |
812 return 1; | 810 return m_pMaskStream ? StartLoadMaskDIB() : 1; |
813 } | |
814 if (m_pMaskStream->GetType() == PDFOBJ_STREAM) { | |
815 return StartLoadMaskDIB(); | |
816 } | |
817 return 1; | |
818 } | 811 } |
819 int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) { | 812 int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) { |
820 if (m_pMask == NULL) { | 813 if (m_pMask == NULL) { |
821 return 1; | 814 return 1; |
822 } | 815 } |
823 int ret = m_pMask->ContinueLoadDIBSource(pPause); | 816 int ret = m_pMask->ContinueLoadDIBSource(pPause); |
824 if (ret == 2) { | 817 if (ret == 2) { |
825 return ret; | 818 return ret; |
826 } | 819 } |
827 if (m_pColorSpace && m_bStdCS) { | 820 if (m_pColorSpace && m_bStdCS) { |
(...skipping 14 matching lines...) Expand all Loading... |
842 CPDF_DIBSource* CPDF_DIBSource::LoadMaskDIB(CPDF_Stream* pMask) { | 835 CPDF_DIBSource* CPDF_DIBSource::LoadMaskDIB(CPDF_Stream* pMask) { |
843 CPDF_DIBSource* pMaskSource = new CPDF_DIBSource; | 836 CPDF_DIBSource* pMaskSource = new CPDF_DIBSource; |
844 if (!pMaskSource->Load(m_pDocument, pMask, NULL, NULL, NULL, NULL, TRUE)) { | 837 if (!pMaskSource->Load(m_pDocument, pMask, NULL, NULL, NULL, NULL, TRUE)) { |
845 delete pMaskSource; | 838 delete pMaskSource; |
846 return NULL; | 839 return NULL; |
847 } | 840 } |
848 return pMaskSource; | 841 return pMaskSource; |
849 } | 842 } |
850 int CPDF_DIBSource::StartLoadMaskDIB() { | 843 int CPDF_DIBSource::StartLoadMaskDIB() { |
851 m_pMask = new CPDF_DIBSource; | 844 m_pMask = new CPDF_DIBSource; |
852 int ret = m_pMask->StartLoadDIBSource( | 845 int ret = m_pMask->StartLoadDIBSource(m_pDocument, m_pMaskStream, FALSE, |
853 m_pDocument, (CPDF_Stream*)m_pMaskStream, FALSE, NULL, NULL, TRUE); | 846 nullptr, nullptr, TRUE); |
854 if (ret == 2) { | 847 if (ret == 2) { |
855 if (m_Status == 0) { | 848 if (m_Status == 0) |
856 m_Status = 2; | 849 m_Status = 2; |
857 } | |
858 return 2; | 850 return 2; |
859 } | 851 } |
860 if (!ret) { | 852 if (!ret) { |
861 delete m_pMask; | 853 delete m_pMask; |
862 m_pMask = NULL; | 854 m_pMask = nullptr; |
863 return 1; | 855 return 1; |
864 } | 856 } |
865 return 1; | 857 return 1; |
866 } | 858 } |
867 void CPDF_DIBSource::LoadPalette() { | 859 void CPDF_DIBSource::LoadPalette() { |
868 if (m_bpc == 0) { | 860 if (m_bpc == 0) { |
869 return; | 861 return; |
870 } | 862 } |
871 if (m_bpc * m_nComponents > 8) { | 863 if (m_bpc * m_nComponents > 8) { |
872 return; | 864 return; |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 } | 1644 } |
1653 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { | 1645 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { |
1654 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); | 1646 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); |
1655 } | 1647 } |
1656 CPDF_ImageLoader::~CPDF_ImageLoader() { | 1648 CPDF_ImageLoader::~CPDF_ImageLoader() { |
1657 if (!m_bCached) { | 1649 if (!m_bCached) { |
1658 delete m_pBitmap; | 1650 delete m_pBitmap; |
1659 delete m_pMask; | 1651 delete m_pMask; |
1660 } | 1652 } |
1661 } | 1653 } |
OLD | NEW |