aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-02-11 13:07:12 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-11 13:07:13 -0800
commit2e6024248f81329779a6915c0312f99151d998fd (patch)
treeb899fe04dae4dfe93fe3fc6578d5f45b185051e9 /tools
parent94dff15404a6c82873f3f5092023426937274cc1 (diff)
Revert of Remove SkPictureFlat.h include from SkDrawCommands.h (patchset #2 id:20001 of https://codereview.chromium.org/912403004/)
Reason for revert: Chrome Original issue's description: > Remove SkPictureFlat.h include from SkDrawCommands.h > > Committed: https://skia.googlesource.com/skia/+/5a4c233a3657d12d836de388b41e30405b4ab976 TBR=reed@google.com,fmalita@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/917933002
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 ec4d6aa1d6..9e15445c84 100644
--- a/tools/filtermain.cpp
+++ b/tools/filtermain.cpp
@@ -48,10 +48,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;
}
@@ -120,13 +120,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;
}
@@ -186,11 +186,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;
}
@@ -221,11 +221,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;
}
@@ -269,11 +269,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;
}
@@ -298,6 +298,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
@@ -319,21 +356,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;
}
@@ -495,11 +532,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;
}
@@ -569,11 +606,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;
}
@@ -614,6 +651,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 },