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

Unified Diff: src/utils/debugger/SkDrawCommand.cpp

Issue 1253473002: Add drawImage{Rect,} support to SkDebugCanvas (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: win warnings Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/debugger/SkDrawCommand.cpp
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 1d28d2e8e0cbb195ff4629bb82e74a6c9ebcb1b0..15fc9ca8fbba996314d3e6f390f9a408dd5c127a 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -36,6 +36,8 @@ const char* SkDrawCommand::GetCommandString(OpType type) {
case kDrawBitmapRect_OpType: return "DrawBitmapRect";
case kDrawClear_OpType: return "DrawClear";
case kDrawDRRect_OpType: return "DrawDRRect";
+ case kDrawImage_OpType: return "DrawImage";
+ case kDrawImageRect_OpType: return "DrawImageRect";
case kDrawOval_OpType: return "DrawOval";
case kDrawPaint_OpType: return "DrawPaint";
case kDrawPatch_OpType: return "DrawPatch";
@@ -358,6 +360,64 @@ bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
return true;
}
+SkDrawImageCommand::SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top,
+ const SkPaint* paint)
+ : INHERITED(kDrawImage_OpType)
+ , fImage(SkRef(image))
+ , fLeft(left)
+ , fTop(top) {
+
+ if (paint) {
+ fPaint.set(*paint);
+ }
+}
+
+void SkDrawImageCommand::execute(SkCanvas* canvas) const {
+ canvas->drawImage(fImage, fLeft, fTop, fPaint.getMaybeNull());
+}
+
+bool SkDrawImageCommand::render(SkCanvas* canvas) const {
+ SkAutoCanvasRestore acr(canvas, true);
+ canvas->clear(0xFFFFFFFF);
+
+ xlate_and_scale_to_bounds(canvas, SkRect::MakeXYWH(fLeft, fTop,
+ SkIntToScalar(fImage->width()),
+ SkIntToScalar(fImage->height())));
+ this->execute(canvas);
+ return true;
+}
+
+SkDrawImageRectCommand::SkDrawImageRectCommand(const SkImage* image, const SkRect* src,
+ const SkRect& dst, const SkPaint* paint,
+ SkCanvas::SrcRectConstraint constraint)
+ : INHERITED(kDrawImageRect_OpType)
+ , fImage(SkRef(image))
+ , fDst(dst)
+ , fConstraint(constraint) {
+
+ if (src) {
+ fSrc.set(*src);
+ }
+
+ if (paint) {
+ fPaint.set(*paint);
+ }
+}
+
+void SkDrawImageRectCommand::execute(SkCanvas* canvas) const {
+ canvas->drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
+}
+
+bool SkDrawImageRectCommand::render(SkCanvas* canvas) const {
+ SkAutoCanvasRestore acr(canvas, true);
+ canvas->clear(0xFFFFFFFF);
+
+ xlate_and_scale_to_bounds(canvas, fDst);
+
+ this->execute(canvas);
+ return true;
+}
+
SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint)
: INHERITED(kDrawOval_OpType) {
fOval = oval;
« no previous file with comments | « src/utils/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698