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

Unified Diff: tools/debugger/SkDrawCommand.cpp

Issue 2127233002: Added the framework for having canvas/recorder/picture record depth_set's. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Added comment and default value to depth Created 4 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
« tests/CanvasTest.cpp ('K') | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/debugger/SkDrawCommand.cpp
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 6c9287fa31d8c711948fd77a72aeb7bed721f6a6..51b06cefd55e3a64c11fb701e0f51dc9e66de94d 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"
+#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(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(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,
robertphillips 2016/07/11 20:57:27 line this up with the prior parameter ?
vjiaoblack 2016/07/12 13:14:23 Done.
+ UrlDataManager& urlDataManager) {
+ SkScalar z;
+ extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTH], &z);
+ return new SkSetZCommand(z);
+}
« tests/CanvasTest.cpp ('K') | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698