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 */
19class SkObjectParser {
20public:
21
22    /**
23        Returns a string about a bitmaps bounds and colortype.
24        @param bitmap  SkBitmap
25    */
26    static SkString* BitmapToString(const SkBitmap& bitmap);
27
28    /**
29        Returns a string representation of a boolean.
30        @param doAA  boolean
31     */
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);
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     */
45    static SkString* IntToString(int x, const char* text);
46    /**
47        Returns a string representation of the SkIRects coordinates.
48        @param rect  SkIRect
49     */
50    static SkString* IRectToString(const SkIRect& rect);
51
52    /**
53        Returns a string representation of an SkMatrix's contents
54        @param matrix  SkMatrix
55     */
56    static SkString* MatrixToString(const SkMatrix& matrix);
57
58    /**
59        Returns a string representation of an SkPaint's color
60        @param paint  SkPaint
61     */
62    static SkString* PaintToString(const SkPaint& paint);
63
64    /**
65        Returns a string representation of a SkPath's points.
66        @param path  SkPath
67     */
68    static SkString* PathToString(const SkPath& path);
69
70    /**
71        Returns a string representation of the points in the point array.
72        @param pts[]  Array of SkPoints
73        @param count
74     */
75    static SkString* PointsToString(const SkPoint pts[], size_t count);
76
77    /**
78        Returns a string representation of the SkCanvas PointMode enum.
79     */
80    static SkString* PointModeToString(SkCanvas::PointMode mode);
81
82    /**
83        Returns a string representation of the SkRects coordinates.
84        @param rect  SkRect
85     */
86    static SkString* RectToString(const SkRect& rect, const char* title = NULL);
87
88    /**
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    /**
95        Returns a string representation of the SkRegion enum.
96        @param op  SkRegion::op enum
97     */
98    static SkString* RegionOpToString(SkRegion::Op op);
99
100    /**
101        Returns a string representation of the SkRegion.
102        @param region  SkRegion
103     */
104    static SkString* RegionToString(const SkRegion& region);
105
106    /**
107        Returns a string representation of the SkCanvas::SaveFlags enum.
108        @param flags  SkCanvas::SaveFlags enum
109     */
110    static SkString* SaveFlagsToString(SkCanvas::SaveFlags flags);
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     */
118    static SkString* ScalarToString(SkScalar x, const char* text);
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     */
124    static SkString* TextToString(const void* text, size_t byteLength,
125                                  SkPaint::TextEncoding encoding);
126};
127
128#endif
129