summaryrefslogtreecommitdiff
path: root/core/src/fxge/win32
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
committerLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
commit412e908082a361d0fd9591eab939e96a882212f1 (patch)
tree11726052ae08f13dc5a05a82cbce870758580aeb /core/src/fxge/win32
parent96660d6f382204339d6b1aadc3913303d436e252 (diff)
downloadpdfium-412e908082a361d0fd9591eab939e96a882212f1.tar.xz
Merge to XFA: Get rid of most instance of 'foo == NULL'
TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1520063002 . (cherry picked from commit e385244f8cd6ae376f6b3cf1265a0795d5d30eff) Review URL: https://codereview.chromium.org/1528763003 .
Diffstat (limited to 'core/src/fxge/win32')
-rw-r--r--core/src/fxge/win32/fx_win32_device.cpp25
-rw-r--r--core/src/fxge/win32/fx_win32_dib.cpp22
-rw-r--r--core/src/fxge/win32/fx_win32_dwrite.cpp4
-rw-r--r--core/src/fxge/win32/fx_win32_gdipext.cpp18
-rw-r--r--core/src/fxge/win32/fx_win32_print.cpp16
5 files changed, 42 insertions, 43 deletions
diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp
index 6d520468a3..c346d1bbc1 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -192,7 +192,7 @@ static const struct {
{"Times-Italic", "Times New Roman", FALSE, TRUE},
};
CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) {
- if (m_pMapper == NULL) {
+ if (!m_pMapper) {
return name;
}
int nFonts = m_pMapper->m_InstalledTTFonts.GetSize();
@@ -251,7 +251,7 @@ FX_BOOL _GetSubFontName(CFX_ByteString& name) {
_FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(
name.c_str(), pFontnameMap, size / sizeof(_FontNameMap),
sizeof(_FontNameMap), compareString);
- if (found == NULL) {
+ if (!found) {
return FALSE;
}
name = found->m_pSubFontName;
@@ -528,7 +528,7 @@ FX_BOOL CGdiDeviceDriver::GDI_SetDIBits(const CFX_DIBitmap* pBitmap1,
void* pIccTransform) {
if (m_DeviceClass == FXDC_PRINTER) {
CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(FALSE, TRUE);
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -575,7 +575,7 @@ FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1,
FX_DWORD flags,
void* pIccTransform) {
CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
- if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+ if (!pBitmap || dest_width == 0 || dest_height == 0) {
return FALSE;
}
if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -620,7 +620,7 @@ FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1,
int alpha_flag,
void* pIccTransform) {
CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
- if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+ if (!pBitmap || dest_width == 0 || dest_height == 0) {
return FALSE;
}
_Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24),
@@ -855,7 +855,7 @@ FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
_Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform);
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
- if ((pGraphState == NULL || stroke_color == 0) &&
+ if (!(pGraphState || stroke_color == 0) &&
!pPlatform->m_GdiplusExt.IsAvailable()) {
CFX_FloatRect bbox_f = pPathData->GetBoundingBox();
if (pMatrix) {
@@ -1066,8 +1066,7 @@ FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap,
!CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
pIccTransform = NULL;
}
- if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() &&
- pIccTransform == NULL) {
+ if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && !pIccTransform) {
ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi,
DIB_RGB_COLORS) == height;
} else {
@@ -1165,7 +1164,7 @@ FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource,
bitmap_clip.Offset(-dest_left, -dest_top);
CFX_DIBitmap* pStretched =
pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip);
- if (pStretched == NULL) {
+ if (!pStretched) {
return TRUE;
}
FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
@@ -1205,7 +1204,7 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
CFX_DIBitmap* pStretched =
pSource->StretchTo(dest_width, dest_height, flags, &clip_rect);
- if (pStretched == NULL) {
+ if (!pStretched) {
return TRUE;
}
CFX_DIBitmap background;
@@ -1228,11 +1227,11 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (pSource->HasAlpha()) {
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
- if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL &&
+ if (pPlatform->m_GdiplusExt.IsAvailable() && !pIccTransform &&
!pSource->IsCmykImage()) {
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return pPlatform->m_GdiplusExt.StretchDIBits(
@@ -1340,7 +1339,7 @@ CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width,
uint8_t* pBuffer;
m_hBitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
(void**)&pBuffer, NULL, 0);
- if (m_hBitmap == NULL) {
+ if (!m_hBitmap) {
return;
}
CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp
index 1aa60f084e..1fdf3ae9b1 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -28,24 +28,24 @@ CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) {
pbmih->biWidth = pBitmap->GetWidth();
if (pBitmap->GetBPP() == 8) {
FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
- if (pBitmap->GetPalette() == NULL) {
+ if (pBitmap->GetPalette()) {
for (int i = 0; i < 256; i++) {
- pPalette[i] = i * 0x010101;
+ pPalette[i] = pBitmap->GetPalette()[i];
}
} else {
for (int i = 0; i < 256; i++) {
- pPalette[i] = pBitmap->GetPalette()[i];
+ pPalette[i] = i * 0x010101;
}
}
}
if (pBitmap->GetBPP() == 1) {
FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
- if (pBitmap->GetPalette() == NULL) {
- pPalette[0] = 0;
- pPalette[1] = 0xffffff;
- } else {
+ if (pBitmap->GetPalette()) {
pPalette[0] = pBitmap->GetPalette()[0];
pPalette[1] = pBitmap->GetPalette()[1];
+ } else {
+ pPalette[0] = 0;
+ pPalette[1] = 0xffffff;
}
}
result.ReleaseBuffer(len);
@@ -125,7 +125,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) {
}
HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE);
- if (hBitmap == NULL) {
+ if (!hBitmap) {
return NULL;
}
HDC hDC = CreateCompatibleDC(NULL);
@@ -158,7 +158,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) {
}
HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name,
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- if (hBitmap == NULL) {
+ if (!hBitmap) {
return NULL;
}
HDC hDC = CreateCompatibleDC(NULL);
@@ -184,8 +184,8 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC,
HBITMAP hBitmap,
FX_DWORD* pPalette,
FX_DWORD palsize) {
- FX_BOOL bCreatedDC = hDC == NULL;
- if (hDC == NULL) {
+ FX_BOOL bCreatedDC = !hDC;
+ if (bCreatedDC) {
hDC = CreateCompatibleDC(NULL);
}
BITMAPINFOHEADER bmih;
diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp
index 83924f23e7..9e56ee7672 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -65,7 +65,7 @@ class CDwFontFileLoader final : public IDWriteFontFileLoader {
OUT IDWriteFontFileStream** fontFileStream);
static IDWriteFontFileLoader* GetLoader() {
- if (instance_ == NULL) {
+ if (!instance_) {
instance_ = new CDwFontFileLoader();
}
return instance_;
@@ -216,7 +216,7 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget,
FX_FLOAT baselineOriginY,
void* glyph_offsets,
FX_FLOAT* glyph_advances) {
- if (renderTarget == NULL) {
+ if (!renderTarget) {
return TRUE;
}
CDwGdiTextRenderer* pTextRenderer = (CDwGdiTextRenderer*)renderTarget;
diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp
index e79a88cb81..1e4f89540b 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -686,12 +686,12 @@ void CGdiplusExt::Load() {
strPlusPath += "\\";
strPlusPath += "GDIPLUS.DLL";
m_hModule = LoadLibraryA(strPlusPath);
- if (m_hModule == NULL) {
+ if (!m_hModule) {
return;
}
for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
- if (m_Functions[i] == NULL) {
+ if (!m_Functions[i]) {
m_hModule = NULL;
return;
}
@@ -701,7 +701,7 @@ void CGdiplusExt::Load() {
((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])(
&gdiplusToken, &gdiplusStartupInput, NULL);
m_GdiModule = LoadLibraryA("GDI32.DLL");
- if (m_GdiModule == NULL) {
+ if (!m_GdiModule) {
return;
}
m_pGdiAddFontMemResourceEx =
@@ -973,9 +973,9 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState,
FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f;
if (!bTextMode) {
FX_FLOAT unit =
- pMatrix == NULL
- ? 1.0f
- : FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2);
+ pMatrix
+ ? FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2)
+ : 1.0f;
if (width < unit) {
width = unit;
}
@@ -1198,7 +1198,7 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC,
}
}
int new_fill_mode = fill_mode & 3;
- if (nPoints == 4 && pGraphState == NULL) {
+ if (nPoints == 4 && !pGraphState) {
int v1, v2;
if (IsSmallTriangle(points, pObject2Device, v1, v2)) {
GpPen* pPen = NULL;
@@ -1380,7 +1380,7 @@ class GpStream final : public IStream {
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) {
- if (pStatstg == NULL) {
+ if (!pStatstg) {
return STG_E_INVALIDFUNCTION;
}
ZeroMemory(pStatstg, sizeof(STATSTG));
@@ -1492,7 +1492,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
FX_BOOL bAlpha);
CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) {
PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
- if (pInfo == NULL) {
+ if (!pInfo) {
return NULL;
}
int height = abs(pInfo->pbmi->bmiHeader.biHeight);
diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp
index 39828b14d8..0c00a7b3d9 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -56,7 +56,7 @@ FX_BOOL CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
@@ -82,7 +82,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (dest_width < 0 || dest_height < 0) {
CFX_DIBitmap* pFlipped =
pSource->FlipImage(dest_width < 0, dest_height < 0);
- if (pFlipped == NULL) {
+ if (!pFlipped) {
return FALSE;
}
if (dest_width < 0) {
@@ -99,7 +99,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width,
@@ -112,7 +112,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (dest_width < 0 || dest_height < 0) {
CFX_DIBitmap* pFlipped =
pSource->FlipImage(dest_width < 0, dest_height < 0);
- if (pFlipped == NULL) {
+ if (!pFlipped) {
return FALSE;
}
if (dest_width < 0) {
@@ -129,7 +129,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width,
@@ -142,7 +142,7 @@ static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc,
pSrc->GetFormat() == FXDIB_1bppCmyk);
CFX_DIBExtractor src_bitmap(pSrc);
CFX_DIBitmap* pSrcBitmap = src_bitmap;
- if (pSrcBitmap == NULL) {
+ if (!pSrcBitmap) {
return NULL;
}
int src_width = pSrcBitmap->GetWidth(), src_height = pSrcBitmap->GetHeight();
@@ -250,7 +250,7 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
if (FXSYS_fabs(pMatrix->a) < 0.5f && FXSYS_fabs(pMatrix->d) < 0.5f) {
CFX_DIBitmap* pTransformed =
pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0);
- if (pTransformed == NULL) {
+ if (!pTransformed) {
return FALSE;
}
FX_BOOL ret = StretchDIBits(
@@ -261,7 +261,7 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
}
if (pSource->GetBPP() == 1) {
CFX_DIBitmap* pTransformed = Transform1bppBitmap(pSource, pMatrix);
- if (pIccTransform == NULL) {
+ if (!pIccTransform) {
return FALSE;
}
SaveState();