Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: src/utils/debugger/SkDrawCommand.cpp

Issue 1048383002: [SkDebugger] Flatten drawPicture ops (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/utils/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkDrawCommand.h" 10 #include "SkDrawCommand.h"
11 #include "SkObjectParser.h" 11 #include "SkObjectParser.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkTextBlob.h" 13 #include "SkTextBlob.h"
14 14
15 // TODO(chudy): Refactor into non subclass model. 15 // TODO(chudy): Refactor into non subclass model.
16 16
17 SkDrawCommand::SkDrawCommand(OpType type) 17 SkDrawCommand::SkDrawCommand(OpType type)
18 : fOpType(type) 18 : fOpType(type)
19 , fVisible(true) { 19 , fVisible(true) {
20 } 20 }
21 21
22 SkDrawCommand::~SkDrawCommand() { 22 SkDrawCommand::~SkDrawCommand() {
23 fInfo.deleteAll(); 23 fInfo.deleteAll();
24 } 24 }
25 25
26 const char* SkDrawCommand::GetCommandString(OpType type) { 26 const char* SkDrawCommand::GetCommandString(OpType type) {
27 switch (type) { 27 switch (type) {
28 case kBeginCommentGroup_OpType: return "BeginCommentGroup"; 28 case kBeginCommentGroup_OpType: return "BeginCommentGroup";
29 case kBeginDrawPicture_OpType: return "BeginDrawPicture";
29 case kClipPath_OpType: return "ClipPath"; 30 case kClipPath_OpType: return "ClipPath";
30 case kClipRegion_OpType: return "ClipRegion"; 31 case kClipRegion_OpType: return "ClipRegion";
31 case kClipRect_OpType: return "ClipRect"; 32 case kClipRect_OpType: return "ClipRect";
32 case kClipRRect_OpType: return "ClipRRect"; 33 case kClipRRect_OpType: return "ClipRRect";
33 case kComment_OpType: return "Comment"; 34 case kComment_OpType: return "Comment";
34 case kConcat_OpType: return "Concat"; 35 case kConcat_OpType: return "Concat";
35 case kDrawBitmap_OpType: return "DrawBitmap"; 36 case kDrawBitmap_OpType: return "DrawBitmap";
36 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; 37 case kDrawBitmapNine_OpType: return "DrawBitmapNine";
37 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; 38 case kDrawBitmapRect_OpType: return "DrawBitmapRect";
38 case kDrawClear_OpType: return "DrawClear"; 39 case kDrawClear_OpType: return "DrawClear";
39 case kDrawDRRect_OpType: return "DrawDRRect"; 40 case kDrawDRRect_OpType: return "DrawDRRect";
40 case kDrawOval_OpType: return "DrawOval"; 41 case kDrawOval_OpType: return "DrawOval";
41 case kDrawPaint_OpType: return "DrawPaint"; 42 case kDrawPaint_OpType: return "DrawPaint";
42 case kDrawPatch_OpType: return "DrawPatch"; 43 case kDrawPatch_OpType: return "DrawPatch";
43 case kDrawPath_OpType: return "DrawPath"; 44 case kDrawPath_OpType: return "DrawPath";
44 case kDrawPicture_OpType: return "DrawPicture";
45 case kDrawPoints_OpType: return "DrawPoints"; 45 case kDrawPoints_OpType: return "DrawPoints";
46 case kDrawPosText_OpType: return "DrawPosText"; 46 case kDrawPosText_OpType: return "DrawPosText";
47 case kDrawPosTextH_OpType: return "DrawPosTextH"; 47 case kDrawPosTextH_OpType: return "DrawPosTextH";
48 case kDrawRect_OpType: return "DrawRect"; 48 case kDrawRect_OpType: return "DrawRect";
49 case kDrawRRect_OpType: return "DrawRRect"; 49 case kDrawRRect_OpType: return "DrawRRect";
50 case kDrawSprite_OpType: return "DrawSprite"; 50 case kDrawSprite_OpType: return "DrawSprite";
51 case kDrawText_OpType: return "DrawText"; 51 case kDrawText_OpType: return "DrawText";
52 case kDrawTextBlob_OpType: return "DrawTextBlob"; 52 case kDrawTextBlob_OpType: return "DrawTextBlob";
53 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; 53 case kDrawTextOnPath_OpType: return "DrawTextOnPath";
54 case kDrawVertices_OpType: return "DrawVertices"; 54 case kDrawVertices_OpType: return "DrawVertices";
55 case kEndCommentGroup_OpType: return "EndCommentGroup"; 55 case kEndCommentGroup_OpType: return "EndCommentGroup";
56 case kEndDrawPicture_OpType: return "EndDrawPicture";
56 case kRestore_OpType: return "Restore"; 57 case kRestore_OpType: return "Restore";
57 case kSave_OpType: return "Save"; 58 case kSave_OpType: return "Save";
58 case kSaveLayer_OpType: return "SaveLayer"; 59 case kSaveLayer_OpType: return "SaveLayer";
59 case kSetMatrix_OpType: return "SetMatrix"; 60 case kSetMatrix_OpType: return "SetMatrix";
60 default: 61 default:
61 SkDebugf("OpType error 0x%08x\n", type); 62 SkDebugf("OpType error 0x%08x\n", type);
62 SkASSERT(0); 63 SkASSERT(0);
63 break; 64 break;
64 } 65 }
65 SkDEBUGFAIL("DrawType UNUSED\n"); 66 SkDEBUGFAIL("DrawType UNUSED\n");
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 439
439 void SkDrawPathCommand::execute(SkCanvas* canvas) const { 440 void SkDrawPathCommand::execute(SkCanvas* canvas) const {
440 canvas->drawPath(fPath, fPaint); 441 canvas->drawPath(fPath, fPaint);
441 } 442 }
442 443
443 bool SkDrawPathCommand::render(SkCanvas* canvas) const { 444 bool SkDrawPathCommand::render(SkCanvas* canvas) const {
444 render_path(canvas, fPath); 445 render_path(canvas, fPath);
445 return true; 446 return true;
446 } 447 }
447 448
448 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, 449 SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture,
449 const SkMatrix* matrix, 450 const SkMatrix* matrix,
450 const SkPaint* paint) 451 const SkPaint* paint)
451 : INHERITED(kDrawPicture_OpType) 452 : INHERITED(kBeginDrawPicture_OpType)
452 , fPicture(SkRef(picture)) 453 , fPicture(SkRef(picture)) {
453 , fMatrixPtr(NULL) 454
454 , fPaintPtr(NULL) { 455 SkString* str = new SkString;
456 str->appendf("SkPicture: L: %f T: %f R: %f B: %f",
457 picture->cullRect().fLeft, picture->cullRect().fTop,
458 picture->cullRect().fRight, picture->cullRect().fBottom);
459 fInfo.push(str);
455 460
456 if (matrix) { 461 if (matrix) {
457 fMatrix = *matrix; 462 fMatrix.set(*matrix);
458 fMatrixPtr = &fMatrix; 463 fInfo.push(SkObjectParser::MatrixToString(*matrix));
459 }
460 if (paint) {
461 fPaint = *paint;
462 fPaintPtr = &fPaint;
463 } 464 }
464 465
465 SkString* temp = new SkString; 466 if (paint) {
466 temp->appendf("SkPicture: L: %f T: %f R: %f B: %f", 467 fPaint.set(*paint);
467 picture->cullRect().fLeft, picture->cullRect().fTop, 468 fInfo.push(SkObjectParser::PaintToString(*paint));
468 picture->cullRect().fRight, picture->cullRect().fBottom);
469 fInfo.push(temp);
470 if (matrix) {
471 fInfo.push(SkObjectParser::MatrixToString(*matrix));
472 } 469 }
473 if (paint) { 470
474 fInfo.push(SkObjectParser::PaintToString(*paint)); 471 }
472
473 void SkBeginDrawPictureCommand::execute(SkCanvas* canvas) const {
474 if (fPaint.isValid()) {
475 SkRect bounds = fPicture->cullRect();
476 if (fMatrix.isValid()) {
477 fMatrix.get()->mapRect(&bounds);
478 }
479 canvas->saveLayer(&bounds, fPaint.get());
480 }
481
482 if (fMatrix.isValid()) {
483 if (!fPaint.isValid()) {
484 canvas->save();
485 }
486 canvas->concat(*fMatrix.get());
475 } 487 }
476 } 488 }
477 489
478 void SkDrawPictureCommand::execute(SkCanvas* canvas) const { 490 bool SkBeginDrawPictureCommand::render(SkCanvas* canvas) const {
479 canvas->drawPicture(fPicture, fMatrixPtr, fPaintPtr);
480 }
481
482 bool SkDrawPictureCommand::render(SkCanvas* canvas) const {
483 canvas->clear(0xFFFFFFFF); 491 canvas->clear(0xFFFFFFFF);
484 canvas->save(); 492 canvas->save();
485 493
486 xlate_and_scale_to_bounds(canvas, fPicture->cullRect()); 494 xlate_and_scale_to_bounds(canvas, fPicture->cullRect());
487 495
488 canvas->drawPicture(fPicture.get()); 496 canvas->drawPicture(fPicture.get());
489 497
490 canvas->restore(); 498 canvas->restore();
491 499
492 return true; 500 return true;
493 } 501 }
494 502
503 SkEndDrawPictureCommand::SkEndDrawPictureCommand(bool restore)
504 : INHERITED(kEndDrawPicture_OpType) , fRestore(restore) { }
505
506 void SkEndDrawPictureCommand::execute(SkCanvas* canvas) const {
507 if (fRestore) {
508 canvas->restore();
509 }
510 }
511
495 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, 512 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
496 const SkPoint pts[], const SkPaint& pai nt) 513 const SkPoint pts[], const SkPaint& pai nt)
497 : INHERITED(kDrawPoints_OpType) { 514 : INHERITED(kDrawPoints_OpType) {
498 fMode = mode; 515 fMode = mode;
499 fCount = count; 516 fCount = count;
500 fPts = new SkPoint[count]; 517 fPts = new SkPoint[count];
501 memcpy(fPts, pts, count * sizeof(SkPoint)); 518 memcpy(fPts, pts, count * sizeof(SkPoint));
502 fPaint = paint; 519 fPaint = paint;
503 520
504 fInfo.push(SkObjectParser::PointsToString(pts, count)); 521 fInfo.push(SkObjectParser::PointsToString(pts, count));
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 911
895 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { 912 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) {
896 fUserMatrix = userMatrix; 913 fUserMatrix = userMatrix;
897 } 914 }
898 915
899 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { 916 void SkSetMatrixCommand::execute(SkCanvas* canvas) const {
900 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); 917 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix);
901 canvas->setMatrix(temp); 918 canvas->setMatrix(temp);
902 } 919 }
903 920
OLDNEW
« no previous file with comments | « src/utils/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698