Index: tools/filtermain.cpp |
diff --git a/tools/filtermain.cpp b/tools/filtermain.cpp |
index 6883ff2047491d306ce5764c5672186d672ede56..3b9d05682c1d5d0e42bec87dbed36dd705834b49 100644 |
--- a/tools/filtermain.cpp |
+++ b/tools/filtermain.cpp |
@@ -49,10 +49,10 @@ |
// RESTORE |
// where the saveLayer's color can be moved into the drawBitmapRect |
static bool check_0(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+2 || |
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+2)->getType()) { |
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+2)->getType()) { |
return false; |
} |
@@ -121,13 +121,13 @@ |
// RESTORE |
// where the saveLayer's color can be moved into the drawBitmapRect |
static bool check_1(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+5 || |
- SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() || |
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+3)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+4)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+5)->getType()) { |
+ SAVE != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+3)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+4)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+5)->getType()) { |
return false; |
} |
@@ -187,11 +187,11 @@ |
// RESTORE |
// where the rect is entirely within the clip and the clip is an intersect |
static bool check_2(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+4 || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
return false; |
} |
@@ -222,11 +222,11 @@ |
// RESTORE |
// where the rect entirely encloses the clip |
static bool check_3(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+4 || |
- SkDrawCommand::kClipRRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
+ CLIP_RRECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
return false; |
} |
@@ -270,11 +270,11 @@ |
// RESTORE |
// where the rect and drawBitmapRect dst exactly match |
static bool check_4(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+4 || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
return false; |
} |
@@ -296,6 +296,43 @@ |
// drawBitmapRectToRect |
canvas->deleteDrawCommandAt(curCommand+1); // clipRect |
canvas->deleteDrawCommandAt(curCommand); // save |
+} |
+ |
+// Check for: |
+// TRANSLATE |
+// where the translate is zero |
+static bool check_5(SkDebugCanvas* canvas, int curCommand) { |
+ if (TRANSLATE != canvas->getDrawCommandAt(curCommand)->getType()) { |
+ return false; |
+ } |
+ |
+ SkTranslateCommand* t = |
+ (SkTranslateCommand*) canvas->getDrawCommandAt(curCommand); |
+ |
+ return 0 == t->x() && 0 == t->y(); |
+} |
+ |
+// Just remove the translate |
+static void apply_5(SkDebugCanvas* canvas, int curCommand) { |
+ canvas->deleteDrawCommandAt(curCommand); // translate |
+} |
+ |
+// Check for: |
+// SCALE |
+// where the scale is 1,1 |
+static bool check_6(SkDebugCanvas* canvas, int curCommand) { |
+ if (SCALE != canvas->getDrawCommandAt(curCommand)->getType()) { |
+ return false; |
+ } |
+ |
+ SkScaleCommand* s = (SkScaleCommand*) canvas->getDrawCommandAt(curCommand); |
+ |
+ return SK_Scalar1 == s->x() && SK_Scalar1 == s->y(); |
+} |
+ |
+// Just remove the scale |
+static void apply_6(SkDebugCanvas* canvas, int curCommand) { |
+ canvas->deleteDrawCommandAt(curCommand); // scale |
} |
// Check for: |
@@ -320,21 +357,21 @@ |
// all the saveLayer's paints can be rolled into the drawBitmapRectToRect's paint |
// This pattern is used by Google spreadsheet when drawing the toolbar buttons |
static bool check_7(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+13 || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() || |
- SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+3)->getType() || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+4)->getType() || |
- SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+5)->getType() || |
- SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+6)->getType() || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+7)->getType() || |
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+8)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+9)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+10)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+11)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+12)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+13)->getType()) { |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ SAVE_LAYER != canvas->getDrawCommandAt(curCommand+2)->getType() || |
+ SAVE != canvas->getDrawCommandAt(curCommand+3)->getType() || |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+4)->getType() || |
+ SAVE_LAYER != canvas->getDrawCommandAt(curCommand+5)->getType() || |
+ SAVE != canvas->getDrawCommandAt(curCommand+6)->getType() || |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+7)->getType() || |
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+8)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+9)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+10)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+11)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+12)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+13)->getType()) { |
return false; |
} |
@@ -496,11 +533,11 @@ |
// the drawBitmapRectToRect is a 1-1 copy from src to dest |
// the clip rect is BW and a subset of the drawBitmapRectToRect's dest rect |
static bool check_8(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+4 || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
return false; |
} |
@@ -570,11 +607,11 @@ |
// where: |
// clipRect is BW and encloses the DBMR2R's dest rect |
static bool check_9(SkDebugCanvas* canvas, int curCommand) { |
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() || |
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
canvas->getSize() <= curCommand+4 || |
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() || |
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() || |
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
return false; |
} |
@@ -615,6 +652,8 @@ |
{ 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 }, |
{ check_7, apply_7, 0 }, |
{ check_8, apply_8, 0 }, |
{ check_9, apply_9, 0 }, |