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

Side by Side Diff: core/fxcodec/codec/fx_codec_png.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Git rid of comparisons against NULL Created 4 years, 6 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "core/fxcodec/codec/codec_int.h" 9 #include "core/fxcodec/codec/codec_int.h"
10 #include "core/fxcodec/include/fx_codec.h" 10 #include "core/fxcodec/include/fx_codec.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 extern "C" { 103 extern "C" {
104 static void* _png_alloc_func(unsigned int size) { 104 static void* _png_alloc_func(unsigned int size) {
105 return FX_Alloc(char, size); 105 return FX_Alloc(char, size);
106 } 106 }
107 static void _png_free_func(void* p) { 107 static void _png_free_func(void* p) {
108 FX_Free(p); 108 FX_Free(p);
109 } 109 }
110 }; 110 };
111 static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) { 111 static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) {
112 FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr); 112 FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr);
113 if (p == NULL) { 113 if (!p)
114 return; 114 return;
115 } 115
116 CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr; 116 CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr;
117 if (pModule == NULL) { 117 if (!pModule)
118 return; 118 return;
119 } 119
120 png_uint_32 width = 0, height = 0; 120 png_uint_32 width = 0, height = 0;
121 int bpc = 0, color_type = 0, color_type1 = 0, pass = 0; 121 int bpc = 0, color_type = 0, color_type1 = 0, pass = 0;
122 double gamma = 1.0; 122 double gamma = 1.0;
123 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, NULL, 123 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, NULL,
124 NULL, NULL); 124 NULL, NULL);
125 color_type1 = color_type; 125 color_type1 = color_type;
126 if (bpc > 8) { 126 if (bpc > 8) {
127 png_set_strip_16(png_ptr); 127 png_set_strip_16(png_ptr);
128 } else if (bpc < 8) { 128 } else if (bpc < 8) {
129 png_set_expand_gray_1_2_4_to_8(png_ptr); 129 png_set_expand_gray_1_2_4_to_8(png_ptr);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); 175 png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
176 } 176 }
177 png_read_update_info(png_ptr, info_ptr); 177 png_read_update_info(png_ptr, info_ptr);
178 } 178 }
179 static void _png_get_end_func(png_structp png_ptr, png_infop info_ptr) {} 179 static void _png_get_end_func(png_structp png_ptr, png_infop info_ptr) {}
180 static void _png_get_row_func(png_structp png_ptr, 180 static void _png_get_row_func(png_structp png_ptr,
181 png_bytep new_row, 181 png_bytep new_row,
182 png_uint_32 row_num, 182 png_uint_32 row_num,
183 int pass) { 183 int pass) {
184 FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr); 184 FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr);
185 if (p == NULL) { 185 if (!p)
186 return; 186 return;
187 } 187
188 CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr; 188 CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr;
189 uint8_t* src_buf = NULL; 189 uint8_t* src_buf = NULL;
190 if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) { 190 if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) {
191 png_error(png_ptr, "Ask Scanline buffer Callback Error"); 191 png_error(png_ptr, "Ask Scanline buffer Callback Error");
192 } 192 }
193 if (src_buf) { 193 if (src_buf) {
194 png_progressive_combine_row(png_ptr, src_buf, new_row); 194 png_progressive_combine_row(png_ptr, src_buf, new_row);
195 } 195 }
196 pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num); 196 pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num);
197 } 197 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (setjmp(png_jmpbuf(ctx->png_ptr))) { 247 if (setjmp(png_jmpbuf(ctx->png_ptr))) {
248 if (pAttribute && 248 if (pAttribute &&
249 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) { 249 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) {
250 _png_load_bmp_attribute(ctx->png_ptr, ctx->info_ptr, pAttribute); 250 _png_load_bmp_attribute(ctx->png_ptr, ctx->info_ptr, pAttribute);
251 } 251 }
252 return FALSE; 252 return FALSE;
253 } 253 }
254 png_process_data(ctx->png_ptr, ctx->info_ptr, (uint8_t*)src_buf, src_size); 254 png_process_data(ctx->png_ptr, ctx->info_ptr, (uint8_t*)src_buf, src_size);
255 return TRUE; 255 return TRUE;
256 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698