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

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

Issue 1136673005: Merge to XFA: Add safe FX_Alloc2D() macro (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 7 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 | « core/src/fxge/skia/fx_skia_device.cpp ('k') | no next file » | 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 "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
9 #include <windows.h> 9 #include <windows.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha); 1265 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha);
1266 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) 1266 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args)
1267 { 1267 {
1268 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args); 1268 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
1269 if (pInfo == NULL) { 1269 if (pInfo == NULL) {
1270 return NULL; 1270 return NULL;
1271 } 1271 }
1272 int height = abs(pInfo->pbmi->bmiHeader.biHeight); 1272 int height = abs(pInfo->pbmi->bmiHeader.biHeight);
1273 int width = pInfo->pbmi->bmiHeader.biWidth; 1273 int width = pInfo->pbmi->bmiHeader.biWidth;
1274 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4; 1274 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4;
1275 LPBYTE pData = FX_Alloc(BYTE, dest_pitch * height); 1275 LPBYTE pData = FX_Alloc2D(BYTE, dest_pitch, height);
1276 if (pData == NULL) {
1277 FreeDIBitmap(pInfo);
1278 return NULL;
1279 }
1280 if (dest_pitch == pInfo->Stride) { 1276 if (dest_pitch == pInfo->Stride) {
1281 FXSYS_memcpy32(pData, pInfo->pScan0, dest_pitch * height); 1277 FXSYS_memcpy32(pData, pInfo->pScan0, dest_pitch * height);
1282 } else for (int i = 0; i < height; i ++) { 1278 } else {
1279 for (int i = 0; i < height; i ++) {
1283 FXSYS_memcpy32(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, dest_pitch); 1280 FXSYS_memcpy32(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, dest_pitch);
1284 } 1281 }
1282 }
1285 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(pInfo->pbmi, pData, pIn fo->pbmi->bmiHeader.biBitCount == 32); 1283 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(pInfo->pbmi, pData, pIn fo->pbmi->bmiHeader.biBitCount == 32);
1286 FX_Free(pData); 1284 FX_Free(pData);
1287 FreeDIBitmap(pInfo); 1285 FreeDIBitmap(pInfo);
1288 return pDIBitmap; 1286 return pDIBitmap;
1289 } 1287 }
1290 #endif 1288 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/skia/fx_skia_device.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698