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

Side by Side Diff: core/src/fxge/win32/fx_win32_gdipext.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase 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
« no previous file with comments | « core/src/fxge/win32/fx_win32_dwrite.cpp ('k') | core/src/fxge/win32/fx_win32_print.cpp » ('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 "core/include/fxge/fx_ge.h" 7 #include "core/include/fxge/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 #include <windows.h> 10 #include <windows.h>
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 m_pGdiRemoveFontMemResourseEx = NULL; 679 m_pGdiRemoveFontMemResourseEx = NULL;
680 } 680 }
681 void CGdiplusExt::Load() { 681 void CGdiplusExt::Load() {
682 CFX_ByteString strPlusPath = ""; 682 CFX_ByteString strPlusPath = "";
683 FX_CHAR buf[MAX_PATH]; 683 FX_CHAR buf[MAX_PATH];
684 GetSystemDirectoryA(buf, MAX_PATH); 684 GetSystemDirectoryA(buf, MAX_PATH);
685 strPlusPath += buf; 685 strPlusPath += buf;
686 strPlusPath += "\\"; 686 strPlusPath += "\\";
687 strPlusPath += "GDIPLUS.DLL"; 687 strPlusPath += "GDIPLUS.DLL";
688 m_hModule = LoadLibraryA(strPlusPath); 688 m_hModule = LoadLibraryA(strPlusPath);
689 if (m_hModule == NULL) { 689 if (!m_hModule) {
690 return; 690 return;
691 } 691 }
692 for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) { 692 for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
693 m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]); 693 m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
694 if (m_Functions[i] == NULL) { 694 if (!m_Functions[i]) {
695 m_hModule = NULL; 695 m_hModule = NULL;
696 return; 696 return;
697 } 697 }
698 } 698 }
699 uintptr_t gdiplusToken; 699 uintptr_t gdiplusToken;
700 GdiplusStartupInput gdiplusStartupInput; 700 GdiplusStartupInput gdiplusStartupInput;
701 ((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])( 701 ((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])(
702 &gdiplusToken, &gdiplusStartupInput, NULL); 702 &gdiplusToken, &gdiplusStartupInput, NULL);
703 m_GdiModule = LoadLibraryA("GDI32.DLL"); 703 m_GdiModule = LoadLibraryA("GDI32.DLL");
704 if (m_GdiModule == NULL) { 704 if (!m_GdiModule) {
705 return; 705 return;
706 } 706 }
707 m_pGdiAddFontMemResourceEx = 707 m_pGdiAddFontMemResourceEx =
708 GetProcAddress(m_GdiModule, "AddFontMemResourceEx"); 708 GetProcAddress(m_GdiModule, "AddFontMemResourceEx");
709 m_pGdiRemoveFontMemResourseEx = 709 m_pGdiRemoveFontMemResourseEx =
710 GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx"); 710 GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx");
711 } 711 }
712 CGdiplusExt::~CGdiplusExt() {} 712 CGdiplusExt::~CGdiplusExt() {}
713 LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, FX_DWORD size) { 713 LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, FX_DWORD size) {
714 GpFontCollection* pCollection = NULL; 714 GpFontCollection* pCollection = NULL;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 } 966 }
967 static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, 967 static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState,
968 const CFX_Matrix* pMatrix, 968 const CFX_Matrix* pMatrix,
969 DWORD argb, 969 DWORD argb,
970 FX_BOOL bTextMode = FALSE) { 970 FX_BOOL bTextMode = FALSE) {
971 CGdiplusExt& GdiplusExt = 971 CGdiplusExt& GdiplusExt =
972 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 972 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
973 FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f; 973 FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f;
974 if (!bTextMode) { 974 if (!bTextMode) {
975 FX_FLOAT unit = 975 FX_FLOAT unit =
976 pMatrix == NULL 976 pMatrix
977 ? 1.0f 977 ? FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2)
978 : FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2); 978 : 1.0f;
979 if (width < unit) { 979 if (width < unit) {
980 width = unit; 980 width = unit;
981 } 981 }
982 } 982 }
983 GpPen* pPen = NULL; 983 GpPen* pPen = NULL;
984 CallFunc(GdipCreatePen1)((ARGB)argb, width, UnitWorld, &pPen); 984 CallFunc(GdipCreatePen1)((ARGB)argb, width, UnitWorld, &pPen);
985 LineCap lineCap; 985 LineCap lineCap;
986 DashCap dashCap = DashCapFlat; 986 DashCap dashCap = DashCapFlat;
987 FX_BOOL bDashExtend = FALSE; 987 FX_BOOL bDashExtend = FALSE;
988 switch (pGraphState->m_LineCap) { 988 switch (pGraphState->m_LineCap) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeNone); 1191 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeNone);
1192 } else if (!(fill_mode & FXFILL_FULLCOVER)) { 1192 } else if (!(fill_mode & FXFILL_FULLCOVER)) {
1193 if (!bSmooth && (fill_mode & 3)) { 1193 if (!bSmooth && (fill_mode & 3)) {
1194 bSmooth = TRUE; 1194 bSmooth = TRUE;
1195 } 1195 }
1196 if (bSmooth || (pGraphState && pGraphState->m_LineWidth > 2)) { 1196 if (bSmooth || (pGraphState && pGraphState->m_LineWidth > 2)) {
1197 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeAntiAlias); 1197 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeAntiAlias);
1198 } 1198 }
1199 } 1199 }
1200 int new_fill_mode = fill_mode & 3; 1200 int new_fill_mode = fill_mode & 3;
1201 if (nPoints == 4 && pGraphState == NULL) { 1201 if (nPoints == 4 && !pGraphState) {
1202 int v1, v2; 1202 int v1, v2;
1203 if (IsSmallTriangle(points, pObject2Device, v1, v2)) { 1203 if (IsSmallTriangle(points, pObject2Device, v1, v2)) {
1204 GpPen* pPen = NULL; 1204 GpPen* pPen = NULL;
1205 CallFunc(GdipCreatePen1)(fill_argb, 1.0f, UnitPixel, &pPen); 1205 CallFunc(GdipCreatePen1)(fill_argb, 1.0f, UnitPixel, &pPen);
1206 CallFunc(GdipDrawLineI)( 1206 CallFunc(GdipDrawLineI)(
1207 pGraphics, pPen, FXSYS_round(points[v1].X), FXSYS_round(points[v1].Y), 1207 pGraphics, pPen, FXSYS_round(points[v1].X), FXSYS_round(points[v1].Y),
1208 FXSYS_round(points[v2].X), FXSYS_round(points[v2].Y)); 1208 FXSYS_round(points[v2].X), FXSYS_round(points[v2].Y));
1209 CallFunc(GdipDeletePen)(pPen); 1209 CallFunc(GdipDeletePen)(pPen);
1210 return TRUE; 1210 return TRUE;
1211 } 1211 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 new_read_position > m_InterStream.GetLength()) { 1373 new_read_position > m_InterStream.GetLength()) {
1374 return STG_E_SEEKERROR; 1374 return STG_E_SEEKERROR;
1375 } 1375 }
1376 m_ReadPos = new_read_position; 1376 m_ReadPos = new_read_position;
1377 if (lpNewFilePointer) { 1377 if (lpNewFilePointer) {
1378 lpNewFilePointer->QuadPart = m_ReadPos; 1378 lpNewFilePointer->QuadPart = m_ReadPos;
1379 } 1379 }
1380 return S_OK; 1380 return S_OK;
1381 } 1381 }
1382 virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) { 1382 virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) {
1383 if (pStatstg == NULL) { 1383 if (!pStatstg) {
1384 return STG_E_INVALIDFUNCTION; 1384 return STG_E_INVALIDFUNCTION;
1385 } 1385 }
1386 ZeroMemory(pStatstg, sizeof(STATSTG)); 1386 ZeroMemory(pStatstg, sizeof(STATSTG));
1387 pStatstg->cbSize.QuadPart = m_InterStream.GetLength(); 1387 pStatstg->cbSize.QuadPart = m_InterStream.GetLength();
1388 return S_OK; 1388 return S_OK;
1389 } 1389 }
1390 }; 1390 };
1391 typedef struct { 1391 typedef struct {
1392 BITMAPINFO* pbmi; 1392 BITMAPINFO* pbmi;
1393 int Stride; 1393 int Stride;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 if (pInfo->pStream) { 1485 if (pInfo->pStream) {
1486 pInfo->pStream->Release(); 1486 pInfo->pStream->Release();
1487 } 1487 }
1488 FX_Free(pInfo); 1488 FX_Free(pInfo);
1489 } 1489 }
1490 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, 1490 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
1491 LPVOID pData, 1491 LPVOID pData,
1492 FX_BOOL bAlpha); 1492 FX_BOOL bAlpha);
1493 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { 1493 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) {
1494 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args); 1494 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
1495 if (pInfo == NULL) { 1495 if (!pInfo) {
1496 return NULL; 1496 return NULL;
1497 } 1497 }
1498 int height = abs(pInfo->pbmi->bmiHeader.biHeight); 1498 int height = abs(pInfo->pbmi->bmiHeader.biHeight);
1499 int width = pInfo->pbmi->bmiHeader.biWidth; 1499 int width = pInfo->pbmi->bmiHeader.biWidth;
1500 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4; 1500 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4;
1501 LPBYTE pData = FX_Alloc2D(BYTE, dest_pitch, height); 1501 LPBYTE pData = FX_Alloc2D(BYTE, dest_pitch, height);
1502 if (dest_pitch == pInfo->Stride) { 1502 if (dest_pitch == pInfo->Stride) {
1503 FXSYS_memcpy(pData, pInfo->pScan0, dest_pitch * height); 1503 FXSYS_memcpy(pData, pInfo->pScan0, dest_pitch * height);
1504 } else { 1504 } else {
1505 for (int i = 0; i < height; i++) { 1505 for (int i = 0; i < height; i++) {
1506 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, 1506 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i,
1507 dest_pitch); 1507 dest_pitch);
1508 } 1508 }
1509 } 1509 }
1510 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( 1510 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(
1511 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); 1511 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32);
1512 FX_Free(pData); 1512 FX_Free(pData);
1513 FreeDIBitmap(pInfo); 1513 FreeDIBitmap(pInfo);
1514 return pDIBitmap; 1514 return pDIBitmap;
1515 } 1515 }
1516 #endif 1516 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/win32/fx_win32_dwrite.cpp ('k') | core/src/fxge/win32/fx_win32_print.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698