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

Unified Diff: tools/render_pictures_main.cpp

Issue 12801002: Modifying the behavior of render_pictures --validate to test the effect of bbh. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | « tools/PictureRenderer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/render_pictures_main.cpp
===================================================================
--- tools/render_pictures_main.cpp (revision 8119)
+++ tools/render_pictures_main.cpp (working copy)
@@ -142,6 +142,32 @@
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 +185,23 @@
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
edisonn 2013/03/13 15:25:34 you can simplify the comment, and include this exc
+ // will be the same renderer, without the bbh. This allows us to
+ // validate the effect of the bbh in isolation. In all other cases,
+ // the reference renderer is a SimplePictureRenderer.
+ 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()) {
« no previous file with comments | « tools/PictureRenderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698