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

Side by Side Diff: core/fxge/win32/fx_win32_print.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: s/NULL/nullptr/ 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
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/fxge/include/fx_ge.h" 7 #include "core/fxge/include/fx_ge.h"
8 8
9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
10 10
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 StretchDIBits(pTransformed.get(), color, full_rect.left, full_rect.top, 271 StretchDIBits(pTransformed.get(), color, full_rect.left, full_rect.top,
272 full_rect.Width(), full_rect.Height(), nullptr, 0, 272 full_rect.Width(), full_rect.Height(), nullptr, 0,
273 alpha_flag, pIccTransform, blend_type); 273 alpha_flag, pIccTransform, blend_type);
274 RestoreState(false); 274 RestoreState(false);
275 handle = nullptr; 275 handle = nullptr;
276 return ret; 276 return ret;
277 } 277 }
278 278
279 CPSOutput::CPSOutput(HDC hDC) { 279 CPSOutput::CPSOutput(HDC hDC) {
280 m_hDC = hDC; 280 m_hDC = hDC;
281 m_pBuf = NULL; 281 m_pBuf = nullptr;
282 } 282 }
283 CPSOutput::~CPSOutput() { 283 CPSOutput::~CPSOutput() {
284 FX_Free(m_pBuf); 284 FX_Free(m_pBuf);
285 } 285 }
286 void CPSOutput::Init() { 286 void CPSOutput::Init() {
287 m_pBuf = FX_Alloc(FX_CHAR, 1026); 287 m_pBuf = FX_Alloc(FX_CHAR, 1026);
288 } 288 }
289 void CPSOutput::OutputPS(const FX_CHAR* str, int len) { 289 void CPSOutput::OutputPS(const FX_CHAR* str, int len) {
290 if (len < 0) { 290 if (len < 0) {
291 len = (int)FXSYS_strlen(str); 291 len = (int)FXSYS_strlen(str);
292 } 292 }
293 int sent_len = 0; 293 int sent_len = 0;
294 while (len > 0) { 294 while (len > 0) {
295 int send_len = len > 1024 ? 1024 : len; 295 int send_len = len > 1024 ? 1024 : len;
296 *(uint16_t*)m_pBuf = send_len; 296 *(uint16_t*)m_pBuf = send_len;
297 FXSYS_memcpy(m_pBuf + 2, str + sent_len, send_len); 297 FXSYS_memcpy(m_pBuf + 2, str + sent_len, send_len);
298 ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, m_pBuf, 0, NULL); 298 ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, m_pBuf, 0, nullptr);
299 sent_len += send_len; 299 sent_len += send_len;
300 len -= send_len; 300 len -= send_len;
301 } 301 }
302 } 302 }
303 CPSPrinterDriver::CPSPrinterDriver() { 303 CPSPrinterDriver::CPSPrinterDriver() {
304 m_pPSOutput = NULL; 304 m_pPSOutput = nullptr;
305 m_bCmykOutput = FALSE; 305 m_bCmykOutput = FALSE;
306 } 306 }
307 CPSPrinterDriver::~CPSPrinterDriver() { 307 CPSPrinterDriver::~CPSPrinterDriver() {
308 EndRendering(); 308 EndRendering();
309 delete m_pPSOutput; 309 delete m_pPSOutput;
310 } 310 }
311 FX_BOOL CPSPrinterDriver::Init(HDC hDC, int pslevel, FX_BOOL bCmykOutput) { 311 FX_BOOL CPSPrinterDriver::Init(HDC hDC, int pslevel, FX_BOOL bCmykOutput) {
312 m_hDC = hDC; 312 m_hDC = hDC;
313 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); 313 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE);
314 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); 314 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE);
315 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); 315 m_Width = ::GetDeviceCaps(m_hDC, HORZRES);
316 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); 316 m_Height = ::GetDeviceCaps(m_hDC, VERTRES);
317 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL); 317 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL);
318 m_pPSOutput = new CPSOutput(hDC); 318 m_pPSOutput = new CPSOutput(hDC);
319 ((CPSOutput*)m_pPSOutput)->Init(); 319 ((CPSOutput*)m_pPSOutput)->Init();
320 m_PSRenderer.Init(m_pPSOutput, pslevel, m_Width, m_Height, bCmykOutput); 320 m_PSRenderer.Init(m_pPSOutput, pslevel, m_Width, m_Height, bCmykOutput);
321 m_bCmykOutput = bCmykOutput; 321 m_bCmykOutput = bCmykOutput;
322 HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1); 322 HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1);
323 int ret = ::GetClipRgn(hDC, hRgn); 323 int ret = ::GetClipRgn(hDC, hRgn);
324 if (ret == 1) { 324 if (ret == 1) {
325 ret = ::GetRegionData(hRgn, 0, NULL); 325 ret = ::GetRegionData(hRgn, 0, nullptr);
326 if (ret) { 326 if (ret) {
327 RGNDATA* pData = (RGNDATA*)FX_Alloc(uint8_t, ret); 327 RGNDATA* pData = (RGNDATA*)FX_Alloc(uint8_t, ret);
328 ret = ::GetRegionData(hRgn, ret, pData); 328 ret = ::GetRegionData(hRgn, ret, pData);
329 if (ret) { 329 if (ret) {
330 CFX_PathData path; 330 CFX_PathData path;
331 path.AllocPointCount(pData->rdh.nCount * 5); 331 path.AllocPointCount(pData->rdh.nCount * 5);
332 for (uint32_t i = 0; i < pData->rdh.nCount; i++) { 332 for (uint32_t i = 0; i < pData->rdh.nCount; i++) {
333 RECT* pRect = (RECT*)(pData->Buffer + pData->rdh.nRgnSize * i); 333 RECT* pRect = (RECT*)(pData->Buffer + pData->rdh.nRgnSize * i);
334 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bottom, 334 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bottom,
335 (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); 335 (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top);
336 } 336 }
337 m_PSRenderer.SetClip_PathFill(&path, NULL, FXFILL_WINDING); 337 m_PSRenderer.SetClip_PathFill(&path, nullptr, FXFILL_WINDING);
338 } 338 }
339 FX_Free(pData); 339 FX_Free(pData);
340 } 340 }
341 } 341 }
342 ::DeleteObject(hRgn); 342 ::DeleteObject(hRgn);
343 return TRUE; 343 return TRUE;
344 } 344 }
345 int CPSPrinterDriver::GetDeviceCaps(int caps_id) { 345 int CPSPrinterDriver::GetDeviceCaps(int caps_id) {
346 switch (caps_id) { 346 switch (caps_id) {
347 case FXDC_DEVICE_CLASS: 347 case FXDC_DEVICE_CLASS:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 void*& handle, 448 void*& handle,
449 int alpha_flag, 449 int alpha_flag,
450 void* pIccTransform, 450 void* pIccTransform,
451 int blend_type) { 451 int blend_type) {
452 if (blend_type != FXDIB_BLEND_NORMAL) { 452 if (blend_type != FXDIB_BLEND_NORMAL) {
453 return FALSE; 453 return FALSE;
454 } 454 }
455 if (bitmap_alpha < 255) { 455 if (bitmap_alpha < 255) {
456 return FALSE; 456 return FALSE;
457 } 457 }
458 handle = NULL; 458 handle = nullptr;
459 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags, 459 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags,
460 alpha_flag, pIccTransform); 460 alpha_flag, pIccTransform);
461 } 461 }
462 FX_BOOL CPSPrinterDriver::DrawDeviceText(int nChars, 462 FX_BOOL CPSPrinterDriver::DrawDeviceText(int nChars,
463 const FXTEXT_CHARPOS* pCharPos, 463 const FXTEXT_CHARPOS* pCharPos,
464 CFX_Font* pFont, 464 CFX_Font* pFont,
465 CFX_FontCache* pCache, 465 CFX_FontCache* pCache,
466 const CFX_Matrix* pObject2Device, 466 const CFX_Matrix* pObject2Device,
467 FX_FLOAT font_size, 467 FX_FLOAT font_size,
468 uint32_t color, 468 uint32_t color,
469 int alpha_flag, 469 int alpha_flag,
470 void* pIccTransform) { 470 void* pIccTransform) {
471 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device, 471 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device,
472 font_size, color, alpha_flag, pIccTransform); 472 font_size, color, alpha_flag, pIccTransform);
473 } 473 }
474 #endif 474 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698