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

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

Issue 1255693002: Revert "FX_BOOL considered harmful, part 2." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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
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 "../../../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 "pageint.h" 9 #include "pageint.h"
10 CPDF_PageObject* CPDF_PageObject::Create(int type) 10 CPDF_PageObject* CPDF_PageObject::Create(int type)
(...skipping 26 matching lines...) Expand all
37 if (m_Type != pSrc->m_Type) { 37 if (m_Type != pSrc->m_Type) {
38 return; 38 return;
39 } 39 }
40 CopyData(pSrc); 40 CopyData(pSrc);
41 CopyStates(*pSrc); 41 CopyStates(*pSrc);
42 m_Left = pSrc->m_Left; 42 m_Left = pSrc->m_Left;
43 m_Right = pSrc->m_Right; 43 m_Right = pSrc->m_Right;
44 m_Top = pSrc->m_Top; 44 m_Top = pSrc->m_Top;
45 m_Bottom = pSrc->m_Bottom; 45 m_Bottom = pSrc->m_Bottom;
46 } 46 }
47 void CPDF_PageObject::AppendClipPath(CPDF_Path path, int type, bool bAutoMerge) 47 void CPDF_PageObject::AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerg e)
48 { 48 {
49 m_ClipPath.AppendPath(path, type, bAutoMerge); 49 m_ClipPath.AppendPath(path, type, bAutoMerge);
50 } 50 }
51 void CPDF_PageObject::CopyClipPath(CPDF_PageObject* pObj) 51 void CPDF_PageObject::CopyClipPath(CPDF_PageObject* pObj)
52 { 52 {
53 m_ClipPath = pObj->m_ClipPath; 53 m_ClipPath = pObj->m_ClipPath;
54 } 54 }
55 void CPDF_PageObject::RemoveClipPath() 55 void CPDF_PageObject::RemoveClipPath()
56 { 56 {
57 m_ClipPath.SetNull(); 57 m_ClipPath.SetNull();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } else { 346 } else {
347 m_pCharCodes = (FX_DWORD*)(uintptr_t)pCharCodes[0]; 347 m_pCharCodes = (FX_DWORD*)(uintptr_t)pCharCodes[0];
348 } 348 }
349 RecalcPositionData(); 349 RecalcPositionData();
350 } 350 }
351 351
352 FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const 352 FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const
353 { 353 {
354 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; 354 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000;
355 CPDF_Font* pFont = m_TextState.GetFont(); 355 CPDF_Font* pFont = m_TextState.GetFont();
356 bool bVertWriting = false; 356 FX_BOOL bVertWriting = FALSE;
357 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); 357 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
358 if (pCIDFont) { 358 if (pCIDFont) {
359 bVertWriting = pCIDFont->IsVertWriting(); 359 bVertWriting = pCIDFont->IsVertWriting();
360 } 360 }
361 if (!bVertWriting) 361 if (!bVertWriting)
362 return pFont->GetCharWidthF(charcode, 0) * fontsize; 362 return pFont->GetCharWidthF(charcode, 0) * fontsize;
363 363
364 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode); 364 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode);
365 return pCIDFont->GetVertWidth(CID) * fontsize; 365 return pCIDFont->GetVertWidth(CID) * fontsize;
366 } 366 }
367 367
368 FX_FLOAT CPDF_TextObject::GetSpaceCharWidth() const 368 FX_FLOAT CPDF_TextObject::GetSpaceCharWidth() const
369 { 369 {
370 CPDF_Font* pFont = m_TextState.GetFont(); 370 CPDF_Font* pFont = m_TextState.GetFont();
371 FX_DWORD charCode = m_TextState.GetFont()->CharCodeFromUnicode(32); 371 FX_DWORD charCode = m_TextState.GetFont()->CharCodeFromUnicode(32);
372 if (charCode != (FX_DWORD) - 1) { 372 if (charCode != (FX_DWORD) - 1) {
373 return GetCharWidth(charCode); 373 return GetCharWidth(charCode);
374 } 374 }
375 FX_FLOAT fontSize = m_TextState.GetFontSize() / 4000.0f; 375 FX_FLOAT fontSize = m_TextState.GetFontSize() / 4000.0f;
376 bool bVertWriting = false; 376 FX_BOOL bVertWriting = FALSE;
377 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); 377 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
378 if (pCIDFont) { 378 if (pCIDFont) {
379 bVertWriting = pCIDFont->IsVertWriting(); 379 bVertWriting = pCIDFont->IsVertWriting();
380 } 380 }
381 FX_RECT fontRect; 381 FX_RECT fontRect;
382 pFont->GetFontBBox(fontRect); 382 pFont->GetFontBBox(fontRect);
383 fontSize *= bVertWriting ? 383 fontSize *= bVertWriting ?
384 (FX_FLOAT)fontRect.Height() : (FX_FLOAT)fontRect.Width(); 384 (FX_FLOAT)fontRect.Height() : (FX_FLOAT)fontRect.Width();
385 return fontSize; 385 return fontSize;
386 } 386 }
387 387
388 void CPDF_TextObject::GetCharRect(int index, CFX_FloatRect& rect) const 388 void CPDF_TextObject::GetCharRect(int index, CFX_FloatRect& rect) const
389 { 389 {
390 CPDF_Font* pFont = m_TextState.GetFont(); 390 CPDF_Font* pFont = m_TextState.GetFont();
391 bool bVertWriting = false; 391 FX_BOOL bVertWriting = FALSE;
392 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); 392 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
393 if (pCIDFont) { 393 if (pCIDFont) {
394 bVertWriting = pCIDFont->IsVertWriting(); 394 bVertWriting = pCIDFont->IsVertWriting();
395 } 395 }
396 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; 396 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000;
397 int count = 0; 397 int count = 0;
398 for (int i = 0; i < m_nChars; ++i) { 398 for (int i = 0; i < m_nChars; ++i) {
399 FX_DWORD charcode = m_nChars == 1 ? 399 FX_DWORD charcode = m_nChars == 1 ?
400 (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i]; 400 (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
401 if (charcode == (FX_DWORD) - 1) { 401 if (charcode == (FX_DWORD) - 1) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 FX_FLOAT* pTextAdvanceY, 434 FX_FLOAT* pTextAdvanceY,
435 FX_FLOAT horz_scale, 435 FX_FLOAT horz_scale,
436 int level) 436 int level)
437 { 437 {
438 FX_FLOAT curpos = 0; 438 FX_FLOAT curpos = 0;
439 FX_FLOAT min_x = 10000 * 1.0f; 439 FX_FLOAT min_x = 10000 * 1.0f;
440 FX_FLOAT max_x = -10000 * 1.0f; 440 FX_FLOAT max_x = -10000 * 1.0f;
441 FX_FLOAT min_y = 10000 * 1.0f; 441 FX_FLOAT min_y = 10000 * 1.0f;
442 FX_FLOAT max_y = -10000 * 1.0f; 442 FX_FLOAT max_y = -10000 * 1.0f;
443 CPDF_Font* pFont = m_TextState.GetFont(); 443 CPDF_Font* pFont = m_TextState.GetFont();
444 bool bVertWriting = false; 444 FX_BOOL bVertWriting = FALSE;
445 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); 445 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
446 if (pCIDFont) { 446 if (pCIDFont) {
447 bVertWriting = pCIDFont->IsVertWriting(); 447 bVertWriting = pCIDFont->IsVertWriting();
448 } 448 }
449 FX_FLOAT fontsize = m_TextState.GetFontSize(); 449 FX_FLOAT fontsize = m_TextState.GetFontSize();
450 for (int i = 0; i < m_nChars; ++i) { 450 for (int i = 0; i < m_nChars; ++i) {
451 FX_DWORD charcode = m_nChars == 1 ? 451 FX_DWORD charcode = m_nChars == 1 ?
452 (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i]; 452 (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
453 if (charcode == (FX_DWORD) - 1) { 453 if (charcode == (FX_DWORD) - 1) {
454 curpos -= FXSYS_Mul(m_pCharPos[i - 1], fontsize) / 1000; 454 curpos -= FXSYS_Mul(m_pCharPos[i - 1], fontsize) / 1000;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 m_Left -= half_width; 563 m_Left -= half_width;
564 m_Right += half_width; 564 m_Right += half_width;
565 m_Top += half_width; 565 m_Top += half_width;
566 m_Bottom -= half_width; 566 m_Bottom -= half_width;
567 } 567 }
568 } 568 }
569 569
570 void CPDF_TextObject::CalcCharPos(FX_FLOAT* pPosArray) const 570 void CPDF_TextObject::CalcCharPos(FX_FLOAT* pPosArray) const
571 { 571 {
572 CPDF_Font* pFont = m_TextState.GetFont(); 572 CPDF_Font* pFont = m_TextState.GetFont();
573 bool bVertWriting = false; 573 FX_BOOL bVertWriting = FALSE;
574 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); 574 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
575 if (pCIDFont) { 575 if (pCIDFont) {
576 bVertWriting = pCIDFont->IsVertWriting(); 576 bVertWriting = pCIDFont->IsVertWriting();
577 } 577 }
578 FX_FLOAT fontsize = m_TextState.GetFontSize(); 578 FX_FLOAT fontsize = m_TextState.GetFontSize();
579 for (int i = 0, index = 0; i < m_nChars; ++i) { 579 for (int i = 0, index = 0; i < m_nChars; ++i) {
580 FX_DWORD charcode = m_nChars == 1 ? 580 FX_DWORD charcode = m_nChars == 1 ?
581 (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i]; 581 (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
582 if (charcode == (FX_DWORD) - 1) { 582 if (charcode == (FX_DWORD) - 1) {
583 continue; 583 continue;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 713 }
714 void CPDF_FormObject::CalcBoundingBox() 714 void CPDF_FormObject::CalcBoundingBox()
715 { 715 {
716 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); 716 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox();
717 form_rect.Transform(&m_FormMatrix); 717 form_rect.Transform(&m_FormMatrix);
718 m_Left = form_rect.left; 718 m_Left = form_rect.left;
719 m_Bottom = form_rect.bottom; 719 m_Bottom = form_rect.bottom;
720 m_Right = form_rect.right; 720 m_Right = form_rect.right;
721 m_Top = form_rect.top; 721 m_Top = form_rect.top;
722 } 722 }
723 CPDF_PageObjects::CPDF_PageObjects(bool bReleaseMembers) : m_ObjectList(128) 723 CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) : m_ObjectList(128)
724 { 724 {
725 m_bBackgroundAlphaNeeded = false; 725 m_bBackgroundAlphaNeeded = FALSE;
726 m_bReleaseMembers = bReleaseMembers; 726 m_bReleaseMembers = bReleaseMembers;
727 m_ParseState = PDF_CONTENT_NOT_PARSED; 727 m_ParseState = PDF_CONTENT_NOT_PARSED;
728 m_pParser = NULL; 728 m_pParser = NULL;
729 m_pFormStream = NULL; 729 m_pFormStream = NULL;
730 m_pResources = NULL; 730 m_pResources = NULL;
731 } 731 }
732 CPDF_PageObjects::~CPDF_PageObjects() 732 CPDF_PageObjects::~CPDF_PageObjects()
733 { 733 {
734 delete m_pParser; 734 delete m_pParser;
735 if (!m_bReleaseMembers) { 735 if (!m_bReleaseMembers) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 while (pos) { 851 while (pos) {
852 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); 852 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
853 } 853 }
854 } 854 }
855 m_ObjectList.RemoveAll(); 855 m_ObjectList.RemoveAll();
856 } 856 }
857 CPDF_Page::CPDF_Page() 857 CPDF_Page::CPDF_Page()
858 { 858 {
859 m_pPageRender = NULL; 859 m_pPageRender = NULL;
860 } 860 }
861 void CPDF_Page::Load(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, bool bPageCache) 861 void CPDF_Page::Load(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, FX_BO OL bPageCache)
862 { 862 {
863 m_pDocument = (CPDF_Document*)pDocument; 863 m_pDocument = (CPDF_Document*)pDocument;
864 m_pFormDict = pPageDict; 864 m_pFormDict = pPageDict;
865 if (bPageCache) { 865 if (bPageCache) {
866 m_pPageRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCach e(this); 866 m_pPageRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCach e(this);
867 } 867 }
868 if (pPageDict == NULL) { 868 if (pPageDict == NULL) {
869 m_PageWidth = m_PageHeight = 100 * 1.0f; 869 m_PageWidth = m_PageHeight = 100 * 1.0f;
870 m_pPageResources = m_pResources = NULL; 870 m_pPageResources = m_pResources = NULL;
871 return; 871 return;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 case 2: 918 case 2:
919 m_PageMatrix.Set(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top); 919 m_PageMatrix.Set(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top);
920 break; 920 break;
921 case 3: 921 case 3:
922 m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left); 922 m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left);
923 break; 923 break;
924 } 924 }
925 m_Transparency = PDFTRANS_ISOLATED; 925 m_Transparency = PDFTRANS_ISOLATED;
926 LoadTransInfo(); 926 LoadTransInfo();
927 } 927 }
928 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, bool bReParse) 928 void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse)
929 { 929 {
930 if (bReParse) { 930 if (bReParse) {
931 ClearCacheObjects(); 931 ClearCacheObjects();
932 } 932 }
933 if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSIN G) { 933 if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSIN G) {
934 return; 934 return;
935 } 935 }
936 m_pParser = new CPDF_ContentParser; 936 m_pParser = new CPDF_ContentParser;
937 m_pParser->Start(this, pOptions); 937 m_pParser->Start(this, pOptions);
938 m_ParseState = PDF_CONTENT_PARSING; 938 m_ParseState = PDF_CONTENT_PARSING;
939 } 939 }
940 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, bool bReParse) 940 void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse)
941 { 941 {
942 StartParse(pOptions, bReParse); 942 StartParse(pOptions, bReParse);
943 ContinueParse(NULL); 943 ContinueParse(NULL);
944 } 944 }
945 CPDF_Page::~CPDF_Page() 945 CPDF_Page::~CPDF_Page()
946 { 946 {
947 if (m_pPageRender) { 947 if (m_pPageRender) {
948 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); 948 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule();
949 pModule->DestroyPageCache(m_pPageRender); 949 pModule->DestroyPageCache(m_pPageRender);
950 } 950 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 display_matrix.Set(FXSYS_Div((FX_FLOAT)(x2 - x0), m_PageWidth), 1063 display_matrix.Set(FXSYS_Div((FX_FLOAT)(x2 - x0), m_PageWidth),
1064 FXSYS_Div((FX_FLOAT)(y2 - y0), m_PageWidth), 1064 FXSYS_Div((FX_FLOAT)(y2 - y0), m_PageWidth),
1065 FXSYS_Div((FX_FLOAT)(x1 - x0), m_PageHeight), 1065 FXSYS_Div((FX_FLOAT)(x1 - x0), m_PageHeight),
1066 FXSYS_Div((FX_FLOAT)(y1 - y0), m_PageHeight), 1066 FXSYS_Div((FX_FLOAT)(y1 - y0), m_PageHeight),
1067 (FX_FLOAT)x0, (FX_FLOAT)y0); 1067 (FX_FLOAT)x0, (FX_FLOAT)y0);
1068 matrix = m_PageMatrix; 1068 matrix = m_PageMatrix;
1069 matrix.Concat(display_matrix); 1069 matrix.Concat(display_matrix);
1070 } 1070 }
1071 CPDF_ParseOptions::CPDF_ParseOptions() 1071 CPDF_ParseOptions::CPDF_ParseOptions()
1072 { 1072 {
1073 m_bTextOnly = false; 1073 m_bTextOnly = FALSE;
1074 m_bMarkedContent = true; 1074 m_bMarkedContent = TRUE;
1075 m_bSeparateForm = true; 1075 m_bSeparateForm = TRUE;
1076 m_bDecodeInlineImage = false; 1076 m_bDecodeInlineImage = FALSE;
1077 } 1077 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/ttgsubtable.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698