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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_doc.cpp

Issue 1977093002: Make CFX_ByteString(const CFX_ByteStringC&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nit Created 4 years, 7 months 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 | « no previous file | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('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/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include "core/fdrm/crypto/include/fx_crypt.h" 9 #include "core/fdrm/crypto/include/fx_crypt.h"
10 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h" 10 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 if (!fontData) { 153 if (!fontData) {
154 fontData = new CPDF_CountedFont(pFont); 154 fontData = new CPDF_CountedFont(pFont);
155 m_FontMap[pFontDict] = fontData; 155 m_FontMap[pFontDict] = fontData;
156 } else { 156 } else {
157 fontData->reset(pFont); 157 fontData->reset(pFont);
158 } 158 }
159 return fontData->AddRef(); 159 return fontData->AddRef();
160 } 160 }
161 161
162 CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteStringC& fontName, 162 CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteString& fontName,
163 CPDF_FontEncoding* pEncoding) { 163 CPDF_FontEncoding* pEncoding) {
164 if (fontName.IsEmpty()) 164 if (fontName.IsEmpty())
165 return nullptr; 165 return nullptr;
166 166
167 for (auto& it : m_FontMap) { 167 for (auto& it : m_FontMap) {
168 CPDF_CountedFont* fontData = it.second; 168 CPDF_CountedFont* fontData = it.second;
169 CPDF_Font* pFont = fontData->get(); 169 CPDF_Font* pFont = fontData->get();
170 if (!pFont) 170 if (!pFont)
171 continue; 171 continue;
172 if (pFont->GetBaseFont() != fontName) 172 if (pFont->GetBaseFont() != fontName)
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 418
419 auto it = m_IccProfileMap.find(pIccProfileStream); 419 auto it = m_IccProfileMap.find(pIccProfileStream);
420 if (it != m_IccProfileMap.end()) { 420 if (it != m_IccProfileMap.end()) {
421 return it->second->AddRef(); 421 return it->second->AddRef();
422 } 422 }
423 423
424 CPDF_StreamAcc stream; 424 CPDF_StreamAcc stream;
425 stream.LoadAllData(pIccProfileStream, FALSE); 425 stream.LoadAllData(pIccProfileStream, FALSE);
426 uint8_t digest[20]; 426 uint8_t digest[20];
427 CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest); 427 CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest);
428 auto hash_it = m_HashProfileMap.find(CFX_ByteStringC(digest, 20)); 428 CFX_ByteString bsDigest(digest, 20);
429 auto hash_it = m_HashProfileMap.find(bsDigest);
429 if (hash_it != m_HashProfileMap.end()) { 430 if (hash_it != m_HashProfileMap.end()) {
430 auto it_copied_stream = m_IccProfileMap.find(hash_it->second); 431 auto it_copied_stream = m_IccProfileMap.find(hash_it->second);
431 return it_copied_stream->second->AddRef(); 432 return it_copied_stream->second->AddRef();
432 } 433 }
433 CPDF_IccProfile* pProfile = 434 CPDF_IccProfile* pProfile =
434 new CPDF_IccProfile(stream.GetData(), stream.GetSize()); 435 new CPDF_IccProfile(stream.GetData(), stream.GetSize());
435 CPDF_CountedIccProfile* ipData = new CPDF_CountedIccProfile(pProfile); 436 CPDF_CountedIccProfile* ipData = new CPDF_CountedIccProfile(pProfile);
436 m_IccProfileMap[pIccProfileStream] = ipData; 437 m_IccProfileMap[pIccProfileStream] = ipData;
437 m_HashProfileMap[CFX_ByteStringC(digest, 20)] = pIccProfileStream; 438 m_HashProfileMap[bsDigest] = pIccProfileStream;
438 return ipData->AddRef(); 439 return ipData->AddRef();
439 } 440 }
440 441
441 void CPDF_DocPageData::ReleaseIccProfile(CPDF_IccProfile* pIccProfile) { 442 void CPDF_DocPageData::ReleaseIccProfile(CPDF_IccProfile* pIccProfile) {
442 ASSERT(pIccProfile); 443 ASSERT(pIccProfile);
443 444
444 for (auto it = m_IccProfileMap.begin(); it != m_IccProfileMap.end(); ++it) { 445 for (auto it = m_IccProfileMap.begin(); it != m_IccProfileMap.end(); ++it) {
445 CPDF_CountedIccProfile* profile = it->second; 446 CPDF_CountedIccProfile* profile = it->second;
446 if (profile->get() != pIccProfile) 447 if (profile->get() != pIccProfile)
447 continue; 448 continue;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 511 }
511 512
512 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( 513 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr(
513 CPDF_Object* pPatternObj) const { 514 CPDF_Object* pPatternObj) const {
514 if (!pPatternObj) 515 if (!pPatternObj)
515 return nullptr; 516 return nullptr;
516 517
517 auto it = m_PatternMap.find(pPatternObj); 518 auto it = m_PatternMap.find(pPatternObj);
518 return it != m_PatternMap.end() ? it->second : nullptr; 519 return it != m_PatternMap.end() ? it->second : nullptr;
519 } 520 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698