blob: e30bd133ade6566c123ea0a649d764b2a0445ce8 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001/*
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.com902ebe52012-06-29 14:21:22 +00008#ifndef SKOBJECTPARSER_H_
9#define SKOBJECTPARSER_H_
10
chudy@google.com902ebe52012-06-29 14:21:22 +000011#include "SkCanvas.h"
chudy@google.com97cee972012-08-07 20:41:37 +000012#include "SkString.h"
tfarina@chromium.orge8d29f52012-09-29 13:17:16 +000013
chudy@google.com902ebe52012-06-29 14:21:22 +000014/** \class SkObjectParser
15
16 The ObjectParser is used to return string information about parameters
17 in each draw command.
chudy@google.com902ebe52012-06-29 14:21:22 +000018 */
19class SkObjectParser {
20public:
21
22 /**
23 Returns a string about a bitmaps bounds and config.
24 @param bitmap SkBitmap
25 */
chudy@google.com97cee972012-08-07 20:41:37 +000026 static SkString* BitmapToString(const SkBitmap& bitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +000027
28 /**
29 Returns a string representation of a boolean.
30 @param doAA boolean
31 */
chudy@google.com97cee972012-08-07 20:41:37 +000032 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.com902ebe52012-06-29 14:21:22 +000038
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.com97cee972012-08-07 20:41:37 +000045 static SkString* IntToString(int x, const char* text);
chudy@google.com902ebe52012-06-29 14:21:22 +000046 /**
47 Returns a string representation of the SkIRects coordinates.
48 @param rect SkIRect
49 */
chudy@google.com97cee972012-08-07 20:41:37 +000050 static SkString* IRectToString(const SkIRect& rect);
chudy@google.com902ebe52012-06-29 14:21:22 +000051
52 /**
53 Returns a string representation of an SkMatrix's contents
54 @param matrix SkMatrix
55 */
chudy@google.com97cee972012-08-07 20:41:37 +000056 static SkString* MatrixToString(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +000057
58 /**
59 Returns a string representation of an SkPaint's color
60 @param paint SkPaint
61 */
chudy@google.com97cee972012-08-07 20:41:37 +000062 static SkString* PaintToString(const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +000063
64 /**
65 Returns a string representation of a SkPath's points.
66 @param path SkPath
67 */
chudy@google.com97cee972012-08-07 20:41:37 +000068 static SkString* PathToString(const SkPath& path);
chudy@google.com902ebe52012-06-29 14:21:22 +000069
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.com97cee972012-08-07 20:41:37 +000075 static SkString* PointsToString(const SkPoint pts[], size_t count);
chudy@google.com902ebe52012-06-29 14:21:22 +000076
77 /**
chudy@google.com92b11f62012-08-01 16:10:06 +000078 Returns a string representation of the SkCanvas PointMode enum.
79 */
chudy@google.com97cee972012-08-07 20:41:37 +000080 static SkString* PointModeToString(SkCanvas::PointMode mode);
chudy@google.com92b11f62012-08-01 16:10:06 +000081
82 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000083 Returns a string representation of the SkRects coordinates.
84 @param rect SkRect
85 */
robertphillips@google.com30d35f22012-11-06 16:45:36 +000086 static SkString* RectToString(const SkRect& rect, const char* title = NULL);
chudy@google.com902ebe52012-06-29 14:21:22 +000087
88 /**
89 Returns a string representation of the SkRegion enum.
90 @param op SkRegion::op enum
91 */
chudy@google.com97cee972012-08-07 20:41:37 +000092 static SkString* RegionOpToString(SkRegion::Op op);
chudy@google.com902ebe52012-06-29 14:21:22 +000093
94 /**
95 Returns a string representation of the SkRegion.
96 @param region SkRegion
97 */
chudy@google.com97cee972012-08-07 20:41:37 +000098 static SkString* RegionToString(const SkRegion& region);
chudy@google.com902ebe52012-06-29 14:21:22 +000099
100 /**
101 Returns a string representation of the SkCanvas::SaveFlags enum.
102 @param flags SkCanvas::SaveFlags enum
103 */
chudy@google.com97cee972012-08-07 20:41:37 +0000104 static SkString* SaveFlagsToString(SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000105
106 /**
107 Returns a string representation of an SkScalar with the text parameter
108 at the front of the string.
109 @param x SkScalar
110 @param text
111 */
chudy@google.com97cee972012-08-07 20:41:37 +0000112 static SkString* ScalarToString(SkScalar x, const char* text);
chudy@google.com902ebe52012-06-29 14:21:22 +0000113
114 /**
115 Returns a string representation of the char pointer passed in.
116 @param text const void* that will be cast to a char*
117 */
chudy@google.com97cee972012-08-07 20:41:37 +0000118 static SkString* TextToString(const void* text, size_t byteLength);
chudy@google.com902ebe52012-06-29 14:21:22 +0000119};
120
121#endif