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

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

Issue 1143663008: Merge to XFA: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebased. 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_engine.cpp ('k') | core/src/fxge/ge/fx_ge_font.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 #include "dib_int.h" 10 #include "dib_int.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return FALSE; 78 return FALSE;
79 } 79 }
80 if (pBuffer) { 80 if (pBuffer) {
81 m_pBuffer = pBuffer; 81 m_pBuffer = pBuffer;
82 m_bExtBuf = TRUE; 82 m_bExtBuf = TRUE;
83 } else { 83 } else {
84 int size = pitch * height + 4; 84 int size = pitch * height + 4;
85 int oomlimit = _MAX_OOM_LIMIT_; 85 int oomlimit = _MAX_OOM_LIMIT_;
86 if (oomlimit >= 0 && size >= oomlimit) { 86 if (oomlimit >= 0 && size >= oomlimit) {
87 m_pBuffer = FX_TryAlloc(FX_BYTE, size); 87 m_pBuffer = FX_TryAlloc(FX_BYTE, size);
88 if (m_pBuffer == NULL) {
89 return FALSE;
90 }
88 } else { 91 } else {
89 m_pBuffer = FX_Alloc(FX_BYTE, size); 92 m_pBuffer = FX_Alloc(FX_BYTE, size);
90 } 93 }
91 if (m_pBuffer == NULL) {
92 return FALSE;
93 }
94 } 94 }
95 m_Width = width; 95 m_Width = width;
96 m_Height = height; 96 m_Height = height;
97 m_Pitch = pitch; 97 m_Pitch = pitch;
98 if (HasAlpha() && format != FXDIB_Argb) { 98 if (HasAlpha() && format != FXDIB_Argb) {
99 FX_BOOL ret = TRUE; 99 FX_BOOL ret = TRUE;
100 ret = BuildAlphaMask(); 100 ret = BuildAlphaMask();
101 if (!ret) { 101 if (!ret) {
102 if (!m_bExtBuf && m_pBuffer) { 102 if (!m_bExtBuf && m_pBuffer) {
103 FX_Free(m_pBuffer); 103 FX_Free(m_pBuffer);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 return pNewBitmap; 199 return pNewBitmap;
200 } 200 }
201 void CFX_DIBSource::BuildPalette() 201 void CFX_DIBSource::BuildPalette()
202 { 202 {
203 if (m_pPalette) { 203 if (m_pPalette) {
204 return; 204 return;
205 } 205 }
206 if (GetBPP() == 1) { 206 if (GetBPP() == 1) {
207 m_pPalette = FX_Alloc(FX_DWORD, 2); 207 m_pPalette = FX_Alloc(FX_DWORD, 2);
208 if (!m_pPalette) {
209 return;
210 }
211 if(IsCmykImage()) { 208 if(IsCmykImage()) {
212 m_pPalette[0] = 0xff; 209 m_pPalette[0] = 0xff;
213 m_pPalette[1] = 0; 210 m_pPalette[1] = 0;
214 } else { 211 } else {
215 m_pPalette[0] = 0xff000000; 212 m_pPalette[0] = 0xff000000;
216 m_pPalette[1] = 0xffffffff; 213 m_pPalette[1] = 0xffffffff;
217 } 214 }
218 } else if (GetBPP() == 8) { 215 } else if (GetBPP() == 8) {
219 m_pPalette = FX_Alloc(FX_DWORD, 256); 216 m_pPalette = FX_Alloc(FX_DWORD, 256);
220 if (!m_pPalette) {
221 return;
222 }
223 if(IsCmykImage()) { 217 if(IsCmykImage()) {
224 for (int i = 0; i < 256; i ++) { 218 for (int i = 0; i < 256; i ++) {
225 m_pPalette[i] = 0xff - i; 219 m_pPalette[i] = 0xff - i;
226 } 220 }
227 } else { 221 } else {
228 for (int i = 0; i < 256; i ++) { 222 for (int i = 0; i < 256; i ++) {
229 m_pPalette[i] = 0xff000000 | (i * 0x10101); 223 m_pPalette[i] = 0xff000000 | (i * 0x10101);
230 } 224 }
231 } 225 }
232 } 226 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (pSrc == NULL || GetBPP() > 8) { 524 if (pSrc == NULL || GetBPP() > 8) {
531 if (m_pPalette) { 525 if (m_pPalette) {
532 FX_Free(m_pPalette); 526 FX_Free(m_pPalette);
533 } 527 }
534 m_pPalette = NULL; 528 m_pPalette = NULL;
535 } else { 529 } else {
536 FX_DWORD pal_size = 1 << GetBPP(); 530 FX_DWORD pal_size = 1 << GetBPP();
537 if (m_pPalette == NULL) { 531 if (m_pPalette == NULL) {
538 m_pPalette = FX_Alloc(FX_DWORD, pal_size); 532 m_pPalette = FX_Alloc(FX_DWORD, pal_size);
539 } 533 }
540 if (!m_pPalette) {
541 return;
542 }
543 if (pal_size > size) { 534 if (pal_size > size) {
544 pal_size = size; 535 pal_size = size;
545 } 536 }
546 FXSYS_memcpy32(m_pPalette, pSrc, pal_size * sizeof(FX_DWORD)); 537 FXSYS_memcpy32(m_pPalette, pSrc, pal_size * sizeof(FX_DWORD));
547 } 538 }
548 } 539 }
549 void CFX_DIBSource::GetPalette(FX_DWORD* pal, int alpha) const 540 void CFX_DIBSource::GetPalette(FX_DWORD* pal, int alpha) const
550 { 541 {
551 ASSERT(GetBPP() <= 8 && !IsCmykImage()); 542 ASSERT(GetBPP() <= 8 && !IsCmykImage());
552 if (GetBPP() == 1) { 543 if (GetBPP() == 1) {
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 if (!m_pBitmap->Create(width, height, src_format)) { 1705 if (!m_pBitmap->Create(width, height, src_format)) {
1715 delete m_pBitmap; 1706 delete m_pBitmap;
1716 m_pBitmap = NULL; 1707 m_pBitmap = NULL;
1717 return FALSE; 1708 return FALSE;
1718 } 1709 }
1719 if (pSrcPalette) { 1710 if (pSrcPalette) {
1720 m_pBitmap->CopyPalette(pSrcPalette); 1711 m_pBitmap->CopyPalette(pSrcPalette);
1721 } 1712 }
1722 return TRUE; 1713 return TRUE;
1723 } 1714 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_engine.cpp ('k') | core/src/fxge/ge/fx_ge_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698