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 <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" | 13 #include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" |
| 14 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" |
14 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h" | 15 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h" |
15 #include "core/fpdfapi/fpdf_page/pageint.h" | 16 #include "core/fpdfapi/fpdf_page/pageint.h" |
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
18 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 19 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
19 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" | 20 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" |
20 #include "core/fpdfapi/include/cpdf_modulemgr.h" | 21 #include "core/fpdfapi/include/cpdf_modulemgr.h" |
21 #include "core/fxcrt/include/fx_safe_types.h" | 22 #include "core/fxcrt/include/fx_safe_types.h" |
22 #include "core/include/fxcodec/fx_codec.h" | 23 #include "core/include/fxcodec/fx_codec.h" |
23 #include "core/include/fxge/fx_ge.h" | 24 #include "core/include/fxge/fx_ge.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 86 |
86 // Disallow evil constructors | 87 // Disallow evil constructors |
87 JpxBitMapContext(const JpxBitMapContext&); | 88 JpxBitMapContext(const JpxBitMapContext&); |
88 void operator=(const JpxBitMapContext&); | 89 void operator=(const JpxBitMapContext&); |
89 }; | 90 }; |
90 | 91 |
91 const int kMaxImageDimension = 0x01FFFF; | 92 const int kMaxImageDimension = 0x01FFFF; |
92 | 93 |
93 } // namespace | 94 } // namespace |
94 | 95 |
95 CFX_DIBSource* CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask, | |
96 FX_DWORD* pMatteColor, | |
97 FX_BOOL bStdCS, | |
98 FX_DWORD GroupFamily, | |
99 FX_BOOL bLoadMask) const { | |
100 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); | |
101 if (source->Load(m_pDocument, m_pStream, | |
102 reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor, | |
103 nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) { | |
104 return source.release(); | |
105 } | |
106 return nullptr; | |
107 } | |
108 | |
109 CFX_DIBSource* CPDF_Image::DetachBitmap() { | |
110 CFX_DIBSource* pBitmap = m_pDIBSource; | |
111 m_pDIBSource = nullptr; | |
112 return pBitmap; | |
113 } | |
114 | |
115 CFX_DIBSource* CPDF_Image::DetachMask() { | |
116 CFX_DIBSource* pBitmap = m_pMask; | |
117 m_pMask = nullptr; | |
118 return pBitmap; | |
119 } | |
120 | |
121 FX_BOOL CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource, | |
122 CPDF_Dictionary* pPageResource, | |
123 FX_BOOL bStdCS, | |
124 FX_DWORD GroupFamily, | |
125 FX_BOOL bLoadMask) { | |
126 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); | |
127 int ret = | |
128 source->StartLoadDIBSource(m_pDocument, m_pStream, TRUE, pFormResource, | |
129 pPageResource, bStdCS, GroupFamily, bLoadMask); | |
130 if (ret == 2) { | |
131 m_pDIBSource = source.release(); | |
132 return TRUE; | |
133 } | |
134 if (!ret) { | |
135 m_pDIBSource = nullptr; | |
136 return FALSE; | |
137 } | |
138 m_pMask = source->DetachMask(); | |
139 m_MatteColor = source->GetMatteColor(); | |
140 m_pDIBSource = source.release(); | |
141 return FALSE; | |
142 } | |
143 | |
144 FX_BOOL CPDF_Image::Continue(IFX_Pause* pPause) { | |
145 CPDF_DIBSource* pSource = static_cast<CPDF_DIBSource*>(m_pDIBSource); | |
146 int ret = pSource->ContinueLoadDIBSource(pPause); | |
147 if (ret == 2) { | |
148 return TRUE; | |
149 } | |
150 if (!ret) { | |
151 delete m_pDIBSource; | |
152 m_pDIBSource = nullptr; | |
153 return FALSE; | |
154 } | |
155 m_pMask = pSource->DetachMask(); | |
156 m_MatteColor = pSource->GetMatteColor(); | |
157 return FALSE; | |
158 } | |
159 | |
160 CPDF_DIBSource::CPDF_DIBSource() | 96 CPDF_DIBSource::CPDF_DIBSource() |
161 : m_pDocument(nullptr), | 97 : m_pDocument(nullptr), |
162 m_pStream(nullptr), | 98 m_pStream(nullptr), |
163 m_pDict(nullptr), | 99 m_pDict(nullptr), |
164 m_pColorSpace(nullptr), | 100 m_pColorSpace(nullptr), |
165 m_Family(0), | 101 m_Family(0), |
166 m_bpc(0), | 102 m_bpc(0), |
167 m_bpc_orig(0), | 103 m_bpc_orig(0), |
168 m_nComponents(0), | 104 m_nComponents(0), |
169 m_GroupFamily(0), | 105 m_GroupFamily(0), |
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 IFX_Pause* pPause) { | 1582 IFX_Pause* pPause) { |
1647 return LoadHandle->Continue(pPause); | 1583 return LoadHandle->Continue(pPause); |
1648 } | 1584 } |
1649 | 1585 |
1650 CPDF_ImageLoader::~CPDF_ImageLoader() { | 1586 CPDF_ImageLoader::~CPDF_ImageLoader() { |
1651 if (!m_bCached) { | 1587 if (!m_bCached) { |
1652 delete m_pBitmap; | 1588 delete m_pBitmap; |
1653 delete m_pMask; | 1589 delete m_pMask; |
1654 } | 1590 } |
1655 } | 1591 } |
OLD | NEW |