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

Side by Side Diff: core/src/fxge/win32/fx_win32_dib.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/win32/fx_win32_device.cpp ('k') | core/src/fxge/win32/fx_win32_gdipext.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_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 "../../../include/fxge/fx_ge_win32.h" 10 #include "../../../include/fxge/fx_ge_win32.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 FXDIB_Format format = bAlpha ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0 x200) : (FXDIB_Format)pbmi->bmiHeader.biBitCount; 66 FXDIB_Format format = bAlpha ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0 x200) : (FXDIB_Format)pbmi->bmiHeader.biBitCount;
67 FX_BOOL ret = pBitmap->Create(width, height, format); 67 FX_BOOL ret = pBitmap->Create(width, height, format);
68 if (!ret) { 68 if (!ret) {
69 delete pBitmap; 69 delete pBitmap;
70 return NULL; 70 return NULL;
71 } 71 }
72 FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height); 72 FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height);
73 if (bBottomUp) { 73 if (bBottomUp) {
74 FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch); 74 FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch);
75 if (!temp_buf) {
76 if (pBitmap) {
77 delete pBitmap;
78 }
79 return NULL;
80 }
81 int top = 0, bottom = height - 1; 75 int top = 0, bottom = height - 1;
82 while (top < bottom) { 76 while (top < bottom) {
83 FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch); 77 FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch);
84 FXSYS_memcpy32(pBitmap->GetBuffer() + top * pitch, pBitmap->GetBuffe r() + bottom * pitch, pitch); 78 FXSYS_memcpy32(pBitmap->GetBuffer() + top * pitch, pBitmap->GetBuffe r() + bottom * pitch, pitch);
85 FXSYS_memcpy32(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitc h); 79 FXSYS_memcpy32(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitc h);
86 top ++; 80 top ++;
87 bottom --; 81 bottom --;
88 } 82 }
89 FX_Free(temp_buf); 83 FX_Free(temp_buf);
90 temp_buf = NULL; 84 temp_buf = NULL;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (!pDIBitmap) { 204 if (!pDIBitmap) {
211 return NULL; 205 return NULL;
212 } 206 }
213 int ret = 0; 207 int ret = 0;
214 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) { 208 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) {
215 int size = sizeof (BITMAPINFOHEADER) + 8; 209 int size = sizeof (BITMAPINFOHEADER) + 8;
216 if (bmih.biBitCount == 8) { 210 if (bmih.biBitCount == 8) {
217 size += sizeof (FX_DWORD) * 254; 211 size += sizeof (FX_DWORD) * 254;
218 } 212 }
219 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size); 213 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size);
220 if (!pbmih) {
221 delete pDIBitmap;
222 if (bCreatedDC) {
223 DeleteDC(hDC);
224 }
225 return NULL;
226 }
227 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 214 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
228 pbmih->bmiHeader.biBitCount = bmih.biBitCount; 215 pbmih->bmiHeader.biBitCount = bmih.biBitCount;
229 pbmih->bmiHeader.biCompression = BI_RGB; 216 pbmih->bmiHeader.biCompression = BI_RGB;
230 pbmih->bmiHeader.biHeight = -height; 217 pbmih->bmiHeader.biHeight = -height;
231 pbmih->bmiHeader.biPlanes = 1; 218 pbmih->bmiHeader.biPlanes = 1;
232 pbmih->bmiHeader.biWidth = bmih.biWidth; 219 pbmih->bmiHeader.biWidth = bmih.biWidth;
233 if (!pDIBitmap->Create(bmih.biWidth, height, bmih.biBitCount == 1 ? FXDI B_1bppRgb : FXDIB_8bppRgb)) { 220 if (!pDIBitmap->Create(bmih.biWidth, height, bmih.biBitCount == 1 ? FXDI B_1bppRgb : FXDIB_8bppRgb)) {
234 delete pDIBitmap; 221 delete pDIBitmap;
235 FX_Free(pbmih); 222 FX_Free(pbmih);
236 if (bCreatedDC) { 223 if (bCreatedDC) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 287 }
301 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) 288 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top)
302 { 289 {
303 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); 290 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY);
304 } 291 }
305 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) 292 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top)
306 { 293 {
307 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); 294 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY);
308 } 295 }
309 #endif 296 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/win32/fx_win32_device.cpp ('k') | core/src/fxge/win32/fx_win32_gdipext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698