Call write() within render_pictures but not bench_pictures
BUG=skia:2584 R=bsalomon@google.com, robertphillips@google.com, bensong@google.com Author: epoger@google.com Review URL: https://codereview.chromium.org/291843010 git-svn-id: http://skia.googlecode.com/svn/trunk@14837 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
336df8fd34
commit
8991c67f0c
@ -398,8 +398,12 @@ bool PipePictureRenderer::render(SkBitmap** out) {
|
|||||||
setup_bitmap(*out, fPicture->width(), fPicture->height());
|
setup_bitmap(*out, fPicture->width(), fPicture->height());
|
||||||
fCanvas->readPixels(*out, 0, 0);
|
fCanvas->readPixels(*out, 0, 0);
|
||||||
}
|
}
|
||||||
return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
if (fEnableWrites) {
|
||||||
fUseChecksumBasedFilenames);
|
return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
||||||
|
fUseChecksumBasedFilenames);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SkString PipePictureRenderer::getConfigNameInternal() {
|
SkString PipePictureRenderer::getConfigNameInternal() {
|
||||||
@ -429,8 +433,12 @@ bool SimplePictureRenderer::render(SkBitmap** out) {
|
|||||||
setup_bitmap(*out, fPicture->width(), fPicture->height());
|
setup_bitmap(*out, fPicture->width(), fPicture->height());
|
||||||
fCanvas->readPixels(*out, 0, 0);
|
fCanvas->readPixels(*out, 0, 0);
|
||||||
}
|
}
|
||||||
return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
if (fEnableWrites) {
|
||||||
fUseChecksumBasedFilenames);
|
return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
||||||
|
fUseChecksumBasedFilenames);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SkString SimplePictureRenderer::getConfigNameInternal() {
|
SkString SimplePictureRenderer::getConfigNameInternal() {
|
||||||
@ -640,8 +648,10 @@ bool TiledPictureRenderer::render(SkBitmap** out) {
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
for (int i = 0; i < fTileRects.count(); ++i) {
|
for (int i = 0; i < fTileRects.count(); ++i) {
|
||||||
draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture);
|
draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture);
|
||||||
success &= write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
if (fEnableWrites) {
|
||||||
fUseChecksumBasedFilenames, &i);
|
success &= write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
||||||
|
fUseChecksumBasedFilenames, &i);
|
||||||
|
}
|
||||||
if (NULL != out) {
|
if (NULL != out) {
|
||||||
if (fCanvas->readPixels(&bitmap, 0, 0)) {
|
if (fCanvas->readPixels(&bitmap, 0, 0)) {
|
||||||
// Add this tile to the entire bitmap.
|
// Add this tile to the entire bitmap.
|
||||||
@ -700,9 +710,10 @@ class CloneData : public SkRunnable {
|
|||||||
public:
|
public:
|
||||||
CloneData(SkPicture* clone, SkCanvas* canvas, SkTDArray<SkRect>& rects, int start, int end,
|
CloneData(SkPicture* clone, SkCanvas* canvas, SkTDArray<SkRect>& rects, int start, int end,
|
||||||
SkRunnable* done, ImageResultsAndExpectations* jsonSummaryPtr,
|
SkRunnable* done, ImageResultsAndExpectations* jsonSummaryPtr,
|
||||||
bool useChecksumBasedFilenames)
|
bool useChecksumBasedFilenames, bool enableWrites)
|
||||||
: fClone(clone)
|
: fClone(clone)
|
||||||
, fCanvas(canvas)
|
, fCanvas(canvas)
|
||||||
|
, fEnableWrites(enableWrites)
|
||||||
, fRects(rects)
|
, fRects(rects)
|
||||||
, fStart(start)
|
, fStart(start)
|
||||||
, fEnd(end)
|
, fEnd(end)
|
||||||
@ -724,23 +735,25 @@ public:
|
|||||||
|
|
||||||
for (int i = fStart; i < fEnd; i++) {
|
for (int i = fStart; i < fEnd; i++) {
|
||||||
draw_tile_to_canvas(fCanvas, fRects[i], fClone);
|
draw_tile_to_canvas(fCanvas, fRects[i], fClone);
|
||||||
if (!write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
if (fEnableWrites) {
|
||||||
fUseChecksumBasedFilenames, &i)
|
if (!write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
|
||||||
&& fSuccess != NULL) {
|
fUseChecksumBasedFilenames, &i)
|
||||||
*fSuccess = false;
|
&& fSuccess != NULL) {
|
||||||
// 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;
|
*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;
|
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();
|
fDone->run();
|
||||||
@ -763,6 +776,8 @@ private:
|
|||||||
SkPicture* fClone; // Picture to draw from. Each CloneData has a unique one which
|
SkPicture* fClone; // Picture to draw from. Each CloneData has a unique one which
|
||||||
// is threadsafe.
|
// is threadsafe.
|
||||||
SkCanvas* fCanvas; // Canvas to draw to. Reused for each tile.
|
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 fWritePath; // If not empty, write all results into this directory.
|
||||||
SkString fMismatchPath; // If not empty, write all unexpected results into this dir.
|
SkString fMismatchPath; // If not empty, write all unexpected results into this dir.
|
||||||
SkString fInputFilename; // Filename of input SkPicture file.
|
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());
|
const int end = SkMin32(start + chunkSize, fTileRects.count());
|
||||||
fCloneData[i] = SkNEW_ARGS(CloneData,
|
fCloneData[i] = SkNEW_ARGS(CloneData,
|
||||||
(pic, fCanvasPool[i], fTileRects, start, end, &fCountdown,
|
(pic, fCanvasPool[i], fTileRects, start, end, &fCountdown,
|
||||||
fJsonSummaryPtr, useChecksumBasedFilenames));
|
fJsonSummaryPtr, useChecksumBasedFilenames, fEnableWrites));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,14 @@ public:
|
|||||||
virtual void init(SkPicture* pict, const SkString* writePath, const SkString* mismatchPath,
|
virtual void init(SkPicture* pict, const SkString* writePath, const SkString* mismatchPath,
|
||||||
const SkString* inputFilename, bool useChecksumBasedFilenames);
|
const SkString* inputFilename, bool useChecksumBasedFilenames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO(epoger): Temporary hack, while we work on http://skbug.com/2584 ('bench_pictures is
|
||||||
|
* timing reading pixels and writing json files'), such that:
|
||||||
|
* - render_pictures can call this method and continue to work
|
||||||
|
* - any other callers (bench_pictures) will skip calls to write() by default
|
||||||
|
*/
|
||||||
|
void enableWrites() { fEnableWrites = true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the viewport so that only the portion listed gets drawn.
|
* Set the viewport so that only the portion listed gets drawn.
|
||||||
*/
|
*/
|
||||||
@ -345,6 +353,7 @@ public:
|
|||||||
PictureRenderer()
|
PictureRenderer()
|
||||||
: fJsonSummaryPtr(NULL)
|
: fJsonSummaryPtr(NULL)
|
||||||
, fDeviceType(kBitmap_DeviceType)
|
, fDeviceType(kBitmap_DeviceType)
|
||||||
|
, fEnableWrites(false)
|
||||||
, fBBoxHierarchyType(kNone_BBoxHierarchyType)
|
, fBBoxHierarchyType(kNone_BBoxHierarchyType)
|
||||||
, fScaleFactor(SK_Scalar1)
|
, fScaleFactor(SK_Scalar1)
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
@ -371,6 +380,7 @@ protected:
|
|||||||
bool fUseChecksumBasedFilenames;
|
bool fUseChecksumBasedFilenames;
|
||||||
ImageResultsAndExpectations* fJsonSummaryPtr;
|
ImageResultsAndExpectations* fJsonSummaryPtr;
|
||||||
SkDeviceTypes fDeviceType;
|
SkDeviceTypes fDeviceType;
|
||||||
|
bool fEnableWrites;
|
||||||
BBoxHierarchyType fBBoxHierarchyType;
|
BBoxHierarchyType fBBoxHierarchyType;
|
||||||
DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount];
|
DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount];
|
||||||
SkString fDrawFiltersConfig;
|
SkString fDrawFiltersConfig;
|
||||||
|
@ -206,6 +206,7 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderer.setup();
|
renderer.setup();
|
||||||
|
renderer.enableWrites();
|
||||||
|
|
||||||
bool success = renderer.render(out);
|
bool success = renderer.render(out);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
Loading…
Reference in New Issue
Block a user