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

Side by Side Diff: core/src/fpdfdoc/doc_annot.cpp

Issue 1519693002: Merge to XFA: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA-specific changes Created 5 years 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 "core/include/fpdfapi/fpdf_pageobj.h" 7 #include "core/include/fpdfapi/fpdf_pageobj.h"
8 #include "core/include/fpdfdoc/fpdf_doc.h" 8 #include "core/include/fpdfdoc/fpdf_doc.h"
9 #include "third_party/base/nonstd_unique_ptr.h" 9 #include "third_party/base/nonstd_unique_ptr.h"
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 CPDF_AnnotList::~CPDF_AnnotList() { 45 CPDF_AnnotList::~CPDF_AnnotList() {
46 for (CPDF_Annot* annot : m_AnnotList) 46 for (CPDF_Annot* annot : m_AnnotList)
47 delete annot; 47 delete annot;
48 } 48 }
49 49
50 void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage, 50 void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage,
51 CFX_RenderDevice* pDevice, 51 CFX_RenderDevice* pDevice,
52 CPDF_RenderContext* pContext, 52 CPDF_RenderContext* pContext,
53 FX_BOOL bPrinting, 53 FX_BOOL bPrinting,
54 CFX_AffineMatrix* pMatrix, 54 CFX_Matrix* pMatrix,
55 FX_BOOL bWidgetPass, 55 FX_BOOL bWidgetPass,
56 CPDF_RenderOptions* pOptions, 56 CPDF_RenderOptions* pOptions,
57 FX_RECT* clip_rect) { 57 FX_RECT* clip_rect) {
58 for (CPDF_Annot* pAnnot : m_AnnotList) { 58 for (CPDF_Annot* pAnnot : m_AnnotList) {
59 FX_BOOL bWidget = pAnnot->GetSubType() == "Widget"; 59 FX_BOOL bWidget = pAnnot->GetSubType() == "Widget";
60 if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget)) 60 if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget))
61 continue; 61 continue;
62 62
63 FX_DWORD annot_flags = pAnnot->GetFlags(); 63 FX_DWORD annot_flags = pAnnot->GetFlags();
64 if (annot_flags & ANNOTFLAG_HIDDEN) 64 if (annot_flags & ANNOTFLAG_HIDDEN)
(...skipping 30 matching lines...) Expand all
95 CPDF_Annot::Normal, pOptions)) { 95 CPDF_Annot::Normal, pOptions)) {
96 pAnnot->DrawBorder(pDevice, &matrix, pOptions); 96 pAnnot->DrawBorder(pDevice, &matrix, pOptions);
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage, 101 void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage,
102 CFX_RenderDevice* pDevice, 102 CFX_RenderDevice* pDevice,
103 CPDF_RenderContext* pContext, 103 CPDF_RenderContext* pContext,
104 FX_BOOL bPrinting, 104 FX_BOOL bPrinting,
105 CFX_AffineMatrix* pUser2Device, 105 CFX_Matrix* pUser2Device,
106 FX_DWORD dwAnnotFlags, 106 FX_DWORD dwAnnotFlags,
107 CPDF_RenderOptions* pOptions, 107 CPDF_RenderOptions* pOptions,
108 FX_RECT* pClipRect) { 108 FX_RECT* pClipRect) {
109 if (dwAnnotFlags & 0x01) { 109 if (dwAnnotFlags & 0x01) {
110 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, FALSE, 110 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, FALSE,
111 pOptions, pClipRect); 111 pOptions, pClipRect);
112 } 112 }
113 if (dwAnnotFlags & 0x02) { 113 if (dwAnnotFlags & 0x02) {
114 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, TRUE, 114 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, TRUE,
115 pOptions, pClipRect); 115 pOptions, pClipRect);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 CPDF_Form* pNewForm = 199 CPDF_Form* pNewForm =
200 new CPDF_Form(m_pList->GetDocument(), pPage->m_pResources, pStream); 200 new CPDF_Form(m_pList->GetDocument(), pPage->m_pResources, pStream);
201 pNewForm->ParseContent(nullptr, nullptr, nullptr, nullptr); 201 pNewForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
202 m_APMap.SetAt(pStream, pNewForm); 202 m_APMap.SetAt(pStream, pNewForm);
203 return pNewForm; 203 return pNewForm;
204 } 204 }
205 205
206 static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage, 206 static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage,
207 CPDF_Annot* pAnnot, 207 CPDF_Annot* pAnnot,
208 CPDF_Annot::AppearanceMode mode, 208 CPDF_Annot::AppearanceMode mode,
209 const CFX_AffineMatrix* pUser2Device, 209 const CFX_Matrix* pUser2Device,
210 CFX_Matrix& matrix) { 210 CFX_Matrix& matrix) {
211 CPDF_Form* pForm = pAnnot->GetAPForm(pPage, mode); 211 CPDF_Form* pForm = pAnnot->GetAPForm(pPage, mode);
212 if (!pForm) { 212 if (!pForm) {
213 return NULL; 213 return NULL;
214 } 214 }
215 CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRect(FX_BSTRC("BBox")); 215 CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRect(FX_BSTRC("BBox"));
216 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrix(FX_BSTRC("Matrix")); 216 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrix(FX_BSTRC("Matrix"));
217 form_matrix.TransformRect(form_bbox); 217 form_matrix.TransformRect(form_bbox);
218 CPDF_Rect arect; 218 CPDF_Rect arect;
219 pAnnot->GetRect(arect); 219 pAnnot->GetRect(arect);
220 matrix.MatchRect(arect, form_bbox); 220 matrix.MatchRect(arect, form_bbox);
221 matrix.Concat(*pUser2Device); 221 matrix.Concat(*pUser2Device);
222 return pForm; 222 return pForm;
223 } 223 }
224 FX_BOOL CPDF_Annot::DrawAppearance(const CPDF_Page* pPage, 224 FX_BOOL CPDF_Annot::DrawAppearance(const CPDF_Page* pPage,
225 CFX_RenderDevice* pDevice, 225 CFX_RenderDevice* pDevice,
226 const CFX_AffineMatrix* pUser2Device, 226 const CFX_Matrix* pUser2Device,
227 AppearanceMode mode, 227 AppearanceMode mode,
228 const CPDF_RenderOptions* pOptions) { 228 const CPDF_RenderOptions* pOptions) {
229 CFX_Matrix matrix; 229 CFX_Matrix matrix;
230 CPDF_Form* pForm = 230 CPDF_Form* pForm =
231 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); 231 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix);
232 if (!pForm) { 232 if (!pForm) {
233 return FALSE; 233 return FALSE;
234 } 234 }
235 CPDF_RenderContext context; 235 CPDF_RenderContext context;
236 context.Create((CPDF_Page*)pPage); 236 context.Create((CPDF_Page*)pPage);
237 context.DrawObjectList(pDevice, pForm, &matrix, pOptions); 237 context.DrawObjectList(pDevice, pForm, &matrix, pOptions);
238 return TRUE; 238 return TRUE;
239 } 239 }
240 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage, 240 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage,
241 const CPDF_RenderContext* pContext, 241 const CPDF_RenderContext* pContext,
242 const CFX_AffineMatrix* pUser2Device, 242 const CFX_Matrix* pUser2Device,
243 AppearanceMode mode) { 243 AppearanceMode mode) {
244 CFX_Matrix matrix; 244 CFX_Matrix matrix;
245 CPDF_Form* pForm = 245 CPDF_Form* pForm =
246 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); 246 FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix);
247 if (!pForm) { 247 if (!pForm) {
248 return FALSE; 248 return FALSE;
249 } 249 }
250 ((CPDF_RenderContext*)pContext)->AppendObjectList(pForm, &matrix); 250 ((CPDF_RenderContext*)pContext)->AppendObjectList(pForm, &matrix);
251 return TRUE; 251 return TRUE;
252 } 252 }
253 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, 253 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
254 const CFX_AffineMatrix* pUser2Device, 254 const CFX_Matrix* pUser2Device,
255 const CPDF_RenderOptions* pOptions) { 255 const CPDF_RenderOptions* pOptions) {
256 if (GetSubType() == "Popup") { 256 if (GetSubType() == "Popup") {
257 return; 257 return;
258 } 258 }
259 FX_DWORD annot_flags = GetFlags(); 259 FX_DWORD annot_flags = GetFlags();
260 if (annot_flags & ANNOTFLAG_HIDDEN) { 260 if (annot_flags & ANNOTFLAG_HIDDEN) {
261 return; 261 return;
262 } 262 }
263 FX_BOOL bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || 263 FX_BOOL bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER ||
264 (pOptions && (pOptions->m_Flags & RENDER_PRINTPREVIEW)); 264 (pOptions && (pOptions->m_Flags & RENDER_PRINTPREVIEW));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 CPDF_PathData path; 343 CPDF_PathData path;
344 width /= 2; 344 width /= 2;
345 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, 345 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
346 rect.top - width); 346 rect.top - width);
347 int fill_type = 0; 347 int fill_type = 0;
348 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { 348 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
349 fill_type |= FXFILL_NOPATHSMOOTH; 349 fill_type |= FXFILL_NOPATHSMOOTH;
350 } 350 }
351 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); 351 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
352 } 352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698