From f4f9df4c193620167dc6f202f1b72245f4a260cd Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 26 Sep 2013 20:44:24 +0000 Subject: gm: add a flag to force perspective usage in all gms BUG= R=reed@google.com, epoger@google.com, borenet@google.com Author: edisonn@google.com Review URL: https://chromiumcodereview.appspot.com/23587029 git-svn-id: http://skia.googlecode.com/svn/trunk@11487 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/gm.cpp | 1 + gm/gm.h | 10 +++++++++- gm/gmmain.cpp | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'gm') diff --git a/gm/gm.cpp b/gm/gm.cpp index 4a8b3c31d7..966e59ba48 100644 --- a/gm/gm.cpp +++ b/gm/gm.cpp @@ -15,6 +15,7 @@ GM::GM() { fCanvasIsDeferred = false; fHaveCalledOnceBeforeDraw = false; fIgnoreFailures = false; + fStarterMatrix.reset(); } GM::~GM() {} diff --git a/gm/gm.h b/gm/gm.h index 3a65160741..bf1a41140d 100644 --- a/gm/gm.h +++ b/gm/gm.h @@ -74,7 +74,9 @@ namespace skiagm { // Most GMs will return the identity matrix, but some PDFs tests // require setting the initial transform. SkMatrix getInitialTransform() const { - return this->onGetInitialTransform(); + SkMatrix matrix = fStarterMatrix; + matrix.preConcat(this->onGetInitialTransform()); + return matrix; } SkColor getBGColor() const { return fBGColor; } @@ -106,6 +108,11 @@ namespace skiagm { static GrContext* GetGr(/*very nearly const*/ SkCanvas*); #endif + const SkMatrix& getStarterMatrix() { return fStarterMatrix; } + void setStarterMatrix(const SkMatrix& matrix) { + fStarterMatrix = matrix; + } + protected: static SkString gResourcePath; @@ -123,6 +130,7 @@ namespace skiagm { bool fCanvasIsDeferred; // work-around problem in srcmode.cpp bool fHaveCalledOnceBeforeDraw; bool fIgnoreFailures; // whether to file any failures as failure-ignored + SkMatrix fStarterMatrix; }; typedef SkTRegistry GMRegistry; diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 2cd8f474f9..84d4d3ac74 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -1423,6 +1423,14 @@ DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, " "which can be in range 0-100). N = -1 will disable JPEG compression. " "Default is N = 100, maximum quality."); +// TODO(edisonn): pass a matrix instead of forcePerspectiveMatrix +// Either the 9 numbers defining the matrix +// or probably more readable would be to replace it with a set of a few predicates +// Like --prerotate 100 200 10 --posttranslate 10, 10 +// Probably define spacial names like centerx, centery, top, bottom, left, right +// then we can write something reabable like --rotate centerx centery 90 +DEFINE_bool(forcePerspectiveMatrix, false, "Force a perspective matrix."); + static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, const SkIRect& rect) { // Filter output of warnings that JPEG is not available for the image. if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return false; @@ -2154,6 +2162,15 @@ int tool_main(int argc, char** argv) { Iter iter; GM* gm; while ((gm = iter.next()) != NULL) { + if (FLAGS_forcePerspectiveMatrix) { + SkMatrix perspective; + perspective.setIdentity(); + perspective.setPerspY(SkScalarDiv(SK_Scalar1, SkIntToScalar(1000))); + perspective.setSkewX(SkScalarDiv(SkIntToScalar(8), + SkIntToScalar(25))); + + gm->setStarterMatrix(perspective); + } SkAutoTDelete adgm(gm); ++gmIndex; if (moduloRemainder >= 0) { -- cgit v1.2.3