blob: 16cd623b8d6e5ea896157be45f44a5ebccd69cba [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
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.com902ebe52012-06-29 14:21:22 +000013#include "SkCanvas.h"
chudy@google.com97cee972012-08-07 20:41:37 +000014#include "SkString.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000015/** \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 */
21class SkObjectParser {
22public:
23
24 /**
25 Returns a string about a bitmaps bounds and config.
26 @param bitmap SkBitmap
27 */
chudy@google.com97cee972012-08-07 20:41:37 +000028 static SkString* BitmapToString(const SkBitmap& bitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +000029
30 /**
31 Returns a string representation of a boolean.
32 @param doAA boolean
33 */
chudy@google.com97cee972012-08-07 20:41:37 +000034 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.com902ebe52012-06-29 14:21:22 +000040
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.com97cee972012-08-07 20:41:37 +000047 static SkString* IntToString(int x, const char* text);
chudy@google.com902ebe52012-06-29 14:21:22 +000048 /**
49 Returns a string representation of the SkIRects coordinates.
50 @param rect SkIRect
51 */
chudy@google.com97cee972012-08-07 20:41:37 +000052 static SkString* IRectToString(const SkIRect& rect);
chudy@google.com902ebe52012-06-29 14:21:22 +000053
54 /**
55 Returns a string representation of an SkMatrix's contents
56 @param matrix SkMatrix
57 */
chudy@google.com97cee972012-08-07 20:41:37 +000058 static SkString* MatrixToString(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +000059
60 /**
61 Returns a string representation of an SkPaint's color
62 @param paint SkPaint
63 */
chudy@google.com97cee972012-08-07 20:41:37 +000064 static SkString* PaintToString(const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +000065
66 /**
67 Returns a string representation of a SkPath's points.
68 @param path SkPath
69 */
chudy@google.com97cee972012-08-07 20:41:37 +000070 static SkString* PathToString(const SkPath& path);
chudy@google.com902ebe52012-06-29 14:21:22 +000071
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.com97cee972012-08-07 20:41:37 +000077 static SkString* PointsToString(const SkPoint pts[], size_t count);
chudy@google.com902ebe52012-06-29 14:21:22 +000078
79 /**
chudy@google.com92b11f62012-08-01 16:10:06 +000080 Returns a string representation of the SkCanvas PointMode enum.
81 */
chudy@google.com97cee972012-08-07 20:41:37 +000082 static SkString* PointModeToString(SkCanvas::PointMode mode);
chudy@google.com92b11f62012-08-01 16:10:06 +000083
84 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000085 Returns a string representation of the SkRects coordinates.
86 @param rect SkRect
87 */
chudy@google.com97cee972012-08-07 20:41:37 +000088 static SkString* RectToString(const SkRect& rect);
chudy@google.com902ebe52012-06-29 14:21:22 +000089
90 /**
91 Returns a string representation of the SkRegion enum.
92 @param op SkRegion::op enum
93 */
chudy@google.com97cee972012-08-07 20:41:37 +000094 static SkString* RegionOpToString(SkRegion::Op op);
chudy@google.com902ebe52012-06-29 14:21:22 +000095
96 /**
97 Returns a string representation of the SkRegion.
98 @param region SkRegion
99 */
chudy@google.com97cee972012-08-07 20:41:37 +0000100 static SkString* RegionToString(const SkRegion& region);
chudy@google.com902ebe52012-06-29 14:21:22 +0000101
102 /**
103 Returns a string representation of the SkCanvas::SaveFlags enum.
104 @param flags SkCanvas::SaveFlags enum
105 */
chudy@google.com97cee972012-08-07 20:41:37 +0000106 static SkString* SaveFlagsToString(SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000107
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.com97cee972012-08-07 20:41:37 +0000114 static SkString* ScalarToString(SkScalar x, const char* text);
chudy@google.com902ebe52012-06-29 14:21:22 +0000115
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.com97cee972012-08-07 20:41:37 +0000120 static SkString* TextToString(const void* text, size_t byteLength);
chudy@google.com902ebe52012-06-29 14:21:22 +0000121};
122
123#endif