Chromium Code Reviews| Index: tools/debugger/SkDrawCommand.cpp |
| diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp |
| index 6c9287fa31d8c711948fd77a72aeb7bed721f6a6..a605518d41755952989dc7633c163e2db6c36403 100644 |
| --- a/tools/debugger/SkDrawCommand.cpp |
| +++ b/tools/debugger/SkDrawCommand.cpp |
| @@ -28,6 +28,7 @@ |
| #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command" |
| #define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible" |
| #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix" |
|
robertphillips
2016/07/08 17:26:43
line up
vjiaoblack
2016/07/11 18:04:42
Done.
|
| +#define SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTH "drawDepth" |
| #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords" |
| #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds" |
| #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint" |
| @@ -210,6 +211,7 @@ const char* SkDrawCommand::GetCommandString(OpType type) { |
| case kSave_OpType: return "Save"; |
| case kSaveLayer_OpType: return "SaveLayer"; |
| case kSetMatrix_OpType: return "SetMatrix"; |
| + case kSetZ_OpType: return "SetZ"; |
| default: |
| SkDebugf("OpType error 0x%08x\n", type); |
| SkASSERT(0); |
| @@ -266,6 +268,8 @@ SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url |
| INSTALL_FACTORY(Save); |
| INSTALL_FACTORY(SaveLayer); |
| INSTALL_FACTORY(SetMatrix); |
| + |
| + INSTALL_FACTORY(SetZ); |
| } |
| SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString()); |
| FROM_JSON* factory = factories.find(name); |
| @@ -468,6 +472,11 @@ Json::Value SkDrawCommand::MakeJsonMatrix(const SkMatrix& matrix) { |
| return result; |
| } |
| +Json::Value SkDrawCommand::MakeJsonScalar(const SkScalar z) { |
| + Json::Value result(z); |
| + return result; |
| +} |
| + |
| Json::Value SkDrawCommand::MakeJsonPath(const SkPath& path) { |
| Json::Value result(Json::objectValue); |
| switch (path.getFillType()) { |
| @@ -1480,6 +1489,11 @@ static void extract_json_matrix(Json::Value& matrix, SkMatrix* result) { |
| result->set9(values); |
| } |
| +static void extract_json_scalar(Json::Value& scalar, SkScalar* result) { |
| + SkScalar value = scalar.asFloat(); |
| + *result = value; |
| +} |
| + |
| static void extract_json_path(Json::Value& path, SkPath* result) { |
| const char* fillType = path[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE].asCString(); |
| if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_WINDING)) { |
| @@ -3224,3 +3238,26 @@ SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
| extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
| return new SkSetMatrixCommand(matrix); |
| } |
| + |
| +SkSetZCommand::SkSetZCommand(const SkScalar z) |
| + : INHERITED(kSetZ_OpType) { |
| + fCurDrawDepth = z; |
| + fInfo.push(SkObjectParser::ScalarToString(z, "drawDepth")); |
| +} |
| + |
| +void SkSetZCommand::execute(SkCanvas* canvas) const { |
| + canvas->setZ(fCurDrawDepth); |
| +} |
| + |
| +Json::Value SkSetZCommand::toJSON(UrlDataManager& urlDataManager) const { |
| + Json::Value result = INHERITED::toJSON(urlDataManager); |
| + result[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTH] = MakeJsonScalar(fCurDrawDepth); |
| + return result; |
| +} |
| + |
| +SkSetZCommand* SkSetZCommand::fromJSON(Json::Value& command, |
| + UrlDataManager& urlDataManager) { |
| + SkScalar z; |
| + extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTH], &z); |
| + return new SkSetZCommand(z); |
| +} |