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

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

Issue 2105113002: add annotations to debugger (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes 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 8
9 #include "SkDrawCommand.h" 9 #include "SkDrawCommand.h"
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 const char* SkDrawCommand::GetCommandString(OpType type) { 172 const char* SkDrawCommand::GetCommandString(OpType type) {
173 switch (type) { 173 switch (type) {
174 case kBeginDrawPicture_OpType: return "BeginDrawPicture"; 174 case kBeginDrawPicture_OpType: return "BeginDrawPicture";
175 case kClipPath_OpType: return "ClipPath"; 175 case kClipPath_OpType: return "ClipPath";
176 case kClipRegion_OpType: return "ClipRegion"; 176 case kClipRegion_OpType: return "ClipRegion";
177 case kClipRect_OpType: return "ClipRect"; 177 case kClipRect_OpType: return "ClipRect";
178 case kClipRRect_OpType: return "ClipRRect"; 178 case kClipRRect_OpType: return "ClipRRect";
179 case kConcat_OpType: return "Concat"; 179 case kConcat_OpType: return "Concat";
180 case kDrawAnnotation_OpType: return "drawAnnotation";
180 case kDrawBitmap_OpType: return "DrawBitmap"; 181 case kDrawBitmap_OpType: return "DrawBitmap";
181 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; 182 case kDrawBitmapNine_OpType: return "DrawBitmapNine";
182 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; 183 case kDrawBitmapRect_OpType: return "DrawBitmapRect";
183 case kDrawClear_OpType: return "DrawClear"; 184 case kDrawClear_OpType: return "DrawClear";
184 case kDrawDRRect_OpType: return "DrawDRRect"; 185 case kDrawDRRect_OpType: return "DrawDRRect";
185 case kDrawImage_OpType: return "DrawImage"; 186 case kDrawImage_OpType: return "DrawImage";
186 case kDrawImageRect_OpType: return "DrawImageRect"; 187 case kDrawImageRect_OpType: return "DrawImageRect";
187 case kDrawOval_OpType: return "DrawOval"; 188 case kDrawOval_OpType: return "DrawOval";
188 case kDrawPaint_OpType: return "DrawPaint"; 189 case kDrawPaint_OpType: return "DrawPaint";
189 case kDrawPatch_OpType: return "DrawPatch"; 190 case kDrawPatch_OpType: return "DrawPatch";
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 static SkTHashMap<SkString, FROM_JSON> factories; 229 static SkTHashMap<SkString, FROM_JSON> factories;
229 static bool initialized = false; 230 static bool initialized = false;
230 if (!initialized) { 231 if (!initialized) {
231 initialized = true; 232 initialized = true;
232 INSTALL_FACTORY(Restore); 233 INSTALL_FACTORY(Restore);
233 INSTALL_FACTORY(ClipPath); 234 INSTALL_FACTORY(ClipPath);
234 INSTALL_FACTORY(ClipRegion); 235 INSTALL_FACTORY(ClipRegion);
235 INSTALL_FACTORY(ClipRect); 236 INSTALL_FACTORY(ClipRect);
236 INSTALL_FACTORY(ClipRRect); 237 INSTALL_FACTORY(ClipRRect);
237 INSTALL_FACTORY(Concat); 238 INSTALL_FACTORY(Concat);
239 INSTALL_FACTORY(DrawAnnotation);
238 INSTALL_FACTORY(DrawBitmap); 240 INSTALL_FACTORY(DrawBitmap);
239 INSTALL_FACTORY(DrawBitmapRect); 241 INSTALL_FACTORY(DrawBitmapRect);
240 INSTALL_FACTORY(DrawBitmapNine); 242 INSTALL_FACTORY(DrawBitmapNine);
241 INSTALL_FACTORY(DrawImage); 243 INSTALL_FACTORY(DrawImage);
242 INSTALL_FACTORY(DrawImageRect); 244 INSTALL_FACTORY(DrawImageRect);
243 INSTALL_FACTORY(DrawOval); 245 INSTALL_FACTORY(DrawOval);
244 INSTALL_FACTORY(DrawPaint); 246 INSTALL_FACTORY(DrawPaint);
245 INSTALL_FACTORY(DrawPath); 247 INSTALL_FACTORY(DrawPath);
246 INSTALL_FACTORY(DrawPoints); 248 INSTALL_FACTORY(DrawPoints);
247 INSTALL_FACTORY(DrawText); 249 INSTALL_FACTORY(DrawText);
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); 1707 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
1706 return result; 1708 return result;
1707 } 1709 }
1708 1710
1709 SkConcatCommand* SkConcatCommand::fromJSON(Json::Value& command, UrlDataManager& urlDataManager) { 1711 SkConcatCommand* SkConcatCommand::fromJSON(Json::Value& command, UrlDataManager& urlDataManager) {
1710 SkMatrix matrix; 1712 SkMatrix matrix;
1711 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 1713 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
1712 return new SkConcatCommand(matrix); 1714 return new SkConcatCommand(matrix);
1713 } 1715 }
1714 1716
1717 ////
1718
1719 SkDrawAnnotationCommand::SkDrawAnnotationCommand(const SkRect& rect, const char key[],
1720 sk_sp<SkData> value)
1721 : INHERITED(kDrawAnnotation_OpType)
1722 , fRect(rect)
1723 , fKey(key)
1724 , fValue(std::move(value))
1725 {}
1726
1727 void SkDrawAnnotationCommand::execute(SkCanvas* canvas) const {
1728 canvas->drawAnnotation(fRect, fKey.c_str(), fValue);
1729 }
1730
1731 Json::Value SkDrawAnnotationCommand::toJSON(UrlDataManager& urlDataManager) cons t {
1732 Json::Value result = INHERITED::toJSON(urlDataManager);
1733
1734 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
1735 result["key"] = Json::Value(fKey.c_str());
1736 if (fValue.get()) {
1737 // TODO: dump out the "value"
1738 }
1739 return result;
1740 }
1741
1742 SkDrawAnnotationCommand* SkDrawAnnotationCommand::fromJSON(Json::Value& command,
1743 UrlDataManager& urlDa taManager) {
1744 SkRect rect;
1745 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect);
1746 sk_sp<SkData> data(nullptr); // TODO: extract "value" from the Json
1747 return new SkDrawAnnotationCommand(rect, command["key"].asCString(), data);
1748 }
1749
1750 ////
1751
1715 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, 1752 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
1716 const SkPaint* paint) 1753 const SkPaint* paint)
1717 : INHERITED(kDrawBitmap_OpType) { 1754 : INHERITED(kDrawBitmap_OpType) {
1718 fBitmap = bitmap; 1755 fBitmap = bitmap;
1719 fLeft = left; 1756 fLeft = left;
1720 fTop = top; 1757 fTop = top;
1721 if (paint) { 1758 if (paint) {
1722 fPaint = *paint; 1759 fPaint = *paint;
1723 fPaintPtr = &fPaint; 1760 fPaintPtr = &fPaint;
1724 } else { 1761 } else {
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
3132 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); 3169 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
3133 return result; 3170 return result;
3134 } 3171 }
3135 3172
3136 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, 3173 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3137 UrlDataManager& urlDataManager) { 3174 UrlDataManager& urlDataManager) {
3138 SkMatrix matrix; 3175 SkMatrix matrix;
3139 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3176 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3140 return new SkSetMatrixCommand(matrix); 3177 return new SkSetMatrixCommand(matrix);
3141 } 3178 }
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