Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 | |
| 1728 void SkDrawAnnotationCommand::execute(SkCanvas* canvas) const { | |
| 1729 canvas->drawAnnotation(fRect, fKey.c_str(), fValue); | |
| 1730 } | |
| 1731 | |
|
robertphillips
2016/06/28 21:30:37
You can just remove this override from this class
reed1
2016/06/29 01:40:00
Done.
| |
| 1732 bool SkDrawAnnotationCommand::render(SkCanvas* canvas) const { | |
| 1733 // render_bitmap(canvas, fBitmap); | |
| 1734 return true; | |
| 1735 } | |
| 1736 | |
| 1737 Json::Value SkDrawAnnotationCommand::toJSON(UrlDataManager& urlDataManager) cons t { | |
| 1738 Json::Value result = INHERITED::toJSON(urlDataManager); | |
| 1739 | |
| 1740 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); | |
| 1741 result["key"] = Json::Value(fKey.c_str()); | |
| 1742 if (fValue.get()) { | |
| 1743 // result["value"] = encoded; | |
| 1744 } | |
| 1745 return result; | |
| 1746 } | |
| 1747 | |
| 1748 SkDrawAnnotationCommand* SkDrawAnnotationCommand::fromJSON(Json::Value& command, | |
|
robertphillips
2016/06/28 21:30:37
line this up ?
reed1
2016/06/29 01:40:00
Done.
| |
| 1749 UrlDataManager& urlDataManage r) { | |
| 1750 SkRect rect; | |
| 1751 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); | |
|
robertphillips
2016/06/28 21:30:37
nullptr seems less than optimal here
reed1
2016/06/29 01:40:00
Not sure what you mean. Added a TODO to in the fut
| |
| 1752 return new SkDrawAnnotationCommand(rect, command["key"].asCString(), nullptr ); | |
| 1753 } | |
| 1754 | |
| 1755 //// | |
| 1756 | |
| 1715 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, | 1757 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
| 1716 const SkPaint* paint) | 1758 const SkPaint* paint) |
| 1717 : INHERITED(kDrawBitmap_OpType) { | 1759 : INHERITED(kDrawBitmap_OpType) { |
| 1718 fBitmap = bitmap; | 1760 fBitmap = bitmap; |
| 1719 fLeft = left; | 1761 fLeft = left; |
| 1720 fTop = top; | 1762 fTop = top; |
| 1721 if (paint) { | 1763 if (paint) { |
| 1722 fPaint = *paint; | 1764 fPaint = *paint; |
| 1723 fPaintPtr = &fPaint; | 1765 fPaintPtr = &fPaint; |
| 1724 } else { | 1766 } else { |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3132 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 3174 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
| 3133 return result; | 3175 return result; |
| 3134 } | 3176 } |
| 3135 | 3177 |
| 3136 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3178 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
| 3137 UrlDataManager& urlDataManager) { | 3179 UrlDataManager& urlDataManager) { |
| 3138 SkMatrix matrix; | 3180 SkMatrix matrix; |
| 3139 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3181 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
| 3140 return new SkSetMatrixCommand(matrix); | 3182 return new SkSetMatrixCommand(matrix); |
| 3141 } | 3183 } |
| OLD | NEW |