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

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libpng.cpp
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index bccdfc8cf5910d06c2e99ce4ef298782563a287e..31ec4dd48a13dd167984d4285ea0d43fa8cd3bdc 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -26,19 +26,19 @@
/* These were dropped in libpng >= 1.4 */
#ifndef png_infopp_NULL
-#define png_infopp_NULL NULL
+#define png_infopp_NULL nullptr
#endif
#ifndef png_bytepp_NULL
-#define png_bytepp_NULL NULL
+#define png_bytepp_NULL nullptr
#endif
#ifndef int_p_NULL
-#define int_p_NULL NULL
+#define int_p_NULL nullptr
#endif
#ifndef png_flush_ptr_NULL
-#define png_flush_ptr_NULL NULL
+#define png_flush_ptr_NULL nullptr
#endif
#if defined(SK_DEBUG)
@@ -62,7 +62,7 @@ public:
, fPng_ptr(png_ptr)
, fInfo_ptr(info_ptr)
, fColorType(kUnknown_SkColorType) {
- SkASSERT(stream != NULL);
+ SkASSERT(stream != nullptr);
}
~SkPNGImageIndex() {
if (fPng_ptr) {
@@ -79,7 +79,7 @@ public:
class SkPNGImageDecoder : public SkImageDecoder {
public:
SkPNGImageDecoder() {
- fImageIndex = NULL;
+ fImageIndex = nullptr;
}
Format getFormat() const override {
return kPNG_Format;
@@ -205,7 +205,7 @@ static bool hasTransparencyInPalette(png_structp png_ptr, png_infop info_ptr) {
int num_trans;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
- png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, NULL);
+ png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, nullptr);
return num_trans > 0;
}
return false;
@@ -219,13 +219,13 @@ bool SkPNGImageDecoder::onDecodeInit(SkStream* sk_stream, png_structp *png_ptrp,
png_infop *info_ptrp) {
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
- * you can supply NULL for the last three parameters. We also supply the
+ * you can supply nullptr for the last three parameters. We also supply the
* the compiler header file version, so that we know if the application
* was compiled with a compatible version of the library. */
png_error_ptr user_warning_fn =
- (c_suppressPNGImageDecoderWarnings) ? (&do_nothing_warning_fn) : NULL;
- /* NULL means to leave as default library behavior. */
+ (c_suppressPNGImageDecoderWarnings) ? (&do_nothing_warning_fn) : nullptr;
+ /* nullptr means to leave as default library behavior. */
/* c_suppressPNGImageDecoderWarnings default depends on SK_DEBUG. */
/* To suppress warnings with a SK_DEBUG binary, set the
* environment variable "skia_images_png_suppressDecoderWarnings"
@@ -233,9 +233,9 @@ bool SkPNGImageDecoder::onDecodeInit(SkStream* sk_stream, png_structp *png_ptrp,
* SK_CONF_SET("images.png.suppressDecoderWarnings", true); */
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
- NULL, sk_error_fn, user_warning_fn);
+ nullptr, sk_error_fn, user_warning_fn);
// png_voidp user_error_ptr, user_error_fn, user_warning_fn);
- if (png_ptr == NULL) {
+ if (png_ptr == nullptr) {
return false;
}
@@ -243,7 +243,7 @@ bool SkPNGImageDecoder::onDecodeInit(SkStream* sk_stream, png_structp *png_ptrp,
/* Allocate/initialize the memory for image information. */
png_infop info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL) {
+ if (info_ptr == nullptr) {
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return false;
}
@@ -348,7 +348,7 @@ SkImageDecoder::Result SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap
// to |= PNG_COLOR_MASK_ALPHA, but all of its pixels are in fact opaque. We care, since we
// draw lots faster if we can flag the bitmap has being opaque
bool reallyHasAlpha = false;
- SkColorTable* colorTable = NULL;
+ SkColorTable* colorTable = nullptr;
if (pngColorType == PNG_COLOR_TYPE_PALETTE) {
decodePalette(png_ptr, info_ptr, bitDepth, &hasAlpha, &reallyHasAlpha, &colorTable);
@@ -357,7 +357,7 @@ SkImageDecoder::Result SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap
SkAutoUnref aur(colorTable);
if (!this->allocPixelRef(decodedBitmap,
- kIndex_8_SkColorType == colorType ? colorTable : NULL)) {
+ kIndex_8_SkColorType == colorType ? colorTable : nullptr)) {
return kFailure;
}
@@ -402,7 +402,7 @@ SkImageDecoder::Result SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap
SkScaledBitmapSampler::SrcConfig sc;
int srcBytesPerPixel = 4;
- if (colorTable != NULL) {
+ if (colorTable != nullptr) {
sc = SkScaledBitmapSampler::kIndex;
srcBytesPerPixel = 1;
} else if (kAlpha_8_SkColorType == colorType) {
@@ -420,7 +420,7 @@ SkImageDecoder::Result SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap
even if our decodedBitmap doesn't, due to the request that we
upscale png's palette to a direct model
*/
- const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL;
+ const SkPMColor* colors = colorTable ? colorTable->readColors() : nullptr;
if (!sampler.begin(decodedBitmap, sc, *this, colors)) {
return kFailure;
}
@@ -532,14 +532,14 @@ bool SkPNGImageDecoder::getBitmapColorType(png_structp png_ptr, png_infop info_p
*colorTypep = kIndex_8_SkColorType;
}
} else {
- png_color_16p transpColor = NULL;
+ png_color_16p transpColor = nullptr;
int numTransp = 0;
- png_get_tRNS(png_ptr, info_ptr, NULL, &numTransp, &transpColor);
+ png_get_tRNS(png_ptr, info_ptr, nullptr, &numTransp, &transpColor);
bool valid = png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS);
- if (valid && numTransp == 1 && transpColor != NULL) {
+ if (valid && numTransp == 1 && transpColor != nullptr) {
/* Compute our transparent color, which we'll match against later.
We don't really handle 16bit components properly here, since we
do our compare *after* the values have been knocked down to 8bit
@@ -627,7 +627,7 @@ bool SkPNGImageDecoder::getBitmapColorType(png_structp png_ptr, png_infop info_p
*colorTypep = kN32_SkColorType;
}
- if (fImageIndex != NULL) {
+ if (fImageIndex != nullptr) {
if (kUnknown_SkColorType == fImageIndex->fColorType) {
// This is the first time for this subset decode. From now on,
// all decodes must be in the same colortype.
@@ -672,7 +672,7 @@ bool SkPNGImageDecoder::decodePalette(png_structp png_ptr, png_infop info_ptr,
SkPMColor* colorPtr = colorStorage;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
- png_get_tRNS(png_ptr, info_ptr, &trans, &numTrans, NULL);
+ png_get_tRNS(png_ptr, info_ptr, &trans, &numTrans, nullptr);
*hasAlphap = (numTrans > 0);
} else {
numTrans = 0;
@@ -761,7 +761,7 @@ bool SkPNGImageDecoder::onBuildTileIndex(SkStreamRewindable* sk_stream, int *wid
}
bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
- if (NULL == fImageIndex) {
+ if (nullptr == fImageIndex) {
return false;
}
@@ -805,7 +805,7 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
// to |= PNG_COLOR_MASK_ALPHA, but all of its pixels are in fact opaque. We care, since we
// draw lots faster if we can flag the bitmap has being opaque
bool reallyHasAlpha = false;
- SkColorTable* colorTable = NULL;
+ SkColorTable* colorTable = nullptr;
if (pngColorType == PNG_COLOR_TYPE_PALETTE) {
decodePalette(png_ptr, info_ptr, bitDepth, &hasAlpha, &reallyHasAlpha, &colorTable);
@@ -822,11 +822,11 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
(h == decodedBitmap.height()) && bm->isNull();
const bool needColorTable = kIndex_8_SkColorType == colorType;
if (swapOnly) {
- if (!this->allocPixelRef(&decodedBitmap, needColorTable ? colorTable : NULL)) {
+ if (!this->allocPixelRef(&decodedBitmap, needColorTable ? colorTable : nullptr)) {
return false;
}
} else {
- if (!decodedBitmap.tryAllocPixels(NULL, needColorTable ? colorTable : NULL)) {
+ if (!decodedBitmap.tryAllocPixels(nullptr, needColorTable ? colorTable : nullptr)) {
return false;
}
}
@@ -882,7 +882,7 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
SkScaledBitmapSampler::SrcConfig sc;
int srcBytesPerPixel = 4;
- if (colorTable != NULL) {
+ if (colorTable != nullptr) {
sc = SkScaledBitmapSampler::kIndex;
srcBytesPerPixel = 1;
} else if (kAlpha_8_SkColorType == colorType) {
@@ -900,7 +900,7 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
even if our decodedBitmap doesn't, due to the request that we
upscale png's palette to a direct model
*/
- const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL;
+ const SkPMColor* colors = colorTable ? colorTable->readColors() : nullptr;
if (!sampler.begin(&decodedBitmap, sc, *this, colors)) {
return false;
}
@@ -1025,7 +1025,7 @@ static transform_scanline_proc choose_proc(SkColorType ct, bool hasAlpha) {
}
}
sk_throw();
- return NULL;
+ return nullptr;
}
// return the minimum legal bitdepth (by png standards) for this many colortable
@@ -1053,7 +1053,7 @@ static int computeBitDepth(int colorCount) {
static inline int pack_palette(SkColorTable* ctable,
png_color* SK_RESTRICT palette,
png_byte* SK_RESTRICT trans, bool hasAlpha) {
- const SkPMColor* SK_RESTRICT colors = ctable ? ctable->readColors() : NULL;
+ const SkPMColor* SK_RESTRICT colors = ctable ? ctable->readColors() : nullptr;
const int ctCount = ctable->count();
int i, num_trans = 0;
@@ -1182,14 +1182,14 @@ bool SkPNGImageEncoder::doEncode(SkWStream* stream, const SkBitmap& bitmap,
png_structp png_ptr;
png_infop info_ptr;
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, sk_error_fn,
- NULL);
- if (NULL == png_ptr) {
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, sk_error_fn,
+ nullptr);
+ if (nullptr == png_ptr) {
return false;
}
info_ptr = png_create_info_struct(png_ptr);
- if (NULL == info_ptr) {
+ if (nullptr == info_ptr) {
png_destroy_write_struct(&png_ptr, png_infopp_NULL);
return false;
}
@@ -1226,7 +1226,7 @@ bool SkPNGImageEncoder::doEncode(SkWStream* stream, const SkBitmap& bitmap,
int numTrans = pack_palette(ct, paletteColors, trans, hasAlpha);
png_set_PLTE(png_ptr, info_ptr, paletteColors, ct->count());
if (numTrans > 0) {
- png_set_tRNS(png_ptr, info_ptr, trans, numTrans, NULL);
+ png_set_tRNS(png_ptr, info_ptr, trans, numTrans, nullptr);
}
}
#ifdef PNG_sBIT_SUPPORTED
@@ -1271,7 +1271,7 @@ SkImageDecoder* sk_libpng_dfactory(SkStreamRewindable* stream) {
if (is_png(stream)) {
return new SkPNGImageDecoder;
}
- return NULL;
+ return nullptr;
}
static SkImageDecoder::Format get_format_png(SkStreamRewindable* stream) {
@@ -1282,7 +1282,7 @@ static SkImageDecoder::Format get_format_png(SkStreamRewindable* stream) {
}
SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
- return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : NULL;
+ return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr;
}
static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory);
« no previous file with comments | « src/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698