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

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

Issue 1418623011: Give names to the shading types (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month 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 "../../../include/fpdfapi/fpdf_serial.h" 9 #include "../../../include/fpdfapi/fpdf_serial.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 if (nvalues != nargs) { 1085 if (nvalues != nargs) {
1086 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); 1086 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
1087 if (pPattern) { 1087 if (pPattern) {
1088 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues); 1088 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues);
1089 } 1089 }
1090 } else { 1090 } else {
1091 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues); 1091 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues);
1092 } 1092 }
1093 FX_Free(values); 1093 FX_Free(values);
1094 } 1094 }
1095 CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream, 1095 CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
1096 int type, 1096 ShadingType type,
1097 const CFX_AffineMatrix* pMatrix, 1097 const CFX_AffineMatrix* pMatrix,
1098 CPDF_Function** pFuncs, 1098 CPDF_Function** pFuncs,
1099 int nFuncs, 1099 int nFuncs,
1100 CPDF_ColorSpace* pCS); 1100 CPDF_ColorSpace* pCS);
1101
1102 static bool IsMeshShading(ShadingType type) {
1103 return type == kFreeFormGouraudTriangleMeshShading ||
1104 type == kLatticeFormGouraudTriangleMeshShading ||
1105 type == kCoonsPatchMeshShading ||
1106 type == kTensorProductPatchMeshShading;
1107 }
1108
1101 void CPDF_StreamContentParser::Handle_ShadeFill() { 1109 void CPDF_StreamContentParser::Handle_ShadeFill() {
1102 if (m_Options.m_bTextOnly) { 1110 if (m_Options.m_bTextOnly) {
1103 return; 1111 return;
1104 } 1112 }
1105 CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE); 1113 CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE);
1106 if (pPattern == NULL) { 1114 if (pPattern == NULL) {
1107 return; 1115 return;
1108 } 1116 }
1109 if (pPattern->m_PatternType != PATTERN_SHADING) { 1117 if (pPattern->m_PatternType != PATTERN_SHADING) {
1110 return; 1118 return;
1111 } 1119 }
1112 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern; 1120 CPDF_ShadingPattern* pShading = (CPDF_ShadingPattern*)pPattern;
1113 if (!pShading->m_bShadingObj) { 1121 if (!pShading->m_bShadingObj) {
1114 return; 1122 return;
1115 } 1123 }
1116 if (!pShading->Load()) { 1124 if (!pShading->Load()) {
1117 return; 1125 return;
1118 } 1126 }
1119 CPDF_ShadingObject* pObj = new CPDF_ShadingObject; 1127 CPDF_ShadingObject* pObj = new CPDF_ShadingObject;
1120 pObj->m_pShading = pShading; 1128 pObj->m_pShading = pShading;
1121 SetGraphicStates(pObj, FALSE, FALSE, FALSE); 1129 SetGraphicStates(pObj, FALSE, FALSE, FALSE);
1122 pObj->m_Matrix = m_pCurStates->m_CTM; 1130 pObj->m_Matrix = m_pCurStates->m_CTM;
1123 pObj->m_Matrix.Concat(m_mtContentToUser); 1131 pObj->m_Matrix.Concat(m_mtContentToUser);
1124 CFX_FloatRect bbox; 1132 CFX_FloatRect bbox;
1125 if (!pObj->m_ClipPath.IsNull()) { 1133 if (!pObj->m_ClipPath.IsNull()) {
1126 bbox = pObj->m_ClipPath.GetClipBox(); 1134 bbox = pObj->m_ClipPath.GetClipBox();
1127 } else { 1135 } else {
1128 bbox = m_BBox; 1136 bbox = m_BBox;
1129 } 1137 }
1130 if (pShading->m_ShadingType >= 4) { 1138 if (IsMeshShading(pShading->m_ShadingType)) {
1131 bbox.Intersect(_GetShadingBBox(ToStream(pShading->m_pShadingObj), 1139 bbox.Intersect(GetShadingBBox(ToStream(pShading->m_pShadingObj),
1132 pShading->m_ShadingType, &pObj->m_Matrix, 1140 pShading->m_ShadingType, &pObj->m_Matrix,
1133 pShading->m_pFunctions, pShading->m_nFuncs, 1141 pShading->m_pFunctions, pShading->m_nFuncs,
1134 pShading->m_pCS)); 1142 pShading->m_pCS));
1135 } 1143 }
1136 pObj->m_Left = bbox.left; 1144 pObj->m_Left = bbox.left;
1137 pObj->m_Right = bbox.right; 1145 pObj->m_Right = bbox.right;
1138 pObj->m_Top = bbox.top; 1146 pObj->m_Top = bbox.top;
1139 pObj->m_Bottom = bbox.bottom; 1147 pObj->m_Bottom = bbox.bottom;
1140 m_pObjectList->m_ObjectList.AddTail(pObj); 1148 m_pObjectList->m_ObjectList.AddTail(pObj);
1141 } 1149 }
1142 void CPDF_StreamContentParser::Handle_SetCharSpace() { 1150 void CPDF_StreamContentParser::Handle_SetCharSpace() {
1143 m_pCurStates->m_TextState.GetModify()->m_CharSpace = GetNumber(0); 1151 m_pCurStates->m_TextState.GetModify()->m_CharSpace = GetNumber(0);
1144 } 1152 }
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 buf.AppendChar((char)code); 1571 buf.AppendChar((char)code);
1564 } 1572 }
1565 bFirst = !bFirst; 1573 bFirst = !bFirst;
1566 } 1574 }
1567 } 1575 }
1568 if (!bFirst) { 1576 if (!bFirst) {
1569 buf.AppendChar((char)code); 1577 buf.AppendChar((char)code);
1570 } 1578 }
1571 return buf.GetByteString(); 1579 return buf.GetByteString();
1572 } 1580 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698