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

Side by Side Diff: core/fpdfdoc/cpdf_annot.cpp

Issue 2323203002: Define behaviors of FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw. (Closed)
Patch Set: roll DEPS 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
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/fpdfdoc/include/cpdf_annot.h" 7 #include "core/fpdfdoc/include/cpdf_annot.h"
8 8
9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 else if (m_nSubtype == CPDF_Annot::Subtype::SQUIGGLY) 66 else if (m_nSubtype == CPDF_Annot::Subtype::SQUIGGLY)
67 CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, m_pAnnotDict); 67 CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, m_pAnnotDict);
68 else if (m_nSubtype == CPDF_Annot::Subtype::STRIKEOUT) 68 else if (m_nSubtype == CPDF_Annot::Subtype::STRIKEOUT)
69 CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, m_pAnnotDict); 69 CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, m_pAnnotDict);
70 else if (m_nSubtype == CPDF_Annot::Subtype::TEXT) 70 else if (m_nSubtype == CPDF_Annot::Subtype::TEXT)
71 CPVT_GenerateAP::GenerateTextAP(m_pDocument, m_pAnnotDict); 71 CPVT_GenerateAP::GenerateTextAP(m_pDocument, m_pAnnotDict);
72 else if (m_nSubtype == CPDF_Annot::Subtype::UNDERLINE) 72 else if (m_nSubtype == CPDF_Annot::Subtype::UNDERLINE)
73 CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict); 73 CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict);
74 } 74 }
75 75
76 bool CPDF_Annot::ShouldDrawAnnotation() {
77 if (IsAnnotationHidden(m_pAnnotDict))
78 return false;
79
80 if (m_nSubtype == CPDF_Annot::Subtype::POPUP && !m_bOpenState)
81 return false;
82
83 return true;
84 }
85
76 void CPDF_Annot::ClearCachedAP() { 86 void CPDF_Annot::ClearCachedAP() {
77 m_APMap.clear(); 87 m_APMap.clear();
78 } 88 }
79 89
80 CPDF_Annot::Subtype CPDF_Annot::GetSubtype() const { 90 CPDF_Annot::Subtype CPDF_Annot::GetSubtype() const {
81 return m_nSubtype; 91 return m_nSubtype;
82 } 92 }
83 93
84 CFX_FloatRect CPDF_Annot::GetRect() const { 94 CFX_FloatRect CPDF_Annot::GetRect() const {
85 if (!m_pAnnotDict) 95 if (!m_pAnnotDict)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 if (nSubtype == CPDF_Annot::Subtype::XFAWIDGET) 297 if (nSubtype == CPDF_Annot::Subtype::XFAWIDGET)
288 return "XFAWidget"; 298 return "XFAWidget";
289 return ""; 299 return "";
290 } 300 }
291 301
292 FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, 302 FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage,
293 CFX_RenderDevice* pDevice, 303 CFX_RenderDevice* pDevice,
294 const CFX_Matrix* pUser2Device, 304 const CFX_Matrix* pUser2Device,
295 AppearanceMode mode, 305 AppearanceMode mode,
296 const CPDF_RenderOptions* pOptions) { 306 const CPDF_RenderOptions* pOptions) {
297 if (IsAnnotationHidden(m_pAnnotDict)) 307 if (!ShouldDrawAnnotation())
298 return FALSE;
299
300 if (m_nSubtype == CPDF_Annot::Subtype::POPUP && !m_bOpenState)
301 return FALSE; 308 return FALSE;
302 309
303 // It might happen that by the time this annotation instance was created, 310 // It might happen that by the time this annotation instance was created,
304 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided 311 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided
305 // to not "generate" its AP. 312 // to not "generate" its AP.
306 // If for a reason the object is no longer hidden, but still does not have 313 // If for a reason the object is no longer hidden, but still does not have
307 // its "AP" generated, generate it now. 314 // its "AP" generated, generate it now.
308 GenerateAPIfNeeded(); 315 GenerateAPIfNeeded();
309 316
310 CFX_Matrix matrix; 317 CFX_Matrix matrix;
311 CPDF_Form* pForm = 318 CPDF_Form* pForm =
312 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); 319 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix);
313 if (!pForm) { 320 if (!pForm) {
314 return FALSE; 321 return FALSE;
315 } 322 }
316 CPDF_RenderContext context(pPage); 323 CPDF_RenderContext context(pPage);
317 context.AppendLayer(pForm, &matrix); 324 context.AppendLayer(pForm, &matrix);
318 context.Render(pDevice, pOptions, nullptr); 325 context.Render(pDevice, pOptions, nullptr);
319 return TRUE; 326 return TRUE;
320 } 327 }
321 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage, 328 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage,
322 CPDF_RenderContext* pContext, 329 CPDF_RenderContext* pContext,
323 const CFX_Matrix* pUser2Device, 330 const CFX_Matrix* pUser2Device,
324 AppearanceMode mode) { 331 AppearanceMode mode) {
332 if (!ShouldDrawAnnotation())
333 return FALSE;
334
335 // It might happen that by the time this annotation instance was created,
336 // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided
337 // to not "generate" its AP.
338 // If for a reason the object is no longer hidden, but still does not have
339 // its "AP" generated, generate it now.
340 GenerateAPIfNeeded();
341
325 CFX_Matrix matrix; 342 CFX_Matrix matrix;
326 CPDF_Form* pForm = 343 CPDF_Form* pForm =
327 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); 344 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix);
328 if (!pForm) { 345 if (!pForm) {
329 return FALSE; 346 return FALSE;
330 } 347 }
331 pContext->AppendLayer(pForm, &matrix); 348 pContext->AppendLayer(pForm, &matrix);
332 return TRUE; 349 return TRUE;
333 } 350 }
334 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, 351 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 CFX_PathData path; 440 CFX_PathData path;
424 width /= 2; 441 width /= 2;
425 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, 442 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
426 rect.top - width); 443 rect.top - width);
427 int fill_type = 0; 444 int fill_type = 0;
428 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { 445 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
429 fill_type |= FXFILL_NOPATHSMOOTH; 446 fill_type |= FXFILL_NOPATHSMOOTH;
430 } 447 }
431 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); 448 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
432 } 449 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h ('k') | core/fpdfdoc/include/cpdf_annot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698