diff --git a/debugger/SkDrawCommand.h b/debugger/SkDrawCommand.h index 3ede8ff908..6c1056c96e 100644 --- a/debugger/SkDrawCommand.h +++ b/debugger/SkDrawCommand.h @@ -408,6 +408,10 @@ class Scale : public SkDrawCommand { public: Scale(SkScalar sx, SkScalar sy); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; + + SkScalar x() const { return fSx; } + SkScalar y() const { return fSy; } + private: SkScalar fSx; SkScalar fSy; @@ -434,6 +438,10 @@ class Translate : public SkDrawCommand { public: Translate(SkScalar dx, SkScalar dy); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; + + SkScalar x() const { return fDx; } + SkScalar y() const { return fDy; } + private: SkScalar fDx; SkScalar fDy; diff --git a/tools/filtermain.cpp b/tools/filtermain.cpp index 5d7241e1c3..14eafdc412 100644 --- a/tools/filtermain.cpp +++ b/tools/filtermain.cpp @@ -280,6 +280,47 @@ static void apply_4(SkTDArray& commands, int curCommand) { restore->setVisible(false); } +// Check for: +// TRANSLATE +// where the translate is zero +static bool check_5(const SkTDArray& commands, int curCommand) { + if (TRANSLATE != commands[curCommand]->getType()) { + return false; + } + + Translate* t = (Translate*) commands[curCommand]; + + return 0 == t->x() && 0 == t->y(); +} + +// Just remove the translate +static void apply_5(SkTDArray& commands, int curCommand) { + Translate* t = (Translate*) commands[curCommand]; + + t->setVisible(false); +} + +// Check for: +// SCALE +// where the scale is 1,1 +static bool check_6(const SkTDArray& commands, int curCommand) { + if (SCALE != commands[curCommand]->getType()) { + return false; + } + + Scale* s = (Scale*) commands[curCommand]; + + return SK_Scalar1 == s->x() && SK_Scalar1 == s->y(); +} + +// Just remove the scale +static void apply_6(SkTDArray& commands, int curCommand) { + Scale* s = (Scale*) commands[curCommand]; + + s->setVisible(false); +} + + typedef bool (*PFCheck)(const SkTDArray& commands, int curCommand); typedef void (*PFApply)(SkTDArray& commands, int curCommand); @@ -293,6 +334,8 @@ struct OptTableEntry { { check_2, apply_2, 0 }, { check_3, apply_3, 0 }, { check_4, apply_4, 0 }, + { check_5, apply_5, 0 }, + { check_6, apply_6, 0 }, }; static int filter_picture(const SkString& inFile, const SkString& outFile) {