| 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/page/cpdf_docpagedata.h" | 7 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( | 438 CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( |
| 439 CPDF_Stream* pIccProfileStream) { | 439 CPDF_Stream* pIccProfileStream) { |
| 440 if (!pIccProfileStream) | 440 if (!pIccProfileStream) |
| 441 return nullptr; | 441 return nullptr; |
| 442 | 442 |
| 443 auto it = m_IccProfileMap.find(pIccProfileStream); | 443 auto it = m_IccProfileMap.find(pIccProfileStream); |
| 444 if (it != m_IccProfileMap.end()) | 444 if (it != m_IccProfileMap.end()) |
| 445 return it->second->AddRef(); | 445 return it->second->AddRef(); |
| 446 | 446 |
| 447 CPDF_StreamAcc stream; | 447 CPDF_StreamAcc stream; |
| 448 stream.LoadAllData(pIccProfileStream, FALSE); | 448 stream.LoadAllData(pIccProfileStream, false); |
| 449 uint8_t digest[20]; | 449 uint8_t digest[20]; |
| 450 CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest); | 450 CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest); |
| 451 CFX_ByteString bsDigest(digest, 20); | 451 CFX_ByteString bsDigest(digest, 20); |
| 452 auto hash_it = m_HashProfileMap.find(bsDigest); | 452 auto hash_it = m_HashProfileMap.find(bsDigest); |
| 453 if (hash_it != m_HashProfileMap.end()) { | 453 if (hash_it != m_HashProfileMap.end()) { |
| 454 auto it_copied_stream = m_IccProfileMap.find(hash_it->second); | 454 auto it_copied_stream = m_IccProfileMap.find(hash_it->second); |
| 455 if (it_copied_stream != m_IccProfileMap.end()) | 455 if (it_copied_stream != m_IccProfileMap.end()) |
| 456 return it_copied_stream->second->AddRef(); | 456 return it_copied_stream->second->AddRef(); |
| 457 } | 457 } |
| 458 CPDF_IccProfile* pProfile = | 458 CPDF_IccProfile* pProfile = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 if (it != m_FontFileMap.end()) | 490 if (it != m_FontFileMap.end()) |
| 491 return it->second->AddRef(); | 491 return it->second->AddRef(); |
| 492 | 492 |
| 493 CPDF_Dictionary* pFontDict = pFontStream->GetDict(); | 493 CPDF_Dictionary* pFontDict = pFontStream->GetDict(); |
| 494 int32_t org_size = pFontDict->GetIntegerFor("Length1") + | 494 int32_t org_size = pFontDict->GetIntegerFor("Length1") + |
| 495 pFontDict->GetIntegerFor("Length2") + | 495 pFontDict->GetIntegerFor("Length2") + |
| 496 pFontDict->GetIntegerFor("Length3"); | 496 pFontDict->GetIntegerFor("Length3"); |
| 497 org_size = std::max(org_size, 0); | 497 org_size = std::max(org_size, 0); |
| 498 | 498 |
| 499 CPDF_StreamAcc* pFontFile = new CPDF_StreamAcc; | 499 CPDF_StreamAcc* pFontFile = new CPDF_StreamAcc; |
| 500 pFontFile->LoadAllData(pFontStream, FALSE, org_size); | 500 pFontFile->LoadAllData(pFontStream, false, org_size); |
| 501 | 501 |
| 502 CPDF_CountedStreamAcc* pCountedFont = new CPDF_CountedStreamAcc(pFontFile); | 502 CPDF_CountedStreamAcc* pCountedFont = new CPDF_CountedStreamAcc(pFontFile); |
| 503 m_FontFileMap[pFontStream] = pCountedFont; | 503 m_FontFileMap[pFontStream] = pCountedFont; |
| 504 return pCountedFont->AddRef(); | 504 return pCountedFont->AddRef(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 void CPDF_DocPageData::ReleaseFontFileStreamAcc( | 507 void CPDF_DocPageData::ReleaseFontFileStreamAcc( |
| 508 const CPDF_Stream* pFontStream) { | 508 const CPDF_Stream* pFontStream) { |
| 509 if (!pFontStream) | 509 if (!pFontStream) |
| 510 return; | 510 return; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 537 } | 537 } |
| 538 | 538 |
| 539 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( | 539 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( |
| 540 CPDF_Object* pPatternObj) const { | 540 CPDF_Object* pPatternObj) const { |
| 541 if (!pPatternObj) | 541 if (!pPatternObj) |
| 542 return nullptr; | 542 return nullptr; |
| 543 | 543 |
| 544 auto it = m_PatternMap.find(pPatternObj); | 544 auto it = m_PatternMap.find(pPatternObj); |
| 545 return it != m_PatternMap.end() ? it->second : nullptr; | 545 return it != m_PatternMap.end() ? it->second : nullptr; |
| 546 } | 546 } |
| OLD | NEW |