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 | /** |
| 23 | Returns a string about a bitmaps bounds and config. |
| 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 | /** |
| 29 | Returns a string representation of a boolean. |
| 30 | @param doAA boolean |
| 31 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 32 | static SkString* BoolToString(bool doAA); |
| 33 | |
| 34 | /** |
| 35 | Returns a string representation of the text pointer passed in. |
| 36 | */ |
| 37 | static SkString* CustomTextToString(const char* text); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | Returns a string representation of an integer with the text parameter |
| 41 | at the front of the string. |
| 42 | @param x integer |
| 43 | @param text |
| 44 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 45 | static SkString* IntToString(int x, const char* text); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 46 | /** |
| 47 | Returns a string representation of the SkIRects coordinates. |
| 48 | @param rect SkIRect |
| 49 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 50 | static SkString* IRectToString(const SkIRect& rect); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | Returns a string representation of an SkMatrix's contents |
| 54 | @param matrix SkMatrix |
| 55 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 56 | static SkString* MatrixToString(const SkMatrix& matrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | Returns a string representation of an SkPaint's color |
| 60 | @param paint SkPaint |
| 61 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 62 | static SkString* PaintToString(const SkPaint& paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | Returns a string representation of a SkPath's points. |
| 66 | @param path SkPath |
| 67 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 68 | static SkString* PathToString(const SkPath& path); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | Returns a string representation of the points in the point array. |
| 72 | @param pts[] Array of SkPoints |
| 73 | @param count |
| 74 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 75 | static SkString* PointsToString(const SkPoint pts[], size_t count); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 76 | |
| 77 | /** |
chudy@google.com | 92b11f6 | 2012-08-01 16:10:06 +0000 | [diff] [blame] | 78 | Returns a string representation of the SkCanvas PointMode enum. |
| 79 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 80 | static SkString* PointModeToString(SkCanvas::PointMode mode); |
chudy@google.com | 92b11f6 | 2012-08-01 16:10:06 +0000 | [diff] [blame] | 81 | |
| 82 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 83 | Returns a string representation of the SkRects coordinates. |
| 84 | @param rect SkRect |
| 85 | */ |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 86 | static SkString* RectToString(const SkRect& rect, const char* title = NULL); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 87 | |
| 88 | /** |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 89 | Returns a string representation of an SkRRect. |
| 90 | @param rrect SkRRect |
| 91 | */ |
| 92 | static SkString* RRectToString(const SkRRect& rrect, const char* title = NULL); |
| 93 | |
| 94 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 95 | Returns a string representation of the SkRegion enum. |
| 96 | @param op SkRegion::op enum |
| 97 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 98 | static SkString* RegionOpToString(SkRegion::Op op); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | Returns a string representation of the SkRegion. |
| 102 | @param region SkRegion |
| 103 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 104 | static SkString* RegionToString(const SkRegion& region); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | Returns a string representation of the SkCanvas::SaveFlags enum. |
| 108 | @param flags SkCanvas::SaveFlags enum |
| 109 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 110 | static SkString* SaveFlagsToString(SkCanvas::SaveFlags flags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | Returns a string representation of an SkScalar with the text parameter |
| 114 | at the front of the string. |
| 115 | @param x SkScalar |
| 116 | @param text |
| 117 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 118 | static SkString* ScalarToString(SkScalar x, const char* text); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | Returns a string representation of the char pointer passed in. |
| 122 | @param text const void* that will be cast to a char* |
| 123 | */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 124 | static SkString* TextToString(const void* text, size_t byteLength); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | #endif |