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

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

Issue 2292363002: Make CPDF_GraphState have a CPDF_GraphStateData instead of inheriting (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nits Created 4 years, 3 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 | « BUILD.gn ('k') | core/fpdfapi/fpdf_page/cpdf_graphstate.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/cpdf_allstates.h" 7 #include "core/fpdfapi/fpdf_page/cpdf_allstates.h"
8 8
9 #include "core/fpdfapi/fpdf_page/pageint.h" 9 #include "core/fpdfapi/fpdf_page/pageint.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
(...skipping 27 matching lines...) Expand all
38 m_TextLineX = src.m_TextLineX; 38 m_TextLineX = src.m_TextLineX;
39 m_TextLineY = src.m_TextLineY; 39 m_TextLineY = src.m_TextLineY;
40 m_TextLeading = src.m_TextLeading; 40 m_TextLeading = src.m_TextLeading;
41 m_TextRise = src.m_TextRise; 41 m_TextRise = src.m_TextRise;
42 m_TextHorzScale = src.m_TextHorzScale; 42 m_TextHorzScale = src.m_TextHorzScale;
43 } 43 }
44 44
45 void CPDF_AllStates::SetLineDash(CPDF_Array* pArray, 45 void CPDF_AllStates::SetLineDash(CPDF_Array* pArray,
46 FX_FLOAT phase, 46 FX_FLOAT phase,
47 FX_FLOAT scale) { 47 FX_FLOAT scale) {
48 CFX_GraphStateData* pData = m_GraphState.GetPrivateCopy(); 48 m_GraphState.SetLineDash(pArray, phase, scale);
49 pData->m_DashPhase = phase * scale;
50 pData->SetDashCount(static_cast<int>(pArray->GetCount()));
51 for (size_t i = 0; i < pArray->GetCount(); i++)
52 pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale;
53 } 49 }
54 50
55 void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, 51 void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
56 CPDF_StreamContentParser* pParser) { 52 CPDF_StreamContentParser* pParser) {
57 CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetPrivateCopy(); 53 CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetPrivateCopy();
58 for (const auto& it : *pGS) { 54 for (const auto& it : *pGS) {
59 const CFX_ByteString& key_str = it.first; 55 const CFX_ByteString& key_str = it.first;
60 CPDF_Object* pElement = it.second; 56 CPDF_Object* pElement = it.second;
61 CPDF_Object* pObject = pElement ? pElement->GetDirect() : nullptr; 57 CPDF_Object* pObject = pElement ? pElement->GetDirect() : nullptr;
62 if (!pObject) 58 if (!pObject)
63 continue; 59 continue;
64 60
65 uint32_t key = key_str.GetID(); 61 uint32_t key = key_str.GetID();
66 switch (key) { 62 switch (key) {
67 case FXBSTR_ID('L', 'W', 0, 0): 63 case FXBSTR_ID('L', 'W', 0, 0):
68 m_GraphState.GetPrivateCopy()->m_LineWidth = pObject->GetNumber(); 64 m_GraphState.SetLineWidth(pObject->GetNumber());
69 break; 65 break;
70 case FXBSTR_ID('L', 'C', 0, 0): 66 case FXBSTR_ID('L', 'C', 0, 0):
71 m_GraphState.GetPrivateCopy()->m_LineCap = 67 m_GraphState.SetLineCap(
72 (CFX_GraphStateData::LineCap)pObject->GetInteger(); 68 static_cast<CFX_GraphStateData::LineCap>(pObject->GetInteger()));
73 break; 69 break;
74 case FXBSTR_ID('L', 'J', 0, 0): 70 case FXBSTR_ID('L', 'J', 0, 0):
75 m_GraphState.GetPrivateCopy()->m_LineJoin = 71 m_GraphState.SetLineJoin(
76 (CFX_GraphStateData::LineJoin)pObject->GetInteger(); 72 static_cast<CFX_GraphStateData::LineJoin>(pObject->GetInteger()));
77 break; 73 break;
78 case FXBSTR_ID('M', 'L', 0, 0): 74 case FXBSTR_ID('M', 'L', 0, 0):
79 m_GraphState.GetPrivateCopy()->m_MiterLimit = pObject->GetNumber(); 75 m_GraphState.SetMiterLimit(pObject->GetNumber());
80 break; 76 break;
81 case FXBSTR_ID('D', 0, 0, 0): { 77 case FXBSTR_ID('D', 0, 0, 0): {
82 CPDF_Array* pDash = pObject->AsArray(); 78 CPDF_Array* pDash = pObject->AsArray();
83 if (!pDash) 79 if (!pDash)
84 break; 80 break;
85 81
86 CPDF_Array* pArray = pDash->GetArrayAt(0); 82 CPDF_Array* pArray = pDash->GetArrayAt(0);
87 if (!pArray) 83 if (!pArray)
88 break; 84 break;
89 85
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 case FXBSTR_ID('A', 'I', 'S', 0): 173 case FXBSTR_ID('A', 'I', 'S', 0):
178 pGeneralState->m_AlphaSource = pObject->GetInteger(); 174 pGeneralState->m_AlphaSource = pObject->GetInteger();
179 break; 175 break;
180 case FXBSTR_ID('T', 'K', 0, 0): 176 case FXBSTR_ID('T', 'K', 0, 0):
181 pGeneralState->m_TextKnockout = pObject->GetInteger(); 177 pGeneralState->m_TextKnockout = pObject->GetInteger();
182 break; 178 break;
183 } 179 }
184 } 180 }
185 pGeneralState->m_Matrix = m_CTM; 181 pGeneralState->m_Matrix = m_CTM;
186 } 182 }
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | core/fpdfapi/fpdf_page/cpdf_graphstate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698