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

Side by Side Diff: core/src/fxge/dib/fx_dib_convert.cpp

Issue 1226403008: Merge to M44: Abort on OOM by default in FX_Alloc(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@2403
Patch Set: Created 5 years, 5 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/fxcrt/fx_basic_memmgr_unittest.cpp ('k') | core/src/fxge/dib/fx_dib_engine.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 "../../../include/fxge/fx_dib.h" 7 #include "../../../include/fxge/fx_dib.h"
8 #include "../../../include/fxge/fx_ge.h" 8 #include "../../../include/fxge/fx_ge.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 const FX_DWORD g_dwWinPalette[256] = { 10 const FX_DWORD g_dwWinPalette[256] = {
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 FX_LPBYTE scanline = m_pBuffer + row * m_Pitch + 3; 1005 FX_LPBYTE scanline = m_pBuffer + row * m_Pitch + 3;
1006 for (int col = 0; col < m_Width; col ++) { 1006 for (int col = 0; col < m_Width; col ++) {
1007 *scanline = 0xff; 1007 *scanline = 0xff;
1008 scanline += 4; 1008 scanline += 4;
1009 } 1009 }
1010 } 1010 }
1011 return TRUE; 1011 return TRUE;
1012 } 1012 }
1013 int dest_bpp = dest_format & 0xff; 1013 int dest_bpp = dest_format & 0xff;
1014 int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4; 1014 int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4;
1015 FX_LPBYTE dest_buf = FX_AllocNL(FX_BYTE, dest_pitch * m_Height + 4); 1015 FX_LPBYTE dest_buf = FX_TryAlloc(FX_BYTE, dest_pitch * m_Height + 4);
1016 if (dest_buf == NULL) { 1016 if (dest_buf == NULL) {
1017 return FALSE; 1017 return FALSE;
1018 } 1018 }
1019 CFX_DIBitmap* pAlphaMask = NULL; 1019 CFX_DIBitmap* pAlphaMask = NULL;
1020 if (dest_format == FXDIB_Argb) { 1020 if (dest_format == FXDIB_Argb) {
1021 FXSYS_memset8(dest_buf, 0xff, dest_pitch * m_Height + 4); 1021 FXSYS_memset8(dest_buf, 0xff, dest_pitch * m_Height + 4);
1022 if (m_pAlphaMask) { 1022 if (m_pAlphaMask) {
1023 for (int row = 0; row < m_Height; row ++) { 1023 for (int row = 0; row < m_Height; row ++) {
1024 FX_LPBYTE pDstScanline = dest_buf + row * dest_pitch + 3; 1024 FX_LPBYTE pDstScanline = dest_buf + row * dest_pitch + 3;
1025 FX_LPCBYTE pSrcScanline = m_pAlphaMask->GetScanline(row); 1025 FX_LPCBYTE pSrcScanline = m_pAlphaMask->GetScanline(row);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 if (!m_bExtBuf) { 1075 if (!m_bExtBuf) {
1076 FX_Free(m_pBuffer); 1076 FX_Free(m_pBuffer);
1077 } 1077 }
1078 m_bExtBuf = FALSE; 1078 m_bExtBuf = FALSE;
1079 m_pBuffer = dest_buf; 1079 m_pBuffer = dest_buf;
1080 m_bpp = (FX_BYTE)dest_format; 1080 m_bpp = (FX_BYTE)dest_format;
1081 m_AlphaFlag = (FX_BYTE)(dest_format >> 8); 1081 m_AlphaFlag = (FX_BYTE)(dest_format >> 8);
1082 m_Pitch = dest_pitch; 1082 m_Pitch = dest_pitch;
1083 return TRUE; 1083 return TRUE;
1084 } 1084 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_memmgr_unittest.cpp ('k') | core/src/fxge/dib/fx_dib_engine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698