From 4997b22f84307521a62838f874928bf56cd3423c Mon Sep 17 00:00:00 2001 From: thestig Date: Tue, 7 Jun 2016 10:46:22 -0700 Subject: Get rid of NULLs in core/ Review-Url: https://codereview.chromium.org/2032613003 --- core/fxge/win32/fx_win32_dib.cpp | 50 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'core/fxge/win32/fx_win32_dib.cpp') diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index eefa991eeb..7221d10536 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -69,7 +69,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, FX_BOOL ret = pBitmap->Create(width, height, format); if (!ret) { delete pBitmap; - return NULL; + return nullptr; } FXSYS_memcpy(pBitmap->GetBuffer(), pData, pitch * height); if (bBottomUp) { @@ -84,7 +84,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, bottom--; } FX_Free(temp_buf); - temp_buf = NULL; + temp_buf = nullptr; } if (pbmi->bmiHeader.biBitCount == 1) { for (int i = 0; i < 2; i++) { @@ -102,11 +102,9 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) { } HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) { CFX_ByteString info = GetBitmapInfo(pBitmap); - HBITMAP hBitmap = NULL; - hBitmap = CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, - pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), - DIB_RGB_COLORS); - return hBitmap; + return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, + pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), + DIB_RGB_COLORS); } void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) { BITMAP bmp; @@ -123,26 +121,26 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) { args.path_name = filename; return pPlatform->m_GdiplusExt.LoadDIBitmap(args); } - HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP, - 0, 0, LR_LOADFROMFILE); + HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)filename, + IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (!hBitmap) { - return NULL; + return nullptr; } - HDC hDC = CreateCompatibleDC(NULL); + HDC hDC = CreateCompatibleDC(nullptr); int width, height; GetBitmapSize(hBitmap, width, height); CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { delete pDIBitmap; DeleteDC(hDC); - return NULL; + return nullptr; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); if (!ret) { delete pDIBitmap; - pDIBitmap = NULL; + pDIBitmap = nullptr; } DeleteDC(hDC); return pDIBitmap; @@ -154,28 +152,28 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { return pPlatform->m_GdiplusExt.LoadDIBitmap(args); } if (args.flags == WINDIB_OPEN_MEMORY) { - return NULL; + return nullptr; } - HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, + HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)args.path_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (!hBitmap) { - return NULL; + return nullptr; } - HDC hDC = CreateCompatibleDC(NULL); + HDC hDC = CreateCompatibleDC(nullptr); int width, height; GetBitmapSize(hBitmap, width, height); CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { delete pDIBitmap; DeleteDC(hDC); - return NULL; + return nullptr; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); if (!ret) { delete pDIBitmap; - pDIBitmap = NULL; + pDIBitmap = nullptr; } DeleteDC(hDC); return pDIBitmap; @@ -186,12 +184,12 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, uint32_t palsize) { FX_BOOL bCreatedDC = !hDC; if (bCreatedDC) { - hDC = CreateCompatibleDC(NULL); + hDC = CreateCompatibleDC(nullptr); } BITMAPINFOHEADER bmih; FXSYS_memset(&bmih, 0, sizeof bmih); bmih.biSize = sizeof bmih; - GetDIBits(hDC, hBitmap, 0, 0, NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS); + GetDIBits(hDC, hBitmap, 0, 0, nullptr, (BITMAPINFO*)&bmih, DIB_RGB_COLORS); int width = bmih.biWidth; int height = abs(bmih.biHeight); bmih.biHeight = -height; @@ -218,12 +216,12 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, if (bCreatedDC) { DeleteDC(hDC); } - return NULL; + return nullptr; } ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)pbmih, DIB_RGB_COLORS); FX_Free(pbmih); - pbmih = NULL; + pbmih = nullptr; pDIBitmap->CopyPalette(pPalette, palsize); } else { if (bmih.biBitCount <= 24) { @@ -237,7 +235,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, if (bCreatedDC) { DeleteDC(hDC); } - return NULL; + return nullptr; } ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)&bmih, DIB_RGB_COLORS); @@ -254,7 +252,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, } if (ret == 0) { delete pDIBitmap; - pDIBitmap = NULL; + pDIBitmap = nullptr; } if (bCreatedDC) { DeleteDC(hDC); @@ -271,7 +269,7 @@ CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) { bmih.biPlanes = 1; bmih.biWidth = width; m_hBitmap = CreateDIBSection(hDC, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, - (LPVOID*)&m_pBuffer, NULL, 0); + (LPVOID*)&m_pBuffer, nullptr, 0); m_hMemDC = CreateCompatibleDC(hDC); m_hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap); } -- cgit v1.2.3