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

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

Issue 1965243002: Clean up CPDF_Color and some related code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: 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 | « core/fpdfapi/fpdf_page/cpdf_colorstate.cpp ('k') | core/fpdfapi/fpdf_page/include/cpdf_color.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/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if (param.m_Type == ContentParam::NUMBER) { 379 if (param.m_Type == ContentParam::NUMBER) {
380 return param.m_Number.m_bInteger ? (FX_FLOAT)param.m_Number.m_Integer 380 return param.m_Number.m_bInteger ? (FX_FLOAT)param.m_Number.m_Integer
381 : param.m_Number.m_Float; 381 : param.m_Number.m_Float;
382 } 382 }
383 if (param.m_Type == 0 && param.m_pObject) { 383 if (param.m_Type == 0 && param.m_pObject) {
384 return param.m_pObject->GetNumber(); 384 return param.m_pObject->GetNumber();
385 } 385 }
386 return 0; 386 return 0;
387 } 387 }
388 388
389 FX_FLOAT CPDF_StreamContentParser::GetNumber16(uint32_t index) {
390 return GetNumber(index);
391 }
392
393 void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj, 389 void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj,
394 FX_BOOL bColor, 390 FX_BOOL bColor,
395 FX_BOOL bText, 391 FX_BOOL bText,
396 FX_BOOL bGraph) { 392 FX_BOOL bGraph) {
397 pObj->m_GeneralState = m_pCurStates->m_GeneralState; 393 pObj->m_GeneralState = m_pCurStates->m_GeneralState;
398 pObj->m_ClipPath = m_pCurStates->m_ClipPath; 394 pObj->m_ClipPath = m_pCurStates->m_ClipPath;
399 pObj->m_ContentMark = m_CurContentMark; 395 pObj->m_ContentMark = m_CurContentMark;
400 if (bColor) { 396 if (bColor) {
401 pObj->m_ColorState = m_pCurStates->m_ColorState; 397 pObj->m_ColorState = m_pCurStates->m_ColorState;
402 } 398 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 m_pCurStates->m_TextLineY = 0; 664 m_pCurStates->m_TextLineY = 0;
669 } 665 }
670 666
671 void CPDF_StreamContentParser::Handle_CurveTo_123() { 667 void CPDF_StreamContentParser::Handle_CurveTo_123() {
672 AddPathPoint(GetNumber(5), GetNumber(4), FXPT_BEZIERTO); 668 AddPathPoint(GetNumber(5), GetNumber(4), FXPT_BEZIERTO);
673 AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO); 669 AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
674 AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO); 670 AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
675 } 671 }
676 672
677 void CPDF_StreamContentParser::Handle_ConcatMatrix() { 673 void CPDF_StreamContentParser::Handle_ConcatMatrix() {
678 FX_FLOAT a2 = GetNumber16(5), b2 = GetNumber16(4), c2 = GetNumber16(3), 674 CFX_Matrix new_matrix(GetNumber(5), GetNumber(4), GetNumber(3), GetNumber(2),
679 d2 = GetNumber16(2); 675 GetNumber(1), GetNumber(0));
680 FX_FLOAT e2 = GetNumber(1), f2 = GetNumber(0);
681 CFX_Matrix new_matrix(a2, b2, c2, d2, e2, f2);
682 new_matrix.Concat(m_pCurStates->m_CTM); 676 new_matrix.Concat(m_pCurStates->m_CTM);
683 m_pCurStates->m_CTM = new_matrix; 677 m_pCurStates->m_CTM = new_matrix;
684 OnChangeTextMatrix(); 678 OnChangeTextMatrix();
685 } 679 }
686 680
687 void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() { 681 void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
688 CFX_ByteString csname = GetString(0); 682 CFX_ByteString csname = GetString(0);
689 CPDF_ColorSpace* pCS = FindColorSpace(csname); 683 CPDF_ColorSpace* pCS = FindColorSpace(csname);
690 if (!pCS) { 684 if (!pCS) {
691 return; 685 return;
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 AddTextObject(pStrs, fInitKerning, pKerning, iSegment); 1353 AddTextObject(pStrs, fInitKerning, pKerning, iSegment);
1360 delete[] pStrs; 1354 delete[] pStrs;
1361 FX_Free(pKerning); 1355 FX_Free(pKerning);
1362 } 1356 }
1363 1357
1364 void CPDF_StreamContentParser::Handle_SetTextLeading() { 1358 void CPDF_StreamContentParser::Handle_SetTextLeading() {
1365 m_pCurStates->m_TextLeading = GetNumber(0); 1359 m_pCurStates->m_TextLeading = GetNumber(0);
1366 } 1360 }
1367 1361
1368 void CPDF_StreamContentParser::Handle_SetTextMatrix() { 1362 void CPDF_StreamContentParser::Handle_SetTextMatrix() {
1369 m_pCurStates->m_TextMatrix.Set(GetNumber16(5), GetNumber16(4), GetNumber16(3), 1363 m_pCurStates->m_TextMatrix.Set(GetNumber(5), GetNumber(4), GetNumber(3),
1370 GetNumber16(2), GetNumber(1), GetNumber(0)); 1364 GetNumber(2), GetNumber(1), GetNumber(0));
1371 OnChangeTextMatrix(); 1365 OnChangeTextMatrix();
1372 m_pCurStates->m_TextX = 0; 1366 m_pCurStates->m_TextX = 0;
1373 m_pCurStates->m_TextY = 0; 1367 m_pCurStates->m_TextY = 0;
1374 m_pCurStates->m_TextLineX = 0; 1368 m_pCurStates->m_TextLineX = 0;
1375 m_pCurStates->m_TextLineY = 0; 1369 m_pCurStates->m_TextLineY = 0;
1376 } 1370 }
1377 1371
1378 void CPDF_StreamContentParser::OnChangeTextMatrix() { 1372 void CPDF_StreamContentParser::OnChangeTextMatrix() {
1379 CFX_Matrix text_matrix(m_pCurStates->m_TextHorzScale, 0.0f, 0.0f, 1.0f, 0.0f, 1373 CFX_Matrix text_matrix(m_pCurStates->m_TextHorzScale, 0.0f, 0.0f, 1.0f, 0.0f,
1380 0.0f); 1374 0.0f);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 } else { 1704 } else {
1711 PDF_ReplaceAbbr(pElement); 1705 PDF_ReplaceAbbr(pElement);
1712 } 1706 }
1713 } 1707 }
1714 break; 1708 break;
1715 } 1709 }
1716 default: 1710 default:
1717 break; 1711 break;
1718 } 1712 }
1719 } 1713 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_colorstate.cpp ('k') | core/fpdfapi/fpdf_page/include/cpdf_color.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698