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

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

Issue 2107913003: add short-desc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: change short-desc to just a string 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 | « no previous file | 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
9 #include "SkDrawCommand.h" 8 #include "SkDrawCommand.h"
10 9
11 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
12 #include "SkColorFilter.h" 11 #include "SkColorFilter.h"
13 #include "SkDashPathEffect.h" 12 #include "SkDashPathEffect.h"
14 #include "SkImageFilter.h" 13 #include "SkImageFilter.h"
15 #include "SkJsonWriteBuffer.h" 14 #include "SkJsonWriteBuffer.h"
16 #include "SkMaskFilter.h" 15 #include "SkMaskFilter.h"
17 #include "SkObjectParser.h" 16 #include "SkObjectParser.h"
18 #include "SkPaintDefaults.h" 17 #include "SkPaintDefaults.h"
19 #include "SkPathEffect.h" 18 #include "SkPathEffect.h"
20 #include "SkPicture.h" 19 #include "SkPicture.h"
21 #include "SkTextBlob.h" 20 #include "SkTextBlob.h"
22 #include "SkTextBlobRunIterator.h" 21 #include "SkTextBlobRunIterator.h"
23 #include "SkTHash.h" 22 #include "SkTHash.h"
24 #include "SkTypeface.h" 23 #include "SkTypeface.h"
25 #include "SkValidatingReadBuffer.h" 24 #include "SkValidatingReadBuffer.h"
26 #include "SkWriteBuffer.h" 25 #include "SkWriteBuffer.h"
27 26
27 static bool gShowShortDesc = true;
jcgregorio 2016/06/29 14:43:40 Is this really needed? The display of the short de
reed1 2016/06/29 18:13:45 Done.
28
28 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command" 29 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command"
29 #define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible" 30 #define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible"
30 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix" 31 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
31 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords" 32 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
32 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds" 33 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
33 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint" 34 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint"
34 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer" 35 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer"
35 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner" 36 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner"
36 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode" 37 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode"
37 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points" 38 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs" 86 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs"
86 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions" 87 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions"
87 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs" 88 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs"
88 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" 89 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font"
89 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" 90 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface"
90 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics" 91 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics"
91 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors" 92 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors"
92 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords" 93 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords"
93 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality" 94 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality"
94 95
96 #define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "short-desc"
97
95 #define SKDEBUGCANVAS_VERB_MOVE "move" 98 #define SKDEBUGCANVAS_VERB_MOVE "move"
96 #define SKDEBUGCANVAS_VERB_LINE "line" 99 #define SKDEBUGCANVAS_VERB_LINE "line"
97 #define SKDEBUGCANVAS_VERB_QUAD "quad" 100 #define SKDEBUGCANVAS_VERB_QUAD "quad"
98 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" 101 #define SKDEBUGCANVAS_VERB_CUBIC "cubic"
99 #define SKDEBUGCANVAS_VERB_CONIC "conic" 102 #define SKDEBUGCANVAS_VERB_CONIC "conic"
100 #define SKDEBUGCANVAS_VERB_CLOSE "close" 103 #define SKDEBUGCANVAS_VERB_CLOSE "close"
101 104
102 #define SKDEBUGCANVAS_STYLE_FILL "fill" 105 #define SKDEBUGCANVAS_STYLE_FILL "fill"
103 #define SKDEBUGCANVAS_STYLE_STROKE "stroke" 106 #define SKDEBUGCANVAS_STYLE_STROKE "stroke"
104 #define SKDEBUGCANVAS_STYLE_STROKEANDFILL "strokeAndFill" 107 #define SKDEBUGCANVAS_STYLE_STROKEANDFILL "strokeAndFill"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul" 154 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul"
152 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul" 155 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul"
153 156
154 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none" 157 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none"
155 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low" 158 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low"
156 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium" 159 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium"
157 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high" 160 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high"
158 161
159 typedef SkDrawCommand* (*FROM_JSON)(Json::Value&, UrlDataManager&); 162 typedef SkDrawCommand* (*FROM_JSON)(Json::Value&, UrlDataManager&);
160 163
164 static SkString* str_append(SkString* str, const SkRect& r) {
165 str->appendf(" [%g %g %g %g]", r.left(), r.top(), r.right(), r.bottom());
166 return str;
167 }
168
161 // TODO(chudy): Refactor into non subclass model. 169 // TODO(chudy): Refactor into non subclass model.
162 170
163 SkDrawCommand::SkDrawCommand(OpType type) 171 SkDrawCommand::SkDrawCommand(OpType type)
164 : fOpType(type) 172 : fOpType(type)
165 , fVisible(true) { 173 , fVisible(true) {
166 } 174 }
167 175
168 SkDrawCommand::~SkDrawCommand() { 176 SkDrawCommand::~SkDrawCommand() {
169 fInfo.deleteAll(); 177 fInfo.deleteAll();
170 } 178 }
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1644
1637 void SkClipRectCommand::execute(SkCanvas* canvas) const { 1645 void SkClipRectCommand::execute(SkCanvas* canvas) const {
1638 canvas->clipRect(fRect, fOp, fDoAA); 1646 canvas->clipRect(fRect, fOp, fDoAA);
1639 } 1647 }
1640 1648
1641 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const { 1649 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const {
1642 Json::Value result = INHERITED::toJSON(urlDataManager); 1650 Json::Value result = INHERITED::toJSON(urlDataManager);
1643 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); 1651 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
1644 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); 1652 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
1645 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); 1653 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA);
1654 if (gShowShortDesc) {
1655 SkString desc;
1656 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc , fRect)->c_str());
1657 }
1646 return result; 1658 return result;
1647 } 1659 }
1648 1660
1649 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command, 1661 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command,
1650 UrlDataManager& urlDataManager) { 1662 UrlDataManager& urlDataManager) {
1651 SkRect rect; 1663 SkRect rect;
1652 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); 1664 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect);
1653 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]), 1665 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]),
1654 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol()); 1666 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol());
1655 } 1667 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 } 1741 }
1730 1742
1731 Json::Value SkDrawAnnotationCommand::toJSON(UrlDataManager& urlDataManager) cons t { 1743 Json::Value SkDrawAnnotationCommand::toJSON(UrlDataManager& urlDataManager) cons t {
1732 Json::Value result = INHERITED::toJSON(urlDataManager); 1744 Json::Value result = INHERITED::toJSON(urlDataManager);
1733 1745
1734 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); 1746 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
1735 result["key"] = Json::Value(fKey.c_str()); 1747 result["key"] = Json::Value(fKey.c_str());
1736 if (fValue.get()) { 1748 if (fValue.get()) {
1737 // TODO: dump out the "value" 1749 // TODO: dump out the "value"
1738 } 1750 }
1751 if (gShowShortDesc) {
1752 SkString desc;
1753 str_append(&desc, fRect)->appendf(" %s", fKey.c_str());
1754 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(desc.c_str());
1755 }
1739 return result; 1756 return result;
1740 } 1757 }
1741 1758
1742 SkDrawAnnotationCommand* SkDrawAnnotationCommand::fromJSON(Json::Value& command, 1759 SkDrawAnnotationCommand* SkDrawAnnotationCommand::fromJSON(Json::Value& command,
1743 UrlDataManager& urlDa taManager) { 1760 UrlDataManager& urlDa taManager) {
1744 SkRect rect; 1761 SkRect rect;
1745 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); 1762 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect);
1746 sk_sp<SkData> data(nullptr); // TODO: extract "value" from the Json 1763 sk_sp<SkData> data(nullptr); // TODO: extract "value" from the Json
1747 return new SkDrawAnnotationCommand(rect, command["key"].asCString(), data); 1764 return new SkDrawAnnotationCommand(rect, command["key"].asCString(), data);
1748 } 1765 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(fSrc); 1950 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(fSrc);
1934 } 1951 }
1935 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); 1952 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
1936 if (fPaintPtr != nullptr) { 1953 if (fPaintPtr != nullptr) {
1937 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, ur lDataManager); 1954 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, ur lDataManager);
1938 } 1955 }
1939 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { 1956 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
1940 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); 1957 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
1941 } 1958 }
1942 } 1959 }
1960 if (gShowShortDesc) {
1961 SkString desc;
1962 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc , fDst)->c_str());
1963 }
1943 return result; 1964 return result;
1944 } 1965 }
1945 1966
1946 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command, 1967 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command,
1947 UrlDataManager& urlDa taManager) { 1968 UrlDataManager& urlDa taManager) {
1948 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD ataManager); 1969 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD ataManager);
1949 if (bitmap == nullptr) { 1970 if (bitmap == nullptr) {
1950 return nullptr; 1971 return nullptr;
1951 } 1972 }
1952 SkRect dst; 1973 SkRect dst;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(*fSrc.get()); 2121 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(*fSrc.get());
2101 } 2122 }
2102 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); 2123 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
2103 if (fPaint.isValid()) { 2124 if (fPaint.isValid()) {
2104 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager); 2125 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
2105 } 2126 }
2106 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { 2127 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
2107 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); 2128 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
2108 } 2129 }
2109 } 2130 }
2131 if (gShowShortDesc) {
2132 SkString desc;
2133 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc , fDst)->c_str());
2134 }
2110 return result; 2135 return result;
2111 } 2136 }
2112 2137
2113 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command, 2138 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command,
2114 UrlDataManager& urlData Manager) { 2139 UrlDataManager& urlData Manager) {
2115 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur lDataManager); 2140 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur lDataManager);
2116 if (image == nullptr) { 2141 if (image == nullptr) {
2117 return nullptr; 2142 return nullptr;
2118 } 2143 }
2119 SkRect dst; 2144 SkRect dst;
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2774 } 2799 }
2775 2800
2776 void SkDrawRectCommand::execute(SkCanvas* canvas) const { 2801 void SkDrawRectCommand::execute(SkCanvas* canvas) const {
2777 canvas->drawRect(fRect, fPaint); 2802 canvas->drawRect(fRect, fPaint);
2778 } 2803 }
2779 2804
2780 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const { 2805 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const {
2781 Json::Value result = INHERITED::toJSON(urlDataManager); 2806 Json::Value result = INHERITED::toJSON(urlDataManager);
2782 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); 2807 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
2783 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager ); 2808 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager );
2809 if (gShowShortDesc) {
2810 SkString desc;
2811 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc , fRect)->c_str());
2812 }
2784 return result; 2813 return result;
2785 } 2814 }
2786 2815
2787 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command, 2816 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command,
2788 UrlDataManager& urlDataManager) { 2817 UrlDataManager& urlDataManager) {
2789 SkRect coords; 2818 SkRect coords;
2790 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); 2819 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
2791 SkPaint paint; 2820 SkPaint paint;
2792 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint); 2821 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2793 return new SkDrawRectCommand(coords, paint); 2822 return new SkDrawRectCommand(coords, paint);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
3169 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); 3198 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
3170 return result; 3199 return result;
3171 } 3200 }
3172 3201
3173 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, 3202 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3174 UrlDataManager& urlDataManager) { 3203 UrlDataManager& urlDataManager) {
3175 SkMatrix matrix; 3204 SkMatrix matrix;
3176 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3205 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3177 return new SkSetMatrixCommand(matrix); 3206 return new SkSetMatrixCommand(matrix);
3178 } 3207 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698