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