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

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

Issue 1062863006: Remove checks in fxge/{apple,win32,skia,dib} now that FX_NEW cant return 0 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 8 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 "../../../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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (bFlipX) { 295 if (bFlipX) {
296 dest_width = -dest_width; 296 dest_width = -dest_width;
297 } 297 }
298 FX_BOOL bFlipY = dest_height < 0; 298 FX_BOOL bFlipY = dest_height < 0;
299 if (bFlipY) { 299 if (bFlipY) {
300 dest_height = -dest_height; 300 dest_height = -dest_height;
301 } 301 }
302 int result_width = pClipRect->Width(); 302 int result_width = pClipRect->Width();
303 int result_height = pClipRect->Height(); 303 int result_height = pClipRect->Height();
304 int result_pitch = (result_width + 3) / 4 * 4; 304 int result_pitch = (result_width + 3) / 4 * 4;
305 CFX_DIBitmap* pStretched = FX_NEW CFX_DIBitmap; 305 CFX_DIBitmap* pStretched = new CFX_DIBitmap;
306 if (!pStretched) {
307 return NULL;
308 }
309 if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb)) { 306 if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb)) {
310 delete pStretched; 307 delete pStretched;
311 return NULL; 308 return NULL;
312 } 309 }
313 LPBYTE dest_buf = pStretched->GetBuffer(); 310 LPBYTE dest_buf = pStretched->GetBuffer();
314 int src_width = pSource->GetWidth(); 311 int src_width = pSource->GetWidth();
315 int src_height = pSource->GetHeight(); 312 int src_height = pSource->GetHeight();
316 int src_count = src_width * src_height; 313 int src_count = src_width * src_height;
317 int dest_count = dest_width * dest_height; 314 int dest_count = dest_width * dest_height;
318 int ratio = 255 * dest_count / src_count; 315 int ratio = 255 * dest_count / src_count;
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 GpBitmap* pBitmap; 1154 GpBitmap* pBitmap;
1158 GpStream* pStream = NULL; 1155 GpStream* pStream = NULL;
1159 CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatform Data())->m_GdiplusExt; 1156 CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatform Data())->m_GdiplusExt;
1160 Status status = Ok; 1157 Status status = Ok;
1161 if (args.flags == WINDIB_OPEN_PATHNAME) { 1158 if (args.flags == WINDIB_OPEN_PATHNAME) {
1162 status = CallFunc(GdipCreateBitmapFromFileICM)((wchar_t*)args.path_name, &pBitmap); 1159 status = CallFunc(GdipCreateBitmapFromFileICM)((wchar_t*)args.path_name, &pBitmap);
1163 } else { 1160 } else {
1164 if (args.memory_size == 0 || !args.memory_base) { 1161 if (args.memory_size == 0 || !args.memory_base) {
1165 return NULL; 1162 return NULL;
1166 } 1163 }
1167 pStream = FX_NEW GpStream; 1164 pStream = new GpStream;
1168 if (!pStream) {
1169 return NULL;
1170 }
1171 pStream->Write(args.memory_base, (ULONG)args.memory_size, NULL); 1165 pStream->Write(args.memory_base, (ULONG)args.memory_size, NULL);
1172 status = CallFunc(GdipCreateBitmapFromStreamICM)(pStream, &pBitmap); 1166 status = CallFunc(GdipCreateBitmapFromStreamICM)(pStream, &pBitmap);
1173 } 1167 }
1174 if (status != Ok) { 1168 if (status != Ok) {
1175 if (pStream) { 1169 if (pStream) {
1176 pStream->Release(); 1170 pStream->Release();
1177 } 1171 }
1178 return NULL; 1172 return NULL;
1179 } 1173 }
1180 UINT height, width; 1174 UINT height, width;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 FXSYS_memcpy32(pData, pInfo->pScan0, dest_pitch * height); 1275 FXSYS_memcpy32(pData, pInfo->pScan0, dest_pitch * height);
1282 } else for (int i = 0; i < height; i ++) { 1276 } else for (int i = 0; i < height; i ++) {
1283 FXSYS_memcpy32(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, dest_pitch); 1277 FXSYS_memcpy32(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, dest_pitch);
1284 } 1278 }
1285 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(pInfo->pbmi, pData, pIn fo->pbmi->bmiHeader.biBitCount == 32); 1279 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(pInfo->pbmi, pData, pIn fo->pbmi->bmiHeader.biBitCount == 32);
1286 FX_Free(pData); 1280 FX_Free(pData);
1287 FreeDIBitmap(pInfo); 1281 FreeDIBitmap(pInfo);
1288 return pDIBitmap; 1282 return pDIBitmap;
1289 } 1283 }
1290 #endif 1284 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698