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

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

Issue 1048383002: [SkDebugger] Flatten drawPicture ops (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 d09de783518477bbcc60f7bd7f591c1fb005bd05..09b18896bcc7adf661ce8138f7760fc08fb43385 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -26,6 +26,7 @@ SkDrawCommand::~SkDrawCommand() {
const char* SkDrawCommand::GetCommandString(OpType type) {
switch (type) {
case kBeginCommentGroup_OpType: return "BeginCommentGroup";
+ case kBeginDrawPicture_OpType: return "BeginDrawPicture";
case kClipPath_OpType: return "ClipPath";
case kClipRegion_OpType: return "ClipRegion";
case kClipRect_OpType: return "ClipRect";
@@ -41,7 +42,6 @@ const char* SkDrawCommand::GetCommandString(OpType type) {
case kDrawPaint_OpType: return "DrawPaint";
case kDrawPatch_OpType: return "DrawPatch";
case kDrawPath_OpType: return "DrawPath";
- case kDrawPicture_OpType: return "DrawPicture";
case kDrawPoints_OpType: return "DrawPoints";
case kDrawPosText_OpType: return "DrawPosText";
case kDrawPosTextH_OpType: return "DrawPosTextH";
@@ -53,6 +53,7 @@ const char* SkDrawCommand::GetCommandString(OpType type) {
case kDrawTextOnPath_OpType: return "DrawTextOnPath";
case kDrawVertices_OpType: return "DrawVertices";
case kEndCommentGroup_OpType: return "EndCommentGroup";
+ case kEndDrawPicture_OpType: return "EndDrawPicture";
case kRestore_OpType: return "Restore";
case kSave_OpType: return "Save";
case kSaveLayer_OpType: return "SaveLayer";
@@ -445,41 +446,48 @@ bool SkDrawPathCommand::render(SkCanvas* canvas) const {
return true;
}
-SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture,
- const SkMatrix* matrix,
- const SkPaint* paint)
- : INHERITED(kDrawPicture_OpType)
- , fPicture(SkRef(picture))
- , fMatrixPtr(NULL)
- , fPaintPtr(NULL) {
+SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture,
+ const SkMatrix* matrix,
+ const SkPaint* paint)
+ : INHERITED(kBeginDrawPicture_OpType)
+ , fPicture(SkRef(picture)) {
- if (matrix) {
- fMatrix = *matrix;
- fMatrixPtr = &fMatrix;
- }
- if (paint) {
- fPaint = *paint;
- fPaintPtr = &fPaint;
- }
+ SkString* str = new SkString;
+ str->appendf("SkPicture: L: %f T: %f R: %f B: %f",
+ picture->cullRect().fLeft, picture->cullRect().fTop,
+ picture->cullRect().fRight, picture->cullRect().fBottom);
+ fInfo.push(str);
- SkString* temp = new SkString;
- temp->appendf("SkPicture: L: %f T: %f R: %f B: %f",
- picture->cullRect().fLeft, picture->cullRect().fTop,
- picture->cullRect().fRight, picture->cullRect().fBottom);
- fInfo.push(temp);
if (matrix) {
+ fMatrix.set(*matrix);
fInfo.push(SkObjectParser::MatrixToString(*matrix));
}
+
if (paint) {
+ fPaint.set(*paint);
fInfo.push(SkObjectParser::PaintToString(*paint));
}
+
}
-void SkDrawPictureCommand::execute(SkCanvas* canvas) const {
- canvas->drawPicture(fPicture, fMatrixPtr, fPaintPtr);
+void SkBeginDrawPictureCommand::execute(SkCanvas* canvas) const {
+ if (fPaint.isValid()) {
+ SkRect bounds = fPicture->cullRect();
+ if (fMatrix.isValid()) {
+ fMatrix.get()->mapRect(&bounds);
+ }
+ canvas->saveLayer(&bounds, fPaint.get());
+ }
+
+ if (fMatrix.isValid()) {
+ if (!fPaint.isValid()) {
+ canvas->save();
+ }
+ canvas->concat(*fMatrix.get());
+ }
}
-bool SkDrawPictureCommand::render(SkCanvas* canvas) const {
+bool SkBeginDrawPictureCommand::render(SkCanvas* canvas) const {
canvas->clear(0xFFFFFFFF);
canvas->save();
@@ -492,6 +500,15 @@ bool SkDrawPictureCommand::render(SkCanvas* canvas) const {
return true;
}
+SkEndDrawPictureCommand::SkEndDrawPictureCommand(bool restore)
+ : INHERITED(kEndDrawPicture_OpType) , fRestore(restore) { }
+
+void SkEndDrawPictureCommand::execute(SkCanvas* canvas) const {
+ if (fRestore) {
+ canvas->restore();
+ }
+}
+
SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint)
: INHERITED(kDrawPoints_OpType) {
« 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