| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkDebugCanvas.h" | 8 #include "SkDebugCanvas.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 NULL == p.getImageFilter(); | 42 NULL == p.getImageFilter(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 // Check for: | 46 // Check for: |
| 47 // SAVE_LAYER | 47 // SAVE_LAYER |
| 48 // DRAW_BITMAP_RECT_TO_RECT | 48 // DRAW_BITMAP_RECT_TO_RECT |
| 49 // RESTORE | 49 // RESTORE |
| 50 // where the saveLayer's color can be moved into the drawBitmapRect | 50 // where the saveLayer's color can be moved into the drawBitmapRect |
| 51 static bool check_0(SkDebugCanvas* canvas, int curCommand) { | 51 static bool check_0(SkDebugCanvas* canvas, int curCommand) { |
| 52 if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)
->getType() || | 52 if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() || |
| 53 canvas->getSize() <= curCommand+2 || | 53 canvas->getSize() <= curCommand+2 || |
| 54 SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCom
mand+1)->getType() || | 54 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+1)->getT
ype() || |
| 55 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+2)
->getType()) { | 55 RESTORE != canvas->getDrawCommandAt(curCommand+2)->getType()) { |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 SkSaveLayerCommand* saveLayer = | 59 SkSaveLayerCommand* saveLayer = |
| 60 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand); | 60 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand); |
| 61 SkDrawBitmapRectCommand* dbmr = | 61 SkDrawBitmapRectCommand* dbmr = |
| 62 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+1); | 62 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+1); |
| 63 | 63 |
| 64 const SkPaint* saveLayerPaint = saveLayer->paint(); | 64 const SkPaint* saveLayerPaint = saveLayer->paint(); |
| 65 SkPaint* dbmrPaint = dbmr->paint(); | 65 SkPaint* dbmrPaint = dbmr->paint(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 // Check for: | 115 // Check for: |
| 116 // SAVE_LAYER | 116 // SAVE_LAYER |
| 117 // SAVE | 117 // SAVE |
| 118 // CLIP_RECT | 118 // CLIP_RECT |
| 119 // DRAW_BITMAP_RECT_TO_RECT | 119 // DRAW_BITMAP_RECT_TO_RECT |
| 120 // RESTORE | 120 // RESTORE |
| 121 // RESTORE | 121 // RESTORE |
| 122 // where the saveLayer's color can be moved into the drawBitmapRect | 122 // where the saveLayer's color can be moved into the drawBitmapRect |
| 123 static bool check_1(SkDebugCanvas* canvas, int curCommand) { | 123 static bool check_1(SkDebugCanvas* canvas, int curCommand) { |
| 124 if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)
->getType() || | 124 if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() || |
| 125 canvas->getSize() <= curCommand+5 || | 125 canvas->getSize() <= curCommand+5 || |
| 126 SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+1)->g
etType() || | 126 SAVE != canvas->getDrawCommandAt(curCommand+1)->getType() || |
| 127 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+2
)->getType() || | 127 CLIP_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
| 128 SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCom
mand+3)->getType() || | 128 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+3)->getT
ype() || |
| 129 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+4)
->getType() || | 129 RESTORE != canvas->getDrawCommandAt(curCommand+4)->getType() || |
| 130 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+5)
->getType()) { | 130 RESTORE != canvas->getDrawCommandAt(curCommand+5)->getType()) { |
| 131 return false; | 131 return false; |
| 132 } | 132 } |
| 133 | 133 |
| 134 SkSaveLayerCommand* saveLayer = | 134 SkSaveLayerCommand* saveLayer = |
| 135 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand); | 135 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand); |
| 136 SkDrawBitmapRectCommand* dbmr = | 136 SkDrawBitmapRectCommand* dbmr = |
| 137 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+3); | 137 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+3); |
| 138 | 138 |
| 139 const SkPaint* saveLayerPaint = saveLayer->paint(); | 139 const SkPaint* saveLayerPaint = saveLayer->paint(); |
| 140 SkPaint* dbmrPaint = dbmr->paint(); | 140 SkPaint* dbmrPaint = dbmr->paint(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 canvas->deleteDrawCommandAt(curCommand); // saveLayer | 180 canvas->deleteDrawCommandAt(curCommand); // saveLayer |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Check for: | 183 // Check for: |
| 184 // SAVE | 184 // SAVE |
| 185 // CLIP_RECT | 185 // CLIP_RECT |
| 186 // DRAW_RECT | 186 // DRAW_RECT |
| 187 // RESTORE | 187 // RESTORE |
| 188 // where the rect is entirely within the clip and the clip is an intersect | 188 // where the rect is entirely within the clip and the clip is an intersect |
| 189 static bool check_2(SkDebugCanvas* canvas, int curCommand) { | 189 static bool check_2(SkDebugCanvas* canvas, int curCommand) { |
| 190 if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->get
Type() || | 190 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
| 191 canvas->getSize() <= curCommand+4 || | 191 canvas->getSize() <= curCommand+4 || |
| 192 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1
)->getType() || | 192 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
| 193 SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2
)->getType() || | 193 DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
| 194 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)
->getType()) { | 194 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
| 195 return false; | 195 return false; |
| 196 } | 196 } |
| 197 | 197 |
| 198 SkClipRectCommand* cr = | 198 SkClipRectCommand* cr = |
| 199 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); | 199 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); |
| 200 SkDrawRectCommand* dr = | 200 SkDrawRectCommand* dr = |
| 201 (SkDrawRectCommand*) canvas->getDrawCommandAt(curCommand+2); | 201 (SkDrawRectCommand*) canvas->getDrawCommandAt(curCommand+2); |
| 202 | 202 |
| 203 if (SkRegion::kIntersect_Op != cr->op()) { | 203 if (SkRegion::kIntersect_Op != cr->op()) { |
| 204 return false; | 204 return false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 215 canvas->deleteDrawCommandAt(curCommand); // save | 215 canvas->deleteDrawCommandAt(curCommand); // save |
| 216 } | 216 } |
| 217 | 217 |
| 218 // Check for: | 218 // Check for: |
| 219 // SAVE | 219 // SAVE |
| 220 // CLIP_RRECT | 220 // CLIP_RRECT |
| 221 // DRAW_RECT | 221 // DRAW_RECT |
| 222 // RESTORE | 222 // RESTORE |
| 223 // where the rect entirely encloses the clip | 223 // where the rect entirely encloses the clip |
| 224 static bool check_3(SkDebugCanvas* canvas, int curCommand) { | 224 static bool check_3(SkDebugCanvas* canvas, int curCommand) { |
| 225 if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->get
Type() || | 225 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
| 226 canvas->getSize() <= curCommand+4 || | 226 canvas->getSize() <= curCommand+4 || |
| 227 SkDrawCommand::kClipRRect_OpType != canvas->getDrawCommandAt(curCommand+
1)->getType() || | 227 CLIP_RRECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
| 228 SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2
)->getType() || | 228 DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() || |
| 229 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)
->getType()) { | 229 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
| 230 return false; | 230 return false; |
| 231 } | 231 } |
| 232 | 232 |
| 233 SkClipRRectCommand* crr = | 233 SkClipRRectCommand* crr = |
| 234 (SkClipRRectCommand*) canvas->getDrawCommandAt(curCommand+1); | 234 (SkClipRRectCommand*) canvas->getDrawCommandAt(curCommand+1); |
| 235 SkDrawRectCommand* dr = | 235 SkDrawRectCommand* dr = |
| 236 (SkDrawRectCommand*) canvas->getDrawCommandAt(curCommand+2); | 236 (SkDrawRectCommand*) canvas->getDrawCommandAt(curCommand+2); |
| 237 | 237 |
| 238 if (SkRegion::kIntersect_Op != crr->op()) { | 238 if (SkRegion::kIntersect_Op != crr->op()) { |
| 239 return false; | 239 return false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 263 canvas->deleteDrawCommandAt(curCommand); // save | 263 canvas->deleteDrawCommandAt(curCommand); // save |
| 264 } | 264 } |
| 265 | 265 |
| 266 // Check for: | 266 // Check for: |
| 267 // SAVE | 267 // SAVE |
| 268 // CLIP_RECT | 268 // CLIP_RECT |
| 269 // DRAW_BITMAP_RECT_TO_RECT | 269 // DRAW_BITMAP_RECT_TO_RECT |
| 270 // RESTORE | 270 // RESTORE |
| 271 // where the rect and drawBitmapRect dst exactly match | 271 // where the rect and drawBitmapRect dst exactly match |
| 272 static bool check_4(SkDebugCanvas* canvas, int curCommand) { | 272 static bool check_4(SkDebugCanvas* canvas, int curCommand) { |
| 273 if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->get
Type() || | 273 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
| 274 canvas->getSize() <= curCommand+4 || | 274 canvas->getSize() <= curCommand+4 || |
| 275 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1
)->getType() || | 275 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
| 276 SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCom
mand+2)->getType() || | 276 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT
ype() || |
| 277 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)
->getType()) { | 277 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
| 278 return false; | 278 return false; |
| 279 } | 279 } |
| 280 | 280 |
| 281 SkClipRectCommand* cr = | 281 SkClipRectCommand* cr = |
| 282 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); | 282 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); |
| 283 SkDrawBitmapRectCommand* dbmr = | 283 SkDrawBitmapRectCommand* dbmr = |
| 284 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2); | 284 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2); |
| 285 | 285 |
| 286 if (SkRegion::kIntersect_Op != cr->op()) { | 286 if (SkRegion::kIntersect_Op != cr->op()) { |
| 287 return false; | 287 return false; |
| 288 } | 288 } |
| 289 | 289 |
| 290 return dbmr->dstRect() == cr->rect(); | 290 return dbmr->dstRect() == cr->rect(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 // Remove everything but the drawBitmapRect | 293 // Remove everything but the drawBitmapRect |
| 294 static void apply_4(SkDebugCanvas* canvas, int curCommand) { | 294 static void apply_4(SkDebugCanvas* canvas, int curCommand) { |
| 295 canvas->deleteDrawCommandAt(curCommand+3); // restore | 295 canvas->deleteDrawCommandAt(curCommand+3); // restore |
| 296 // drawBitmapRectToRect | 296 // drawBitmapRectToRect |
| 297 canvas->deleteDrawCommandAt(curCommand+1); // clipRect | 297 canvas->deleteDrawCommandAt(curCommand+1); // clipRect |
| 298 canvas->deleteDrawCommandAt(curCommand); // save | 298 canvas->deleteDrawCommandAt(curCommand); // save |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Check for: | 301 // Check for: |
| 302 // TRANSLATE |
| 303 // where the translate is zero |
| 304 static bool check_5(SkDebugCanvas* canvas, int curCommand) { |
| 305 if (TRANSLATE != canvas->getDrawCommandAt(curCommand)->getType()) { |
| 306 return false; |
| 307 } |
| 308 |
| 309 SkTranslateCommand* t = |
| 310 (SkTranslateCommand*) canvas->getDrawCommandAt(curCommand); |
| 311 |
| 312 return 0 == t->x() && 0 == t->y(); |
| 313 } |
| 314 |
| 315 // Just remove the translate |
| 316 static void apply_5(SkDebugCanvas* canvas, int curCommand) { |
| 317 canvas->deleteDrawCommandAt(curCommand); // translate |
| 318 } |
| 319 |
| 320 // Check for: |
| 321 // SCALE |
| 322 // where the scale is 1,1 |
| 323 static bool check_6(SkDebugCanvas* canvas, int curCommand) { |
| 324 if (SCALE != canvas->getDrawCommandAt(curCommand)->getType()) { |
| 325 return false; |
| 326 } |
| 327 |
| 328 SkScaleCommand* s = (SkScaleCommand*) canvas->getDrawCommandAt(curCommand); |
| 329 |
| 330 return SK_Scalar1 == s->x() && SK_Scalar1 == s->y(); |
| 331 } |
| 332 |
| 333 // Just remove the scale |
| 334 static void apply_6(SkDebugCanvas* canvas, int curCommand) { |
| 335 canvas->deleteDrawCommandAt(curCommand); // scale |
| 336 } |
| 337 |
| 338 // Check for: |
| 302 // SAVE | 339 // SAVE |
| 303 // CLIP_RECT | 340 // CLIP_RECT |
| 304 // SAVE_LAYER | 341 // SAVE_LAYER |
| 305 // SAVE | 342 // SAVE |
| 306 // CLIP_RECT | 343 // CLIP_RECT |
| 307 // SAVE_LAYER | 344 // SAVE_LAYER |
| 308 // SAVE | 345 // SAVE |
| 309 // CLIP_RECT | 346 // CLIP_RECT |
| 310 // DRAWBITMAPRECTTORECT | 347 // DRAWBITMAPRECTTORECT |
| 311 // RESTORE | 348 // RESTORE |
| 312 // RESTORE | 349 // RESTORE |
| 313 // RESTORE | 350 // RESTORE |
| 314 // RESTORE | 351 // RESTORE |
| 315 // RESTORE | 352 // RESTORE |
| 316 // where: | 353 // where: |
| 317 // all the clipRect's are BW, nested, intersections | 354 // all the clipRect's are BW, nested, intersections |
| 318 // the drawBitmapRectToRect is a 1-1 copy from src to dest | 355 // the drawBitmapRectToRect is a 1-1 copy from src to dest |
| 319 // the last (smallest) clip rect is a subset of the drawBitmapRectToRect's
dest rect | 356 // the last (smallest) clip rect is a subset of the drawBitmapRectToRect's
dest rect |
| 320 // all the saveLayer's paints can be rolled into the drawBitmapRectToRect's
paint | 357 // all the saveLayer's paints can be rolled into the drawBitmapRectToRect's
paint |
| 321 // This pattern is used by Google spreadsheet when drawing the toolbar buttons | 358 // This pattern is used by Google spreadsheet when drawing the toolbar buttons |
| 322 static bool check_7(SkDebugCanvas* canvas, int curCommand) { | 359 static bool check_7(SkDebugCanvas* canvas, int curCommand) { |
| 323 if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->get
Type() || | 360 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
| 324 canvas->getSize() <= curCommand+13 || | 361 canvas->getSize() <= curCommand+13 || |
| 325 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1
)->getType() || | 362 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
| 326 SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+
2)->getType() || | 363 SAVE_LAYER != canvas->getDrawCommandAt(curCommand+2)->getType() || |
| 327 SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+3)->g
etType() || | 364 SAVE != canvas->getDrawCommandAt(curCommand+3)->getType() || |
| 328 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+4
)->getType() || | 365 CLIP_RECT != canvas->getDrawCommandAt(curCommand+4)->getType() || |
| 329 SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+
5)->getType() || | 366 SAVE_LAYER != canvas->getDrawCommandAt(curCommand+5)->getType() || |
| 330 SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+6)->g
etType() || | 367 SAVE != canvas->getDrawCommandAt(curCommand+6)->getType() || |
| 331 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+7
)->getType() || | 368 CLIP_RECT != canvas->getDrawCommandAt(curCommand+7)->getType() || |
| 332 SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCom
mand+8)->getType() || | 369 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+8)->getT
ype() || |
| 333 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+9)
->getType() || | 370 RESTORE != canvas->getDrawCommandAt(curCommand+9)->getType() || |
| 334 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+10
)->getType() || | 371 RESTORE != canvas->getDrawCommandAt(curCommand+10)->getType() || |
| 335 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+11
)->getType() || | 372 RESTORE != canvas->getDrawCommandAt(curCommand+11)->getType() || |
| 336 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+12
)->getType() || | 373 RESTORE != canvas->getDrawCommandAt(curCommand+12)->getType() || |
| 337 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+13
)->getType()) { | 374 RESTORE != canvas->getDrawCommandAt(curCommand+13)->getType()) { |
| 338 return false; | 375 return false; |
| 339 } | 376 } |
| 340 | 377 |
| 341 SkClipRectCommand* clip0 = | 378 SkClipRectCommand* clip0 = |
| 342 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); | 379 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); |
| 343 SkSaveLayerCommand* saveLayer0 = | 380 SkSaveLayerCommand* saveLayer0 = |
| 344 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+2); | 381 (SkSaveLayerCommand*) canvas->getDrawCommandAt(curCommand+2); |
| 345 SkClipRectCommand* clip1 = | 382 SkClipRectCommand* clip1 = |
| 346 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+4); | 383 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+4); |
| 347 SkSaveLayerCommand* saveLayer1 = | 384 SkSaveLayerCommand* saveLayer1 = |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 526 |
| 490 // Check for: | 527 // Check for: |
| 491 // SAVE | 528 // SAVE |
| 492 // CLIP_RECT | 529 // CLIP_RECT |
| 493 // DRAWBITMAPRECTTORECT | 530 // DRAWBITMAPRECTTORECT |
| 494 // RESTORE | 531 // RESTORE |
| 495 // where: | 532 // where: |
| 496 // the drawBitmapRectToRect is a 1-1 copy from src to dest | 533 // the drawBitmapRectToRect is a 1-1 copy from src to dest |
| 497 // the clip rect is BW and a subset of the drawBitmapRectToRect's dest rect | 534 // the clip rect is BW and a subset of the drawBitmapRectToRect's dest rect |
| 498 static bool check_8(SkDebugCanvas* canvas, int curCommand) { | 535 static bool check_8(SkDebugCanvas* canvas, int curCommand) { |
| 499 if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->get
Type() || | 536 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
| 500 canvas->getSize() <= curCommand+4 || | 537 canvas->getSize() <= curCommand+4 || |
| 501 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1
)->getType() || | 538 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
| 502 SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCom
mand+2)->getType() || | 539 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT
ype() || |
| 503 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)
->getType()) { | 540 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
| 504 return false; | 541 return false; |
| 505 } | 542 } |
| 506 | 543 |
| 507 SkClipRectCommand* clip = | 544 SkClipRectCommand* clip = |
| 508 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); | 545 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); |
| 509 SkDrawBitmapRectCommand* dbmr = | 546 SkDrawBitmapRectCommand* dbmr = |
| 510 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2); | 547 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2); |
| 511 | 548 |
| 512 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) { | 549 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) { |
| 513 return false; | 550 return false; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 600 } |
| 564 | 601 |
| 565 // Check for: | 602 // Check for: |
| 566 // SAVE | 603 // SAVE |
| 567 // CLIP_RECT | 604 // CLIP_RECT |
| 568 // DRAWBITMAPRECTTORECT | 605 // DRAWBITMAPRECTTORECT |
| 569 // RESTORE | 606 // RESTORE |
| 570 // where: | 607 // where: |
| 571 // clipRect is BW and encloses the DBMR2R's dest rect | 608 // clipRect is BW and encloses the DBMR2R's dest rect |
| 572 static bool check_9(SkDebugCanvas* canvas, int curCommand) { | 609 static bool check_9(SkDebugCanvas* canvas, int curCommand) { |
| 573 if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->get
Type() || | 610 if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() || |
| 574 canvas->getSize() <= curCommand+4 || | 611 canvas->getSize() <= curCommand+4 || |
| 575 SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1
)->getType() || | 612 CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() || |
| 576 SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCom
mand+2)->getType() || | 613 DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getT
ype() || |
| 577 SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)
->getType()) { | 614 RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) { |
| 578 return false; | 615 return false; |
| 579 } | 616 } |
| 580 | 617 |
| 581 SkClipRectCommand* clip = | 618 SkClipRectCommand* clip = |
| 582 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); | 619 (SkClipRectCommand*) canvas->getDrawCommandAt(curCommand+1); |
| 583 SkDrawBitmapRectCommand* dbmr = | 620 SkDrawBitmapRectCommand* dbmr = |
| 584 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2); | 621 (SkDrawBitmapRectCommand*) canvas->getDrawCommandAt(curCommand+2); |
| 585 | 622 |
| 586 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) { | 623 if (clip->doAA() || SkRegion::kIntersect_Op != clip->op()) { |
| 587 return false; | 624 return false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 608 struct OptTableEntry { | 645 struct OptTableEntry { |
| 609 PFCheck fCheck; | 646 PFCheck fCheck; |
| 610 PFApply fApply; | 647 PFApply fApply; |
| 611 int fNumTimesApplied; | 648 int fNumTimesApplied; |
| 612 } gOptTable[] = { | 649 } gOptTable[] = { |
| 613 { check_0, apply_0, 0 }, | 650 { check_0, apply_0, 0 }, |
| 614 { check_1, apply_1, 0 }, | 651 { check_1, apply_1, 0 }, |
| 615 { check_2, apply_2, 0 }, | 652 { check_2, apply_2, 0 }, |
| 616 { check_3, apply_3, 0 }, | 653 { check_3, apply_3, 0 }, |
| 617 { check_4, apply_4, 0 }, | 654 { check_4, apply_4, 0 }, |
| 655 { check_5, apply_5, 0 }, |
| 656 { check_6, apply_6, 0 }, |
| 618 { check_7, apply_7, 0 }, | 657 { check_7, apply_7, 0 }, |
| 619 { check_8, apply_8, 0 }, | 658 { check_8, apply_8, 0 }, |
| 620 { check_9, apply_9, 0 }, | 659 { check_9, apply_9, 0 }, |
| 621 }; | 660 }; |
| 622 | 661 |
| 623 | 662 |
| 624 static int filter_picture(const SkString& inFile, const SkString& outFile) { | 663 static int filter_picture(const SkString& inFile, const SkString& outFile) { |
| 625 SkAutoTUnref<SkPicture> inPicture; | 664 SkAutoTUnref<SkPicture> inPicture; |
| 626 | 665 |
| 627 SkFILEStream inStream(inFile.c_str()); | 666 SkFILEStream inStream(inFile.c_str()); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 839 |
| 801 SkGraphics::Term(); | 840 SkGraphics::Term(); |
| 802 return 0; | 841 return 0; |
| 803 } | 842 } |
| 804 | 843 |
| 805 #if !defined SK_BUILD_FOR_IOS | 844 #if !defined SK_BUILD_FOR_IOS |
| 806 int main(int argc, char * const argv[]) { | 845 int main(int argc, char * const argv[]) { |
| 807 return tool_main(argc, (char**) argv); | 846 return tool_main(argc, (char**) argv); |
| 808 } | 847 } |
| 809 #endif | 848 #endif |
| OLD | NEW |