skia2/dm/DMSKPTask.cpp
mtklein e4636aa173 Merge Replay and Quilt tasks, adding in all BBH implementations.
Replay isn't that helpful of a test any more now that we have the more
stringent Quilt tests.  Quilt was missing bounding box hierarchies, though,
while Replay was sort of testing RTree (pointlessly, as it was drawing without
any clip).  Now Quilt does everything, testing RTree, QuadTree, and TileGrid.

Quilt mode now falls back to drawing all at once (i.e. Replay) for GMs that
don't tile perfectly.  Still a TODO to make this check more flexible than exact
pixel matches.

Two GMs fail when using a BBH:
  - imageresizetiled
  - resizeimagefilter
We think we're not adjusting the bounds of save layers by their paint.
This is probably a bug, but one to be fixed separately from adding new tests.

BUG=skia:
R=robertphillips@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/377373003
2014-07-09 13:10:58 -07:00

60 lines
1.9 KiB
C++

#include "DMSKPTask.h"
#include "DMUtil.h"
#include "DMWriteTask.h"
#include "SkCommandLineFlags.h"
#include "SkPictureRecorder.h"
DEFINE_bool(skr, true, "Test that SKPs draw the same when re-recorded with SkRecord backend.");
namespace DM {
// Test that an SkPicture plays back the same when re-recorded into an
// SkPicture backed by SkRecord.
class SkrComparisonTask : public CpuTask {
public:
SkrComparisonTask(const Task& parent, const SkPicture* picture, SkBitmap reference)
: CpuTask(parent)
, fPicture(picture)
, fReference(reference)
, fName(UnderJoin(parent.name().c_str(), "skr")) {}
virtual bool shouldSkip() const SK_OVERRIDE { return !FLAGS_skr; }
virtual SkString name() const SK_OVERRIDE { return fName; }
virtual void draw() SK_OVERRIDE {
SkPictureRecorder recorder;
fPicture->draw(recorder.EXPERIMENTAL_beginRecording(fPicture->width(), fPicture->height()));
SkAutoTDelete<const SkPicture> skrPicture(recorder.endRecording());
SkBitmap bitmap;
AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
DrawPicture(*skrPicture, &bitmap);
if (!BitmapsEqual(fReference, bitmap)) {
this->fail();
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
}
}
private:
SkAutoTUnref<const SkPicture> fPicture;
const SkBitmap fReference;
const SkString fName;
};
SKPTask::SKPTask(Reporter* r, TaskRunner* tr, const SkPicture* pic, SkString filename)
: CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {}
void SKPTask::draw() {
SkBitmap bitmap;
AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
DrawPicture(*fPicture, &bitmap);
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
this->spawnChild(SkNEW_ARGS(SkrComparisonTask, (*this, fPicture.get(), bitmap)));
}
} // namespace DM