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

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

Issue 372473003: Remove custom memory manager (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Change malloc to calloc Created 6 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/xml_int.h ('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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 239 if (!m_pPalette) {
240 return FALSE; 240 return FALSE;
241 } 241 }
242 FXSYS_memset32(m_pPalette, 0, sizeof(FX_DWORD) * 256);
243 int bpp = pBitmap->GetBPP() / 8; 242 int bpp = pBitmap->GetBPP() / 8;
244 int width = pBitmap->GetWidth(); 243 int width = pBitmap->GetWidth();
245 int height = pBitmap->GetHeight(); 244 int height = pBitmap->GetHeight();
246 if (m_cLut) { 245 if (m_cLut) {
247 FX_Free(m_cLut); 246 FX_Free(m_cLut);
248 m_cLut = NULL; 247 m_cLut = NULL;
249 } 248 }
250 if (m_aLut) { 249 if (m_aLut) {
251 FX_Free(m_aLut); 250 FX_Free(m_aLut);
252 m_aLut = NULL; 251 m_aLut = NULL;
253 } 252 }
254 m_cLut = FX_Alloc(FX_DWORD, 4096); 253 m_cLut = FX_Alloc(FX_DWORD, 4096);
255 if (!m_cLut) { 254 if (!m_cLut) {
256 return FALSE; 255 return FALSE;
257 } 256 }
258 m_aLut = FX_Alloc(FX_DWORD, 4096); 257 m_aLut = FX_Alloc(FX_DWORD, 4096);
259 if (!m_aLut) { 258 if (!m_aLut) {
260 return FALSE; 259 return FALSE;
261 } 260 }
262 FXSYS_memset32(m_aLut, 0, sizeof(FX_DWORD) * 4096);
263 FXSYS_memset32(m_cLut, 0, sizeof(FX_DWORD) * 4096);
264 int row, col; 261 int row, col;
265 m_lut = 0; 262 m_lut = 0;
266 for (row = 0; row < height; row++) { 263 for (row = 0; row < height; row++) {
267 FX_BYTE* scan_line = (FX_BYTE*)pBitmap->GetScanline(row); 264 FX_BYTE* scan_line = (FX_BYTE*)pBitmap->GetScanline(row);
268 for (col = 0; col < width; col++) { 265 for (col = 0; col < width; col++) {
269 FX_BYTE* src_port = scan_line + col * bpp; 266 FX_BYTE* src_port = scan_line + col * bpp;
270 FX_DWORD b = src_port[0] & 0xf0; 267 FX_DWORD b = src_port[0] & 0xf0;
271 FX_DWORD g = src_port[1] & 0xf0; 268 FX_DWORD g = src_port[1] & 0xf0;
272 FX_DWORD r = src_port[2] & 0xf0; 269 FX_DWORD r = src_port[2] & 0xf0;
273 FX_DWORD index = (r << 4) + g + (b >> 4); 270 FX_DWORD index = (r << 4) + g + (b >> 4);
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 } 868 }
872 case FXDIB_8bppRgb: 869 case FXDIB_8bppRgb:
873 case FXDIB_8bppRgba: { 870 case FXDIB_8bppRgba: {
874 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL ) { 871 if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL ) {
875 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 872 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, w idth, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
876 } 873 }
877 d_pal = FX_Alloc(FX_DWORD, 256); 874 d_pal = FX_Alloc(FX_DWORD, 256);
878 if (!d_pal) { 875 if (!d_pal) {
879 return FALSE; 876 return FALSE;
880 } 877 }
881 FXSYS_memset32(d_pal, 0, sizeof(FX_DWORD) * 256);
882 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS rcBitmap->GetPalette()) { 878 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pS rcBitmap->GetPalette()) {
883 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 879 return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
884 } else if ((src_format & 0xff) >= 24) { 880 } else if ((src_format & 0xff) >= 24) {
885 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); 881 return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, widt h, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
886 } 882 }
887 return FALSE; 883 return FALSE;
888 } 884 }
889 case FXDIB_Rgb: 885 case FXDIB_Rgb:
890 case FXDIB_Rgba: { 886 case FXDIB_Rgba: {
891 if ((src_format & 0xff) == 1) { 887 if ((src_format & 0xff) == 1) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 if (!m_bExtBuf) { 1078 if (!m_bExtBuf) {
1083 FX_Free(m_pBuffer); 1079 FX_Free(m_pBuffer);
1084 } 1080 }
1085 m_bExtBuf = FALSE; 1081 m_bExtBuf = FALSE;
1086 m_pBuffer = dest_buf; 1082 m_pBuffer = dest_buf;
1087 m_bpp = (FX_BYTE)dest_format; 1083 m_bpp = (FX_BYTE)dest_format;
1088 m_AlphaFlag = (FX_BYTE)(dest_format >> 8); 1084 m_AlphaFlag = (FX_BYTE)(dest_format >> 8);
1089 m_Pitch = dest_pitch; 1085 m_Pitch = dest_pitch;
1090 return TRUE; 1086 return TRUE;
1091 } 1087 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/xml_int.h ('k') | core/src/fxge/dib/fx_dib_engine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698