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

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: remove global 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"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs" 84 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs"
86 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions" 85 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions"
87 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs" 86 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs"
88 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" 87 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font"
89 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" 88 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface"
90 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics" 89 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics"
91 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors" 90 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors"
92 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords" 91 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords"
93 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality" 92 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality"
94 93
94 #define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "short-desc"
95
95 #define SKDEBUGCANVAS_VERB_MOVE "move" 96 #define SKDEBUGCANVAS_VERB_MOVE "move"
96 #define SKDEBUGCANVAS_VERB_LINE "line" 97 #define SKDEBUGCANVAS_VERB_LINE "line"
97 #define SKDEBUGCANVAS_VERB_QUAD "quad" 98 #define SKDEBUGCANVAS_VERB_QUAD "quad"
98 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" 99 #define SKDEBUGCANVAS_VERB_CUBIC "cubic"
99 #define SKDEBUGCANVAS_VERB_CONIC "conic" 100 #define SKDEBUGCANVAS_VERB_CONIC "conic"
100 #define SKDEBUGCANVAS_VERB_CLOSE "close" 101 #define SKDEBUGCANVAS_VERB_CLOSE "close"
101 102
102 #define SKDEBUGCANVAS_STYLE_FILL "fill" 103 #define SKDEBUGCANVAS_STYLE_FILL "fill"
103 #define SKDEBUGCANVAS_STYLE_STROKE "stroke" 104 #define SKDEBUGCANVAS_STYLE_STROKE "stroke"
104 #define SKDEBUGCANVAS_STYLE_STROKEANDFILL "strokeAndFill" 105 #define SKDEBUGCANVAS_STYLE_STROKEANDFILL "strokeAndFill"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul" 152 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul"
152 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul" 153 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul"
153 154
154 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none" 155 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none"
155 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low" 156 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low"
156 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium" 157 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium"
157 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high" 158 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high"
158 159
159 typedef SkDrawCommand* (*FROM_JSON)(Json::Value&, UrlDataManager&); 160 typedef SkDrawCommand* (*FROM_JSON)(Json::Value&, UrlDataManager&);
160 161
162 static SkString* str_append(SkString* str, const SkRect& r) {
163 str->appendf(" [%g %g %g %g]", r.left(), r.top(), r.right(), r.bottom());
164 return str;
165 }
166
161 // TODO(chudy): Refactor into non subclass model. 167 // TODO(chudy): Refactor into non subclass model.
162 168
163 SkDrawCommand::SkDrawCommand(OpType type) 169 SkDrawCommand::SkDrawCommand(OpType type)
164 : fOpType(type) 170 : fOpType(type)
165 , fVisible(true) { 171 , fVisible(true) {
166 } 172 }
167 173
168 SkDrawCommand::~SkDrawCommand() { 174 SkDrawCommand::~SkDrawCommand() {
169 fInfo.deleteAll(); 175 fInfo.deleteAll();
170 } 176 }
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1642
1637 void SkClipRectCommand::execute(SkCanvas* canvas) const { 1643 void SkClipRectCommand::execute(SkCanvas* canvas) const {
1638 canvas->clipRect(fRect, fOp, fDoAA); 1644 canvas->clipRect(fRect, fOp, fDoAA);
1639 } 1645 }
1640 1646
1641 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const { 1647 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const {
1642 Json::Value result = INHERITED::toJSON(urlDataManager); 1648 Json::Value result = INHERITED::toJSON(urlDataManager);
1643 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); 1649 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
1644 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); 1650 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
1645 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); 1651 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA);
1652
1653 SkString desc;
1654 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fR ect)->c_str());
1655
1646 return result; 1656 return result;
1647 } 1657 }
1648 1658
1649 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command, 1659 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command,
1650 UrlDataManager& urlDataManager) { 1660 UrlDataManager& urlDataManager) {
1651 SkRect rect; 1661 SkRect rect;
1652 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); 1662 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect);
1653 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]), 1663 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]),
1654 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol()); 1664 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol());
1655 } 1665 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 } 1749 }
1740 1750
1741 Json::Value SkDrawAnnotationCommand::toJSON(UrlDataManager& urlDataManager) cons t { 1751 Json::Value SkDrawAnnotationCommand::toJSON(UrlDataManager& urlDataManager) cons t {
1742 Json::Value result = INHERITED::toJSON(urlDataManager); 1752 Json::Value result = INHERITED::toJSON(urlDataManager);
1743 1753
1744 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); 1754 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
1745 result["key"] = Json::Value(fKey.c_str()); 1755 result["key"] = Json::Value(fKey.c_str());
1746 if (fValue.get()) { 1756 if (fValue.get()) {
1747 // TODO: dump out the "value" 1757 // TODO: dump out the "value"
1748 } 1758 }
1759
1760 SkString desc;
1761 str_append(&desc, fRect)->appendf(" %s", fKey.c_str());
1762 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(desc.c_str());
1763
1749 return result; 1764 return result;
1750 } 1765 }
1751 1766
1752 SkDrawAnnotationCommand* SkDrawAnnotationCommand::fromJSON(Json::Value& command, 1767 SkDrawAnnotationCommand* SkDrawAnnotationCommand::fromJSON(Json::Value& command,
1753 UrlDataManager& urlDa taManager) { 1768 UrlDataManager& urlDa taManager) {
1754 SkRect rect; 1769 SkRect rect;
1755 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); 1770 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect);
1756 sk_sp<SkData> data(nullptr); // TODO: extract "value" from the Json 1771 sk_sp<SkData> data(nullptr); // TODO: extract "value" from the Json
1757 return new SkDrawAnnotationCommand(rect, command["key"].asCString(), data); 1772 return new SkDrawAnnotationCommand(rect, command["key"].asCString(), data);
1758 } 1773 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(fSrc); 1958 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(fSrc);
1944 } 1959 }
1945 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); 1960 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
1946 if (fPaintPtr != nullptr) { 1961 if (fPaintPtr != nullptr) {
1947 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, ur lDataManager); 1962 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, ur lDataManager);
1948 } 1963 }
1949 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { 1964 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
1950 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); 1965 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
1951 } 1966 }
1952 } 1967 }
1968
1969 SkString desc;
1970 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fD st)->c_str());
1971
1953 return result; 1972 return result;
1954 } 1973 }
1955 1974
1956 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command, 1975 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command,
1957 UrlDataManager& urlDa taManager) { 1976 UrlDataManager& urlDa taManager) {
1958 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD ataManager); 1977 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD ataManager);
1959 if (bitmap == nullptr) { 1978 if (bitmap == nullptr) {
1960 return nullptr; 1979 return nullptr;
1961 } 1980 }
1962 SkRect dst; 1981 SkRect dst;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(*fSrc.get()); 2129 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(*fSrc.get());
2111 } 2130 }
2112 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); 2131 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
2113 if (fPaint.isValid()) { 2132 if (fPaint.isValid()) {
2114 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager); 2133 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
2115 } 2134 }
2116 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { 2135 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
2117 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); 2136 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
2118 } 2137 }
2119 } 2138 }
2139
2140 SkString desc;
2141 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fD st)->c_str());
2142
2120 return result; 2143 return result;
2121 } 2144 }
2122 2145
2123 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command, 2146 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command,
2124 UrlDataManager& urlData Manager) { 2147 UrlDataManager& urlData Manager) {
2125 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur lDataManager); 2148 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur lDataManager);
2126 if (image == nullptr) { 2149 if (image == nullptr) {
2127 return nullptr; 2150 return nullptr;
2128 } 2151 }
2129 SkRect dst; 2152 SkRect dst;
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 } 2807 }
2785 2808
2786 void SkDrawRectCommand::execute(SkCanvas* canvas) const { 2809 void SkDrawRectCommand::execute(SkCanvas* canvas) const {
2787 canvas->drawRect(fRect, fPaint); 2810 canvas->drawRect(fRect, fPaint);
2788 } 2811 }
2789 2812
2790 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const { 2813 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const {
2791 Json::Value result = INHERITED::toJSON(urlDataManager); 2814 Json::Value result = INHERITED::toJSON(urlDataManager);
2792 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); 2815 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
2793 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager ); 2816 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager );
2817
2818 SkString desc;
2819 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fR ect)->c_str());
2820
2794 return result; 2821 return result;
2795 } 2822 }
2796 2823
2797 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command, 2824 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command,
2798 UrlDataManager& urlDataManager) { 2825 UrlDataManager& urlDataManager) {
2799 SkRect coords; 2826 SkRect coords;
2800 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); 2827 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
2801 SkPaint paint; 2828 SkPaint paint;
2802 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint); 2829 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2803 return new SkDrawRectCommand(coords, paint); 2830 return new SkDrawRectCommand(coords, paint);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); 3206 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
3180 return result; 3207 return result;
3181 } 3208 }
3182 3209
3183 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, 3210 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3184 UrlDataManager& urlDataManager) { 3211 UrlDataManager& urlDataManager) {
3185 SkMatrix matrix; 3212 SkMatrix matrix;
3186 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3213 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3187 return new SkSetMatrixCommand(matrix); 3214 return new SkSetMatrixCommand(matrix);
3188 } 3215 }
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