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

Side by Side Diff: tools/debugger/SkDrawCommand.cpp

Issue 2142183003: Revert of Added the framework for having canvas/recorder/picture record depth_set's. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDrawCommand.h" 8 #include "SkDrawCommand.h"
9 9
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 10 matching lines...) Expand all
21 #include "SkTextBlobRunIterator.h" 21 #include "SkTextBlobRunIterator.h"
22 #include "SkTHash.h" 22 #include "SkTHash.h"
23 #include "SkTypeface.h" 23 #include "SkTypeface.h"
24 #include "SkValidatingReadBuffer.h" 24 #include "SkValidatingReadBuffer.h"
25 #include "SkWriteBuffer.h" 25 #include "SkWriteBuffer.h"
26 #include "picture_utils.h" 26 #include "picture_utils.h"
27 27
28 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command" 28 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command"
29 #define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible" 29 #define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible"
30 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix" 30 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
31 #define SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS "drawDepthTranslation"
32 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords" 31 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
33 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds" 32 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
34 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint" 33 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint"
35 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer" 34 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer"
36 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner" 35 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner"
37 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode" 36 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode"
38 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points" 37 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points"
39 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path" 38 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path"
40 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text" 39 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text"
41 #define SKDEBUGCANVAS_ATTRIBUTE_COLOR "color" 40 #define SKDEBUGCANVAS_ATTRIBUTE_COLOR "color"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 case kDrawRRect_OpType: return "DrawRRect"; 203 case kDrawRRect_OpType: return "DrawRRect";
205 case kDrawText_OpType: return "DrawText"; 204 case kDrawText_OpType: return "DrawText";
206 case kDrawTextBlob_OpType: return "DrawTextBlob"; 205 case kDrawTextBlob_OpType: return "DrawTextBlob";
207 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; 206 case kDrawTextOnPath_OpType: return "DrawTextOnPath";
208 case kDrawVertices_OpType: return "DrawVertices"; 207 case kDrawVertices_OpType: return "DrawVertices";
209 case kEndDrawPicture_OpType: return "EndDrawPicture"; 208 case kEndDrawPicture_OpType: return "EndDrawPicture";
210 case kRestore_OpType: return "Restore"; 209 case kRestore_OpType: return "Restore";
211 case kSave_OpType: return "Save"; 210 case kSave_OpType: return "Save";
212 case kSaveLayer_OpType: return "SaveLayer"; 211 case kSaveLayer_OpType: return "SaveLayer";
213 case kSetMatrix_OpType: return "SetMatrix"; 212 case kSetMatrix_OpType: return "SetMatrix";
214 case kTranslateZ_OpType: return "TranslateZ";
215 default: 213 default:
216 SkDebugf("OpType error 0x%08x\n", type); 214 SkDebugf("OpType error 0x%08x\n", type);
217 SkASSERT(0); 215 SkASSERT(0);
218 break; 216 break;
219 } 217 }
220 SkDEBUGFAIL("DrawType UNUSED\n"); 218 SkDEBUGFAIL("DrawType UNUSED\n");
221 return nullptr; 219 return nullptr;
222 } 220 }
223 221
224 SkString SkDrawCommand::toString() const { 222 SkString SkDrawCommand::toString() const {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 INSTALL_FACTORY(DrawTextOnPath); 259 INSTALL_FACTORY(DrawTextOnPath);
262 INSTALL_FACTORY(DrawTextBlob); 260 INSTALL_FACTORY(DrawTextBlob);
263 261
264 INSTALL_FACTORY(DrawRect); 262 INSTALL_FACTORY(DrawRect);
265 INSTALL_FACTORY(DrawRRect); 263 INSTALL_FACTORY(DrawRRect);
266 INSTALL_FACTORY(DrawDRRect); 264 INSTALL_FACTORY(DrawDRRect);
267 INSTALL_FACTORY(DrawPatch); 265 INSTALL_FACTORY(DrawPatch);
268 INSTALL_FACTORY(Save); 266 INSTALL_FACTORY(Save);
269 INSTALL_FACTORY(SaveLayer); 267 INSTALL_FACTORY(SaveLayer);
270 INSTALL_FACTORY(SetMatrix); 268 INSTALL_FACTORY(SetMatrix);
271
272 INSTALL_FACTORY(TranslateZ);
273 } 269 }
274 SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString( )); 270 SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString( ));
275 FROM_JSON* factory = factories.find(name); 271 FROM_JSON* factory = factories.find(name);
276 if (factory == nullptr) { 272 if (factory == nullptr) {
277 SkDebugf("no JSON factory for '%s'\n", name.c_str()); 273 SkDebugf("no JSON factory for '%s'\n", name.c_str());
278 return nullptr; 274 return nullptr;
279 } 275 }
280 return (*factory)(command, urlDataManager); 276 return (*factory)(command, urlDataManager);
281 } 277 }
282 278
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 row2.append(Json::Value(matrix[5])); 461 row2.append(Json::Value(matrix[5]));
466 result.append(row2); 462 result.append(row2);
467 Json::Value row3(Json::arrayValue); 463 Json::Value row3(Json::arrayValue);
468 row3.append(Json::Value(matrix[6])); 464 row3.append(Json::Value(matrix[6]));
469 row3.append(Json::Value(matrix[7])); 465 row3.append(Json::Value(matrix[7]));
470 row3.append(Json::Value(matrix[8])); 466 row3.append(Json::Value(matrix[8]));
471 result.append(row3); 467 result.append(row3);
472 return result; 468 return result;
473 } 469 }
474 470
475 Json::Value SkDrawCommand::MakeJsonScalar(SkScalar z) {
476 Json::Value result(z);
477 return result;
478 }
479
480 Json::Value SkDrawCommand::MakeJsonPath(const SkPath& path) { 471 Json::Value SkDrawCommand::MakeJsonPath(const SkPath& path) {
481 Json::Value result(Json::objectValue); 472 Json::Value result(Json::objectValue);
482 switch (path.getFillType()) { 473 switch (path.getFillType()) {
483 case SkPath::kWinding_FillType: 474 case SkPath::kWinding_FillType:
484 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_WI NDING; 475 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_WI NDING;
485 break; 476 break;
486 case SkPath::kEvenOdd_FillType: 477 case SkPath::kEvenOdd_FillType:
487 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV ENODD; 478 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV ENODD;
488 break; 479 break;
489 case SkPath::kInverseWinding_FillType: 480 case SkPath::kInverseWinding_FillType:
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 1473
1483 static void extract_json_matrix(Json::Value& matrix, SkMatrix* result) { 1474 static void extract_json_matrix(Json::Value& matrix, SkMatrix* result) {
1484 SkScalar values[] = { 1475 SkScalar values[] = {
1485 matrix[0][0].asFloat(), matrix[0][1].asFloat(), matrix[0][2].asFloat(), 1476 matrix[0][0].asFloat(), matrix[0][1].asFloat(), matrix[0][2].asFloat(),
1486 matrix[1][0].asFloat(), matrix[1][1].asFloat(), matrix[1][2].asFloat(), 1477 matrix[1][0].asFloat(), matrix[1][1].asFloat(), matrix[1][2].asFloat(),
1487 matrix[2][0].asFloat(), matrix[2][1].asFloat(), matrix[2][2].asFloat() 1478 matrix[2][0].asFloat(), matrix[2][1].asFloat(), matrix[2][2].asFloat()
1488 }; 1479 };
1489 result->set9(values); 1480 result->set9(values);
1490 } 1481 }
1491 1482
1492 static void extract_json_scalar(Json::Value& scalar, SkScalar* result) {
1493 SkScalar value = scalar.asFloat();
1494 *result = value;
1495 }
1496
1497 static void extract_json_path(Json::Value& path, SkPath* result) { 1483 static void extract_json_path(Json::Value& path, SkPath* result) {
1498 const char* fillType = path[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE].asCString(); 1484 const char* fillType = path[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE].asCString();
1499 if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_WINDING)) { 1485 if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_WINDING)) {
1500 result->setFillType(SkPath::kWinding_FillType); 1486 result->setFillType(SkPath::kWinding_FillType);
1501 } 1487 }
1502 else if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_EVENODD)) { 1488 else if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_EVENODD)) {
1503 result->setFillType(SkPath::kEvenOdd_FillType); 1489 result->setFillType(SkPath::kEvenOdd_FillType);
1504 } 1490 }
1505 else if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_INVERSEWINDING)) { 1491 else if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_INVERSEWINDING)) {
1506 result->setFillType(SkPath::kInverseWinding_FillType); 1492 result->setFillType(SkPath::kInverseWinding_FillType);
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); 3217 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
3232 return result; 3218 return result;
3233 } 3219 }
3234 3220
3235 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, 3221 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3236 UrlDataManager& urlDataManager) { 3222 UrlDataManager& urlDataManager) {
3237 SkMatrix matrix; 3223 SkMatrix matrix;
3238 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3224 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3239 return new SkSetMatrixCommand(matrix); 3225 return new SkSetMatrixCommand(matrix);
3240 } 3226 }
3241
3242 SkTranslateZCommand::SkTranslateZCommand(SkScalar z)
3243 : INHERITED(kTranslateZ_OpType) {
3244 fZTranslate = z;
3245 fInfo.push(SkObjectParser::ScalarToString(fZTranslate, "drawDepthTranslation "));
3246 }
3247
3248 void SkTranslateZCommand::execute(SkCanvas* canvas) const {
3249 canvas->translateZ(fZTranslate);
3250 }
3251
3252 Json::Value SkTranslateZCommand::toJSON(UrlDataManager& urlDataManager) const {
3253 Json::Value result = INHERITED::toJSON(urlDataManager);
3254 result[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS] = MakeJsonScalar(fZTranslate) ;
3255 return result;
3256 }
3257
3258 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command,
3259 UrlDataManager& urlDataManager) {
3260 SkScalar z;
3261 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z);
3262 return new SkTranslateZCommand(z);
3263 }
OLDNEW
« no previous file with comments | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698