aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-17 18:33:46 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-17 18:33:46 +0000
commit91217d0b0cdf80a1f18ca24d49e4a925d4629f1f (patch)
treec673b79bfa914a0ae358d5b23e10c84b9872bd62 /debugger
parentd4be5dd36c1e8618c756d6b67edb422d29ae608e (diff)
Making SkDrawCommand more robust
Diffstat (limited to 'debugger')
-rw-r--r--debugger/SkDrawCommand.cpp104
-rw-r--r--debugger/SkDrawCommand.h40
2 files changed, 81 insertions, 63 deletions
diff --git a/debugger/SkDrawCommand.cpp b/debugger/SkDrawCommand.cpp
index c85d8c98a1..a24b891850 100644
--- a/debugger/SkDrawCommand.cpp
+++ b/debugger/SkDrawCommand.cpp
@@ -80,19 +80,19 @@ void Clear::execute(SkCanvas* canvas) {
}
ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap) {
- this->fPath = &path;
- this->fOp = op;
- this->fDoAA = doAA;
- this->fDrawType = CLIP_PATH;
- this->fBitmap = bitmap;
+ fPath = path;
+ fOp = op;
+ fDoAA = doAA;
+ fDrawType = CLIP_PATH;
+ fBitmap = bitmap;
- this->fInfo.push(SkObjectParser::PathToString(path));
- this->fInfo.push(SkObjectParser::RegionOpToString(op));
- this->fInfo.push(SkObjectParser::BoolToString(doAA));
+ fInfo.push(SkObjectParser::PathToString(path));
+ fInfo.push(SkObjectParser::RegionOpToString(op));
+ fInfo.push(SkObjectParser::BoolToString(doAA));
}
void ClipPath::execute(SkCanvas* canvas) {
- canvas->clipPath(*this->fPath, this->fOp, this->fDoAA);
+ canvas->clipPath(fPath, fOp, fDoAA);
}
const SkBitmap* ClipPath::getBitmap() const {
@@ -227,31 +227,37 @@ const SkBitmap* DrawBitmapNine::getBitmap() const {
}
DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
- const SkRect& dst, const SkPaint* paint, SkBitmap& resizedBitmap) {
- this->fBitmap = &bitmap;
- this->fSrc = src;
- this->fDst = &dst;
+ const SkRect& dst, const SkPaint* paint,
+ SkBitmap& resizedBitmap) {
+ fBitmap = bitmap;
+ if (NULL != src) {
+ fSrc = *src;
+ } else {
+ fSrc.setEmpty();
+ }
+ fDst = dst;
+
if (NULL != paint) {
- this->fPaint = *paint;
- this->fPaintPtr = &this->fPaint;
+ fPaint = *paint;
+ fPaintPtr = &fPaint;
} else {
- this->fPaintPtr = NULL;
+ fPaintPtr = NULL;
}
- this->fDrawType = DRAW_BITMAP_RECT_TO_RECT;
- this->fResizedBitmap = resizedBitmap;
+ fDrawType = DRAW_BITMAP_RECT_TO_RECT;
+ fResizedBitmap = resizedBitmap;
- this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
+ fInfo.push(SkObjectParser::BitmapToString(bitmap));
if (NULL != src) {
- this->fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
+ fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
}
- this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
+ fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
if (NULL != paint) {
- this->fInfo.push(SkObjectParser::PaintToString(*paint));
+ fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
void DrawBitmapRect::execute(SkCanvas* canvas) {
- canvas->drawBitmapRectToRect(*this->fBitmap, this->fSrc, *this->fDst, this->fPaintPtr);
+ canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr);
}
const SkBitmap* DrawBitmapRect::getBitmap() const {
@@ -294,17 +300,17 @@ void DrawPaint::execute(SkCanvas* canvas) {
}
DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) {
- this->fPath = &path;
- this->fPaint = &paint;
- this->fBitmap = bitmap;
- this->fDrawType = DRAW_PATH;
+ fPath = path;
+ fPaint = paint;
+ fBitmap = bitmap;
+ fDrawType = DRAW_PATH;
- this->fInfo.push(SkObjectParser::PathToString(path));
- this->fInfo.push(SkObjectParser::PaintToString(paint));
+ fInfo.push(SkObjectParser::PathToString(path));
+ fInfo.push(SkObjectParser::PaintToString(paint));
}
void DrawPath::execute(SkCanvas* canvas) {
- canvas->drawPath(*this->fPath, *this->fPaint);
+ canvas->drawPath(fPath, fPaint);
}
const SkBitmap* DrawPath::getBitmap() const {
@@ -360,36 +366,36 @@ void DrawPosText::execute(SkCanvas* canvas) {
DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
- this->fText = text;
- this->fByteLength = byteLength;
- this->fXpos = xpos;
- this->fConstY = constY;
- this->fPaint = &paint;
- this->fDrawType = DRAW_POS_TEXT_H;
+ const SkScalar xpos[], SkScalar constY,
+ const SkPaint& paint) {
+ fText = text;
+ fByteLength = byteLength;
+ fXpos = xpos;
+ fConstY = constY;
+ fPaint = paint;
+ fDrawType = DRAW_POS_TEXT_H;
- this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
- this->fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
- this->fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
- this->fInfo.push(SkObjectParser::PaintToString(paint));
+ fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
+ fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
+ fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
+ fInfo.push(SkObjectParser::PaintToString(paint));
}
void DrawPosTextH::execute(SkCanvas* canvas) {
- canvas->drawPosTextH(this->fText, this->fByteLength, this->fXpos, this->fConstY,
- *this->fPaint);
+ canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint);
}
DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) {
- this->fRect = &rect;
- this->fPaint = &paint;
- this->fDrawType = DRAW_RECT;
+ fRect = rect;
+ fPaint = paint;
+ fDrawType = DRAW_RECT;
- this->fInfo.push(SkObjectParser::RectToString(rect));
- this->fInfo.push(SkObjectParser::PaintToString(paint));
+ fInfo.push(SkObjectParser::RectToString(rect));
+ fInfo.push(SkObjectParser::PaintToString(paint));
}
void DrawRectC::execute(SkCanvas* canvas) {
- canvas->drawRect(*this->fRect, *this->fPaint);
+ canvas->drawRect(fRect, fPaint);
}
DrawRRect::DrawRRect(const SkRRect& rrect, const SkPaint& paint) {
diff --git a/debugger/SkDrawCommand.h b/debugger/SkDrawCommand.h
index d06e7fe2b8..3ede8ff908 100644
--- a/debugger/SkDrawCommand.h
+++ b/debugger/SkDrawCommand.h
@@ -73,10 +73,12 @@ public:
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
private:
- const SkPath* fPath;
+ SkPath fPath;
SkRegion::Op fOp;
bool fDoAA;
SkBitmap fBitmap;
+
+ typedef SkDrawCommand INHERITED;
};
class ClipRegion : public SkDrawCommand {
@@ -170,7 +172,8 @@ private:
class DrawBitmapRect : public SkDrawCommand {
public:
DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
- 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;
@@ -183,15 +186,18 @@ public:
void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
- const SkRect& dstRect() { return *fDst; }
+ const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
+ const SkRect& dstRect() const { return fDst; }
private:
- const SkRect* fSrc;
+ SkRect fSrc;
SkPaint fPaint;
SkPaint* fPaintPtr;
- const SkBitmap* fBitmap;
- const SkRect* fDst;
+ SkBitmap fBitmap;
+ SkRect fDst;
SkBitmap fResizedBitmap;
+
+ typedef SkDrawCommand INHERITED;
};
class DrawData : public SkDrawCommand {
@@ -227,9 +233,11 @@ public:
virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
private:
- const SkPath* fPath;
- const SkPaint* fPaint;
+ SkPath fPath;
+ SkPaint fPaint;
SkBitmap fBitmap;
+
+ typedef SkDrawCommand INHERITED;
};
class DrawPicture : public SkDrawCommand {
@@ -296,14 +304,16 @@ private:
class DrawPosTextH : public SkDrawCommand {
public:
DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
- SkScalar constY, const SkPaint& paint);
+ SkScalar constY, const SkPaint& paint);
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
const SkScalar* fXpos;
const void* fText;
size_t fByteLength;
SkScalar fConstY;
- const SkPaint* fPaint;
+ SkPaint fPaint;
+
+ typedef SkDrawCommand INHERITED;
};
class DrawRectC : public SkDrawCommand {
@@ -311,11 +321,13 @@ public:
DrawRectC(const SkRect& rect, const SkPaint& paint);
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
- const SkRect& rect() const { return *fRect; }
- const SkPaint* paint() const { return fPaint; }
+ const SkRect& rect() const { return fRect; }
+ const SkPaint& paint() const { return fPaint; }
private:
- const SkRect* fRect;
- const SkPaint* fPaint;
+ SkRect fRect;
+ SkPaint fPaint;
+
+ typedef SkDrawCommand INHERITED;
};
class DrawRRect : public SkDrawCommand {