diff --git a/debugger/SkDrawCommand.cpp b/debugger/SkDrawCommand.cpp index cf3c09872d..36459023ac 100644 --- a/debugger/SkDrawCommand.cpp +++ b/debugger/SkDrawCommand.cpp @@ -70,13 +70,13 @@ SkString SkDrawCommand::toString() { } Clear::Clear(SkColor color) { - this->fColor = color; - this->fDrawType = DRAW_CLEAR; - this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); + fColor = color; + fDrawType = DRAW_CLEAR; + fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); } void Clear::execute(SkCanvas* canvas) { - canvas->clear(this->fColor); + canvas->clear(fColor); } ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap) { @@ -100,16 +100,16 @@ const SkBitmap* ClipPath::getBitmap() const { } ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) { - this->fRegion = ®ion; - this->fOp = op; - this->fDrawType = CLIP_REGION; + fRegion = region; + fOp = op; + fDrawType = CLIP_REGION; - this->fInfo.push(SkObjectParser::RegionToString(region)); - this->fInfo.push(SkObjectParser::RegionOpToString(op)); + fInfo.push(SkObjectParser::RegionToString(region)); + fInfo.push(SkObjectParser::RegionOpToString(op)); } void ClipRegion::execute(SkCanvas* canvas) { - canvas->clipRegion(*this->fRegion, this->fOp); + canvas->clipRegion(fRegion, fOp); } ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { @@ -143,35 +143,40 @@ void ClipRRect::execute(SkCanvas* canvas) { } Concat::Concat(const SkMatrix& matrix) { - this->fMatrix = &matrix; - this->fDrawType = CONCAT; + fMatrix = matrix; + fDrawType = CONCAT; - this->fInfo.push(SkObjectParser::MatrixToString(matrix)); + fInfo.push(SkObjectParser::MatrixToString(matrix)); } void Concat::execute(SkCanvas* canvas) { - canvas->concat(*this->fMatrix); + canvas->concat(fMatrix); } DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, - const SkPaint* paint, SkBitmap& resizedBitmap) { - this->fBitmap = &bitmap; - this->fLeft = left; - this->fTop = top; - this->fPaint = paint; - this->fDrawType = DRAW_BITMAP; - this->fResizedBitmap = resizedBitmap; - - this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); - this->fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); - this->fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); + const SkPaint* paint, SkBitmap& resizedBitmap) { + fBitmap = bitmap; + fLeft = left; + fTop = top; if (NULL != paint) { - this->fInfo.push(SkObjectParser::PaintToString(*paint)); + fPaint = *paint; + fPaintPtr = &fPaint; + } else { + fPaintPtr = NULL; + } + fDrawType = DRAW_BITMAP; + fResizedBitmap = resizedBitmap; + + fInfo.push(SkObjectParser::BitmapToString(bitmap)); + fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); + fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); + if (NULL != paint) { + fInfo.push(SkObjectParser::PaintToString(*paint)); } } void DrawBitmap::execute(SkCanvas* canvas) { - canvas->drawBitmap(*this->fBitmap, this->fLeft, this->fTop, this->fPaint); + canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); } const SkBitmap* DrawBitmap::getBitmap() const { @@ -179,22 +184,29 @@ const SkBitmap* DrawBitmap::getBitmap() const { } DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap, - const SkMatrix& matrix, const SkPaint* paint, SkBitmap& resizedBitmap) { - this->fBitmap = &bitmap; - this->fMatrix = &matrix; - this->fPaint = paint; - this->fDrawType = DRAW_BITMAP_MATRIX; - this->fResizedBitmap = resizedBitmap; - - this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); - this->fInfo.push(SkObjectParser::MatrixToString(matrix)); + const SkMatrix& matrix, + const SkPaint* paint, + SkBitmap& resizedBitmap) { + fBitmap = bitmap; + fMatrix = matrix; if (NULL != paint) { - this->fInfo.push(SkObjectParser::PaintToString(*paint)); + fPaint = *paint; + fPaintPtr = &fPaint; + } else { + fPaintPtr = NULL; + } + fDrawType = DRAW_BITMAP_MATRIX; + fResizedBitmap = resizedBitmap; + + fInfo.push(SkObjectParser::BitmapToString(bitmap)); + fInfo.push(SkObjectParser::MatrixToString(matrix)); + if (NULL != paint) { + fInfo.push(SkObjectParser::PaintToString(*paint)); } } void DrawBitmapMatrix::execute(SkCanvas* canvas) { - canvas->drawBitmapMatrix(*this->fBitmap, *this->fMatrix, this->fPaint); + canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); } const SkBitmap* DrawBitmapMatrix::getBitmap() const { @@ -202,24 +214,30 @@ const SkBitmap* DrawBitmapMatrix::getBitmap() const { } DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, - const SkRect& dst, const SkPaint* paint, SkBitmap& resizedBitmap) { - this->fBitmap = &bitmap; - this->fCenter = ¢er; - this->fDst = &dst; - this->fPaint = paint; - this->fDrawType = DRAW_BITMAP_NINE; - this->fResizedBitmap = resizedBitmap; - - this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); - this->fInfo.push(SkObjectParser::IRectToString(center)); - this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); + const SkRect& dst, const SkPaint* paint, + SkBitmap& resizedBitmap) { + fBitmap = bitmap; + fCenter = center; + fDst = dst; if (NULL != paint) { - this->fInfo.push(SkObjectParser::PaintToString(*paint)); + fPaint = *paint; + fPaintPtr = &fPaint; + } else { + fPaintPtr = NULL; + } + fDrawType = DRAW_BITMAP_NINE; + fResizedBitmap = resizedBitmap; + + fInfo.push(SkObjectParser::BitmapToString(bitmap)); + fInfo.push(SkObjectParser::IRectToString(center)); + fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); + if (NULL != paint) { + fInfo.push(SkObjectParser::PaintToString(*paint)); } } void DrawBitmapNine::execute(SkCanvas* canvas) { - canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fPaint); + canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); } const SkBitmap* DrawBitmapNine::getBitmap() const { @@ -509,8 +527,8 @@ void DrawVertices::execute(SkCanvas* canvas) { } Restore::Restore() { - this->fDrawType = RESTORE; - this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); + fDrawType = RESTORE; + fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); } void Restore::execute(SkCanvas* canvas) { @@ -533,13 +551,13 @@ void Rotate::execute(SkCanvas* canvas) { } Save::Save(SkCanvas::SaveFlags flags) { - this->fFlags = flags; - this->fDrawType = SAVE; - this->fInfo.push(SkObjectParser::SaveFlagsToString(flags)); + fFlags = flags; + fDrawType = SAVE; + fInfo.push(SkObjectParser::SaveFlagsToString(flags)); } void Save::execute(SkCanvas* canvas) { - canvas->save(this->fFlags); + canvas->save(fFlags); } void Save::trackSaveState(int* state) { @@ -547,19 +565,35 @@ void Save::trackSaveState(int* state) { } SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint, - SkCanvas::SaveFlags flags) { - this->fBounds = bounds; - this->fPaint = paint; - this->fFlags = flags; - this->fDrawType = SAVE_LAYER; + SkCanvas::SaveFlags flags) { + if (NULL != bounds) { + fBounds = *bounds; + } else { + fBounds.setEmpty(); + } - if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); - if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); - this->fInfo.push(SkObjectParser::SaveFlagsToString(flags)); + if (NULL != paint) { + fPaint = *paint; + fPaintPtr = &fPaint; + } else { + fPaintPtr = NULL; + } + fFlags = flags; + fDrawType = SAVE_LAYER; + + if (NULL != bounds) { + fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); + } + if (NULL != paint) { + fInfo.push(SkObjectParser::PaintToString(*paint)); + } + fInfo.push(SkObjectParser::SaveFlagsToString(flags)); } void SaveLayer::execute(SkCanvas* canvas) { - canvas->saveLayer(this->fBounds, this->fPaint, this->fFlags); + canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, + fPaintPtr, + fFlags); } void SaveLayer::trackSaveState(int* state) { diff --git a/debugger/SkDrawCommand.h b/debugger/SkDrawCommand.h index 0948af0a37..086627a2f7 100644 --- a/debugger/SkDrawCommand.h +++ b/debugger/SkDrawCommand.h @@ -57,6 +57,9 @@ public: Restore(); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; virtual void trackSaveState(int* state) SK_OVERRIDE; + +private: + typedef SkDrawCommand INHERITED; }; class Clear : public SkDrawCommand { @@ -65,6 +68,8 @@ public: virtual void execute(SkCanvas* canvas) SK_OVERRIDE; private: SkColor fColor; + + typedef SkDrawCommand INHERITED; }; class ClipPath : public SkDrawCommand { @@ -73,10 +78,10 @@ public: virtual void execute(SkCanvas* canvas) SK_OVERRIDE; virtual const SkBitmap* getBitmap() const SK_OVERRIDE; private: - SkPath fPath; + SkPath fPath; SkRegion::Op fOp; - bool fDoAA; - SkBitmap fBitmap; + bool fDoAA; + SkBitmap fBitmap; typedef SkDrawCommand INHERITED; }; @@ -86,8 +91,10 @@ public: ClipRegion(const SkRegion& region, SkRegion::Op op); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; private: - const SkRegion* fRegion; + SkRegion fRegion; SkRegion::Op fOp; + + typedef SkDrawCommand INHERITED; }; class ClipRect : public SkDrawCommand { @@ -129,48 +136,60 @@ public: Concat(const SkMatrix& matrix); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; private: - const SkMatrix* fMatrix; + SkMatrix fMatrix; + + typedef SkDrawCommand INHERITED; }; class DrawBitmap : public SkDrawCommand { public: DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, - const SkPaint* paint, SkBitmap& resizedBitmap); + const SkPaint* paint, SkBitmap& resizedBitmap); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; virtual const SkBitmap* getBitmap() const SK_OVERRIDE; private: - const SkPaint* fPaint; - const SkBitmap* fBitmap; + SkBitmap fBitmap; SkScalar fLeft; SkScalar fTop; + SkPaint fPaint; + SkPaint* fPaintPtr; SkBitmap fResizedBitmap; + + typedef SkDrawCommand INHERITED; }; class DrawBitmapMatrix : public SkDrawCommand { public: DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix, - const SkPaint* paint, SkBitmap& resizedBitmap); + const SkPaint* paint, SkBitmap& resizedBitmap); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; virtual const SkBitmap* getBitmap() const SK_OVERRIDE; private: - const SkPaint* fPaint; - const SkBitmap* fBitmap; - const SkMatrix* fMatrix; + SkBitmap fBitmap; + SkMatrix fMatrix; + SkPaint fPaint; + SkPaint* fPaintPtr; SkBitmap fResizedBitmap; + + typedef SkDrawCommand INHERITED; }; class DrawBitmapNine : public SkDrawCommand { public: DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, - const SkRect& dst, const SkPaint* paint, SkBitmap& resizedBitmap); + const SkRect& dst, const SkPaint* paint, + SkBitmap& resizedBitmap); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; virtual const SkBitmap* getBitmap() const SK_OVERRIDE; private: - const SkBitmap* fBitmap; - const SkIRect* fCenter; - const SkRect* fDst; - const SkPaint* fPaint; + SkBitmap fBitmap; + SkIRect fCenter; + SkRect fDst; + SkPaint fPaint; + SkPaint* fPaintPtr; SkBitmap fResizedBitmap; + + typedef SkDrawCommand INHERITED; }; class DrawBitmapRect : public SkDrawCommand { @@ -194,11 +213,11 @@ public: const SkRect& dstRect() const { return fDst; } private: - SkRect fSrc; - SkPaint fPaint; - SkPaint* fPaintPtr; SkBitmap fBitmap; - SkRect fDst; + SkRect fSrc; + SkRect fDst; + SkPaint fPaint; + SkPaint* fPaintPtr; SkBitmap fResizedBitmap; typedef SkDrawCommand INHERITED; @@ -401,21 +420,26 @@ public: virtual void trackSaveState(int* state) SK_OVERRIDE; private: SkCanvas::SaveFlags fFlags; + + typedef SkDrawCommand INHERITED; }; class SaveLayer : public SkDrawCommand { public: SaveLayer(const SkRect* bounds, const SkPaint* paint, - SkCanvas::SaveFlags flags); + SkCanvas::SaveFlags flags); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; virtual void trackSaveState(int* state) SK_OVERRIDE; - const SkPaint* paint() const { return fPaint; } + const SkPaint* paint() const { return fPaintPtr; } private: - const SkRect* fBounds; - const SkPaint* fPaint; + SkRect fBounds; + SkPaint fPaint; + SkPaint* fPaintPtr; SkCanvas::SaveFlags fFlags; + + typedef SkDrawCommand INHERITED; }; class Scale : public SkDrawCommand {