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

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

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
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/dib/fx_dib_composite.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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) 230 FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type)
231 { 231 {
232 if (pBitmap == NULL) { 232 if (pBitmap == NULL) {
233 return FALSE; 233 return FALSE;
234 } 234 }
235 if (m_pPalette != NULL) { 235 if (m_pPalette != NULL) {
236 FX_Free(m_pPalette); 236 FX_Free(m_pPalette);
237 } 237 }
238 m_pPalette = FX_Alloc(FX_DWORD, 256); 238 m_pPalette = FX_Alloc(FX_DWORD, 256);
239 if (!m_pPalette) {
240 return FALSE;
241 }
239 int bpp = pBitmap->GetBPP() / 8; 242 int bpp = pBitmap->GetBPP() / 8;
240 int width = pBitmap->GetWidth(); 243 int width = pBitmap->GetWidth();
241 int height = pBitmap->GetHeight(); 244 int height = pBitmap->GetHeight();
242 if (m_cLut) { 245 if (m_cLut) {
243 FX_Free(m_cLut); 246 FX_Free(m_cLut);
244 m_cLut = NULL; 247 m_cLut = NULL;
245 } 248 }
246 if (m_aLut) { 249 if (m_aLut) {
247 FX_Free(m_aLut); 250 FX_Free(m_aLut);
248 m_aLut = NULL; 251 m_aLut = NULL;
249 } 252 }
250 m_cLut = FX_Alloc(FX_DWORD, 4096); 253 m_cLut = FX_Alloc(FX_DWORD, 4096);
254 if (!m_cLut) {
255 return FALSE;
256 }
251 m_aLut = FX_Alloc(FX_DWORD, 4096); 257 m_aLut = FX_Alloc(FX_DWORD, 4096);
258 if (!m_aLut) {
259 return FALSE;
260 }
252 int row, col; 261 int row, col;
253 m_lut = 0; 262 m_lut = 0;
254 for (row = 0; row < height; row++) { 263 for (row = 0; row < height; row++) {
255 FX_BYTE* scan_line = (FX_BYTE*)pBitmap->GetScanline(row); 264 FX_BYTE* scan_line = (FX_BYTE*)pBitmap->GetScanline(row);
256 for (col = 0; col < width; col++) { 265 for (col = 0; col < width; col++) {
257 FX_BYTE* src_port = scan_line + col * bpp; 266 FX_BYTE* src_port = scan_line + col * bpp;
258 FX_DWORD b = src_port[0] & 0xf0; 267 FX_DWORD b = src_port[0] & 0xf0;
259 FX_DWORD g = src_port[1] & 0xf0; 268 FX_DWORD g = src_port[1] & 0xf0;
260 FX_DWORD r = src_port[2] & 0xf0; 269 FX_DWORD r = src_port[2] & 0xf0;
261 FX_DWORD index = (r << 4) + g + (b >> 4); 270 FX_DWORD index = (r << 4) + g + (b >> 4);
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform); 861 return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, pIccTransform);
853 } 862 }
854 return FALSE; 863 return FALSE;
855 } 864 }
856 case FXDIB_8bppRgb: 865 case FXDIB_8bppRgb:
857 case FXDIB_8bppRgba: { 866 case FXDIB_8bppRgba: {
858 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL ) { 867 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL ) {
859 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 868 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
860 } 869 }
861 d_pal = FX_Alloc(FX_DWORD, 256); 870 d_pal = FX_Alloc(FX_DWORD, 256);
871 if (!d_pal) {
872 return FALSE;
873 }
862 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS rcBitmap->GetPalette()) { 874 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS rcBitmap->GetPalette()) {
863 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 875 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
864 } else if ((src_format & 0xff) >= 24) { 876 } else if ((src_format & 0xff) >= 24) {
865 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 877 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
866 } 878 }
867 return FALSE; 879 return FALSE;
868 } 880 }
869 case FXDIB_Rgb: 881 case FXDIB_Rgb:
870 case FXDIB_Rgba: { 882 case FXDIB_Rgba: {
871 if ((src_format & 0xff) == 1) { 883 if ((src_format & 0xff) == 1) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 if (!m_bExtBuf) { 1071 if (!m_bExtBuf) {
1060 FX_Free(m_pBuffer); 1072 FX_Free(m_pBuffer);
1061 } 1073 }
1062 m_bExtBuf = FALSE; 1074 m_bExtBuf = FALSE;
1063 m_pBuffer = dest_buf; 1075 m_pBuffer = dest_buf;
1064 m_bpp = (FX_BYTE)dest_format; 1076 m_bpp = (FX_BYTE)dest_format;
1065 m_AlphaFlag = (FX_BYTE)(dest_format >> 8); 1077 m_AlphaFlag = (FX_BYTE)(dest_format >> 8);
1066 m_Pitch = dest_pitch; 1078 m_Pitch = dest_pitch;
1067 return TRUE; 1079 return TRUE;
1068 } 1080 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_composite.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