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

Unified Diff: tools/PictureRenderer.cpp

Issue 259703002: fix contents of render_pictures JSON summary (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Leon comments Created 6 years, 8 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 | « no previous file | tools/render_pictures_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/PictureRenderer.cpp
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index e531a30dc065a7fa12fd2b6a74501743bfad52e2..c712ae672fbfae196bc16504fef214b9d3bcbdd2 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -323,26 +323,17 @@ uint32_t PictureRenderer::recordFlags() {
}
/**
- * Write the canvas to the specified path.
+ * 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 outputDir If nonempty, write the binary image to a file within this directory.
+ * @param outputDir If nonempty, write the binary image to a file within this directory;
+ * if empty, don't write out the image at all.
* @param inputFilename If we are writing out a binary image, use this to build its filename.
- * @param jsonSummaryPtr If not null, add image results to this summary.
+ * @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 Canvas is written to a file.
*
- * 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.
+ * @return bool True if the operation completed successfully.
*/
static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& inputFilename,
ImageResultsSummary *jsonSummaryPtr, bool useChecksumBasedFilenames,
@@ -407,8 +398,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 +463,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 +493,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 +707,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 +790,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.
« no previous file with comments | « no previous file | tools/render_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698