Add DRRect to debugger

R=reed@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/177683003

git-svn-id: http://skia.googlecode.com/svn/trunk@13565 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-02-24 17:28:55 +00:00
parent 6c5f1fd66c
commit 3d305207bd
3 changed files with 54 additions and 1 deletions

View File

@ -403,7 +403,7 @@ void SkDebugCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
void SkDebugCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
const SkPaint& paint) {
// TODO: add DRRect to debugger
this->addDrawCommand(new SkDrawDRRectCommand(outer, inner, paint));
}
void SkDebugCanvas::drawSprite(const SkBitmap& bitmap, int left, int top,

View File

@ -64,6 +64,7 @@ const char* SkDrawCommand::GetCommandString(DrawType type) {
case BEGIN_COMMENT_GROUP: return "BeginCommentGroup";
case COMMENT: return "Comment";
case END_COMMENT_GROUP: return "EndCommentGroup";
case DRAW_DRRECT: return "Draw DRRect";
default:
SkDebugf("DrawType error 0x%08x\n", type);
SkASSERT(0);
@ -170,6 +171,22 @@ void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
canvas->restore();
}
void render_drrect(SkCanvas* canvas, const SkRRect& outer, const SkRRect& inner) {
canvas->clear(0xFFFFFFFF);
canvas->save();
const SkRect& bounds = outer.getBounds();
xlate_and_scale_to_bounds(canvas, bounds);
SkPaint p;
p.setColor(SK_ColorBLACK);
p.setStyle(SkPaint::kStroke_Style);
canvas->drawDRRect(outer, inner, p);
canvas->restore();
}
};
@ -634,6 +651,28 @@ bool SkDrawRRectCommand::render(SkCanvas* canvas) const {
return true;
}
SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
const SkRRect& inner,
const SkPaint& paint) {
fOuter = outer;
fInner = inner;
fPaint = paint;
fDrawType = DRAW_DRRECT;
fInfo.push(SkObjectParser::RRectToString(outer));
fInfo.push(SkObjectParser::RRectToString(inner));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawDRRectCommand::execute(SkCanvas* canvas) {
canvas->drawDRRect(fOuter, fInner, fPaint);
}
bool SkDrawDRRectCommand::render(SkCanvas* canvas) const {
render_drrect(canvas, fOuter, fInner);
return true;
}
SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint) {
fBitmap = bitmap;

View File

@ -429,6 +429,20 @@ private:
typedef SkDrawCommand INHERITED;
};
class SkDrawDRRectCommand : public SkDrawCommand {
public:
SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
const SkPaint& paint);
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
private:
SkRRect fOuter;
SkRRect fInner;
SkPaint fPaint;
typedef SkDrawCommand INHERITED;
};
class SkDrawSpriteCommand : public SkDrawCommand {
public:
SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);