chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 8 | #ifndef SKOBJECTPARSER_H_ |
| 9 | #define SKOBJECTPARSER_H_ |
| 10 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 11 | #include "SkCanvas.h" |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 12 | #include "SkString.h" |
tfarina@chromium.org | e8d29f5 | 2012-09-29 13:17:16 +0000 | [diff] [blame] | 13 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 14 | /** \class SkObjectParser |
| 15 | |
| 16 | The ObjectParser is used to return string information about parameters |
| 17 | in each draw command. |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 18 | */ |
| 19 | class SkObjectParser { |
| 20 | public: |
| 21 | |
| 22 | /** |
robertphillips | 80af645 | 2015-08-24 08:27:38 -0700 | [diff] [blame] | 23 | Returns a string about a bitmap's bounds and colortype. |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 24 | @param bitmap SkBitmap |
| 25 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 26 | static SkString* BitmapToString(const SkBitmap& bitmap); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 27 | |
| 28 | /** |
robertphillips | 80af645 | 2015-08-24 08:27:38 -0700 | [diff] [blame] | 29 | Returns a string about a image |
| 30 | @param image SkImage |
| 31 | */ |
| 32 | static SkString* ImageToString(const SkImage* image); |
| 33 | |
| 34 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 35 | Returns a string representation of a boolean. |
| 36 | @param doAA boolean |
| 37 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 38 | static SkString* BoolToString(bool doAA); |
| 39 | |
| 40 | /** |
| 41 | Returns a string representation of the text pointer passed in. |
| 42 | */ |
| 43 | static SkString* CustomTextToString(const char* text); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | Returns a string representation of an integer with the text parameter |
| 47 | at the front of the string. |
| 48 | @param x integer |
| 49 | @param text |
| 50 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 51 | static SkString* IntToString(int x, const char* text); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 52 | /** |
| 53 | Returns a string representation of the SkIRects coordinates. |
| 54 | @param rect SkIRect |
| 55 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 56 | static SkString* IRectToString(const SkIRect& rect); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | Returns a string representation of an SkMatrix's contents |
| 60 | @param matrix SkMatrix |
| 61 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 62 | static SkString* MatrixToString(const SkMatrix& matrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | Returns a string representation of an SkPaint's color |
| 66 | @param paint SkPaint |
| 67 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 68 | static SkString* PaintToString(const SkPaint& paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | Returns a string representation of a SkPath's points. |
| 72 | @param path SkPath |
| 73 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 74 | static SkString* PathToString(const SkPath& path); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | Returns a string representation of the points in the point array. |
| 78 | @param pts[] Array of SkPoints |
| 79 | @param count |
| 80 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 81 | static SkString* PointsToString(const SkPoint pts[], size_t count); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 82 | |
| 83 | /** |
chudy@google.com | 92b11f6 | 2012-08-01 16:10:06 +0000 | [diff] [blame] | 84 | Returns a string representation of the SkCanvas PointMode enum. |
| 85 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 86 | static SkString* PointModeToString(SkCanvas::PointMode mode); |
chudy@google.com | 92b11f6 | 2012-08-01 16:10:06 +0000 | [diff] [blame] | 87 | |
| 88 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 89 | Returns a string representation of the SkRects coordinates. |
| 90 | @param rect SkRect |
| 91 | */ |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 92 | static SkString* RectToString(const SkRect& rect, const char* title = nullptr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 93 | |
| 94 | /** |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 95 | Returns a string representation of an SkRRect. |
| 96 | @param rrect SkRRect |
| 97 | */ |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 98 | static SkString* RRectToString(const SkRRect& rrect, const char* title = nullptr); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 99 | |
| 100 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 101 | Returns a string representation of the SkRegion enum. |
| 102 | @param op SkRegion::op enum |
| 103 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 104 | static SkString* RegionOpToString(SkRegion::Op op); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | Returns a string representation of the SkRegion. |
| 108 | @param region SkRegion |
| 109 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 110 | static SkString* RegionToString(const SkRegion& region); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 111 | |
| 112 | /** |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 113 | Returns a string representation of the SkCanvas::SaveLayerFlags enum. |
| 114 | @param flags SkCanvas::SaveLayerFlags enum |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 115 | */ |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 116 | static SkString* SaveLayerFlagsToString(uint32_t saveLayerFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | Returns a string representation of an SkScalar with the text parameter |
| 120 | at the front of the string. |
| 121 | @param x SkScalar |
| 122 | @param text |
| 123 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 124 | static SkString* ScalarToString(SkScalar x, const char* text); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | Returns a string representation of the char pointer passed in. |
| 128 | @param text const void* that will be cast to a char* |
| 129 | */ |
bungeman@google.com | 428fc4a | 2013-03-07 20:30:32 +0000 | [diff] [blame] | 130 | static SkString* TextToString(const void* text, size_t byteLength, |
| 131 | SkPaint::TextEncoding encoding); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | #endif |