Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: core/fpdfapi/page/cpdf_docpagedata.cpp

Issue 2489423002: Make CPDF_PageContentGenerator methods take object numbers (Closed)
Patch Set: Rebase past fix in separate CL Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/page/cpdf_docpagedata.h ('k') | core/fpdfapi/page/cpdf_image.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return; 386 return;
387 387
388 pPattern->RemoveRef(); 388 pPattern->RemoveRef();
389 if (pPattern->use_count() > 1) 389 if (pPattern->use_count() > 1)
390 return; 390 return;
391 391
392 // We have item only in m_PatternMap cache. Clean it. 392 // We have item only in m_PatternMap cache. Clean it.
393 pPattern->clear(); 393 pPattern->clear();
394 } 394 }
395 395
396 CPDF_Image* CPDF_DocPageData::GetImage(CPDF_Object* pImageStream) { 396 CPDF_Image* CPDF_DocPageData::GetImage(uint32_t dwStreamObjNum) {
397 if (!pImageStream) 397 ASSERT(dwStreamObjNum);
398 return nullptr; 398 auto it = m_ImageMap.find(dwStreamObjNum);
399
400 ASSERT(!pImageStream->IsInline());
401 const uint32_t dwObjNum = pImageStream->GetObjNum();
402 auto it = m_ImageMap.find(dwObjNum);
403 if (it != m_ImageMap.end()) 399 if (it != m_ImageMap.end())
404 return it->second->AddRef(); 400 return it->second->AddRef();
405 401
406 CPDF_CountedImage* pCountedImage = 402 CPDF_CountedImage* pCountedImage =
407 new CPDF_CountedImage(new CPDF_Image(m_pPDFDoc, dwObjNum)); 403 new CPDF_CountedImage(new CPDF_Image(m_pPDFDoc, dwStreamObjNum));
408 m_ImageMap[dwObjNum] = pCountedImage; 404 m_ImageMap[dwStreamObjNum] = pCountedImage;
409 return pCountedImage->AddRef(); 405 return pCountedImage->AddRef();
410 } 406 }
411 407
412 void CPDF_DocPageData::ReleaseImage(const CPDF_Object* pImageStream) { 408 void CPDF_DocPageData::ReleaseImage(uint32_t dwStreamObjNum) {
413 if (!pImageStream) 409 ASSERT(dwStreamObjNum);
414 return; 410 auto it = m_ImageMap.find(dwStreamObjNum);
415
416 uint32_t dwObjNum = pImageStream->GetObjNum();
417 if (!dwObjNum)
418 return;
419
420 auto it = m_ImageMap.find(dwObjNum);
421 if (it == m_ImageMap.end()) 411 if (it == m_ImageMap.end())
422 return; 412 return;
423 413
424 CPDF_CountedImage* pCountedImage = it->second; 414 CPDF_CountedImage* pCountedImage = it->second;
425 if (!pCountedImage) 415 if (!pCountedImage)
426 return; 416 return;
427 417
428 pCountedImage->RemoveRef(); 418 pCountedImage->RemoveRef();
429 if (pCountedImage->use_count() > 1) 419 if (pCountedImage->use_count() > 1)
430 return; 420 return;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 527 }
538 528
539 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( 529 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr(
540 CPDF_Object* pPatternObj) const { 530 CPDF_Object* pPatternObj) const {
541 if (!pPatternObj) 531 if (!pPatternObj)
542 return nullptr; 532 return nullptr;
543 533
544 auto it = m_PatternMap.find(pPatternObj); 534 auto it = m_PatternMap.find(pPatternObj);
545 return it != m_PatternMap.end() ? it->second : nullptr; 535 return it != m_PatternMap.end() ? it->second : nullptr;
546 } 536 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_docpagedata.h ('k') | core/fpdfapi/page/cpdf_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698