aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-02-12 13:29:15 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-12 13:29:15 -0800
commit3a092042bce0a8b7c43bf621cacdb2c644febeb2 (patch)
tree3ac5095fc9dca4fa97459850737abfc7384c235f /tools
parent7cd3f64385ab161a69c39be41fd1827e49da3170 (diff)
Revert of Remove SkPictureFlat.h include from SkDrawCommands.h (patchset #3 id:40001 of https://codereview.chromium.org/912403004/)
Reason for revert: Erm - Chrome. Original issue's description: > Remove SkPictureFlat.h include from SkDrawCommands.h > > This cannot land until https://codereview.chromium.org/909353004/ (Prepare SkiaBenchmarkingExtensionTest for upcoming Skia changes) lands in Chromium > > Committed: https://skia.googlesource.com/skia/+/5a4c233a3657d12d836de388b41e30405b4ab976 > > Committed: https://skia.googlesource.com/skia/+/fa3a83d0fe53907e618346d3f1c17a95da1a9d22 TBR=reed@google.com,fmalita@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/923753002
Diffstat (limited to 'tools')
-rw-r--r--tools/filtermain.cpp125
1 files changed, 82 insertions, 43 deletions
diff --git a/tools/filtermain.cpp b/tools/filtermain.cpp
index 6883ff2047..3b9d05682c 100644
--- a/tools/filtermain.cpp
+++ b/tools/filtermain.cpp
@@ -49,10 +49,10 @@ static bool is_simple(const SkPaint& p) {
// 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 @@ static void apply_0(SkDebugCanvas* canvas, int curCommand) {
// 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 @@ static void apply_1(SkDebugCanvas* canvas, int curCommand) {
// 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 @@ static void apply_2(SkDebugCanvas* canvas, int curCommand) {
// 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 @@ static void apply_3(SkDebugCanvas* canvas, int curCommand) {
// 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;
}
@@ -299,6 +299,43 @@ static void apply_4(SkDebugCanvas* canvas, int curCommand) {
}
// 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:
// SAVE
// CLIP_RECT
// SAVE_LAYER
@@ -320,21 +357,21 @@ static void apply_4(SkDebugCanvas* canvas, int curCommand) {
// 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 @@ static void apply_7(SkDebugCanvas* canvas, int curCommand) {
// 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 @@ static void apply_8(SkDebugCanvas* canvas, int curCommand) {
// 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 @@ 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 },
{ check_7, apply_7, 0 },
{ check_8, apply_8, 0 },
{ check_9, apply_9, 0 },