| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |