diff options
Diffstat (limited to 'tools')
50 files changed, 278 insertions, 270 deletions
diff --git a/tools/CopyTilesRenderer.cpp b/tools/CopyTilesRenderer.cpp index bc1e32ec11..f5ffb25d03 100644 --- a/tools/CopyTilesRenderer.cpp +++ b/tools/CopyTilesRenderer.cpp @@ -32,7 +32,7 @@ namespace sk_tools { bool useChecksumBasedFilenames, bool useMultiPictureDraw) { // Do not call INHERITED::init(), which would create a (potentially large) canvas which is // not used by bench_pictures. - SkASSERT(pict != NULL); + SkASSERT(pict != nullptr); // Only work with absolute widths (as opposed to percentages). SkASSERT(this->getTileWidth() != 0 && this->getTileHeight() != 0); fPicture.reset(pict)->ref(); diff --git a/tools/CrashHandler.cpp b/tools/CrashHandler.cpp index e26772b4ba..6707b65de4 100644 --- a/tools/CrashHandler.cpp +++ b/tools/CrashHandler.cpp @@ -150,10 +150,10 @@ GetCurrentThread(), &frame, c, - NULL, + nullptr, SymFunctionTableAccess64, SymGetModuleBase64, - NULL)) { + nullptr)) { // Buffer to store symbol name in. static const int kMaxNameLength = 1024; uint8_t buffer[sizeof(IMAGEHLP_SYMBOL64) + kMaxNameLength]; diff --git a/tools/DumpRecord.cpp b/tools/DumpRecord.cpp index 3c34231e18..667c9ef506 100644 --- a/tools/DumpRecord.cpp +++ b/tools/DumpRecord.cpp @@ -21,7 +21,7 @@ public: : fDigits(0) , fIndent(0) , fIndex(0) - , fDraw(canvas, NULL, NULL, 0, NULL) + , fDraw(canvas, nullptr, nullptr, 0, nullptr) , fTimeWithCommand(timeWithCommand) { while (count > 0) { count /= 10; diff --git a/tools/LazyDecodeBitmap.cpp b/tools/LazyDecodeBitmap.cpp index bcd8cad44d..b6ac2d5566 100644 --- a/tools/LazyDecodeBitmap.cpp +++ b/tools/LazyDecodeBitmap.cpp @@ -24,21 +24,21 @@ DEFINE_bool(useVolatileCache, false, "Use a volatile cache for deferred image de // Used in SkPictureData::CreateFromStream bool sk_tools::LazyDecodeBitmap(const void* src, size_t length, SkBitmap* dst) { SkAutoDataUnref data(SkData::NewWithCopy(src, length)); - if (NULL == data.get()) { + if (nullptr == data.get()) { return false; } SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded(data)); - if (NULL == gen.get()) { + if (nullptr == gen.get()) { return false; } const SkImageInfo info = gen->getInfo(); - SkDiscardableMemory::Factory* pool = NULL; + SkDiscardableMemory::Factory* pool = nullptr; if ((!FLAGS_useVolatileCache) || (info.width() * info.height() < 32 * 1024)) { // how to do switching with SkDiscardableMemory. pool = SkGetGlobalDiscardableMemoryPool(); // Only meaningful if platform has a default discardable // memory implementation that differs from the global DM pool. } - return SkInstallDiscardablePixelRef(gen.detach(), NULL, dst, pool); + return SkInstallDiscardablePixelRef(gen.detach(), nullptr, dst, pool); } diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp index 9a86d85f9b..84528e5744 100644 --- a/tools/PictureBenchmark.cpp +++ b/tools/PictureBenchmark.cpp @@ -16,12 +16,12 @@ namespace sk_tools { PictureBenchmark::PictureBenchmark() : fRepeats(1) - , fRenderer(NULL) + , fRenderer(nullptr) , fTimerResult(TimerData::kAvg_Result) , fTimerTypes(0) , fTimeIndividualTiles(false) , fPurgeDecodedTex(false) - , fWriter(NULL) { + , fWriter(nullptr) { } PictureBenchmark::~PictureBenchmark() { @@ -43,11 +43,11 @@ void PictureBenchmark::setTimersToShow(bool wall, Timer* PictureBenchmark::setupTimer(bool useGLTimer) { #if SK_SUPPORT_GPU - if (useGLTimer && fRenderer != NULL && fRenderer->isUsingGpuDevice()) { + if (useGLTimer && fRenderer != nullptr && fRenderer->isUsingGpuDevice()) { return new Timer(fRenderer->getGLContext()); } #endif - return new Timer(NULL); + return new Timer(nullptr); } PictureRenderer* PictureBenchmark::setRenderer(sk_tools::PictureRenderer* renderer) { @@ -57,21 +57,21 @@ PictureRenderer* PictureBenchmark::setRenderer(sk_tools::PictureRenderer* render void PictureBenchmark::run(SkPicture* pict, bool useMultiPictureDraw) { SkASSERT(pict); - if (NULL == pict) { + if (nullptr == pict) { return; } - SkASSERT(fRenderer != NULL); - if (NULL == fRenderer) { + SkASSERT(fRenderer != nullptr); + if (nullptr == fRenderer) { return; } - fRenderer->init(pict, NULL, NULL, NULL, false, useMultiPictureDraw); + fRenderer->init(pict, nullptr, nullptr, nullptr, false, useMultiPictureDraw); // We throw this away to remove first time effects (such as paging in this program) fRenderer->setup(); - fRenderer->render(NULL); + fRenderer->render(nullptr); fRenderer->resetState(true); // flush, swapBuffers and Finish if (fPurgeDecodedTex) { @@ -109,7 +109,7 @@ void PictureBenchmark::run(SkPicture* pict, bool useMultiPictureDraw) { if (fTimeIndividualTiles) { TiledPictureRenderer* tiledRenderer = fRenderer->getTiledRenderer(); SkASSERT(tiledRenderer && tiledRenderer->supportsTimingIndividualTiles()); - if (NULL == tiledRenderer || !tiledRenderer->supportsTimingIndividualTiles()) { + if (nullptr == tiledRenderer || !tiledRenderer->supportsTimingIndividualTiles()) { return; } int xTiles, yTiles; @@ -200,7 +200,7 @@ void PictureBenchmark::run(SkPicture* pict, bool useMultiPictureDraw) { fRenderer->setup(); perRunTimer->start(); - fRenderer->render(NULL); + fRenderer->render(nullptr); perRunTimer->truncatedEnd(); fRenderer->resetState(false); // flush & swapBuffers, but don't Finish perRunTimer->end(); diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index ee8e981a39..700d3d3982 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -65,14 +65,14 @@ void PictureRenderer::init(const SkPicture* pict, fUseChecksumBasedFilenames = useChecksumBasedFilenames; fUseMultiPictureDraw = useMultiPictureDraw; - SkASSERT(NULL == fPicture); - SkASSERT(NULL == fCanvas.get()); + SkASSERT(nullptr == fPicture); + SkASSERT(nullptr == fCanvas.get()); if (fPicture || fCanvas.get()) { return; } - SkASSERT(pict != NULL); - if (NULL == pict) { + SkASSERT(pict != nullptr); + if (nullptr == pict) { return; } @@ -102,7 +102,7 @@ protected: if (PictureRenderer::kMaskFilter_DrawFilterFlag & fFlags[t]) { SkMaskFilter* maskFilter = paint->getMaskFilter(); if (maskFilter) { - paint->setMaskFilter(NULL); + paint->setMaskFilter(nullptr); } } if (PictureRenderer::kHinting_DrawFilterFlag & fFlags[t]) { @@ -154,7 +154,7 @@ SkCanvas* PictureRenderer::setupCanvas(int width, int height) { desc.fWidth = width; desc.fHeight = height; desc.fSampleCnt = fSampleCount; - target.reset(fGrContext->textureProvider()->createTexture(desc, false, NULL, 0)); + target.reset(fGrContext->textureProvider()->createTexture(desc, false, nullptr, 0)); } uint32_t flags = fUseDFText ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; @@ -163,7 +163,7 @@ SkCanvas* PictureRenderer::setupCanvas(int width, int height) { SkGpuDevice::Create(target->asRenderTarget(), &props, SkGpuDevice::kUninit_InitContents)); if (!device) { - return NULL; + return nullptr; } canvas.reset(new SkCanvas(device)); break; @@ -171,7 +171,7 @@ SkCanvas* PictureRenderer::setupCanvas(int width, int height) { #endif default: SkASSERT(0); - return NULL; + return nullptr; } if (fHasDrawFilters) { @@ -192,7 +192,7 @@ SkCanvas* PictureRenderer::setupCanvas(int width, int height) { } void PictureRenderer::scaleToScaleFactor(SkCanvas* canvas) { - SkASSERT(canvas != NULL); + SkASSERT(canvas != nullptr); if (fScaleFactor != SK_Scalar1) { canvas->scale(fScaleFactor, fScaleFactor); } @@ -200,12 +200,12 @@ void PictureRenderer::scaleToScaleFactor(SkCanvas* canvas) { void PictureRenderer::end() { this->resetState(true); - fPicture.reset(NULL); - fCanvas.reset(NULL); + fPicture.reset(nullptr); + fCanvas.reset(nullptr); } int PictureRenderer::getViewWidth() { - SkASSERT(fPicture != NULL); + SkASSERT(fPicture != nullptr); int width = SkScalarCeilToInt(fPicture->cullRect().width() * fScaleFactor); if (fViewport.width() > 0) { width = SkMin32(width, fViewport.width()); @@ -214,7 +214,7 @@ int PictureRenderer::getViewWidth() { } int PictureRenderer::getViewHeight() { - SkASSERT(fPicture != NULL); + SkASSERT(fPicture != nullptr); int height = SkScalarCeilToInt(fPicture->cullRect().height() * fScaleFactor); if (fViewport.height() > 0) { height = SkMin32(height, fViewport.height()); @@ -247,7 +247,7 @@ void PictureRenderer::buildBBoxHierarchy() { void PictureRenderer::resetState(bool callFinish) { #if SK_SUPPORT_GPU SkGLContext* glContext = this->getGLContext(); - if (NULL == glContext) { + if (nullptr == glContext) { SkASSERT(kBitmap_DeviceType == fDeviceType); return; } @@ -267,7 +267,7 @@ void PictureRenderer::purgeTextures() { #if SK_SUPPORT_GPU SkGLContext* glContext = this->getGLContext(); - if (NULL == glContext) { + if (nullptr == glContext) { SkASSERT(kBitmap_DeviceType == fDeviceType); return; } @@ -295,9 +295,9 @@ void PictureRenderer::purgeTextures() { */ static bool write(SkCanvas* canvas, const SkString& writePath, const SkString& mismatchPath, const SkString& inputFilename, ImageResultsAndExpectations *jsonSummaryPtr, - bool useChecksumBasedFilenames, const int* tileNumberPtr=NULL) { - SkASSERT(canvas != NULL); - if (NULL == canvas) { + bool useChecksumBasedFilenames, const int* tileNumberPtr=nullptr) { + SkASSERT(canvas != nullptr); + if (nullptr == canvas) { return false; } @@ -315,7 +315,7 @@ static bool write(SkCanvas* canvas, const SkString& writePath, const SkString& m // TODO(epoger): what about including the config type within outputFilename? That way, // we could combine results of different config types without conflicting filenames. SkString outputFilename; - const char *outputSubdirPtr = NULL; + const char *outputSubdirPtr = nullptr; if (useChecksumBasedFilenames) { ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr(); outputSubdirPtr = escapedInputFilename.c_str(); @@ -364,7 +364,7 @@ static bool write(SkCanvas* canvas, const SkString& writePath, const SkString& m SkCanvas* RecordPictureRenderer::setupCanvas(int width, int height) { // defer the canvas setup until the render step - return NULL; + return nullptr; } bool RecordPictureRenderer::render(SkBitmap** out) { @@ -395,9 +395,9 @@ SkString RecordPictureRenderer::getConfigNameInternal() { /////////////////////////////////////////////////////////////////////////////////////////////// bool PipePictureRenderer::render(SkBitmap** out) { - SkASSERT(fCanvas.get() != NULL); - SkASSERT(fPicture != NULL); - if (NULL == fCanvas.get() || NULL == fPicture) { + SkASSERT(fCanvas.get() != nullptr); + SkASSERT(fPicture != nullptr); + if (nullptr == fCanvas.get() || nullptr == fPicture) { return false; } @@ -436,9 +436,9 @@ void SimplePictureRenderer::init(const SkPicture* picture, const SkString* write } bool SimplePictureRenderer::render(SkBitmap** out) { - SkASSERT(fCanvas.get() != NULL); + SkASSERT(fCanvas.get() != nullptr); SkASSERT(fPicture); - if (NULL == fCanvas.get() || NULL == fPicture) { + if (nullptr == fCanvas.get() || nullptr == fPicture) { return false; } @@ -493,7 +493,7 @@ void TiledPictureRenderer::init(const SkPicture* pict, const SkString* writePath bool useChecksumBasedFilenames, bool useMultiPictureDraw) { SkASSERT(pict); SkASSERT(0 == fTileRects.count()); - if (NULL == pict || fTileRects.count() != 0) { + if (nullptr == pict || fTileRects.count() != 0) { return; } @@ -550,7 +550,7 @@ void TiledPictureRenderer::setupTiles() { } bool TiledPictureRenderer::tileDimensions(int &x, int &y) { - if (fTileRects.count() == 0 || NULL == fPicture) { + if (fTileRects.count() == 0 || nullptr == fPicture) { return false; } x = fTilesX; @@ -687,8 +687,8 @@ bool TiledPictureRenderer::postRender(SkCanvas* canvas, const SkIRect& tileRect, } bool TiledPictureRenderer::render(SkBitmap** out) { - SkASSERT(fPicture != NULL); - if (NULL == fPicture) { + SkASSERT(fPicture != nullptr); + if (nullptr == fPicture) { return false; } @@ -819,12 +819,12 @@ SkString PlaybackCreationRenderer::getConfigNameInternal() { SkBBHFactory* PictureRenderer::getFactory() { switch (fBBoxHierarchyType) { case kNone_BBoxHierarchyType: - return NULL; + return nullptr; case kRTree_BBoxHierarchyType: return new SkRTreeFactory; } SkASSERT(0); // invalid bbhType - return NULL; + return nullptr; } } // namespace sk_tools diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index a06604bc87..3139801910 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -83,9 +83,9 @@ public: * * @param pict The SkPicture to render. * @param writePath The output directory within which this renderer should write all images, - * or NULL if this renderer should not write all images. + * or nullptr if this renderer should not write all images. * @param mismatchPath The output directory within which this renderer should write any images - * which do not match expectations, or NULL if this renderer should not write mismatches. + * which do not match expectations, or nullptr if this renderer should not write mismatches. * @param inputFilename The name of the input file we are rendering. * @param useChecksumBasedFilenames Whether to use checksum-based filenames when writing * bitmap images to disk. @@ -138,7 +138,7 @@ public: * @return bool True if rendering succeeded and, if fWritePath had been specified, the output * was successfully written to a file. */ - virtual bool render(SkBitmap** out = NULL) = 0; + virtual bool render(SkBitmap** out = nullptr) = 0; /** * Called once finished with a particular SkPicture, before calling init again, and before @@ -150,7 +150,7 @@ public: * If this PictureRenderer is actually a TiledPictureRender, return a pointer to this as a * TiledPictureRender so its methods can be called. */ - virtual TiledPictureRenderer* getTiledRenderer() { return NULL; } + virtual TiledPictureRenderer* getTiledRenderer() { return nullptr; } /** * Resets the GPU's state. Does nothing if the backing is raster. For a GPU renderer, calls @@ -177,7 +177,7 @@ public: #if SK_SUPPORT_GPU // In case this function is called more than once SkSafeUnref(fGrContext); - fGrContext = NULL; + fGrContext = nullptr; // Set to Native so it will have an initial value. GrContextFactory::GLContextType glContextType = GrContextFactory::kNative_GLContextType; #endif @@ -208,7 +208,7 @@ public: } #if SK_SUPPORT_GPU fGrContext = fGrContextFactory.get(glContextType, gpuAPI); - if (NULL == fGrContext) { + if (nullptr == fGrContext) { return false; } else { fGrContext->ref(); @@ -390,7 +390,7 @@ public: break; #endif default: - return NULL; + return nullptr; } return fGrContextFactory.getGLContext(glContextType); } @@ -417,7 +417,7 @@ public: #else PictureRenderer() #endif - : fJsonSummaryPtr(NULL) + : fJsonSummaryPtr(nullptr) , fDeviceType(kBitmap_DeviceType) , fEnableWrites(false) , fBBoxHierarchyType(kNone_BBoxHierarchyType) @@ -425,7 +425,7 @@ public: , fScaleFactor(SK_Scalar1) #if SK_SUPPORT_GPU , fGrContextFactory(opts) - , fGrContext(NULL) + , fGrContext(nullptr) , fSampleCount(0) , fUseDFText(false) #endif @@ -481,7 +481,7 @@ protected: virtual SkCanvas* setupCanvas(int width, int height); /** - * Copy src to dest; if src==NULL, set dest to empty string. + * Copy src to dest; if src==nullptr, set dest to empty string. */ static void CopyString(SkString* dest, const SkString* src); @@ -510,7 +510,7 @@ public: RecordPictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { } #endif - bool render(SkBitmap** out = NULL) override; + bool render(SkBitmap** out = nullptr) override; SkString getPerIterTimeFormat() override { return SkString("%.4f"); } @@ -531,7 +531,7 @@ public: PipePictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { } #endif - bool render(SkBitmap** out = NULL) override; + bool render(SkBitmap** out = nullptr) override; private: SkString getConfigNameInternal() override; @@ -552,7 +552,7 @@ public: bool useChecksumBasedFilenames, bool useMultiPictureDraw) override; - bool render(SkBitmap** out = NULL) override; + bool render(SkBitmap** out = nullptr) override; private: SkString getConfigNameInternal() override; @@ -580,7 +580,7 @@ public: * If fWritePath was provided, a separate file is * created for each tile, named "path0.png", "path1.png", etc. */ - bool render(SkBitmap** out = NULL) override; + bool render(SkBitmap** out = nullptr) override; void end() override; @@ -703,7 +703,7 @@ public: void setup() override; - bool render(SkBitmap** out = NULL) override; + bool render(SkBitmap** out = nullptr) override; SkString getPerIterTimeFormat() override { return SkString("%.4f"); } diff --git a/tools/PictureRenderingFlags.cpp b/tools/PictureRenderingFlags.cpp index 7a2fc259d7..b0456baa82 100644 --- a/tools/PictureRenderingFlags.cpp +++ b/tools/PictureRenderingFlags.cpp @@ -92,11 +92,11 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { error.reset(); bool useTiles = false; - const char* widthString = NULL; - const char* heightString = NULL; + const char* widthString = nullptr; + const char* heightString = nullptr; bool isPowerOf2Mode = false; bool isCopyMode = false; - const char* mode = NULL; + const char* mode = nullptr; #if SK_SUPPORT_GPU GrContextOptions grContextOpts; @@ -123,13 +123,13 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { if (FLAGS_mode.count() < 2) { error.printf("Missing width for --mode %s\n", mode); - return NULL; + return nullptr; } widthString = FLAGS_mode[1]; if (FLAGS_mode.count() < 3) { error.printf("Missing height for --mode %s\n", mode); - return NULL; + return nullptr; } heightString = FLAGS_mode[2]; @@ -144,12 +144,12 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { // be created below. } else { error.printf("%s is not a valid mode for --mode\n", mode); - return NULL; + return nullptr; } } if (useTiles) { - SkASSERT(NULL == renderer); + SkASSERT(nullptr == renderer); SkAutoTUnref<sk_tools::TiledPictureRenderer> tiledRenderer; if (isCopyMode) { int xTiles = -1; @@ -157,7 +157,7 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { if (FLAGS_tiles.count() > 0) { if (FLAGS_tiles.count() != 2) { error.printf("--tiles requires an x value and a y value.\n"); - return NULL; + return nullptr; } xTiles = atoi(FLAGS_tiles[0]); yTiles = atoi(FLAGS_tiles[1]); @@ -169,7 +169,7 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { y = yTiles; if (x <= 0 || y <= 0) { error.printf("--tiles must be given values > 0\n"); - return NULL; + return nullptr; } } else { x = y = 4; @@ -189,43 +189,43 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { SkString err; error.printf("-mode %s must be given a width" " value that is a power of two\n", mode); - return NULL; + return nullptr; } tiledRenderer->setTileMinPowerOf2Width(minWidth); } else if (sk_tools::is_percentage(widthString)) { if (isCopyMode) { error.printf("--mode %s does not support percentages.\n", mode); - return NULL; + return nullptr; } tiledRenderer->setTileWidthPercentage(atof(widthString)); if (!(tiledRenderer->getTileWidthPercentage() > 0)) { error.printf("--mode %s must be given a width percentage > 0\n", mode); - return NULL; + return nullptr; } } else { tiledRenderer->setTileWidth(atoi(widthString)); if (!(tiledRenderer->getTileWidth() > 0)) { error.printf("--mode %s must be given a width > 0\n", mode); - return NULL; + return nullptr; } } if (sk_tools::is_percentage(heightString)) { if (isCopyMode) { error.printf("--mode %s does not support percentages.\n", mode); - return NULL; + return nullptr; } tiledRenderer->setTileHeightPercentage(atof(heightString)); if (!(tiledRenderer->getTileHeightPercentage() > 0)) { error.printf("--mode %s must be given a height percentage > 0\n", mode); - return NULL; + return nullptr; } } else { tiledRenderer->setTileHeight(atoi(heightString)); if (!(tiledRenderer->getTileHeight() > 0)) { SkString err; error.printf("--mode %s must be given a height > 0\n", mode); - return NULL; + return nullptr; } } @@ -237,22 +237,22 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { } else { // useTiles if (FLAGS_pipe) { - if (renderer != NULL) { + if (renderer != nullptr) { error.printf("Pipe is incompatible with other modes.\n"); - return NULL; + return nullptr; } renderer.reset(new sk_tools::PipePictureRenderer RENDERER_ARGS); } } - if (NULL == renderer) { + if (nullptr == renderer) { renderer.reset(new sk_tools::SimplePictureRenderer RENDERER_ARGS); } if (FLAGS_viewport.count() > 0) { if (FLAGS_viewport.count() != 2) { error.printf("--viewport requires a width and a height.\n"); - return NULL; + return nullptr; } SkISize viewport; viewport.fWidth = atoi(FLAGS_viewport[0]); @@ -271,11 +271,11 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { gpuAPI = kGLES_GrGLStandard; } else { error.printf("--gpuAPI invalid api value.\n"); - return NULL; + return nullptr; } } else if (FLAGS_gpuAPI.count() > 1) { error.printf("--gpuAPI invalid api value.\n"); - return NULL; + return nullptr; } int sampleCount = 0; @@ -322,7 +322,7 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { #endif else { error.printf("%s is not a valid mode for --config\n", FLAGS_config[0]); - return NULL; + return nullptr; } #if SK_SUPPORT_GPU if (!renderer->setDeviceType(deviceType, gpuAPI)) { @@ -330,7 +330,7 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { if (!renderer->setDeviceType(deviceType)) { #endif error.printf("Could not create backend for --config %s\n", FLAGS_config[0]); - return NULL; + return nullptr; } #if SK_SUPPORT_GPU renderer->setSampleCount(sampleCount); @@ -349,11 +349,11 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { bbhType = sk_tools::PictureRenderer::kRTree_BBoxHierarchyType; } else { error.printf("%s is not a valid value for --bbhType\n", type); - return NULL; + return nullptr; } if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType != bbhType) { error.printf("--pipe and --bbh cannot be used together\n"); - return NULL; + return nullptr; } } renderer->setBBoxHierarchyType(bbhType); diff --git a/tools/PictureRenderingFlags.h b/tools/PictureRenderingFlags.h index 29215ac7e1..9f0ee79432 100644 --- a/tools/PictureRenderingFlags.h +++ b/tools/PictureRenderingFlags.h @@ -26,7 +26,7 @@ enum PictureTool { * @param error If there is an error or warning, it will be stored in error. * @param tool Which tool is being used. * @return PictureRenderer A PictureRenderer with the settings specified - * on the command line, or NULL if the command line is invalid. + * on the command line, or nullptr if the command line is invalid. */ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool); diff --git a/tools/PictureResultsWriter.h b/tools/PictureResultsWriter.h index c9aaed0b35..8e606dceeb 100644 --- a/tools/PictureResultsWriter.h +++ b/tools/PictureResultsWriter.h @@ -104,7 +104,7 @@ private: class PictureResultsLoggerWriter : public PictureResultsWriter { private: void logProgress(const char str[]) { - if(fLogger != NULL) { + if(fLogger != nullptr) { fLogger->logProgress(str); } } diff --git a/tools/Resources.cpp b/tools/Resources.cpp index 75625b40a6..a2a59029bc 100644 --- a/tools/Resources.cpp +++ b/tools/Resources.cpp @@ -44,14 +44,14 @@ SkStreamAsset* GetResourceAsStream(const char* resource) { return stream.detach(); } else { SkDebugf("Resource %s not found.\n", resource); - return NULL; + return nullptr; } } SkTypeface* GetResourceAsTypeface(const char* resource) { SkAutoTDelete<SkStreamAsset> stream(GetResourceAsStream(resource)); if (!stream) { - return NULL; + return nullptr; } return SkTypeface::CreateFromStream(stream.detach()); } diff --git a/tools/VisualBench/VisualBench.cpp b/tools/VisualBench/VisualBench.cpp index 0763d5cacc..ae3526bfea 100644 --- a/tools/VisualBench/VisualBench.cpp +++ b/tools/VisualBench/VisualBench.cpp @@ -56,7 +56,7 @@ VisualBench::VisualBench(void* hwnd, int argc, char** argv) , fFlushes(1) , fLoops(1) , fState(kPreWarmLoops_State) - , fBenchmark(NULL) + , fBenchmark(nullptr) , fResults(new ResultsWriter) { SkCommandLineFlags::Parse(argc, argv); @@ -123,7 +123,7 @@ bool VisualBench::setupBackend() { } void VisualBench::resetContext() { - fSurface.reset(NULL); + fSurface.reset(nullptr); fInterface.reset(GrGLCreateNativeInterface()); SkASSERT(fInterface); @@ -266,7 +266,7 @@ void VisualBench::draw(SkCanvas* canvas) { } // Invalidate the window to force a redraw. Poor man's animation mechanism. - this->inval(NULL); + this->inval(nullptr); } inline double VisualBench::elapsed() { @@ -311,7 +311,7 @@ void VisualBench::recordMeasurement() { void VisualBench::postDraw(SkCanvas* canvas) { fBenchmark->perCanvasPostDraw(canvas); - fBenchmark.reset(NULL); + fBenchmark.reset(nullptr); fCurrentSample = 0; fFlushes = 1; fLoops = 1; diff --git a/tools/VisualBench/VisualBenchmarkStream.cpp b/tools/VisualBench/VisualBenchmarkStream.cpp index f8d01a1d91..4cc819ded5 100644 --- a/tools/VisualBench/VisualBenchmarkStream.cpp +++ b/tools/VisualBench/VisualBenchmarkStream.cpp @@ -13,7 +13,7 @@ #include "SkStream.h" #include "VisualSKPBench.h" -DEFINE_string2(match, m, NULL, +DEFINE_string2(match, m, nullptr, "[~][^]substring[$] [...] of bench name to run.\n" "Multiple matches may be separated by spaces.\n" "~ causes a matching bench to always be skipped\n" @@ -27,8 +27,8 @@ DEFINE_string(skps, "skps", "Directory to read skps from."); VisualBenchmarkStream::VisualBenchmarkStream() : fBenches(BenchRegistry::Head()) , fGMs(skiagm::GMRegistry::Head()) - , fSourceType(NULL) - , fBenchType(NULL) + , fSourceType(nullptr) + , fBenchType(nullptr) , fCurrentSKP(0) { for (int i = 0; i < FLAGS_skps.count(); i++) { if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { @@ -51,13 +51,13 @@ bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture } SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); - if (stream.get() == NULL) { + if (stream.get() == nullptr) { SkDebugf("Could not read %s.\n", path); return false; } pic->reset(SkPicture::CreateFromStream(stream.get())); - if (pic->get() == NULL) { + if (pic->get() == nullptr) { SkDebugf("Could not read %s as an SkPicture.\n", path); return false; } @@ -77,7 +77,7 @@ Benchmark* VisualBenchmarkStream::next() { Benchmark* VisualBenchmarkStream::innerNext() { while (fBenches) { - Benchmark* bench = fBenches->factory()(NULL); + Benchmark* bench = fBenches->factory()(nullptr); fBenches = fBenches->next(); if (bench->isVisual()) { fSourceType = "bench"; @@ -88,7 +88,7 @@ Benchmark* VisualBenchmarkStream::innerNext() { } while (fGMs) { - SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(NULL)); + SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(nullptr)); fGMs = fGMs->next(); if (gm->runAsBench()) { fSourceType = "gm"; @@ -111,5 +111,5 @@ Benchmark* VisualBenchmarkStream::innerNext() { return new VisualSKPBench(name.c_str(), pic.get()); } - return NULL; + return nullptr; } diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index 865bb5184f..79cce56dca 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -195,7 +195,7 @@ static bool run_single_benchmark(const SkString& inputPath, } SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc)); - if (NULL == picture.get()) { + if (nullptr == picture.get()) { SkString err; err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); gLogger.logError(err); @@ -337,13 +337,13 @@ static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) { gLogger.logError(errorString); } - if (NULL == renderer.get()) { + if (nullptr == renderer.get()) { exit(-1); } if (FLAGS_timeIndividualTiles) { sk_tools::TiledPictureRenderer* tiledRenderer = renderer->getTiledRenderer(); - if (NULL == tiledRenderer) { + if (nullptr == tiledRenderer) { gLogger.logError("--timeIndividualTiles requires tiled rendering.\n"); exit(-1); } diff --git a/tools/chrome_fuzz.cpp b/tools/chrome_fuzz.cpp index 94d276fb9b..f05c646351 100644 --- a/tools/chrome_fuzz.cpp +++ b/tools/chrome_fuzz.cpp @@ -34,7 +34,7 @@ static void run_test_case(const SkString& testdata, const SkBitmap& bitmap, testdata.c_str(), testdata.size(), SkImageFilter::GetFlattenableType()); // Adding some info, but the test passed if we got here without any trouble - if (flattenable != NULL) { + if (flattenable != nullptr) { SkDebugf("Valid stream detected.\n"); // Let's see if using the filters can cause any trouble... SkPaint paint; diff --git a/tools/create_test_font.cpp b/tools/create_test_font.cpp index 9193ba257e..1de08ac038 100644 --- a/tools/create_test_font.cpp +++ b/tools/create_test_font.cpp @@ -327,7 +327,7 @@ static int written_index(const FontDesc& fontDesc) { } static void generate_fonts() { - FILE* out = NULL; + FILE* out = nullptr; for (int index = 0; index < gFontsCount; ++index) { FontDesc& fontDesc = gFonts[index]; if ((index & 3) == 0) { @@ -391,7 +391,7 @@ static void generate_index(const char* defaultName) { fprintf(out, " { %sPoints, %sVerbs, %sCharCodes,\n" " %sCharCodesCount, %sWidths,\n" - " %sMetrics, \"Toy %s\", SkTypeface::k%s, NULL\n" + " %sMetrics, \"Toy %s\", SkTypeface::k%s, nullptr\n" " },\n", strip, strip, strip, strip, strip, strip, name, gStyleName[writ.fStyle]); } diff --git a/tools/filtermain.cpp b/tools/filtermain.cpp index c1edb48adf..1ed9797396 100644 --- a/tools/filtermain.cpp +++ b/tools/filtermain.cpp @@ -32,14 +32,14 @@ static void usage() { // Is the supplied paint simply a color? static bool is_simple(const SkPaint& p) { - return NULL == p.getPathEffect() && - NULL == p.getShader() && - NULL == p.getXfermode() && - NULL == p.getMaskFilter() && - NULL == p.getColorFilter() && - NULL == p.getRasterizer() && - NULL == p.getLooper() && - NULL == p.getImageFilter(); + return nullptr == p.getPathEffect() && + nullptr == p.getShader() && + nullptr == p.getXfermode() && + nullptr == p.getMaskFilter() && + nullptr == p.getColorFilter() && + nullptr == p.getRasterizer() && + nullptr == p.getLooper() && + nullptr == p.getImageFilter(); } @@ -71,8 +71,8 @@ static bool check_0(SkDebugCanvas* canvas, int curCommand) { SkColor dbmrColor = dbmrPaint->getColor() | 0xFF000000; // force opaque // If either operation lacks a paint then the collapse is trivial - return NULL == saveLayerPaint || - NULL == dbmrPaint || + return nullptr == saveLayerPaint || + nullptr == dbmrPaint || (is_simple(*saveLayerPaint) && dbmrColor == layerColor); } @@ -83,13 +83,13 @@ static void apply_0(SkDebugCanvas* canvas, int curCommand) { (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand); const SkPaint* saveLayerPaint = saveLayer->paint(); - // if (NULL == saveLayerPaint) the dbmr's paint doesn't need to be changed + // if (nullptr == saveLayerPaint) the dbmr's paint doesn't need to be changed if (saveLayerPaint) { SkDrawBitmapRectCommand* dbmr = (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+1); SkPaint* dbmrPaint = dbmr->paint(); - if (NULL == dbmrPaint) { + if (nullptr == dbmrPaint) { // if the DBMR doesn't have a paint just use the saveLayer's dbmr->setPaint(*saveLayerPaint); } else if (saveLayerPaint) { @@ -149,8 +149,8 @@ static bool check_1(SkDebugCanvas* canvas, int curCommand) { // If either operation lacks a paint then the collapse is trivial SkColor layerColor = saveLayerPaint->getColor() | 0xFF000000; // force opaque - return NULL == saveLayerPaint || - NULL == dbmrPaint || + return nullptr == saveLayerPaint || + nullptr == dbmrPaint || (is_simple(*saveLayerPaint) && dbmrPaint->getColor() == layerColor); } @@ -161,13 +161,13 @@ static void apply_1(SkDebugCanvas* canvas, int curCommand) { (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand); const SkPaint* saveLayerPaint = saveLayer->paint(); - // if (NULL == saveLayerPaint) the dbmr's paint doesn't need to be changed + // if (nullptr == saveLayerPaint) the dbmr's paint doesn't need to be changed if (saveLayerPaint) { SkDrawBitmapRectCommand* dbmr = (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+3); SkPaint* dbmrPaint = dbmr->paint(); - if (NULL == dbmrPaint) { + if (nullptr == dbmrPaint) { dbmr->setPaint(*saveLayerPaint); } else { SkColor newColor = SkColorSetA(dbmrPaint->getColor(), @@ -367,7 +367,7 @@ static bool check_7(SkDebugCanvas* canvas, int curCommand) { } // The src->dest mapping needs to be 1-to-1 - if (NULL == dbmr->srcRect()) { + if (nullptr == dbmr->srcRect()) { if (dbmr->bitmap().width() != dbmr->dstRect().width() || dbmr->bitmap().height() != dbmr->dstRect().height()) { return false; @@ -393,7 +393,7 @@ static bool check_7(SkDebugCanvas* canvas, int curCommand) { SkPaint* dbmrPaint = dbmr->paint(); - if (NULL == dbmrPaint) { + if (nullptr == dbmrPaint) { return true; } @@ -514,7 +514,7 @@ static bool check_8(SkDebugCanvas* canvas, int curCommand) { } // The src->dest mapping needs to be 1-to-1 - if (NULL == dbmr->srcRect()) { + if (nullptr == dbmr->srcRect()) { if (dbmr->bitmap().width() != dbmr->dstRect().width() || dbmr->bitmap().height() != dbmr->dstRect().height()) { return false; @@ -629,7 +629,7 @@ static int filter_picture(const SkString& inFile, const SkString& outFile) { inPicture.reset(SkPicture::CreateFromStream(&inStream)); } - if (NULL == inPicture.get()) { + if (nullptr == inPicture.get()) { SkDebugf("Could not read file %s\n", inFile.c_str()); return -1; } @@ -680,7 +680,7 @@ static int filter_picture(const SkString& inFile, const SkString& outFile) { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(inPicture->cullRect().width(), inPicture->cullRect().height(), - NULL, 0); + nullptr, 0); debugCanvas.draw(canvas); SkAutoTUnref<SkPicture> outPicture(recorder.endRecording()); diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp index 2ea45c2e71..fe3dfd193d 100644 --- a/tools/flags/SkCommandLineFlags.cpp +++ b/tools/flags/SkCommandLineFlags.cpp @@ -29,7 +29,7 @@ bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, void SkFlagInfo::SetDefaultStrings(SkCommandLineFlags::StringArray* pStrings, const char* defaultValue) { pStrings->reset(); - if (NULL == defaultValue) { + if (nullptr == defaultValue) { return; } // If default is "", leave the array empty. @@ -268,7 +268,7 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { if (!helpPrinted) { bool flagMatched = false; SkFlagInfo* flag = gHead; - while (flag != NULL) { + while (flag != nullptr) { if (flag->match(argv[i])) { flagMatched = true; switch (flag->getFlagType()) { @@ -287,7 +287,7 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { flag->resetStrings(); // Add all arguments until another flag is reached. while (i+1 < argc) { - char* end = NULL; + char* end = nullptr; // Negative numbers aren't flags. ignore_result(strtod(argv[i+1], &end)); if (end == argv[i+1] && SkStrStartsWith(argv[i+1], '-')) { @@ -331,8 +331,8 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { // Since all of the flags have been set, release the memory used by each // flag. FLAGS_x can still be used after this. SkFlagInfo* flag = gHead; - gHead = NULL; - while (flag != NULL) { + gHead = nullptr; + while (flag != nullptr) { SkFlagInfo* next = flag->next(); delete flag; flag = next; diff --git a/tools/flags/SkCommandLineFlags.h b/tools/flags/SkCommandLineFlags.h index ae504cba81..bf8f1403d0 100644 --- a/tools/flags/SkCommandLineFlags.h +++ b/tools/flags/SkCommandLineFlags.h @@ -181,7 +181,7 @@ private: #define DEFINE_bool(name, defaultValue, helpString) \ bool FLAGS_##name; \ SK_UNUSED static bool unused_##name = SkFlagInfo::CreateBoolFlag(TO_STRING(name), \ - NULL, \ + nullptr, \ &FLAGS_##name, \ defaultValue, \ helpString) @@ -201,7 +201,7 @@ SK_UNUSED static bool unused_##name = SkFlagInfo::CreateBoolFlag(TO_STRING(name) #define DEFINE_string(name, defaultValue, helpString) \ SkCommandLineFlags::StringArray FLAGS_##name; \ SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \ - NULL, \ + nullptr, \ &FLAGS_##name, \ defaultValue, \ helpString) @@ -283,7 +283,7 @@ public: */ static bool CreateIntFlag(const char* name, int32_t* pInt, int32_t defaultValue, const char* helpString) { - SkFlagInfo* info = new SkFlagInfo(name, NULL, kInt_FlagType, helpString); + SkFlagInfo* info = new SkFlagInfo(name, nullptr, kInt_FlagType, helpString); info->fIntValue = pInt; *info->fIntValue = info->fDefaultInt = defaultValue; return true; @@ -294,7 +294,7 @@ public: */ static bool CreateDoubleFlag(const char* name, double* pDouble, double defaultValue, const char* helpString) { - SkFlagInfo* info = new SkFlagInfo(name, NULL, kDouble_FlagType, helpString); + SkFlagInfo* info = new SkFlagInfo(name, nullptr, kDouble_FlagType, helpString); info->fDoubleValue = pDouble; *info->fDoubleValue = info->fDefaultDouble = defaultValue; return true; @@ -407,17 +407,17 @@ private: , fShortName(shortName) , fFlagType(type) , fHelpString(helpString) - , fBoolValue(NULL) + , fBoolValue(nullptr) , fDefaultBool(false) - , fIntValue(NULL) + , fIntValue(nullptr) , fDefaultInt(0) - , fDoubleValue(NULL) + , fDoubleValue(nullptr) , fDefaultDouble(0) - , fStrings(NULL) { + , fStrings(nullptr) { fNext = SkCommandLineFlags::gHead; SkCommandLineFlags::gHead = this; SkASSERT(name && strlen(name) > 1); - SkASSERT(NULL == shortName || 1 == strlen(shortName)); + SkASSERT(nullptr == shortName || 1 == strlen(shortName)); } /** diff --git a/tools/flags/SkCommonFlags.cpp b/tools/flags/SkCommonFlags.cpp index 7c7634f16d..9783dde373 100644 --- a/tools/flags/SkCommonFlags.cpp +++ b/tools/flags/SkCommonFlags.cpp @@ -26,7 +26,7 @@ DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" " DEFINE_string(images, "", "Directory of images to decode."); -DEFINE_string2(match, m, NULL, +DEFINE_string2(match, m, nullptr, "[~][^]substring[$] [...] of GM name to run.\n" "Multiple matches may be separated by spaces.\n" "~ causes a matching GM to always be skipped\n" diff --git a/tools/gpuveto.cpp b/tools/gpuveto.cpp index 4e9fdebd4b..204f44965b 100644 --- a/tools/gpuveto.cpp +++ b/tools/gpuveto.cpp @@ -45,7 +45,7 @@ int tool_main(int argc, char** argv) { SkPicture::InstallPixelRefProc proc = &sk_tools::LazyDecodeBitmap; SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc)); - if (NULL == picture.get()) { + if (nullptr == picture.get()) { if (!FLAGS_quiet) { SkDebugf("Could not read the SkPicture\n"); } @@ -57,10 +57,10 @@ int tool_main(int argc, char** argv) { SkPictureRecorder recorder; picture->playback(recorder.beginRecording(picture->cullRect().width(), picture->cullRect().height(), - NULL, 0)); + nullptr, 0)); SkAutoTUnref<SkPicture> recorded(recorder.endRecording()); - if (recorded->suitableForGpuRasterization(NULL)) { + if (recorded->suitableForGpuRasterization(nullptr)) { SkDebugf("suitable\n"); } else { SkDebugf("unsuitable\n"); diff --git a/tools/image_expectations.cpp b/tools/image_expectations.cpp index 05a905dd58..cb0c03afc6 100644 --- a/tools/image_expectations.cpp +++ b/tools/image_expectations.cpp @@ -122,12 +122,12 @@ namespace sk_tools { // ImageResultsAndExpectations class... bool ImageResultsAndExpectations::readExpectationsFile(const char *jsonPath) { - if (NULL == jsonPath) { + if (nullptr == jsonPath) { SkDebugf("JSON expectations filename not specified\n"); return false; } SkFILE* filePtr = sk_fopen(jsonPath, kRead_SkFILE_Flag); - if (NULL == filePtr) { + if (nullptr == filePtr) { SkDebugf("JSON expectations file '%s' does not exist\n", jsonPath); return false; } @@ -188,7 +188,7 @@ namespace sk_tools { actualImage[kJsonKey_Image_ComparisonResult] = comparisonResult; // Add this actual result to our collection. - if (NULL == tileNumber) { + if (nullptr == tileNumber) { fActualResults[sourceName][kJsonKey_Source_WholeImage] = actualImage; } else { fActualResults[sourceName][kJsonKey_Source_TiledImages][*tileNumber] = actualImage; @@ -210,7 +210,7 @@ namespace sk_tools { } Json::Value expectedImage; - if (NULL == tileNumber) { + if (nullptr == tileNumber) { expectedImage = fExpectedResults[sourceName][kJsonKey_Source_WholeImage]; } else { expectedImage = fExpectedResults[sourceName][kJsonKey_Source_TiledImages][*tileNumber]; @@ -242,7 +242,7 @@ namespace sk_tools { /*static*/ bool ImageResultsAndExpectations::Parse(SkFILE *filePtr, Json::Value *jsonRoot) { SkAutoDataUnref dataRef(SkData::NewFromFILE(filePtr)); - if (NULL == dataRef.get()) { + if (nullptr == dataRef.get()) { return false; } diff --git a/tools/image_expectations.h b/tools/image_expectations.h index 422c64d4ed..a72d7a2c46 100644 --- a/tools/image_expectations.h +++ b/tools/image_expectations.h @@ -171,10 +171,10 @@ namespace sk_tools { * @param sourceName name of the source file that generated this result * @param fileName relative path to the image output file on local disk * @param digest description of the image's contents - * @param tileNumber if not NULL, pointer to tile number + * @param tileNumber if not nullptr, pointer to tile number */ void add(const char *sourceName, const char *fileName, ImageDigest &digest, - const int *tileNumber=NULL); + const int *tileNumber=nullptr); /** * Adds a key/value pair to the descriptions dict within the summary of results. @@ -195,12 +195,12 @@ namespace sk_tools { * Returns the Expectation for this test. * * @param sourceName name of the source file that generated this result - * @param tileNumber if not NULL, pointer to tile number + * @param tileNumber if not nullptr, pointer to tile number * * TODO(stephana): To make this work for GMs, we will need to add parameters for * config, and maybe renderMode/builder? */ - Expectation getExpectation(const char *sourceName, const int *tileNumber=NULL); + Expectation getExpectation(const char *sourceName, const int *tileNumber=nullptr); /** * Writes the summary (as constructed so far) to a file. diff --git a/tools/lua/lua_app.cpp b/tools/lua/lua_app.cpp index f24570a829..6aea8ee437 100644 --- a/tools/lua/lua_app.cpp +++ b/tools/lua/lua_app.cpp @@ -33,7 +33,7 @@ int tool_main(int argc, char** argv) { SkLua L; for (int i = 1; i < argc; ++i) { - SkData* data = NULL; + SkData* data = nullptr; const void* ptr; size_t len; diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp index 315e4bfb89..6fa5813d77 100644 --- a/tools/lua/lua_pictures.cpp +++ b/tools/lua/lua_pictures.cpp @@ -42,7 +42,7 @@ DEFINE_bool2(quiet, q, false, "Silence all non-error related output"); static SkPicture* load_picture(const char path[]) { SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); - SkPicture* pic = NULL; + SkPicture* pic = nullptr; if (stream.get()) { pic = SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeBitmap); } @@ -89,7 +89,7 @@ int tool_main(int argc, char** argv) { for (int i = 0; i < FLAGS_luaFile.count(); ++i) { SkAutoDataUnref data(SkData::NewFromFileName(FLAGS_luaFile[i])); - if (NULL == data.get()) { + if (nullptr == data.get()) { data.reset(SkData::NewEmpty()); } if (!FLAGS_quiet) { diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp index 5c120b010d..9661daf2d0 100644 --- a/tools/picture_utils.cpp +++ b/tools/picture_utils.cpp @@ -16,7 +16,7 @@ namespace sk_tools { void force_all_opaque(const SkBitmap& bitmap) { - SkASSERT(NULL == bitmap.getTexture()); + SkASSERT(nullptr == bitmap.getTexture()); SkASSERT(kN32_SkColorType == bitmap.colorType()); if (bitmap.getTexture() || kN32_SkColorType == bitmap.colorType()) { return; @@ -31,7 +31,7 @@ namespace sk_tools { } void replace_char(SkString* str, const char oldChar, const char newChar) { - if (NULL == str) { + if (nullptr == str) { return; } for (size_t i = 0; i < str->size(); ++i) { diff --git a/tools/picture_utils.h b/tools/picture_utils.h index b72f9d7b41..1373020a5b 100644 --- a/tools/picture_utils.h +++ b/tools/picture_utils.h @@ -39,7 +39,7 @@ namespace sk_tools { * * @param bm the bitmap to record * @param dirPath directory within which to write the image file - * @param subdirOrNull subdirectory within dirPath, or NULL to just write into dirPath + * @param subdirOrNull subdirectory within dirPath, or nullptr to just write into dirPath * @param baseName last part of the filename * * @return true if written out successfully diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp index 18c0d70cc4..5c04608c4e 100644 --- a/tools/pinspect.cpp +++ b/tools/pinspect.cpp @@ -20,7 +20,7 @@ static SkPicture* inspect(const char path[]) { SkFILEStream stream(path); if (!stream.isValid()) { printf("-- Can't open '%s'\n", path); - return NULL; + return nullptr; } printf("Opening '%s'...\n", path); @@ -29,16 +29,16 @@ static SkPicture* inspect(const char path[]) { int32_t header[3]; if (stream.read(header, sizeof(header)) != sizeof(header)) { printf("-- Failed to read header (12 bytes)\n"); - return NULL; + return nullptr; } printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]); } stream.rewind(); SkPicture* pic = SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap); - if (NULL == pic) { + if (nullptr == pic) { SkDebugf("Could not create SkPicture: %s\n", path); - return NULL; + return nullptr; } printf("picture cullRect: [%f %f %f %f]\n", pic->cullRect().fLeft, pic->cullRect().fTop, diff --git a/tools/render_pdfs_main.cpp b/tools/render_pdfs_main.cpp index 9b80ef4d50..b182d8b408 100644 --- a/tools/render_pdfs_main.cpp +++ b/tools/render_pdfs_main.cpp @@ -120,13 +120,13 @@ static SkWStream* open_stream(const SkString& outputDir, SkString outputPath; if (!make_output_filepath(&outputPath, outputDir, inputFilename)) { - return NULL; + return nullptr; } SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(outputPath.c_str())); if (!stream.get() || !stream->isValid()) { SkDebugf("Could not write to file %s\n", outputPath.c_str()); - return NULL; + return nullptr; } return stream.detach(); @@ -222,7 +222,7 @@ int tool_main_core(int argc, char** argv) { SkAutoTUnref<SkPicture> picture( SkPicture::CreateFromStream(&inputStream)); - if (NULL == picture.get()) { + if (nullptr == picture.get()) { SkDebugf("Could not read an SkPicture from %s\n", files[i].c_str()); ++failures; diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index 8cda966664..401c205d67 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -112,7 +112,7 @@ static void reset_image_file_base_name(const SkString& name) { // Remove ".skp" const char* cName = name.c_str(); const char* dot = strrchr(cName, '.'); - if (dot != NULL) { + if (dot != nullptr) { gInputFileName.set(cName, dot - cName); } else { gInputFileName.set(name); @@ -181,7 +181,7 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc)); - if (NULL == picture) { + if (nullptr == picture) { SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str()); return false; } @@ -190,7 +190,7 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w SkPictureRecorder recorder; picture->playback(recorder.beginRecording(picture->cullRect().width(), picture->cullRect().height(), - NULL, 0)); + nullptr, 0)); SkAutoTUnref<SkPicture> other(recorder.endRecording()); } @@ -228,7 +228,7 @@ static int MaxByteDiff(uint32_t v1, uint32_t v2) { class AutoRestoreBbhType { public: AutoRestoreBbhType() { - fRenderer = NULL; + fRenderer = nullptr; fSavedBbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; } @@ -254,31 +254,31 @@ private: * Render the SKP file(s) within inputPath. * * @param inputPath path to an individual SKP file, or a directory of SKP files - * @param writePath if not NULL, write all image(s) generated into this directory - * @param mismatchPath if not NULL, write any image(s) not matching expectations into this directory + * @param writePath if not nullptr, write all image(s) generated into this directory + * @param mismatchPath if not nullptr, write any image(s) not matching expectations into this directory * @param renderer PictureRenderer to use to render the SKPs - * @param jsonSummaryPtr if not NULL, add the image(s) generated to this summary + * @param jsonSummaryPtr if not nullptr, add the image(s) generated to this summary */ static bool render_picture(const SkString& inputPath, const SkString* writePath, const SkString* mismatchPath, sk_tools::PictureRenderer& renderer, sk_tools::ImageResultsAndExpectations *jsonSummaryPtr) { int diffs[256] = {0}; - SkBitmap* bitmap = NULL; + SkBitmap* bitmap = nullptr; renderer.setJsonSummaryPtr(jsonSummaryPtr); bool success = render_picture_internal(inputPath, - FLAGS_writeWholeImage ? NULL : writePath, - FLAGS_writeWholeImage ? NULL : mismatchPath, + FLAGS_writeWholeImage ? nullptr : writePath, + FLAGS_writeWholeImage ? nullptr : mismatchPath, renderer, - FLAGS_validate || FLAGS_writeWholeImage ? &bitmap : NULL); + FLAGS_validate || FLAGS_writeWholeImage ? &bitmap : nullptr); - if (!success || ((FLAGS_validate || FLAGS_writeWholeImage) && bitmap == NULL)) { + if (!success || ((FLAGS_validate || FLAGS_writeWholeImage) && bitmap == nullptr)) { SkDebugf("Failed to draw the picture.\n"); delete bitmap; return false; } if (FLAGS_validate) { - SkBitmap* referenceBitmap = NULL; + SkBitmap* referenceBitmap = nullptr; sk_tools::PictureRenderer* referenceRenderer; // If the renderer uses a BBoxHierarchy, then the reference renderer // will be the same renderer, without the bbh. @@ -297,10 +297,10 @@ static bool render_picture(const SkString& inputPath, const SkString* writePath, } SkAutoTUnref<sk_tools::PictureRenderer> aurReferenceRenderer(referenceRenderer); - success = render_picture_internal(inputPath, NULL, NULL, *referenceRenderer, + success = render_picture_internal(inputPath, nullptr, nullptr, *referenceRenderer, &referenceBitmap); - if (!success || NULL == referenceBitmap || NULL == referenceBitmap->getPixels()) { + if (!success || nullptr == referenceBitmap || nullptr == referenceBitmap->getPixels()) { SkDebugf("Failed to draw the reference picture.\n"); delete bitmap; delete referenceBitmap; @@ -363,13 +363,13 @@ static bool render_picture(const SkString& inputPath, const SkString* writePath, jsonSummaryPtr->add(inputFilename.c_str(), outputFilename.c_str(), imageDigest); if ((mismatchPath) && !mismatchPath->isEmpty() && !jsonSummaryPtr->getExpectation(inputFilename.c_str()).matches(imageDigest)) { - success &= sk_tools::write_bitmap_to_disk(*bitmap, *mismatchPath, NULL, + success &= sk_tools::write_bitmap_to_disk(*bitmap, *mismatchPath, nullptr, outputFilename); } } if ((writePath) && !writePath->isEmpty()) { - success &= sk_tools::write_bitmap_to_disk(*bitmap, *writePath, NULL, outputFilename); + success &= sk_tools::write_bitmap_to_disk(*bitmap, *writePath, nullptr, outputFilename); } } delete bitmap; @@ -443,7 +443,7 @@ int tool_main(int argc, char** argv) { SkDebugf("%s\n", errorString.c_str()); } - if (renderer.get() == NULL) { + if (renderer.get() == nullptr) { exit(-1); } @@ -458,7 +458,7 @@ int tool_main(int argc, char** argv) { mismatchPath.set(FLAGS_mismatchPath[0]); } sk_tools::ImageResultsAndExpectations jsonSummary; - sk_tools::ImageResultsAndExpectations* jsonSummaryPtr = NULL; + sk_tools::ImageResultsAndExpectations* jsonSummaryPtr = nullptr; if (FLAGS_writeJsonSummaryPath.count() == 1) { jsonSummaryPtr = &jsonSummary; if (FLAGS_readJsonSummaryPath.count() == 1) { diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index 8d1eb44b92..a746d8b9fd 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -84,7 +84,7 @@ void emoji_typeface(SkAutoTUnref<SkTypeface>* tf) { tf->reset(SkTypeface::CreateFromName("Apple Color Emoji", SkTypeface::kNormal)); return; } - tf->reset(NULL); + tf->reset(nullptr); return; } @@ -201,12 +201,12 @@ void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPain SkTDArray<uint16_t> glyphs; size_t len = strlen(text); - glyphs.append(paint.textToGlyphs(text, len, NULL)); + glyphs.append(paint.textToGlyphs(text, len, nullptr)); paint.textToGlyphs(text, len, glyphs.begin()); paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.count(), x, y, - NULL); + nullptr); memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); } diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h index b7a5dd78d0..2f70090e49 100644 --- a/tools/sk_tool_utils.h +++ b/tools/sk_tool_utils.h @@ -68,7 +68,7 @@ namespace sk_tool_utils { /** * Sets the paint to use a platform-independent text renderer */ - void set_portable_typeface(SkPaint* paint, const char* name = NULL, + void set_portable_typeface(SkPaint* paint, const char* name = nullptr, SkTypeface::Style style = SkTypeface::kNormal); /** diff --git a/tools/sk_tool_utils_font.cpp b/tools/sk_tool_utils_font.cpp index 6d6fda97c8..af52b37a4e 100644 --- a/tools/sk_tool_utils_font.cpp +++ b/tools/sk_tool_utils_font.cpp @@ -30,7 +30,7 @@ void release_portable_typefaces() { SK_DECLARE_STATIC_MUTEX(gTestFontMutex); SkTypeface* create_font(const char* name, SkTypeface::Style style) { - SkTestFontData* fontData = NULL; + SkTestFontData* fontData = nullptr; const SubFont* sub; if (name) { for (int index = 0; index < gSubFontsCount; ++index) { diff --git a/tools/skdiff_image.cpp b/tools/skdiff_image.cpp index 89f73810e7..9166988719 100644 --- a/tools/skdiff_image.cpp +++ b/tools/skdiff_image.cpp @@ -44,11 +44,11 @@ static void create_diff_images (DiffMetricProc dmp, if (comparisonFileBits) { drp->fComparison.fStatus = DiffResource::kRead_Status; } - if (NULL == baseFileBits || NULL == comparisonFileBits) { - if (NULL == baseFileBits) { + if (nullptr == baseFileBits || nullptr == comparisonFileBits) { + if (nullptr == baseFileBits) { drp->fBase.fStatus = DiffResource::kCouldNotRead_Status; } - if (NULL == comparisonFileBits) { + if (nullptr == comparisonFileBits) { drp->fComparison.fStatus = DiffResource::kCouldNotRead_Status; } drp->fResult = DiffRecord::kCouldNotCompare_Result; @@ -314,7 +314,7 @@ int tool_main(int argc, char** argv) { } else { const char* baseLabelCstr = baseLabel.c_str(); const char* tab = strchr(baseLabelCstr, '\t'); - if (NULL == tab) { + if (nullptr == tab) { outputFile = baseLabel; } else { outputFile.set(baseLabelCstr, tab - baseLabelCstr); diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp index 4e360a8e49..00bcdfcda0 100644 --- a/tools/skdiff_main.cpp +++ b/tools/skdiff_main.cpp @@ -329,13 +329,13 @@ class AutoReleasePixels { public: AutoReleasePixels(DiffRecord* drp) : fDrp(drp) { - SkASSERT(drp != NULL); + SkASSERT(drp != nullptr); } ~AutoReleasePixels() { - fDrp->fBase.fBitmap.setPixelRef(NULL); - fDrp->fComparison.fBitmap.setPixelRef(NULL); - fDrp->fDifference.fBitmap.setPixelRef(NULL); - fDrp->fWhite.fBitmap.setPixelRef(NULL); + fDrp->fBase.fBitmap.setPixelRef(nullptr); + fDrp->fComparison.fBitmap.setPixelRef(nullptr); + fDrp->fDifference.fBitmap.setPixelRef(nullptr); + fDrp->fWhite.fBitmap.setPixelRef(nullptr); } private: @@ -345,7 +345,7 @@ private: static void get_bounds(DiffResource& resource, const char* name) { if (resource.fBitmap.empty() && !DiffResource::isStatusFailed(resource.fStatus)) { SkAutoDataUnref fileBits(read_file(resource.fFullPath.c_str())); - if (NULL == fileBits) { + if (nullptr == fileBits) { SkDebugf("WARNING: couldn't read %s file <%s>\n", name, resource.fFullPath.c_str()); resource.fStatus = DiffResource::kCouldNotRead_Status; } else { @@ -477,12 +477,12 @@ static void create_diff_images (DiffMetricProc dmp, if (comparisonFileBits) { drp->fComparison.fStatus = DiffResource::kRead_Status; } - if (NULL == baseFileBits || NULL == comparisonFileBits) { - if (NULL == baseFileBits) { + if (nullptr == baseFileBits || nullptr == comparisonFileBits) { + if (nullptr == baseFileBits) { drp->fBase.fStatus = DiffResource::kCouldNotRead_Status; VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, baseFiles[i]); } - if (NULL == comparisonFileBits) { + if (nullptr == comparisonFileBits) { drp->fComparison.fStatus = DiffResource::kCouldNotRead_Status; VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[j]); } diff --git a/tools/skdiff_utils.cpp b/tools/skdiff_utils.cpp index e656e3c44b..1e2a727945 100644 --- a/tools/skdiff_utils.cpp +++ b/tools/skdiff_utils.cpp @@ -16,7 +16,7 @@ #include <memory> bool are_buffers_equal(SkData* skdata1, SkData* skdata2) { - if ((NULL == skdata1) || (NULL == skdata2)) { + if ((nullptr == skdata1) || (nullptr == skdata2)) { return false; } if (skdata1->size() != skdata2->size()) { @@ -39,7 +39,7 @@ bool get_bitmap(SkData* fileBits, DiffResource& resource, SkImageDecoder::Mode m // In debug, the DLL will automatically be unloaded when this is deleted, // but that shouldn't be a problem in release mode. std::unique_ptr<SkImageDecoder> codec(SkImageDecoder::Factory(&stream)); - if (NULL == codec) { + if (nullptr == codec) { SkDebugf("ERROR: no codec found for <%s>\n", resource.fFullPath.c_str()); resource.fStatus = DiffResource::kCouldNotDecode_Status; return false; diff --git a/tools/skdiff_utils.h b/tools/skdiff_utils.h index 00ebf899a9..8b94117eef 100644 --- a/tools/skdiff_utils.h +++ b/tools/skdiff_utils.h @@ -15,13 +15,13 @@ class SkBitmap; class SkData; class SkString; -/** Returns true if the two buffers passed in are both non-NULL, +/** Returns true if the two buffers passed in are both non-nullptr, * have the same length, and contain exactly the same byte values. */ bool are_buffers_equal(SkData* skdata1, SkData* skdata2); /** Reads the file at the given path and returns its complete contents as an - * SkData object (or returns NULL on error). + * SkData object (or returns nullptr on error). */ SkData* read_file(const char* file_path); diff --git a/tools/skhello.cpp b/tools/skhello.cpp index b46ba084ab..5614a56f5d 100644 --- a/tools/skhello.cpp +++ b/tools/skhello.cpp @@ -39,7 +39,7 @@ static bool do_surface(int w, int h, const char path[], const char text[], SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); SkAutoDataUnref data(image->encode()); - if (NULL == data.get()) { + if (nullptr == data.get()) { return false; } SkFILEWStream stream(path); @@ -52,7 +52,7 @@ static bool do_document(int w, int h, const char path[], const char text[], if (doc.get()) { SkScalar width = SkIntToScalar(w); SkScalar height = SkIntToScalar(h); - doDraw(doc->beginPage(width, height, NULL), paint, text); + doDraw(doc->beginPage(width, height, nullptr), paint, text); return true; } return false; diff --git a/tools/skpdiff/SkCLImageDiffer.cpp b/tools/skpdiff/SkCLImageDiffer.cpp index 1c5d5c56ea..f181682db5 100644 --- a/tools/skpdiff/SkCLImageDiffer.cpp +++ b/tools/skpdiff/SkCLImageDiffer.cpp @@ -60,15 +60,15 @@ bool SkCLImageDiffer::loadKernelStream(SkStream* stream, const char name[], cl_k bool SkCLImageDiffer::loadKernelSource(const char source[], const char name[], cl_kernel* kernel) { // Build the kernel source size_t sourceLen = strlen(source); - cl_program program = clCreateProgramWithSource(fContext, 1, &source, &sourceLen, NULL); - cl_int programErr = clBuildProgram(program, 1, &fDevice, "", NULL, NULL); + cl_program program = clCreateProgramWithSource(fContext, 1, &source, &sourceLen, nullptr); + cl_int programErr = clBuildProgram(program, 1, &fDevice, "", nullptr, nullptr); if (CL_SUCCESS != programErr) { SkDebugf("Program creation failed: %s\n", cl_error_to_string(programErr)); // Attempt to get information about why the build failed char buildLog[4096]; clGetProgramBuildInfo(program, fDevice, CL_PROGRAM_BUILD_LOG, sizeof(buildLog), - buildLog, NULL); + buildLog, nullptr); SkDebugf("Build log: %s\n", buildLog); return false; diff --git a/tools/skpdiff/SkDiffContext.cpp b/tools/skpdiff/SkDiffContext.cpp index 5add0df515..8da346ed5c 100644 --- a/tools/skpdiff/SkDiffContext.cpp +++ b/tools/skpdiff/SkDiffContext.cpp @@ -22,7 +22,7 @@ #include "skpdiff_util.h" SkDiffContext::SkDiffContext() { - fDiffers = NULL; + fDiffers = nullptr; fDifferCount = 0; } @@ -58,7 +58,7 @@ void SkDiffContext::setDiffers(const SkTDArray<SkImageDiffer*>& differs) { // Delete whatever the last array of differs was if (fDiffers) { delete[] fDiffers; - fDiffers = NULL; + fDiffers = nullptr; fDifferCount = 0; } diff --git a/tools/skpdiff/SkDifferentPixelsMetric_opencl.cpp b/tools/skpdiff/SkDifferentPixelsMetric_opencl.cpp index 2e5ab8f725..95ab9530ae 100644 --- a/tools/skpdiff/SkDifferentPixelsMetric_opencl.cpp +++ b/tools/skpdiff/SkDifferentPixelsMetric_opencl.cpp @@ -72,7 +72,7 @@ bool SkDifferentPixelsMetric::diff(SkBitmap* baseline, SkBitmap* test, bool comp static const int kZero = 0; // We know OpenCL won't write to it because we use CL_MEM_COPY_HOST_PTR resultsBuffer = clCreateBuffer(fContext, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, - sizeof(int), (int*)&kZero, NULL); + sizeof(int), (int*)&kZero, nullptr); // Set all kernel arguments cl_int setArgErr = clSetKernelArg(fKernel, 0, sizeof(cl_mem), &baselineImage); @@ -87,8 +87,8 @@ bool SkDifferentPixelsMetric::diff(SkBitmap* baseline, SkBitmap* test, bool comp cl_event event; const size_t workSize[] = { baseline->width(), baseline->height() }; cl_int enqueueErr; - enqueueErr = clEnqueueNDRangeKernel(fCommandQueue, fKernel, 2, NULL, workSize, - NULL, 0, NULL, &event); + enqueueErr = clEnqueueNDRangeKernel(fCommandQueue, fKernel, 2, nullptr, workSize, + nullptr, 0, nullptr, &event); if (CL_SUCCESS != enqueueErr) { SkDebugf("Enqueue failed: %s\n", cl_error_to_string(enqueueErr)); return false; @@ -99,7 +99,7 @@ bool SkDifferentPixelsMetric::diff(SkBitmap* baseline, SkBitmap* test, bool comp // Immediate read back the results clEnqueueReadBuffer(fCommandQueue, resultsBuffer, CL_TRUE, 0, - sizeof(int), &result->poiCount, 0, NULL, NULL); + sizeof(int), &result->poiCount, 0, nullptr, nullptr); result->result *= (double)result->poiCount; result->result = (1.0 - result->result); diff --git a/tools/skpdiff/skpdiff_main.cpp b/tools/skpdiff/skpdiff_main.cpp index b5ba31072d..90b4f715c5 100644 --- a/tools/skpdiff/skpdiff_main.cpp +++ b/tools/skpdiff/skpdiff_main.cpp @@ -87,7 +87,7 @@ static bool init_device_and_context(cl::Device* device, cl::Context* context) { // Create a CL context and check for all errors cl_int contextErr = CL_SUCCESS; - *context = cl::Context(deviceList, NULL, error_notify, NULL, &contextErr); + *context = cl::Context(deviceList, nullptr, error_notify, nullptr, &contextErr); if (contextErr != CL_SUCCESS) { SkDebugf("Context creation failed: %s\n", cl_error_to_string(contextErr)); return false; @@ -118,7 +118,7 @@ SkDifferentPixelsMetric gDiffPixel; SkPMetric gPDiff; // A null terminated array of pointer to every differ declared above -SkImageDiffer* gDiffers[] = { &gDiffPixel, &gPDiff, NULL }; +SkImageDiffer* gDiffers[] = { &gDiffPixel, &gPDiff, nullptr }; int tool_main(int argc, char * argv[]); int tool_main(int argc, char * argv[]) { diff --git a/tools/skpdiff/skpdiff_util.cpp b/tools/skpdiff/skpdiff_util.cpp index 4b5d52110b..d33ca24a3a 100644 --- a/tools/skpdiff/skpdiff_util.cpp +++ b/tools/skpdiff/skpdiff_util.cpp @@ -5,6 +5,8 @@ * found in the LICENSE file. */ +#include "SkTypes.h" + #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) # include <unistd.h> # include <sys/time.h> @@ -97,7 +99,7 @@ double get_seconds() { return currentTime.tv_sec + (double)currentTime.tv_nsec / 1e9; #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) struct timeval currentTime; - gettimeofday(¤tTime, NULL); + gettimeofday(¤tTime, nullptr); return currentTime.tv_sec + (double)currentTime.tv_usec / 1e6; #else return clock() / (double)CLOCKS_PER_SEC; @@ -108,11 +110,11 @@ bool get_directory(const char path[], SkTArray<SkString>* entries) { #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) // Open the directory and check for success DIR* dir = opendir(path); - if (NULL == dir) { + if (nullptr == dir) { return false; } - // Loop through dir entries until there are none left (i.e. readdir returns NULL) + // Loop through dir entries until there are none left (i.e. readdir returns nullptr) struct dirent* entry; while ((entry = readdir(dir))) { // dirent only gives relative paths, we need to join them to the base path to check if they @@ -167,7 +169,7 @@ bool glob_files(const char globPattern[], SkTArray<SkString>* entries) { #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) // TODO Make sure this works on windows. This may require use of FindNextFile windows function. glob_t globBuffer; - if (glob(globPattern, 0, NULL, &globBuffer) != 0) { + if (glob(globPattern, 0, nullptr, &globBuffer) != 0) { return false; } @@ -190,13 +192,13 @@ bool glob_files(const char globPattern[], SkTArray<SkString>* entries) { SkString get_absolute_path(const SkString& path) { #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) SkString fullPath(PATH_MAX + 1); - if (realpath(path.c_str(), fullPath.writable_str()) == NULL) { + if (realpath(path.c_str(), fullPath.writable_str()) == nullptr) { fullPath.reset(); } return fullPath; #elif defined(SK_BUILD_FOR_WIN32) SkString fullPath(MAX_PATH); - if (_fullpath(fullPath.writable_str(), path.c_str(), MAX_PATH) == NULL) { + if (_fullpath(fullPath.writable_str(), path.c_str(), MAX_PATH) == nullptr) { fullPath.reset(); } return fullPath; diff --git a/tools/skpmaker.cpp b/tools/skpmaker.cpp index 0e378ed088..8fa969a6f0 100644 --- a/tools/skpmaker.cpp +++ b/tools/skpmaker.cpp @@ -32,7 +32,7 @@ DEFINE_string(writePath, "", "Filepath to write the SKP into."); static void make_skp(SkScalar width, SkScalar height, SkScalar border, SkColor color, const char *writePath) { SkPictureRecorder recorder; - SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0); + SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setColor(SK_ColorBLACK); diff --git a/tools/test_font_data.cpp b/tools/test_font_data.cpp index 2db09b736b..ff0aaccc11 100644 --- a/tools/test_font_data.cpp +++ b/tools/test_font_data.cpp @@ -8514,59 +8514,59 @@ const SkPaint::FontMetrics TimesNewRomankBoldItalicMetrics = { static SkTestFontData gTestFonts[] = { { CourierNewkNormalPoints, CourierNewkNormalVerbs, CourierNewkNormalCharCodes, CourierNewkNormalCharCodesCount, CourierNewkNormalWidths, - CourierNewkNormalMetrics, "Courier New", SkTypeface::kNormal, NULL + CourierNewkNormalMetrics, "Courier New", SkTypeface::kNormal, nullptr }, { CourierNewkBoldPoints, CourierNewkBoldVerbs, CourierNewkBoldCharCodes, CourierNewkBoldCharCodesCount, CourierNewkBoldWidths, - CourierNewkBoldMetrics, "Courier New", SkTypeface::kBold, NULL + CourierNewkBoldMetrics, "Courier New", SkTypeface::kBold, nullptr }, { CourierNewkItalicPoints, CourierNewkItalicVerbs, CourierNewkItalicCharCodes, CourierNewkItalicCharCodesCount, CourierNewkItalicWidths, - CourierNewkItalicMetrics, "Courier New", SkTypeface::kItalic, NULL + CourierNewkItalicMetrics, "Courier New", SkTypeface::kItalic, nullptr }, { CourierNewkBoldItalicPoints, CourierNewkBoldItalicVerbs, CourierNewkBoldItalicCharCodes, CourierNewkBoldItalicCharCodesCount, CourierNewkBoldItalicWidths, - CourierNewkBoldItalicMetrics, "Courier New", SkTypeface::kBoldItalic, NULL + CourierNewkBoldItalicMetrics, "Courier New", SkTypeface::kBoldItalic, nullptr }, { LiberationSanskNormalPoints, LiberationSanskNormalVerbs, LiberationSanskNormalCharCodes, LiberationSanskNormalCharCodesCount, LiberationSanskNormalWidths, - LiberationSanskNormalMetrics, "Liberation Sans", SkTypeface::kNormal, NULL + LiberationSanskNormalMetrics, "Liberation Sans", SkTypeface::kNormal, nullptr }, { LiberationSanskBoldPoints, LiberationSanskBoldVerbs, LiberationSanskBoldCharCodes, LiberationSanskBoldCharCodesCount, LiberationSanskBoldWidths, - LiberationSanskBoldMetrics, "Liberation Sans", SkTypeface::kBold, NULL + LiberationSanskBoldMetrics, "Liberation Sans", SkTypeface::kBold, nullptr }, { LiberationSanskItalicPoints, LiberationSanskItalicVerbs, LiberationSanskItalicCharCodes, LiberationSanskItalicCharCodesCount, LiberationSanskItalicWidths, - LiberationSanskItalicMetrics, "Liberation Sans", SkTypeface::kItalic, NULL + LiberationSanskItalicMetrics, "Liberation Sans", SkTypeface::kItalic, nullptr }, { LiberationSanskBoldItalicPoints, LiberationSanskBoldItalicVerbs, LiberationSanskBoldItalicCharCodes, LiberationSanskBoldItalicCharCodesCount, LiberationSanskBoldItalicWidths, - LiberationSanskBoldItalicMetrics, "Liberation Sans", SkTypeface::kBoldItalic, NULL + LiberationSanskBoldItalicMetrics, "Liberation Sans", SkTypeface::kBoldItalic, nullptr }, { HiraginoMaruGothicProkNormalPoints, HiraginoMaruGothicProkNormalVerbs, HiraginoMaruGothicProkNormalCharCodes, HiraginoMaruGothicProkNormalCharCodesCount, HiraginoMaruGothicProkNormalWidths, - HiraginoMaruGothicProkNormalMetrics, "Hiragino Maru Gothic Pro", SkTypeface::kNormal, NULL + HiraginoMaruGothicProkNormalMetrics, "Hiragino Maru Gothic Pro", SkTypeface::kNormal, nullptr }, { PapyruskNormalPoints, PapyruskNormalVerbs, PapyruskNormalCharCodes, PapyruskNormalCharCodesCount, PapyruskNormalWidths, - PapyruskNormalMetrics, "Papyrus", SkTypeface::kNormal, NULL + PapyruskNormalMetrics, "Papyrus", SkTypeface::kNormal, nullptr }, { TimesNewRomankNormalPoints, TimesNewRomankNormalVerbs, TimesNewRomankNormalCharCodes, TimesNewRomankNormalCharCodesCount, TimesNewRomankNormalWidths, - TimesNewRomankNormalMetrics, "Times New Roman", SkTypeface::kNormal, NULL + TimesNewRomankNormalMetrics, "Times New Roman", SkTypeface::kNormal, nullptr }, { TimesNewRomankBoldPoints, TimesNewRomankBoldVerbs, TimesNewRomankBoldCharCodes, TimesNewRomankBoldCharCodesCount, TimesNewRomankBoldWidths, - TimesNewRomankBoldMetrics, "Times New Roman", SkTypeface::kBold, NULL + TimesNewRomankBoldMetrics, "Times New Roman", SkTypeface::kBold, nullptr }, { TimesNewRomankItalicPoints, TimesNewRomankItalicVerbs, TimesNewRomankItalicCharCodes, TimesNewRomankItalicCharCodesCount, TimesNewRomankItalicWidths, - TimesNewRomankItalicMetrics, "Times New Roman", SkTypeface::kItalic, NULL + TimesNewRomankItalicMetrics, "Times New Roman", SkTypeface::kItalic, nullptr }, { TimesNewRomankBoldItalicPoints, TimesNewRomankBoldItalicVerbs, TimesNewRomankBoldItalicCharCodes, TimesNewRomankBoldItalicCharCodesCount, TimesNewRomankBoldItalicWidths, - TimesNewRomankBoldItalicMetrics, "Times New Roman", SkTypeface::kBoldItalic, NULL + TimesNewRomankBoldItalicMetrics, "Times New Roman", SkTypeface::kBoldItalic, nullptr }, }; diff --git a/tools/test_font_index.cpp b/tools/test_font_index.cpp index ec135c1499..b9bc24c63f 100644 --- a/tools/test_font_index.cpp +++ b/tools/test_font_index.cpp @@ -10,51 +10,51 @@ static SkTestFontData gTestFonts[] = { { LiberationMonoNormalPoints, LiberationMonoNormalVerbs, LiberationMonoNormalCharCodes, LiberationMonoNormalCharCodesCount, LiberationMonoNormalWidths, - LiberationMonoNormalMetrics, "Toy Liberation Mono", SkTypeface::kNormal, NULL + LiberationMonoNormalMetrics, "Toy Liberation Mono", SkTypeface::kNormal, nullptr }, { LiberationMonoBoldPoints, LiberationMonoBoldVerbs, LiberationMonoBoldCharCodes, LiberationMonoBoldCharCodesCount, LiberationMonoBoldWidths, - LiberationMonoBoldMetrics, "Toy Liberation Mono", SkTypeface::kBold, NULL + LiberationMonoBoldMetrics, "Toy Liberation Mono", SkTypeface::kBold, nullptr }, { LiberationMonoItalicPoints, LiberationMonoItalicVerbs, LiberationMonoItalicCharCodes, LiberationMonoItalicCharCodesCount, LiberationMonoItalicWidths, - LiberationMonoItalicMetrics, "Toy Liberation Mono", SkTypeface::kItalic, NULL + LiberationMonoItalicMetrics, "Toy Liberation Mono", SkTypeface::kItalic, nullptr }, { LiberationMonoBoldItalicPoints, LiberationMonoBoldItalicVerbs, LiberationMonoBoldItalicCharCodes, LiberationMonoBoldItalicCharCodesCount, LiberationMonoBoldItalicWidths, - LiberationMonoBoldItalicMetrics, "Toy Liberation Mono", SkTypeface::kBoldItalic, NULL + LiberationMonoBoldItalicMetrics, "Toy Liberation Mono", SkTypeface::kBoldItalic, nullptr }, { LiberationSansNormalPoints, LiberationSansNormalVerbs, LiberationSansNormalCharCodes, LiberationSansNormalCharCodesCount, LiberationSansNormalWidths, - LiberationSansNormalMetrics, "Toy Liberation Sans", SkTypeface::kNormal, NULL + LiberationSansNormalMetrics, "Toy Liberation Sans", SkTypeface::kNormal, nullptr }, { LiberationSansBoldPoints, LiberationSansBoldVerbs, LiberationSansBoldCharCodes, LiberationSansBoldCharCodesCount, LiberationSansBoldWidths, - LiberationSansBoldMetrics, "Toy Liberation Sans", SkTypeface::kBold, NULL + LiberationSansBoldMetrics, "Toy Liberation Sans", SkTypeface::kBold, nullptr }, { LiberationSansItalicPoints, LiberationSansItalicVerbs, LiberationSansItalicCharCodes, LiberationSansItalicCharCodesCount, LiberationSansItalicWidths, - LiberationSansItalicMetrics, "Toy Liberation Sans", SkTypeface::kItalic, NULL + LiberationSansItalicMetrics, "Toy Liberation Sans", SkTypeface::kItalic, nullptr }, { LiberationSansBoldItalicPoints, LiberationSansBoldItalicVerbs, LiberationSansBoldItalicCharCodes, LiberationSansBoldItalicCharCodesCount, LiberationSansBoldItalicWidths, - LiberationSansBoldItalicMetrics, "Toy Liberation Sans", SkTypeface::kBoldItalic, NULL + LiberationSansBoldItalicMetrics, "Toy Liberation Sans", SkTypeface::kBoldItalic, nullptr }, { LiberationSerifNormalPoints, LiberationSerifNormalVerbs, LiberationSerifNormalCharCodes, LiberationSerifNormalCharCodesCount, LiberationSerifNormalWidths, - LiberationSerifNormalMetrics, "Toy Liberation Serif", SkTypeface::kNormal, NULL + LiberationSerifNormalMetrics, "Toy Liberation Serif", SkTypeface::kNormal, nullptr }, { LiberationSerifBoldPoints, LiberationSerifBoldVerbs, LiberationSerifBoldCharCodes, LiberationSerifBoldCharCodesCount, LiberationSerifBoldWidths, - LiberationSerifBoldMetrics, "Toy Liberation Serif", SkTypeface::kBold, NULL + LiberationSerifBoldMetrics, "Toy Liberation Serif", SkTypeface::kBold, nullptr }, { LiberationSerifItalicPoints, LiberationSerifItalicVerbs, LiberationSerifItalicCharCodes, LiberationSerifItalicCharCodesCount, LiberationSerifItalicWidths, - LiberationSerifItalicMetrics, "Toy Liberation Serif", SkTypeface::kItalic, NULL + LiberationSerifItalicMetrics, "Toy Liberation Serif", SkTypeface::kItalic, nullptr }, { LiberationSerifBoldItalicPoints, LiberationSerifBoldItalicVerbs, LiberationSerifBoldItalicCharCodes, LiberationSerifBoldItalicCharCodesCount, LiberationSerifBoldItalicWidths, - LiberationSerifBoldItalicMetrics, "Toy Liberation Serif", SkTypeface::kBoldItalic, NULL + LiberationSerifBoldItalicMetrics, "Toy Liberation Serif", SkTypeface::kBoldItalic, nullptr }, }; diff --git a/tools/timer/Timer.h b/tools/timer/Timer.h index e28a515b54..9557596248 100644 --- a/tools/timer/Timer.h +++ b/tools/timer/Timer.h @@ -35,7 +35,7 @@ class SkGLContext; */ class Timer { public: - explicit Timer(SkGLContext* gl = NULL); + explicit Timer(SkGLContext* gl = nullptr); void start(); void truncatedEnd(); diff --git a/tools/timer/TimerData.cpp b/tools/timer/TimerData.cpp index 21529bc2e0..d1460f73fd 100644 --- a/tools/timer/TimerData.cpp +++ b/tools/timer/TimerData.cpp @@ -19,7 +19,7 @@ TimerData::TimerData(int maxNumTimings) , fGpuTimes(maxNumTimings) {} bool TimerData::appendTimes(Timer* timer) { - SkASSERT(timer != NULL); + SkASSERT(timer != nullptr); if (fCurrTiming >= fMaxNumTimings) { return false; } diff --git a/tools/win_dbghelp.cpp b/tools/win_dbghelp.cpp index 57389b430d..7291f369a9 100644 --- a/tools/win_dbghelp.cpp +++ b/tools/win_dbghelp.cpp @@ -45,7 +45,7 @@ #define CDB_PRINT_CALLSTACK_CURRENT_THREAD "? " MARKER_THREAD_CALLSTACK_START_NUMBER "; k; ? " MARKER_THREAD_CALLSTACK_STOP_NUMBER "; .ecxr; ? " MARKER_EXCEPTION_CALLSTACK_START_NUMBER "; k; ? " MARKER_EXCEPTION_CALLSTACK_STOP_NUMBER "; q" static void strncpyOrSetBlank(char* dest, const char* src, size_t len) { - const char* srcOrEmptyString = (NULL == src) ? "" : src; + const char* srcOrEmptyString = (nullptr == src) ? "" : src; strncpy(dest, srcOrEmptyString, len); } @@ -105,7 +105,7 @@ static void printCallstack(const char* filename, break; } else if (started) { // Filter messages. Calstack lines contain "exe/dll!function" - if (strchr(line, '!') != NULL && strlen(line) > CDB_CALLSTACK_PREFIX) { + if (strchr(line, '!') != nullptr && strlen(line) > CDB_CALLSTACK_PREFIX) { printf("%s", line + CDB_CALLSTACK_PREFIX); // fgets includes \n already. } } @@ -139,7 +139,7 @@ int GenerateDumpAndPrintCallstack(EXCEPTION_POINTERS* pExceptionPointers) { GetTempPath( dwBufferSize, szPath ); sprintf( szFileName, "%s%s", szPath, szAppName ); - CreateDirectory( szFileName, NULL ); + CreateDirectory( szFileName, nullptr ); BUILD_UNIQUE_FILENAME(szFileName, ".dmp", szPath, szAppName, szVersion, stLocalTime); BUILD_UNIQUE_FILENAME(szFileNameOutput, ".out", szPath, szAppName, szVersion, stLocalTime); @@ -161,8 +161,8 @@ int GenerateDumpAndPrintCallstack(EXCEPTION_POINTERS* pExceptionPointers) { hDumpFile, MiniDumpWithDataSegs, &ExpParam, - NULL, - NULL); + nullptr, + nullptr); printf("MiniDump file: %s\n", szFileName); printf("App exe and pdb: %s\n", getBinariesPath()); diff --git a/tools/win_lcid.cpp b/tools/win_lcid.cpp index f4901719ec..8cb7463d49 100644 --- a/tools/win_lcid.cpp +++ b/tools/win_lcid.cpp @@ -1,3 +1,9 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ #include "windows.h" #include "stdio.h" @@ -12,7 +18,7 @@ BOOL CALLBACK MyFuncLocaleEx(LPWSTR pStr, DWORD dwFlags, LPARAM lparam) { return (TRUE); } - LCID lcid = LocaleNameToLCID(pStr, NULL); + LCID lcid = LocaleNameToLCID(pStr, nullptr); if (lcid == 0) { wprintf(L"Error %d getting LCID\n", GetLastError()); return (TRUE); @@ -27,5 +33,5 @@ BOOL CALLBACK MyFuncLocaleEx(LPWSTR pStr, DWORD dwFlags, LPARAM lparam) { } int main(int argc, wchar_t* argv[]) { - EnumSystemLocalesEx(MyFuncLocaleEx, LOCALE_ALL, NULL, NULL); + EnumSystemLocalesEx(MyFuncLocaleEx, LOCALE_ALL, nullptr, nullptr); } |