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

Side by Side Diff: xfa/fde/fde_gedevice.cpp

Issue 2031873003: Get rid of NULLs in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_fpdfsdk
Patch Set: Created 4 years, 6 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
« no previous file with comments | « xfa/fde/fde_gedevice.h ('k') | xfa/fde/fde_iterator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "xfa/fde/fde_gedevice.h" 7 #include "xfa/fde/fde_gedevice.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 (int32_t)FXSYS_ceil(rtClip.right()), 52 (int32_t)FXSYS_ceil(rtClip.right()),
53 (int32_t)FXSYS_ceil(rtClip.bottom()))); 53 (int32_t)FXSYS_ceil(rtClip.bottom())));
54 } 54 }
55 const CFX_RectF& CFDE_RenderDevice::GetClipRect() { 55 const CFX_RectF& CFDE_RenderDevice::GetClipRect() {
56 return m_rtClip; 56 return m_rtClip;
57 } 57 }
58 FX_BOOL CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) { 58 FX_BOOL CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) {
59 return FALSE; 59 return FALSE;
60 } 60 }
61 CFDE_Path* CFDE_RenderDevice::GetClipPath() const { 61 CFDE_Path* CFDE_RenderDevice::GetClipPath() const {
62 return NULL; 62 return nullptr;
63 } 63 }
64 FX_FLOAT CFDE_RenderDevice::GetDpiX() const { 64 FX_FLOAT CFDE_RenderDevice::GetDpiX() const {
65 return 96; 65 return 96;
66 } 66 }
67 FX_FLOAT CFDE_RenderDevice::GetDpiY() const { 67 FX_FLOAT CFDE_RenderDevice::GetDpiY() const {
68 return 96; 68 return 96;
69 } 69 }
70 FX_BOOL CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, 70 FX_BOOL CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib,
71 const CFX_RectF* pSrcRect, 71 const CFX_RectF* pSrcRect,
72 const CFX_RectF& dstRect, 72 const CFX_RectF& dstRect,
73 const CFX_Matrix* pImgMatrix, 73 const CFX_Matrix* pImgMatrix,
74 const CFX_Matrix* pDevMatrix) { 74 const CFX_Matrix* pDevMatrix) {
75 ASSERT(pDib != NULL); 75 ASSERT(pDib);
76 CFX_RectF srcRect; 76 CFX_RectF srcRect;
77 if (pSrcRect) { 77 if (pSrcRect) {
78 srcRect = *pSrcRect; 78 srcRect = *pSrcRect;
79 } else { 79 } else {
80 srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight()); 80 srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight());
81 } 81 }
82 if (srcRect.IsEmpty()) { 82 if (srcRect.IsEmpty()) {
83 return FALSE; 83 return FALSE;
84 } 84 }
85 CFX_Matrix dib2fxdev; 85 CFX_Matrix dib2fxdev;
86 if (pImgMatrix) { 86 if (pImgMatrix) {
87 dib2fxdev = *pImgMatrix; 87 dib2fxdev = *pImgMatrix;
88 } else { 88 } else {
89 dib2fxdev.SetIdentity(); 89 dib2fxdev.SetIdentity();
90 } 90 }
91 dib2fxdev.a = dstRect.width; 91 dib2fxdev.a = dstRect.width;
92 dib2fxdev.d = -dstRect.height; 92 dib2fxdev.d = -dstRect.height;
93 dib2fxdev.e = dstRect.left; 93 dib2fxdev.e = dstRect.left;
94 dib2fxdev.f = dstRect.bottom(); 94 dib2fxdev.f = dstRect.bottom();
95 if (pDevMatrix) { 95 if (pDevMatrix) {
96 dib2fxdev.Concat(*pDevMatrix); 96 dib2fxdev.Concat(*pDevMatrix);
97 } 97 }
98 void* handle = NULL; 98 void* handle = nullptr;
99 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, 99 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0,
100 handle); 100 handle);
101 while (m_pDevice->ContinueDIBits(handle, NULL)) { 101 while (m_pDevice->ContinueDIBits(handle, nullptr)) {
102 } 102 }
103 m_pDevice->CancelDIBits(handle); 103 m_pDevice->CancelDIBits(handle);
104 return handle != NULL; 104 return !!handle;
105 } 105 }
106 FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, 106 FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
107 IFGAS_Font* pFont, 107 IFGAS_Font* pFont,
108 const FXTEXT_CHARPOS* pCharPos, 108 const FXTEXT_CHARPOS* pCharPos,
109 int32_t iCount, 109 int32_t iCount,
110 FX_FLOAT fFontSize, 110 FX_FLOAT fFontSize,
111 const CFX_Matrix* pMatrix) { 111 const CFX_Matrix* pMatrix) {
112 ASSERT(pBrush && pFont && pCharPos && iCount > 0); 112 ASSERT(pBrush && pFont && pCharPos && iCount > 0);
113 CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache(); 113 CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache();
114 CFX_Font* pFxFont = pFont->GetDevFont(); 114 CFX_Font* pFxFont = pFont->GetDevFont();
115 FX_ARGB argb = pBrush->GetColor(); 115 FX_ARGB argb = pBrush->GetColor();
116 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && 116 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
117 !pFxFont->IsItalic()) { 117 !pFxFont->IsItalic()) {
118 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; 118 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
119 FX_FLOAT* pAM; 119 FX_FLOAT* pAM;
120 for (int32_t i = 0; i < iCount; ++i) { 120 for (int32_t i = 0; i < iCount; ++i) {
121 static const FX_FLOAT mc = 0.267949f; 121 static const FX_FLOAT mc = 0.267949f;
122 pAM = pCP->m_AdjustMatrix; 122 pAM = pCP->m_AdjustMatrix;
123 pAM[2] = mc * pAM[0] + pAM[2]; 123 pAM[2] = mc * pAM[0] + pAM[2];
124 pAM[3] = mc * pAM[1] + pAM[3]; 124 pAM[3] = mc * pAM[1] + pAM[3];
125 pCP++; 125 pCP++;
126 } 126 }
127 } 127 }
128 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; 128 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
129 IFGAS_Font* pCurFont = NULL; 129 IFGAS_Font* pCurFont = nullptr;
130 IFGAS_Font* pSTFont = NULL; 130 IFGAS_Font* pSTFont = nullptr;
131 FXTEXT_CHARPOS* pCurCP = NULL; 131 FXTEXT_CHARPOS* pCurCP = nullptr;
132 int32_t iCurCount = 0; 132 int32_t iCurCount = 0;
133 133
134 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 134 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
135 uint32_t dwFontStyle = pFont->GetFontStyles(); 135 uint32_t dwFontStyle = pFont->GetFontStyles();
136 CFX_Font FxFont; 136 CFX_Font FxFont;
137 CFX_SubstFont SubstFxFont; 137 CFX_SubstFont SubstFxFont;
138 FxFont.SetSubstFont(&SubstFxFont); 138 FxFont.SetSubstFont(&SubstFxFont);
139 SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400; 139 SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
140 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; 140 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight;
141 SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0; 141 SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 const CFX_Matrix* pMatrix) { 242 const CFX_Matrix* pMatrix) {
243 CFDE_Path path; 243 CFDE_Path path;
244 path.AddLine(pt1, pt2); 244 path.AddLine(pt1, pt2);
245 return DrawPath(pPen, fPenWidth, &path, pMatrix); 245 return DrawPath(pPen, fPenWidth, &path, pMatrix);
246 } 246 }
247 FX_BOOL CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, 247 FX_BOOL CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen,
248 FX_FLOAT fPenWidth, 248 FX_FLOAT fPenWidth,
249 const CFDE_Path* pPath, 249 const CFDE_Path* pPath,
250 const CFX_Matrix* pMatrix) { 250 const CFX_Matrix* pMatrix) {
251 CFDE_Path* pGePath = (CFDE_Path*)pPath; 251 CFDE_Path* pGePath = (CFDE_Path*)pPath;
252 if (pGePath == NULL) { 252 if (!pGePath)
253 return FALSE; 253 return FALSE;
254 } 254
255 CFX_GraphStateData graphState; 255 CFX_GraphStateData graphState;
256 if (!CreatePen(pPen, fPenWidth, graphState)) { 256 if (!CreatePen(pPen, fPenWidth, graphState)) {
257 return FALSE; 257 return FALSE;
258 } 258 }
259 return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix, 259 return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix,
260 &graphState, 0, pPen->GetColor(), 0); 260 &graphState, 0, pPen->GetColor(), 0);
261 } 261 }
262 FX_BOOL CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen, 262 FX_BOOL CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen,
263 FX_FLOAT fPenWidth, 263 FX_FLOAT fPenWidth,
264 const CFX_PointsF& points, 264 const CFX_PointsF& points,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 const CFX_Matrix* pMatrix) { 323 const CFX_Matrix* pMatrix) {
324 CFDE_Path* pGePath = (CFDE_Path*)pPath; 324 CFDE_Path* pGePath = (CFDE_Path*)pPath;
325 if (!pGePath) 325 if (!pGePath)
326 return FALSE; 326 return FALSE;
327 if (!pBrush) 327 if (!pBrush)
328 return FALSE; 328 return FALSE;
329 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, 329 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr,
330 pBrush->GetColor(), 0, FXFILL_WINDING); 330 pBrush->GetColor(), 0, FXFILL_WINDING);
331 } 331 }
332 332
OLDNEW
« no previous file with comments | « xfa/fde/fde_gedevice.h ('k') | xfa/fde/fde_iterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698