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/fpdfdoc/cpdf_annot.h" | 7 #include "core/fpdfdoc/cpdf_annot.h" |
8 | 8 |
9 #include "core/fpdfapi/page/cpdf_form.h" | 9 #include "core/fpdfapi/page/cpdf_form.h" |
10 #include "core/fpdfapi/page/cpdf_page.h" | 10 #include "core/fpdfapi/page/cpdf_page.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 return "Watermark"; | 342 return "Watermark"; |
343 if (nSubtype == CPDF_Annot::Subtype::THREED) | 343 if (nSubtype == CPDF_Annot::Subtype::THREED) |
344 return "3D"; | 344 return "3D"; |
345 if (nSubtype == CPDF_Annot::Subtype::RICHMEDIA) | 345 if (nSubtype == CPDF_Annot::Subtype::RICHMEDIA) |
346 return "RichMedia"; | 346 return "RichMedia"; |
347 if (nSubtype == CPDF_Annot::Subtype::XFAWIDGET) | 347 if (nSubtype == CPDF_Annot::Subtype::XFAWIDGET) |
348 return "XFAWidget"; | 348 return "XFAWidget"; |
349 return ""; | 349 return ""; |
350 } | 350 } |
351 | 351 |
352 FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, | 352 bool CPDF_Annot::DrawAppearance(CPDF_Page* pPage, |
353 CFX_RenderDevice* pDevice, | 353 CFX_RenderDevice* pDevice, |
354 const CFX_Matrix* pUser2Device, | 354 const CFX_Matrix* pUser2Device, |
355 AppearanceMode mode, | 355 AppearanceMode mode, |
356 const CPDF_RenderOptions* pOptions) { | 356 const CPDF_RenderOptions* pOptions) { |
357 if (!ShouldDrawAnnotation()) | 357 if (!ShouldDrawAnnotation()) |
358 return FALSE; | 358 return false; |
359 | 359 |
360 // It might happen that by the time this annotation instance was created, | 360 // It might happen that by the time this annotation instance was created, |
361 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided | 361 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided |
362 // to not "generate" its AP. | 362 // to not "generate" its AP. |
363 // If for a reason the object is no longer hidden, but still does not have | 363 // If for a reason the object is no longer hidden, but still does not have |
364 // its "AP" generated, generate it now. | 364 // its "AP" generated, generate it now. |
365 GenerateAPIfNeeded(); | 365 GenerateAPIfNeeded(); |
366 | 366 |
367 CFX_Matrix matrix; | 367 CFX_Matrix matrix; |
368 CPDF_Form* pForm = | 368 CPDF_Form* pForm = |
369 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); | 369 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); |
370 if (!pForm) { | 370 if (!pForm) { |
371 return FALSE; | 371 return false; |
372 } | 372 } |
373 CPDF_RenderContext context(pPage); | 373 CPDF_RenderContext context(pPage); |
374 context.AppendLayer(pForm, &matrix); | 374 context.AppendLayer(pForm, &matrix); |
375 context.Render(pDevice, pOptions, nullptr); | 375 context.Render(pDevice, pOptions, nullptr); |
376 return TRUE; | 376 return true; |
377 } | 377 } |
378 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage, | 378 bool CPDF_Annot::DrawInContext(const CPDF_Page* pPage, |
379 CPDF_RenderContext* pContext, | 379 CPDF_RenderContext* pContext, |
380 const CFX_Matrix* pUser2Device, | 380 const CFX_Matrix* pUser2Device, |
381 AppearanceMode mode) { | 381 AppearanceMode mode) { |
382 if (!ShouldDrawAnnotation()) | 382 if (!ShouldDrawAnnotation()) |
383 return FALSE; | 383 return false; |
384 | 384 |
385 // It might happen that by the time this annotation instance was created, | 385 // It might happen that by the time this annotation instance was created, |
386 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided | 386 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided |
387 // to not "generate" its AP. | 387 // to not "generate" its AP. |
388 // If for a reason the object is no longer hidden, but still does not have | 388 // If for a reason the object is no longer hidden, but still does not have |
389 // its "AP" generated, generate it now. | 389 // its "AP" generated, generate it now. |
390 GenerateAPIfNeeded(); | 390 GenerateAPIfNeeded(); |
391 | 391 |
392 CFX_Matrix matrix; | 392 CFX_Matrix matrix; |
393 CPDF_Form* pForm = | 393 CPDF_Form* pForm = |
394 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); | 394 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); |
395 if (!pForm) { | 395 if (!pForm) { |
396 return FALSE; | 396 return false; |
397 } | 397 } |
398 pContext->AppendLayer(pForm, &matrix); | 398 pContext->AppendLayer(pForm, &matrix); |
399 return TRUE; | 399 return true; |
400 } | 400 } |
401 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, | 401 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, |
402 const CFX_Matrix* pUser2Device, | 402 const CFX_Matrix* pUser2Device, |
403 const CPDF_RenderOptions* pOptions) { | 403 const CPDF_RenderOptions* pOptions) { |
404 if (GetSubtype() == CPDF_Annot::Subtype::POPUP) | 404 if (GetSubtype() == CPDF_Annot::Subtype::POPUP) |
405 return; | 405 return; |
406 | 406 |
407 uint32_t annot_flags = GetFlags(); | 407 uint32_t annot_flags = GetFlags(); |
408 if (annot_flags & ANNOTFLAG_HIDDEN) { | 408 if (annot_flags & ANNOTFLAG_HIDDEN) { |
409 return; | 409 return; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 CFX_PathData path; | 490 CFX_PathData path; |
491 width /= 2; | 491 width /= 2; |
492 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, | 492 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, |
493 rect.top - width); | 493 rect.top - width); |
494 int fill_type = 0; | 494 int fill_type = 0; |
495 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { | 495 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { |
496 fill_type |= FXFILL_NOPATHSMOOTH; | 496 fill_type |= FXFILL_NOPATHSMOOTH; |
497 } | 497 } |
498 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); | 498 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); |
499 } | 499 } |
OLD | NEW |