OLD | NEW |
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 "public/fpdf_transformpage.h" | 7 #include "public/fpdf_transformpage.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 216 } |
217 | 217 |
218 DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, | 218 DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, |
219 float bottom, | 219 float bottom, |
220 float right, | 220 float right, |
221 float top) { | 221 float top) { |
222 CPDF_ClipPath* pNewClipPath = new CPDF_ClipPath(); | 222 CPDF_ClipPath* pNewClipPath = new CPDF_ClipPath(); |
223 pNewClipPath->MakePrivateCopy(); | 223 pNewClipPath->MakePrivateCopy(); |
224 CPDF_Path Path; | 224 CPDF_Path Path; |
225 Path.MakePrivateCopy(); | 225 Path.MakePrivateCopy(); |
226 Path->AppendRect(left, bottom, right, top); | 226 Path.AppendRect(left, bottom, right, top); |
227 pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, FALSE); | 227 pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, FALSE); |
228 return pNewClipPath; | 228 return pNewClipPath; |
229 } | 229 } |
230 | 230 |
231 DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath) { | 231 DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath) { |
232 delete (CPDF_ClipPath*)clipPath; | 232 delete (CPDF_ClipPath*)clipPath; |
233 } | 233 } |
234 | 234 |
235 void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) { | 235 void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) { |
236 const CFX_PathData* pPathData = path.GetObject(); | 236 const CFX_PathData* pPathData = path.GetObject(); |
237 if (!pPathData) | 237 if (!pPathData) |
238 return; | 238 return; |
239 | 239 |
240 FX_PATHPOINT* pPoints = pPathData->GetPoints(); | 240 FX_PATHPOINT* pPoints = pPathData->GetPoints(); |
241 | 241 |
242 if (path->IsRect()) { | 242 if (path.IsRect()) { |
243 buf << (pPoints[0].m_PointX) << " " << (pPoints[0].m_PointY) << " " | 243 buf << (pPoints[0].m_PointX) << " " << (pPoints[0].m_PointY) << " " |
244 << (pPoints[2].m_PointX - pPoints[0].m_PointX) << " " | 244 << (pPoints[2].m_PointX - pPoints[0].m_PointX) << " " |
245 << (pPoints[2].m_PointY - pPoints[0].m_PointY) << " re\n"; | 245 << (pPoints[2].m_PointY - pPoints[0].m_PointY) << " re\n"; |
246 return; | 246 return; |
247 } | 247 } |
248 | 248 |
249 CFX_ByteString temp; | 249 CFX_ByteString temp; |
250 for (int i = 0; i < pPathData->GetPointCount(); i++) { | 250 for (int i = 0; i < pPathData->GetPointCount(); i++) { |
251 buf << (pPoints[i].m_PointX) << " " << (pPoints[i].m_PointY); | 251 buf << (pPoints[i].m_PointX) << " " << (pPoints[i].m_PointY); |
252 int point_type = pPoints[i].m_Flag & FXPT_TYPE; | 252 int point_type = pPoints[i].m_Flag & FXPT_TYPE; |
(...skipping 30 matching lines...) Expand all Loading... |
283 pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; | 283 pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; |
284 if (!pContentObj) | 284 if (!pContentObj) |
285 return; | 285 return; |
286 | 286 |
287 CFX_ByteTextBuf strClip; | 287 CFX_ByteTextBuf strClip; |
288 CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; | 288 CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; |
289 uint32_t i; | 289 uint32_t i; |
290 for (i = 0; i < pClipPath->GetPathCount(); i++) { | 290 for (i = 0; i < pClipPath->GetPathCount(); i++) { |
291 CPDF_Path path = pClipPath->GetPath(i); | 291 CPDF_Path path = pClipPath->GetPath(i); |
292 int iClipType = pClipPath->GetClipType(i); | 292 int iClipType = pClipPath->GetClipType(i); |
293 if (path->GetPointCount() == 0) { | 293 if (path.GetPointCount() == 0) { |
294 // Empty clipping (totally clipped out) | 294 // Empty clipping (totally clipped out) |
295 strClip << "0 0 m W n "; | 295 strClip << "0 0 m W n "; |
296 } else { | 296 } else { |
297 OutputPath(strClip, path); | 297 OutputPath(strClip, path); |
298 if (iClipType == FXFILL_WINDING) | 298 if (iClipType == FXFILL_WINDING) |
299 strClip << "W n\n"; | 299 strClip << "W n\n"; |
300 else | 300 else |
301 strClip << "W* n\n"; | 301 strClip << "W* n\n"; |
302 } | 302 } |
303 } | 303 } |
(...skipping 22 matching lines...) Expand all Loading... |
326 } else if (pDirectObj->IsStream()) { | 326 } else if (pDirectObj->IsStream()) { |
327 pContentArray = new CPDF_Array(); | 327 pContentArray = new CPDF_Array(); |
328 pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 328 pContentArray->AddReference(pDoc, pStream->GetObjNum()); |
329 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 329 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); |
330 pPageDic->SetAtReference("Contents", pDoc, | 330 pPageDic->SetAtReference("Contents", pDoc, |
331 pDoc->AddIndirectObject(pContentArray)); | 331 pDoc->AddIndirectObject(pContentArray)); |
332 } | 332 } |
333 } | 333 } |
334 } | 334 } |
335 } | 335 } |
OLD | NEW |