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

Side by Side Diff: debugger/SkDrawCommand.cpp

Issue 12634024: More SkDrawCommand cleanup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « 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"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 SkDEBUGFAIL("DrawType UNUSED\n"); 64 SkDEBUGFAIL("DrawType UNUSED\n");
65 return NULL; 65 return NULL;
66 } 66 }
67 67
68 SkString SkDrawCommand::toString() { 68 SkString SkDrawCommand::toString() {
69 return SkString(GetCommandString(fDrawType)); 69 return SkString(GetCommandString(fDrawType));
70 } 70 }
71 71
72 Clear::Clear(SkColor color) { 72 Clear::Clear(SkColor color) {
73 this->fColor = color; 73 fColor = color;
74 this->fDrawType = DRAW_CLEAR; 74 fDrawType = DRAW_CLEAR;
75 this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); 75 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
76 } 76 }
77 77
78 void Clear::execute(SkCanvas* canvas) { 78 void Clear::execute(SkCanvas* canvas) {
79 canvas->clear(this->fColor); 79 canvas->clear(fColor);
80 } 80 }
81 81
82 ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bit map) { 82 ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bit map) {
83 fPath = path; 83 fPath = path;
84 fOp = op; 84 fOp = op;
85 fDoAA = doAA; 85 fDoAA = doAA;
86 fDrawType = CLIP_PATH; 86 fDrawType = CLIP_PATH;
87 fBitmap = bitmap; 87 fBitmap = bitmap;
88 88
89 fInfo.push(SkObjectParser::PathToString(path)); 89 fInfo.push(SkObjectParser::PathToString(path));
90 fInfo.push(SkObjectParser::RegionOpToString(op)); 90 fInfo.push(SkObjectParser::RegionOpToString(op));
91 fInfo.push(SkObjectParser::BoolToString(doAA)); 91 fInfo.push(SkObjectParser::BoolToString(doAA));
92 } 92 }
93 93
94 void ClipPath::execute(SkCanvas* canvas) { 94 void ClipPath::execute(SkCanvas* canvas) {
95 canvas->clipPath(fPath, fOp, fDoAA); 95 canvas->clipPath(fPath, fOp, fDoAA);
96 } 96 }
97 97
98 const SkBitmap* ClipPath::getBitmap() const { 98 const SkBitmap* ClipPath::getBitmap() const {
99 return &fBitmap; 99 return &fBitmap;
100 } 100 }
101 101
102 ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) { 102 ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) {
103 this->fRegion = &region; 103 fRegion = region;
104 this->fOp = op; 104 fOp = op;
105 this->fDrawType = CLIP_REGION; 105 fDrawType = CLIP_REGION;
106 106
107 this->fInfo.push(SkObjectParser::RegionToString(region)); 107 fInfo.push(SkObjectParser::RegionToString(region));
108 this->fInfo.push(SkObjectParser::RegionOpToString(op)); 108 fInfo.push(SkObjectParser::RegionOpToString(op));
109 } 109 }
110 110
111 void ClipRegion::execute(SkCanvas* canvas) { 111 void ClipRegion::execute(SkCanvas* canvas) {
112 canvas->clipRegion(*this->fRegion, this->fOp); 112 canvas->clipRegion(fRegion, fOp);
113 } 113 }
114 114
115 ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { 115 ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
116 fRect = rect; 116 fRect = rect;
117 fOp = op; 117 fOp = op;
118 fDoAA = doAA; 118 fDoAA = doAA;
119 fDrawType = CLIP_RECT; 119 fDrawType = CLIP_RECT;
120 120
121 fInfo.push(SkObjectParser::RectToString(rect)); 121 fInfo.push(SkObjectParser::RectToString(rect));
122 fInfo.push(SkObjectParser::RegionOpToString(op)); 122 fInfo.push(SkObjectParser::RegionOpToString(op));
(...skipping 13 matching lines...) Expand all
136 fInfo.push(SkObjectParser::RRectToString(rrect)); 136 fInfo.push(SkObjectParser::RRectToString(rrect));
137 fInfo.push(SkObjectParser::RegionOpToString(op)); 137 fInfo.push(SkObjectParser::RegionOpToString(op));
138 fInfo.push(SkObjectParser::BoolToString(doAA)); 138 fInfo.push(SkObjectParser::BoolToString(doAA));
139 } 139 }
140 140
141 void ClipRRect::execute(SkCanvas* canvas) { 141 void ClipRRect::execute(SkCanvas* canvas) {
142 canvas->clipRRect(fRRect, fOp, fDoAA); 142 canvas->clipRRect(fRRect, fOp, fDoAA);
143 } 143 }
144 144
145 Concat::Concat(const SkMatrix& matrix) { 145 Concat::Concat(const SkMatrix& matrix) {
146 this->fMatrix = &matrix; 146 fMatrix = matrix;
147 this->fDrawType = CONCAT; 147 fDrawType = CONCAT;
148 148
149 this->fInfo.push(SkObjectParser::MatrixToString(matrix)); 149 fInfo.push(SkObjectParser::MatrixToString(matrix));
150 } 150 }
151 151
152 void Concat::execute(SkCanvas* canvas) { 152 void Concat::execute(SkCanvas* canvas) {
153 canvas->concat(*this->fMatrix); 153 canvas->concat(fMatrix);
154 } 154 }
155 155
156 DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 156 DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
157 const SkPaint* paint, SkBitmap& resizedBitmap) { 157 const SkPaint* paint, SkBitmap& resizedBitmap) {
158 this->fBitmap = &bitmap; 158 fBitmap = bitmap;
159 this->fLeft = left; 159 fLeft = left;
160 this->fTop = top; 160 fTop = top;
161 this->fPaint = paint; 161 if (NULL != paint) {
162 this->fDrawType = DRAW_BITMAP; 162 fPaint = *paint;
163 this->fResizedBitmap = resizedBitmap; 163 fPaintPtr = &fPaint;
164 } else {
165 fPaintPtr = NULL;
166 }
167 fDrawType = DRAW_BITMAP;
168 fResizedBitmap = resizedBitmap;
164 169
165 this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); 170 fInfo.push(SkObjectParser::BitmapToString(bitmap));
166 this->fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); 171 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
167 this->fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); 172 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
168 if (NULL != paint) { 173 if (NULL != paint) {
169 this->fInfo.push(SkObjectParser::PaintToString(*paint)); 174 fInfo.push(SkObjectParser::PaintToString(*paint));
170 } 175 }
171 } 176 }
172 177
173 void DrawBitmap::execute(SkCanvas* canvas) { 178 void DrawBitmap::execute(SkCanvas* canvas) {
174 canvas->drawBitmap(*this->fBitmap, this->fLeft, this->fTop, this->fPaint); 179 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr);
175 } 180 }
176 181
177 const SkBitmap* DrawBitmap::getBitmap() const { 182 const SkBitmap* DrawBitmap::getBitmap() const {
178 return &fResizedBitmap; 183 return &fResizedBitmap;
179 } 184 }
180 185
181 DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap, 186 DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap,
182 const SkMatrix& matrix, const SkPaint* paint, SkBitmap& resizedBitmap) { 187 const SkMatrix& matrix,
183 this->fBitmap = &bitmap; 188 const SkPaint* paint,
184 this->fMatrix = &matrix; 189 SkBitmap& resizedBitmap) {
185 this->fPaint = paint; 190 fBitmap = bitmap;
186 this->fDrawType = DRAW_BITMAP_MATRIX; 191 fMatrix = matrix;
187 this->fResizedBitmap = resizedBitmap; 192 if (NULL != paint) {
193 fPaint = *paint;
194 fPaintPtr = &fPaint;
195 } else {
196 fPaintPtr = NULL;
197 }
198 fDrawType = DRAW_BITMAP_MATRIX;
199 fResizedBitmap = resizedBitmap;
188 200
189 this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); 201 fInfo.push(SkObjectParser::BitmapToString(bitmap));
190 this->fInfo.push(SkObjectParser::MatrixToString(matrix)); 202 fInfo.push(SkObjectParser::MatrixToString(matrix));
191 if (NULL != paint) { 203 if (NULL != paint) {
192 this->fInfo.push(SkObjectParser::PaintToString(*paint)); 204 fInfo.push(SkObjectParser::PaintToString(*paint));
193 } 205 }
194 } 206 }
195 207
196 void DrawBitmapMatrix::execute(SkCanvas* canvas) { 208 void DrawBitmapMatrix::execute(SkCanvas* canvas) {
197 canvas->drawBitmapMatrix(*this->fBitmap, *this->fMatrix, this->fPaint); 209 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr);
198 } 210 }
199 211
200 const SkBitmap* DrawBitmapMatrix::getBitmap() const { 212 const SkBitmap* DrawBitmapMatrix::getBitmap() const {
201 return &fResizedBitmap; 213 return &fResizedBitmap;
202 } 214 }
203 215
204 DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 216 DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
205 const SkRect& dst, const SkPaint* paint, SkBitmap& resizedBitmap) { 217 const SkRect& dst, const SkPaint* paint,
206 this->fBitmap = &bitmap; 218 SkBitmap& resizedBitmap) {
207 this->fCenter = &center; 219 fBitmap = bitmap;
208 this->fDst = &dst; 220 fCenter = center;
209 this->fPaint = paint; 221 fDst = dst;
210 this->fDrawType = DRAW_BITMAP_NINE; 222 if (NULL != paint) {
211 this->fResizedBitmap = resizedBitmap; 223 fPaint = *paint;
224 fPaintPtr = &fPaint;
225 } else {
226 fPaintPtr = NULL;
227 }
228 fDrawType = DRAW_BITMAP_NINE;
229 fResizedBitmap = resizedBitmap;
212 230
213 this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); 231 fInfo.push(SkObjectParser::BitmapToString(bitmap));
214 this->fInfo.push(SkObjectParser::IRectToString(center)); 232 fInfo.push(SkObjectParser::IRectToString(center));
215 this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); 233 fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
216 if (NULL != paint) { 234 if (NULL != paint) {
217 this->fInfo.push(SkObjectParser::PaintToString(*paint)); 235 fInfo.push(SkObjectParser::PaintToString(*paint));
218 } 236 }
219 } 237 }
220 238
221 void DrawBitmapNine::execute(SkCanvas* canvas) { 239 void DrawBitmapNine::execute(SkCanvas* canvas) {
222 canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fP aint); 240 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr);
223 } 241 }
224 242
225 const SkBitmap* DrawBitmapNine::getBitmap() const { 243 const SkBitmap* DrawBitmapNine::getBitmap() const {
226 return &fResizedBitmap; 244 return &fResizedBitmap;
227 } 245 }
228 246
229 DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 247 DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
230 const SkRect& dst, const SkPaint* paint, 248 const SkRect& dst, const SkPaint* paint,
231 SkBitmap& resizedBitmap) { 249 SkBitmap& resizedBitmap) {
232 fBitmap = bitmap; 250 fBitmap = bitmap;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); 520 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
503 } 521 }
504 522
505 void DrawVertices::execute(SkCanvas* canvas) { 523 void DrawVertices::execute(SkCanvas* canvas) {
506 canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices, 524 canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices,
507 this->fTexs, this->fColors, this->fXfermode, this->fIndices, 525 this->fTexs, this->fColors, this->fXfermode, this->fIndices,
508 this->fIndexCount, *this->fPaint); 526 this->fIndexCount, *this->fPaint);
509 } 527 }
510 528
511 Restore::Restore() { 529 Restore::Restore() {
512 this->fDrawType = RESTORE; 530 fDrawType = RESTORE;
513 this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); 531 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
514 } 532 }
515 533
516 void Restore::execute(SkCanvas* canvas) { 534 void Restore::execute(SkCanvas* canvas) {
517 canvas->restore(); 535 canvas->restore();
518 } 536 }
519 537
520 void Restore::trackSaveState(int* state) { 538 void Restore::trackSaveState(int* state) {
521 (*state)--; 539 (*state)--;
522 } 540 }
523 541
524 Rotate::Rotate(SkScalar degrees) { 542 Rotate::Rotate(SkScalar degrees) {
525 this->fDegrees = degrees; 543 this->fDegrees = degrees;
526 this->fDrawType = ROTATE; 544 this->fDrawType = ROTATE;
527 545
528 this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); 546 this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
529 } 547 }
530 548
531 void Rotate::execute(SkCanvas* canvas) { 549 void Rotate::execute(SkCanvas* canvas) {
532 canvas->rotate(this->fDegrees); 550 canvas->rotate(this->fDegrees);
533 } 551 }
534 552
535 Save::Save(SkCanvas::SaveFlags flags) { 553 Save::Save(SkCanvas::SaveFlags flags) {
536 this->fFlags = flags; 554 fFlags = flags;
537 this->fDrawType = SAVE; 555 fDrawType = SAVE;
538 this->fInfo.push(SkObjectParser::SaveFlagsToString(flags)); 556 fInfo.push(SkObjectParser::SaveFlagsToString(flags));
539 } 557 }
540 558
541 void Save::execute(SkCanvas* canvas) { 559 void Save::execute(SkCanvas* canvas) {
542 canvas->save(this->fFlags); 560 canvas->save(fFlags);
543 } 561 }
544 562
545 void Save::trackSaveState(int* state) { 563 void Save::trackSaveState(int* state) {
546 (*state)++; 564 (*state)++;
547 } 565 }
548 566
549 SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint, 567 SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint,
550 SkCanvas::SaveFlags flags) { 568 SkCanvas::SaveFlags flags) {
551 this->fBounds = bounds; 569 if (NULL != bounds) {
552 this->fPaint = paint; 570 fBounds = *bounds;
553 this->fFlags = flags; 571 } else {
554 this->fDrawType = SAVE_LAYER; 572 fBounds.setEmpty();
573 }
555 574
556 if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); 575 if (NULL != paint) {
557 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); 576 fPaint = *paint;
558 this->fInfo.push(SkObjectParser::SaveFlagsToString(flags)); 577 fPaintPtr = &fPaint;
578 } else {
579 fPaintPtr = NULL;
580 }
581 fFlags = flags;
582 fDrawType = SAVE_LAYER;
583
584 if (NULL != bounds) {
585 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
586 }
587 if (NULL != paint) {
588 fInfo.push(SkObjectParser::PaintToString(*paint));
589 }
590 fInfo.push(SkObjectParser::SaveFlagsToString(flags));
559 } 591 }
560 592
561 void SaveLayer::execute(SkCanvas* canvas) { 593 void SaveLayer::execute(SkCanvas* canvas) {
562 canvas->saveLayer(this->fBounds, this->fPaint, this->fFlags); 594 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds,
595 fPaintPtr,
596 fFlags);
563 } 597 }
564 598
565 void SaveLayer::trackSaveState(int* state) { 599 void SaveLayer::trackSaveState(int* state) {
566 (*state)++; 600 (*state)++;
567 } 601 }
568 602
569 Scale::Scale(SkScalar sx, SkScalar sy) { 603 Scale::Scale(SkScalar sx, SkScalar sy) {
570 this->fSx = sx; 604 this->fSx = sx;
571 this->fSy = sy; 605 this->fSy = sy;
572 this->fDrawType = SCALE; 606 this->fDrawType = SCALE;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 this->fDy = dy; 642 this->fDy = dy;
609 this->fDrawType = TRANSLATE; 643 this->fDrawType = TRANSLATE;
610 644
611 this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); 645 this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
612 this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); 646 this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
613 } 647 }
614 648
615 void Translate::execute(SkCanvas* canvas) { 649 void Translate::execute(SkCanvas* canvas) {
616 canvas->translate(this->fDx, this->fDy); 650 canvas->translate(this->fDx, this->fDy);
617 } 651 }
OLDNEW
« no previous file with comments | « debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698