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_page/pageint.h" | 7 #include "core/fpdfapi/fpdf_page/pageint.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 return it->second->AddRef(); | 407 return it->second->AddRef(); |
408 | 408 |
409 CPDF_Image* pImage = new CPDF_Image(m_pPDFDoc); | 409 CPDF_Image* pImage = new CPDF_Image(m_pPDFDoc); |
410 pImage->LoadImageF(pImageStream->AsStream(), false); | 410 pImage->LoadImageF(pImageStream->AsStream(), false); |
411 | 411 |
412 CPDF_CountedImage* pCountedImage = new CPDF_CountedImage(pImage); | 412 CPDF_CountedImage* pCountedImage = new CPDF_CountedImage(pImage); |
413 m_ImageMap[dwImageObjNum] = pCountedImage; | 413 m_ImageMap[dwImageObjNum] = pCountedImage; |
414 return pCountedImage->AddRef(); | 414 return pCountedImage->AddRef(); |
415 } | 415 } |
416 | 416 |
417 void CPDF_DocPageData::ReleaseImage(const CPDF_Object* pImageStream) { | 417 bool CPDF_DocPageData::ReleaseImage(const CPDF_Object* pImageStream) { |
418 if (!pImageStream) | 418 if (!pImageStream) |
419 return; | 419 return false; |
420 | 420 |
421 uint32_t dwObjNum = pImageStream->GetObjNum(); | 421 uint32_t dwObjNum = pImageStream->GetObjNum(); |
422 if (!dwObjNum) | 422 if (!dwObjNum) |
423 return; | 423 return false; |
424 | 424 |
425 auto it = m_ImageMap.find(dwObjNum); | 425 auto it = m_ImageMap.find(dwObjNum); |
426 if (it == m_ImageMap.end()) | 426 if (it == m_ImageMap.end()) |
427 return; | 427 return false; |
428 | 428 |
429 CPDF_CountedImage* pCountedImage = it->second; | 429 CPDF_CountedImage* pCountedImage = it->second; |
430 if (!pCountedImage) | 430 if (!pCountedImage) |
431 return; | 431 return false; |
432 | 432 |
433 pCountedImage->RemoveRef(); | 433 pCountedImage->RemoveRef(); |
434 if (pCountedImage->use_count() != 0) | 434 if (pCountedImage->use_count() != 0) |
435 return; | 435 return false; |
436 | 436 |
437 delete pCountedImage->get(); | 437 delete pCountedImage->get(); |
438 delete pCountedImage; | 438 delete pCountedImage; |
439 m_ImageMap.erase(it); | 439 m_ImageMap.erase(it); |
| 440 return true; |
440 } | 441 } |
441 | 442 |
442 CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( | 443 CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( |
443 CPDF_Stream* pIccProfileStream) { | 444 CPDF_Stream* pIccProfileStream) { |
444 if (!pIccProfileStream) | 445 if (!pIccProfileStream) |
445 return nullptr; | 446 return nullptr; |
446 | 447 |
447 auto it = m_IccProfileMap.find(pIccProfileStream); | 448 auto it = m_IccProfileMap.find(pIccProfileStream); |
448 if (it != m_IccProfileMap.end()) | 449 if (it != m_IccProfileMap.end()) |
449 return it->second->AddRef(); | 450 return it->second->AddRef(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 } | 539 } |
539 | 540 |
540 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( | 541 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( |
541 CPDF_Object* pPatternObj) const { | 542 CPDF_Object* pPatternObj) const { |
542 if (!pPatternObj) | 543 if (!pPatternObj) |
543 return nullptr; | 544 return nullptr; |
544 | 545 |
545 auto it = m_PatternMap.find(pPatternObj); | 546 auto it = m_PatternMap.find(pPatternObj); |
546 return it != m_PatternMap.end() ? it->second : nullptr; | 547 return it != m_PatternMap.end() ? it->second : nullptr; |
547 } | 548 } |
OLD | NEW |