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 8 #ifndef SKOBJECTPARSER_H_ 9 #define SKOBJECTPARSER_H_ 10 11 #include "SkCanvas.h" 12 #include "SkString.h" 13 14 /** \class SkObjectParser 15 16 The ObjectParser is used to return string information about parameters 17 in each draw command. 18 */ 19 class SkObjectParser { 20 public: 21 22 /** 23 Returns a string about a bitmap's bounds and colortype. 24 @param bitmap SkBitmap 25 */ 26 static SkString* BitmapToString(const SkBitmap& bitmap); 27 28 /** 29 Returns a string about a image 30 @param image SkImage 31 */ 32 static SkString* ImageToString(const SkImage* image); 33 34 /** 35 Returns a string representation of a boolean. 36 @param doAA boolean 37 */ 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); 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 */ 51 static SkString* IntToString(int x, const char* text); 52 /** 53 Returns a string representation of the SkIRects coordinates. 54 @param rect SkIRect 55 */ 56 static SkString* IRectToString(const SkIRect& rect); 57 58 /** 59 Returns a string representation of an SkMatrix's contents 60 @param matrix SkMatrix 61 */ 62 static SkString* MatrixToString(const SkMatrix& matrix); 63 64 /** 65 Returns a string representation of an SkPaint's color 66 @param paint SkPaint 67 */ 68 static SkString* PaintToString(const SkPaint& paint); 69 70 /** 71 Returns a string representation of a SkPath's points. 72 @param path SkPath 73 */ 74 static SkString* PathToString(const SkPath& path); 75 76 /** 77 Returns a string representation of the points in the point array. 78 @param pts[] Array of SkPoints 79 @param count 80 */ 81 static SkString* PointsToString(const SkPoint pts[], size_t count); 82 83 /** 84 Returns a string representation of the SkCanvas PointMode enum. 85 */ 86 static SkString* PointModeToString(SkCanvas::PointMode mode); 87 88 /** 89 Returns a string representation of the SkRects coordinates. 90 @param rect SkRect 91 */ 92 static SkString* RectToString(const SkRect& rect, const char* title = nullptr); 93 94 /** 95 Returns a string representation of an SkRRect. 96 @param rrect SkRRect 97 */ 98 static SkString* RRectToString(const SkRRect& rrect, const char* title = nullptr); 99 100 /** 101 Returns a string representation of the SkRegion enum. 102 @param op SkRegion::op enum 103 */ 104 static SkString* RegionOpToString(SkRegion::Op op); 105 106 /** 107 Returns a string representation of the SkRegion. 108 @param region SkRegion 109 */ 110 static SkString* RegionToString(const SkRegion& region); 111 112 /** 113 Returns a string representation of the SkCanvas::SaveLayerFlags enum. 114 @param flags SkCanvas::SaveLayerFlags enum 115 */ 116 static SkString* SaveLayerFlagsToString(uint32_t saveLayerFlags); 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 */ 124 static SkString* ScalarToString(SkScalar x, const char* text); 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 */ 130 static SkString* TextToString(const void* text, size_t byteLength, 131 SkPaint::TextEncoding encoding); 132 }; 133 134 #endif 135