aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-24 17:28:55 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-24 17:28:55 +0000
commit3d305207bd40f4e5ae10010492420a2fdfa1153c (patch)
tree1e26d4f1c21135388da1043419833b2572769513 /src
parent6c5f1fd66ca195daf04795907d04e1b0cbd3ecb6 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp2
-rw-r--r--src/utils/debugger/SkDrawCommand.cpp39
-rw-r--r--src/utils/debugger/SkDrawCommand.h14
3 files changed, 54 insertions, 1 deletions
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 88088542bc..58b609a01c 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -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,
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index db041cdce6..f5caa86f92 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -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;
diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h
index b78dc9c3c4..e03eb072b9 100644
--- a/src/utils/debugger/SkDrawCommand.h
+++ b/src/utils/debugger/SkDrawCommand.h
@@ -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);