| 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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../../../include/fdrm/fx_crypt.h" | 9 #include "../../../include/fdrm/fx_crypt.h" |
| 10 #include "../fpdf_font/font_int.h" | 10 #include "../fpdf_font/font_int.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 for (auto it = m_IccProfileMap.begin(); it != m_IccProfileMap.end();) { | 167 for (auto it = m_IccProfileMap.begin(); it != m_IccProfileMap.end();) { |
| 168 auto curr_it = it++; | 168 auto curr_it = it++; |
| 169 CPDF_CountedIccProfile* ipData = curr_it->second; | 169 CPDF_CountedIccProfile* ipData = curr_it->second; |
| 170 if (!ipData->get()) | 170 if (!ipData->get()) |
| 171 continue; | 171 continue; |
| 172 | 172 |
| 173 if (bForceRelease || ipData->use_count() < 2) { | 173 if (bForceRelease || ipData->use_count() < 2) { |
| 174 CPDF_Stream* ipKey = curr_it->first; | 174 for (auto hash_it = m_HashProfileMap.begin(); |
| 175 FX_POSITION pos2 = m_HashProfileMap.GetStartPosition(); | 175 hash_it != m_HashProfileMap.end(); ++hash_it) { |
| 176 while (pos2) { | 176 if (curr_it->first == hash_it->second) { |
| 177 CFX_ByteString bsKey; | 177 m_HashProfileMap.erase(hash_it); |
| 178 CPDF_Stream* pFindStream = nullptr; | |
| 179 m_HashProfileMap.GetNextAssoc(pos2, bsKey, (void*&)pFindStream); | |
| 180 if (ipKey == pFindStream) { | |
| 181 m_HashProfileMap.RemoveKey(bsKey); | |
| 182 break; | 178 break; |
| 183 } | 179 } |
| 184 } | 180 } |
| 185 delete ipData->get(); | 181 delete ipData->get(); |
| 186 delete ipData; | 182 delete ipData; |
| 187 m_IccProfileMap.erase(curr_it); | 183 m_IccProfileMap.erase(curr_it); |
| 188 } | 184 } |
| 189 } | 185 } |
| 190 | 186 |
| 191 for (auto it = m_FontFileMap.begin(); it != m_FontFileMap.end();) { | 187 for (auto it = m_FontFileMap.begin(); it != m_FontFileMap.end();) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 return NULL; | 508 return NULL; |
| 513 | 509 |
| 514 auto it = m_IccProfileMap.find(pIccProfileStream); | 510 auto it = m_IccProfileMap.find(pIccProfileStream); |
| 515 if (it != m_IccProfileMap.end()) { | 511 if (it != m_IccProfileMap.end()) { |
| 516 return it->second->AddRef(); | 512 return it->second->AddRef(); |
| 517 } | 513 } |
| 518 | 514 |
| 519 CPDF_StreamAcc stream; | 515 CPDF_StreamAcc stream; |
| 520 stream.LoadAllData(pIccProfileStream, FALSE); | 516 stream.LoadAllData(pIccProfileStream, FALSE); |
| 521 uint8_t digest[20]; | 517 uint8_t digest[20]; |
| 522 CPDF_Stream* pCopiedStream = nullptr; | |
| 523 CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest); | 518 CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest); |
| 524 if (m_HashProfileMap.Lookup(CFX_ByteStringC(digest, 20), | 519 auto hash_it = m_HashProfileMap.find(CFX_ByteStringC(digest, 20)); |
| 525 (void*&)pCopiedStream)) { | 520 if (hash_it != m_HashProfileMap.end()) { |
| 526 auto it_copied_stream = m_IccProfileMap.find(pCopiedStream); | 521 auto it_copied_stream = m_IccProfileMap.find(hash_it->second); |
| 527 return it_copied_stream->second->AddRef(); | 522 return it_copied_stream->second->AddRef(); |
| 528 } | 523 } |
| 529 CPDF_IccProfile* pProfile = | 524 CPDF_IccProfile* pProfile = |
| 530 new CPDF_IccProfile(stream.GetData(), stream.GetSize()); | 525 new CPDF_IccProfile(stream.GetData(), stream.GetSize()); |
| 531 CPDF_CountedIccProfile* ipData = new CPDF_CountedIccProfile(pProfile); | 526 CPDF_CountedIccProfile* ipData = new CPDF_CountedIccProfile(pProfile); |
| 532 m_IccProfileMap[pIccProfileStream] = ipData; | 527 m_IccProfileMap[pIccProfileStream] = ipData; |
| 533 m_HashProfileMap.SetAt(CFX_ByteStringC(digest, 20), pIccProfileStream); | 528 m_HashProfileMap[CFX_ByteStringC(digest, 20)] = pIccProfileStream; |
| 534 return ipData->AddRef(); | 529 return ipData->AddRef(); |
| 535 } | 530 } |
| 536 | 531 |
| 537 void CPDF_DocPageData::ReleaseIccProfile(CPDF_IccProfile* pIccProfile) { | 532 void CPDF_DocPageData::ReleaseIccProfile(CPDF_IccProfile* pIccProfile) { |
| 538 ASSERT(pIccProfile); | 533 ASSERT(pIccProfile); |
| 539 | 534 |
| 540 for (auto it = m_IccProfileMap.begin(); it != m_IccProfileMap.end(); ++it) { | 535 for (auto it = m_IccProfileMap.begin(); it != m_IccProfileMap.end(); ++it) { |
| 541 CPDF_CountedIccProfile* profile = it->second; | 536 CPDF_CountedIccProfile* profile = it->second; |
| 542 if (profile->get() != pIccProfile) | 537 if (profile->get() != pIccProfile) |
| 543 continue; | 538 continue; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 } | 601 } |
| 607 | 602 |
| 608 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( | 603 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( |
| 609 CPDF_Object* pPatternObj) const { | 604 CPDF_Object* pPatternObj) const { |
| 610 if (!pPatternObj) | 605 if (!pPatternObj) |
| 611 return nullptr; | 606 return nullptr; |
| 612 | 607 |
| 613 auto it = m_PatternMap.find(pPatternObj); | 608 auto it = m_PatternMap.find(pPatternObj); |
| 614 return it != m_PatternMap.end() ? it->second : nullptr; | 609 return it != m_PatternMap.end() ? it->second : nullptr; |
| 615 } | 610 } |
| OLD | NEW |