diff options
author | mtklein <mtklein@chromium.org> | 2015-10-20 14:29:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-20 14:29:10 -0700 |
commit | 0c768a2f330e0e8f0883e174260928097d33e526 (patch) | |
tree | 7b4a19cdbd16d3d1bce3308d7366dc0f9b3cb47e /tools/PictureRenderer.cpp | |
parent | ef33b1e739b23a1201100ff17a572da85b03d9af (diff) |
Clean up some dead code.
This cleans up tools/ code, or code that should have been in tools/.
The only interesting code change trims features off of PictureRenderer.
It's still in use by a few useful-looking tools.
BUG=skia:
Review URL: https://codereview.chromium.org/1416913003
Diffstat (limited to 'tools/PictureRenderer.cpp')
-rw-r--r-- | tools/PictureRenderer.cpp | 99 |
1 files changed, 2 insertions, 97 deletions
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index 19ee7b5f2a..c550b6eefb 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -283,87 +283,6 @@ void PictureRenderer::purgeTextures() { #endif } -/** - * Write the canvas to an image file and/or JSON summary. - * - * @param canvas Must be non-null. Canvas to be written to a file. - * @param writePath If nonempty, write the binary image to a file within this directory. - * @param mismatchPath If nonempty, write the binary image to a file within this directory, - * but only if the image does not match expectations. - * @param inputFilename If we are writing out a binary image, use this to build its filename. - * @param jsonSummaryPtr If not null, add image results (checksum) to this summary. - * @param useChecksumBasedFilenames If true, use checksum-based filenames when writing to disk. - * @param tileNumberPtr If not null, which tile number this image contains. - * - * @return bool True if the operation completed successfully. - */ -static bool write(SkCanvas* canvas, const SkString& writePath, const SkString& mismatchPath, - const SkString& inputFilename, ImageResultsAndExpectations *jsonSummaryPtr, - bool useChecksumBasedFilenames, const int* tileNumberPtr=nullptr) { - SkASSERT(canvas != nullptr); - if (nullptr == canvas) { - return false; - } - - SkBitmap bitmap; - SkISize size = canvas->getDeviceSize(); - setup_bitmap(&bitmap, size.width(), size.height()); - - canvas->readPixels(&bitmap, 0, 0); - force_all_opaque(bitmap); - BitmapAndDigest bitmapAndDigest(bitmap); - - SkString escapedInputFilename(inputFilename); - replace_char(&escapedInputFilename, '.', '_'); - - // 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 = nullptr; - if (useChecksumBasedFilenames) { - ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr(); - outputSubdirPtr = escapedInputFilename.c_str(); - outputFilename.set(imageDigestPtr->getHashType()); - outputFilename.append("_"); - outputFilename.appendU64(imageDigestPtr->getHashValue()); - } else { - outputFilename.set(escapedInputFilename); - if (tileNumberPtr) { - outputFilename.append("-tile"); - outputFilename.appendS32(*tileNumberPtr); - } - } - outputFilename.append(".png"); - - if (jsonSummaryPtr) { - ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr(); - SkString outputRelativePath; - if (outputSubdirPtr) { - outputRelativePath.set(outputSubdirPtr); - outputRelativePath.append("/"); // always use "/", even on Windows - outputRelativePath.append(outputFilename); - } else { - outputRelativePath.set(outputFilename); - } - - jsonSummaryPtr->add(inputFilename.c_str(), outputRelativePath.c_str(), - *imageDigestPtr, tileNumberPtr); - if (!mismatchPath.isEmpty() && - !jsonSummaryPtr->getExpectation(inputFilename.c_str(), - tileNumberPtr).matches(*imageDigestPtr)) { - if (!write_bitmap_to_disk(bitmap, mismatchPath, outputSubdirPtr, outputFilename)) { - return false; - } - } - } - - if (writePath.isEmpty()) { - return true; - } else { - return write_bitmap_to_disk(bitmap, writePath, outputSubdirPtr, outputFilename); - } -} - /////////////////////////////////////////////////////////////////////////////////////////////// SkCanvas* RecordPictureRenderer::setupCanvas(int width, int height) { @@ -417,12 +336,7 @@ bool PipePictureRenderer::render(SkBitmap** out) { SkScalarCeilToInt(fPicture->cullRect().height())); fCanvas->readPixels(*out, 0, 0); } - if (fEnableWrites) { - return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, - fUseChecksumBasedFilenames); - } else { - return true; - } + return true; } SkString PipePictureRenderer::getConfigNameInternal() { @@ -462,12 +376,7 @@ bool SimplePictureRenderer::render(SkBitmap** out) { SkScalarCeilToInt(fPicture->cullRect().height())); fCanvas->readPixels(*out, 0, 0); } - if (fEnableWrites) { - return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, - fUseChecksumBasedFilenames); - } else { - return true; - } + return true; } SkString SimplePictureRenderer::getConfigNameInternal() { @@ -674,10 +583,6 @@ bool TiledPictureRenderer::postRender(SkCanvas* canvas, const SkIRect& tileRect, int tileNumber) { bool success = true; - if (fEnableWrites) { - success &= write(canvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, - fUseChecksumBasedFilenames, &tileNumber); - } if (out) { if (canvas->readPixels(tempBM, 0, 0)) { // Add this tile to the entire bitmap. |