Index: tools/PictureRenderer.cpp |
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp |
index b15b4a798338444a6de64782fa8b326d3dccb22d..5128782d4400a37fcbda7e98b8282c237f0d1c3c 100644 |
--- a/tools/PictureRenderer.cpp |
+++ b/tools/PictureRenderer.cpp |
@@ -398,8 +398,12 @@ bool PipePictureRenderer::render(SkBitmap** out) { |
setup_bitmap(*out, fPicture->width(), fPicture->height()); |
fCanvas->readPixels(*out, 0, 0); |
} |
- return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames); |
+ if (fEnableWrites) { |
+ return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames); |
+ } else { |
+ return true; |
+ } |
} |
SkString PipePictureRenderer::getConfigNameInternal() { |
@@ -429,8 +433,12 @@ bool SimplePictureRenderer::render(SkBitmap** out) { |
setup_bitmap(*out, fPicture->width(), fPicture->height()); |
fCanvas->readPixels(*out, 0, 0); |
} |
- return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames); |
+ if (fEnableWrites) { |
+ return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames); |
+ } else { |
+ return true; |
+ } |
} |
SkString SimplePictureRenderer::getConfigNameInternal() { |
@@ -640,8 +648,10 @@ bool TiledPictureRenderer::render(SkBitmap** out) { |
bool success = true; |
for (int i = 0; i < fTileRects.count(); ++i) { |
draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture); |
- success &= write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames, &i); |
+ if (fEnableWrites) { |
+ success &= write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames, &i); |
+ } |
if (NULL != out) { |
if (fCanvas->readPixels(&bitmap, 0, 0)) { |
// Add this tile to the entire bitmap. |
@@ -700,9 +710,10 @@ class CloneData : public SkRunnable { |
public: |
CloneData(SkPicture* clone, SkCanvas* canvas, SkTDArray<SkRect>& rects, int start, int end, |
SkRunnable* done, ImageResultsAndExpectations* jsonSummaryPtr, |
- bool useChecksumBasedFilenames) |
+ bool useChecksumBasedFilenames, bool enableWrites) |
: fClone(clone) |
, fCanvas(canvas) |
+ , fEnableWrites(enableWrites) |
, fRects(rects) |
, fStart(start) |
, fEnd(end) |
@@ -724,23 +735,25 @@ public: |
for (int i = fStart; i < fEnd; i++) { |
draw_tile_to_canvas(fCanvas, fRects[i], fClone); |
- if (!write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
- fUseChecksumBasedFilenames, &i) |
- && fSuccess != NULL) { |
- *fSuccess = false; |
- // If one tile fails to write to a file, do not continue drawing the rest. |
- break; |
- } |
- if (fBitmap != NULL) { |
- if (fCanvas->readPixels(&bitmap, 0, 0)) { |
- SkAutoLockPixels alp(*fBitmap); |
- bitmapCopyAtOffset(bitmap, fBitmap, SkScalarFloorToInt(fRects[i].left()), |
- SkScalarFloorToInt(fRects[i].top())); |
- } else { |
+ if (fEnableWrites) { |
+ if (!write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, |
+ fUseChecksumBasedFilenames, &i) |
+ && fSuccess != NULL) { |
*fSuccess = false; |
- // If one tile fails to read pixels, do not continue drawing the rest. |
+ // If one tile fails to write to a file, do not continue drawing the rest. |
break; |
} |
+ if (fBitmap != NULL) { |
+ if (fCanvas->readPixels(&bitmap, 0, 0)) { |
+ SkAutoLockPixels alp(*fBitmap); |
+ bitmapCopyAtOffset(bitmap, fBitmap, SkScalarFloorToInt(fRects[i].left()), |
+ SkScalarFloorToInt(fRects[i].top())); |
+ } else { |
+ *fSuccess = false; |
+ // If one tile fails to read pixels, do not continue drawing the rest. |
+ break; |
+ } |
+ } |
} |
} |
fDone->run(); |
@@ -763,6 +776,8 @@ private: |
SkPicture* fClone; // Picture to draw from. Each CloneData has a unique one which |
// is threadsafe. |
SkCanvas* fCanvas; // Canvas to draw to. Reused for each tile. |
+ bool fEnableWrites; // TODO(epoger): Temporary hack; see declaration of |
+ // fEnableWrites in PictureRenderer.h. |
SkString fWritePath; // If not empty, write all results into this directory. |
SkString fMismatchPath; // If not empty, write all unexpected results into this dir. |
SkString fInputFilename; // Filename of input SkPicture file. |
@@ -813,7 +828,7 @@ void MultiCorePictureRenderer::init(SkPicture *pict, const SkString* writePath, |
const int end = SkMin32(start + chunkSize, fTileRects.count()); |
fCloneData[i] = SkNEW_ARGS(CloneData, |
(pic, fCanvasPool[i], fTileRects, start, end, &fCountdown, |
- fJsonSummaryPtr, useChecksumBasedFilenames)); |
+ fJsonSummaryPtr, useChecksumBasedFilenames, fEnableWrites)); |
} |
} |