Index: tools/PictureRenderer.cpp |
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp |
index e531a30dc065a7fa12fd2b6a74501743bfad52e2..0d652d97f09a7eeaeda881c681efccbbae6194d7 100644 |
--- a/tools/PictureRenderer.cpp |
+++ b/tools/PictureRenderer.cpp |
@@ -332,17 +332,6 @@ uint32_t PictureRenderer::recordFlags() { |
* @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 Canvas is written to a file. |
scroggo
2014/04/24 21:15:08
or if outputDir is NULL but we still wrote a summa
epoger
2014/04/25 15:26:43
It's slightly different than that... updated.
|
- * |
- * TODO(epoger): Right now, all canvases must pass through this function in order to be appended |
- * to the ImageResultsSummary. We need some way to add bitmaps to the ImageResultsSummary |
- * even if --writePath has not been specified (and thus this function is not called). |
- * |
- * One fix would be to pass in these path elements separately, and allow this function to be |
- * called even if --writePath was not specified... |
- * const char *outputDir // NULL if we don't want to write image files to disk |
- * const char *filename // name we use within JSON summary, and as the filename within outputDir |
- * |
- * UPDATE: Now that outputDir and inputFilename are passed separately, we should be able to do that. |
*/ |
static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& inputFilename, |
ImageResultsSummary *jsonSummaryPtr, bool useChecksumBasedFilenames, |
@@ -407,8 +396,10 @@ static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& i |
hash, tileNumberPtr); |
} |
- SkASSERT(!outputDir.isEmpty()); // TODO(epoger): we want to remove this constraint, |
- // as noted above |
+ if (outputDir.isEmpty()) { |
+ return true; |
+ } |
+ |
SkString dirPath; |
if (outputSubdirPtr) { |
dirPath = SkOSPath::SkPathJoin(outputDir.c_str(), outputSubdirPtr); |
@@ -470,16 +461,13 @@ bool PipePictureRenderer::render(SkBitmap** out) { |
pipeCanvas->drawPicture(*fPicture); |
writer.endRecording(); |
fCanvas->flush(); |
- if (!fOutputDir.isEmpty()) { |
- return write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames); |
- } |
if (NULL != out) { |
*out = SkNEW(SkBitmap); |
setup_bitmap(*out, fPicture->width(), fPicture->height()); |
fCanvas->readPixels(*out, 0, 0); |
} |
- return true; |
+ return write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames); |
} |
SkString PipePictureRenderer::getConfigNameInternal() { |
@@ -503,18 +491,13 @@ bool SimplePictureRenderer::render(SkBitmap** out) { |
fCanvas->drawPicture(*fPicture); |
fCanvas->flush(); |
- if (!fOutputDir.isEmpty()) { |
- return write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames); |
- } |
- |
if (NULL != out) { |
*out = SkNEW(SkBitmap); |
setup_bitmap(*out, fPicture->width(), fPicture->height()); |
fCanvas->readPixels(*out, 0, 0); |
} |
- |
- return true; |
+ return write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames); |
} |
SkString SimplePictureRenderer::getConfigNameInternal() { |
@@ -722,10 +705,8 @@ bool TiledPictureRenderer::render(SkBitmap** out) { |
bool success = true; |
for (int i = 0; i < fTileRects.count(); ++i) { |
draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture); |
- if (!fOutputDir.isEmpty()) { |
- success &= write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames, &i); |
- } |
+ success &= write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames, &i); |
if (NULL != out) { |
if (fCanvas->readPixels(&bitmap, 0, 0)) { |
// Add this tile to the entire bitmap. |
@@ -807,9 +788,8 @@ public: |
for (int i = fStart; i < fEnd; i++) { |
draw_tile_to_canvas(fCanvas, fRects[i], fClone); |
- if ((!fOutputDir.isEmpty()) |
- && !write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames, &i) |
+ if (!write(fCanvas, fOutputDir, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames, &i) |
&& fSuccess != NULL) { |
*fSuccess = false; |
// If one tile fails to write to a file, do not continue drawing the rest. |