blob: 9bdfad5e79e52c285627298d4365b324f224f6f5 [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 /**
robertphillips80af6452015-08-24 08:27:38 -070023 Returns a string about a bitmap's bounds and colortype.
chudy@google.com902ebe52012-06-29 14:21:22 +000024 @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 /**
robertphillips80af6452015-08-24 08:27:38 -070029 Returns a string about a image
30 @param image SkImage
31 */
32 static SkString* ImageToString(const SkImage* image);
33
34 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000035 Returns a string representation of a boolean.
36 @param doAA boolean
37 */
chudy@google.com97cee972012-08-07 20:41:37 +000038 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);
chudy@google.com902ebe52012-06-29 14:21:22 +000044
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 */
chudy@google.com97cee972012-08-07 20:41:37 +000051 static SkString* IntToString(int x, const char* text);
chudy@google.com902ebe52012-06-29 14:21:22 +000052 /**
53 Returns a string representation of the SkIRects coordinates.
54 @param rect SkIRect
55 */
chudy@google.com97cee972012-08-07 20:41:37 +000056 static SkString* IRectToString(const SkIRect& rect);
chudy@google.com902ebe52012-06-29 14:21:22 +000057
58 /**
59 Returns a string representation of an SkMatrix's contents
60 @param matrix SkMatrix
61 */
chudy@google.com97cee972012-08-07 20:41:37 +000062 static SkString* MatrixToString(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +000063
64 /**
65 Returns a string representation of an SkPaint's color
66 @param paint SkPaint
67 */
chudy@google.com97cee972012-08-07 20:41:37 +000068 static SkString* PaintToString(const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +000069
70 /**
71 Returns a string representation of a SkPath's points.
72 @param path SkPath
73 */
chudy@google.com97cee972012-08-07 20:41:37 +000074 static SkString* PathToString(const SkPath& path);
chudy@google.com902ebe52012-06-29 14:21:22 +000075
76 /**
77 Returns a string representation of the points in the point array.
78 @param pts[] Array of SkPoints
79 @param count
80 */
chudy@google.com97cee972012-08-07 20:41:37 +000081 static SkString* PointsToString(const SkPoint pts[], size_t count);
chudy@google.com902ebe52012-06-29 14:21:22 +000082
83 /**
chudy@google.com92b11f62012-08-01 16:10:06 +000084 Returns a string representation of the SkCanvas PointMode enum.
85 */
chudy@google.com97cee972012-08-07 20:41:37 +000086 static SkString* PointModeToString(SkCanvas::PointMode mode);
chudy@google.com92b11f62012-08-01 16:10:06 +000087
88 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000089 Returns a string representation of the SkRects coordinates.
90 @param rect SkRect
91 */
halcanary96fcdcc2015-08-27 07:41:13 -070092 static SkString* RectToString(const SkRect& rect, const char* title = nullptr);
chudy@google.com902ebe52012-06-29 14:21:22 +000093
94 /**
robertphillips@google.com67baba42013-01-02 20:20:31 +000095 Returns a string representation of an SkRRect.
96 @param rrect SkRRect
97 */
halcanary96fcdcc2015-08-27 07:41:13 -070098 static SkString* RRectToString(const SkRRect& rrect, const char* title = nullptr);
robertphillips@google.com67baba42013-01-02 20:20:31 +000099
100 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000101 Returns a string representation of the SkRegion enum.
102 @param op SkRegion::op enum
103 */
chudy@google.com97cee972012-08-07 20:41:37 +0000104 static SkString* RegionOpToString(SkRegion::Op op);
chudy@google.com902ebe52012-06-29 14:21:22 +0000105
106 /**
107 Returns a string representation of the SkRegion.
108 @param region SkRegion
109 */
chudy@google.com97cee972012-08-07 20:41:37 +0000110 static SkString* RegionToString(const SkRegion& region);
chudy@google.com902ebe52012-06-29 14:21:22 +0000111
112 /**
reed4960eee2015-12-18 07:09:18 -0800113 Returns a string representation of the SkCanvas::SaveLayerFlags enum.
114 @param flags SkCanvas::SaveLayerFlags enum
chudy@google.com902ebe52012-06-29 14:21:22 +0000115 */
reed4960eee2015-12-18 07:09:18 -0800116 static SkString* SaveLayerFlagsToString(uint32_t saveLayerFlags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000117
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 */
chudy@google.com97cee972012-08-07 20:41:37 +0000124 static SkString* ScalarToString(SkScalar x, const char* text);
chudy@google.com902ebe52012-06-29 14:21:22 +0000125
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 */
bungeman@google.com428fc4a2013-03-07 20:30:32 +0000130 static SkString* TextToString(const void* text, size_t byteLength,
131 SkPaint::TextEncoding encoding);
chudy@google.com902ebe52012-06-29 14:21:22 +0000132};
133
134#endif