diff options
author | junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-13 17:27:16 +0000 |
---|---|---|
committer | junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-13 17:27:16 +0000 |
commit | e286e84a6a23f8a4c81708c1a19c9561f355c720 (patch) | |
tree | 2189c730fba73250cd06446671d48c2fa43b6008 /tools | |
parent | 306b2ce0e22e6e906bbe73f339725dc3748e6499 (diff) |
Modifying the behavior of render_pictures --validate to test the effect of bbh.
The new behavior consists in using the same renderer, with bbh disabled, as a reference
renderer when the current renderer has a bbh.
Review URL: https://codereview.chromium.org/12801002
git-svn-id: http://skia.googlecode.com/svn/trunk@8132 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r-- | tools/PictureRenderer.h | 2 | ||||
-rw-r--r-- | tools/render_pictures_main.cpp | 46 |
2 files changed, 45 insertions, 3 deletions
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index b073252199..3fa7a3c3c4 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -171,6 +171,8 @@ public: fBBoxHierarchyType = bbhType; } + BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } + void setGridSize(int width, int height) { fGridInfo.fTileInterval.set(width, height); } diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index e5cb74eb99..dabce4288b 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -35,7 +35,8 @@ DEFINE_string(w, "", "Directory to write the rendered images."); DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered image to a " "file, instead of an image for each tile."); DEFINE_bool(validate, false, "Verify that the rendered image contains the same pixels as " - "the picture rendered in simple mode."); + "the picture rendered in simple mode. When used in conjunction with --bbh, results " + "are validated against the picture rendered in the same mode, but without the bbh."); static void make_output_filepath(SkString* path, const SkString& dir, const SkString& name) { @@ -142,6 +143,32 @@ static int MaxByteDiff(uint32_t v1, uint32_t v2) { SkMax32(abs(getByte(v1, 2) - getByte(v2, 2)), abs(getByte(v1, 3) - getByte(v2, 3)))); } +namespace { +class AutoRestoreBbhType { +public: + AutoRestoreBbhType() { + fRenderer = NULL; + } + + void set(sk_tools::PictureRenderer* renderer, + sk_tools::PictureRenderer::BBoxHierarchyType bbhType) { + fRenderer = renderer; + fSavedBbhType = renderer->getBBoxHierarchyType(); + renderer->setBBoxHierarchyType(bbhType); + } + + ~AutoRestoreBbhType() { + if (NULL != fRenderer) { + fRenderer->setBBoxHierarchyType(fSavedBbhType); + } + } + +private: + sk_tools::PictureRenderer* fRenderer; + sk_tools::PictureRenderer::BBoxHierarchyType fSavedBbhType; +}; +} + static bool render_picture(const SkString& inputPath, const SkString* outputDir, sk_tools::PictureRenderer& renderer) { int diffs[256] = {0}; @@ -159,8 +186,21 @@ static bool render_picture(const SkString& inputPath, const SkString* outputDir, if (FLAGS_validate) { SkBitmap* referenceBitmap = NULL; - sk_tools::SimplePictureRenderer referenceRenderer; - success = render_picture(inputPath, NULL, referenceRenderer, + sk_tools::PictureRenderer* referenceRenderer; + // If the renderer uses a BBoxHierarchy, then the reference renderer + // will be the same renderer, without the bbh. + AutoRestoreBbhType arbbh; + if (sk_tools::PictureRenderer::kNone_BBoxHierarchyType != + renderer.getBBoxHierarchyType()) { + referenceRenderer = &renderer; + referenceRenderer->ref(); // to match auto unref below + arbbh.set(referenceRenderer, sk_tools::PictureRenderer::kNone_BBoxHierarchyType); + } else { + referenceRenderer = SkNEW(sk_tools::SimplePictureRenderer); + } + SkAutoTUnref<sk_tools::PictureRenderer> aurReferenceRenderer(referenceRenderer); + + success = render_picture(inputPath, NULL, *referenceRenderer, &referenceBitmap); if (!success || NULL == referenceBitmap || NULL == referenceBitmap->getPixels()) { |