1902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com/*
2902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * Copyright 2012 Google Inc.
3902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com *
4902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * Use of this source code is governed by a BSD-style license that can be
5902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * found in the LICENSE file.
6902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */
7902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
8902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#ifndef SKOBJECTPARSER_H_
9902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#define SKOBJECTPARSER_H_
10902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
11902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include "SkCanvas.h"
1297cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com#include "SkString.h"
13e8d29f5058153d56423a9d44f278b15e0cc88c9atfarina@chromium.org
14902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com/** \class SkObjectParser
15902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
16902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    The ObjectParser is used to return string information about parameters
17902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    in each draw command.
18902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */
19902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.comclass SkObjectParser {
20902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.compublic:
21902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
22902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
23c77392ed58ec78ab19fa0e3ff99fb8110854fba2reed        Returns a string about a bitmaps bounds and colortype.
24902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param bitmap  SkBitmap
25902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    */
2697cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* BitmapToString(const SkBitmap& bitmap);
27902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
28902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
29902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of a boolean.
30902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param doAA  boolean
31902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
3297cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* BoolToString(bool doAA);
3397cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com
3497cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    /**
3597cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com        Returns a string representation of the text pointer passed in.
3697cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com     */
3797cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* CustomTextToString(const char* text);
38902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
39902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
40902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of an integer with the text parameter
41902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        at the front of the string.
42902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param x  integer
43902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param text
44902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
4597cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* IntToString(int x, const char* text);
46902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
47902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of the SkIRects coordinates.
48902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param rect  SkIRect
49902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
5097cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* IRectToString(const SkIRect& rect);
51902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
52902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
53902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of an SkMatrix's contents
54902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param matrix  SkMatrix
55902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
5697cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* MatrixToString(const SkMatrix& matrix);
57902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
58902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
59902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of an SkPaint's color
60902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param paint  SkPaint
61902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
6297cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* PaintToString(const SkPaint& paint);
63902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
64902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
65902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of a SkPath's points.
66902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param path  SkPath
67902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
6897cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* PathToString(const SkPath& path);
69902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
70902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
71902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of the points in the point array.
72902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param pts[]  Array of SkPoints
73902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param count
74902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
7597cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* PointsToString(const SkPoint pts[], size_t count);
76902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
77902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
7892b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com        Returns a string representation of the SkCanvas PointMode enum.
7992b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com     */
8097cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* PointModeToString(SkCanvas::PointMode mode);
8192b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com
8292b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com    /**
83902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of the SkRects coordinates.
84902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param rect  SkRect
85902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
8630d35f23ae390043462e2aa5fc6863a4621aa74drobertphillips@google.com    static SkString* RectToString(const SkRect& rect, const char* title = NULL);
8767baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com
8867baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com    /**
8967baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com        Returns a string representation of an SkRRect.
9067baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com        @param rrect  SkRRect
9167baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com     */
9267baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com    static SkString* RRectToString(const SkRRect& rrect, const char* title = NULL);
93902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
94902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
95902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of the SkRegion enum.
96902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param op  SkRegion::op enum
97902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
9897cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* RegionOpToString(SkRegion::Op op);
99902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
100902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
101902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of the SkRegion.
102902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param region  SkRegion
103902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
10497cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* RegionToString(const SkRegion& region);
105902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
106902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
107902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of the SkCanvas::SaveFlags enum.
108902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param flags  SkCanvas::SaveFlags enum
109902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
11097cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* SaveFlagsToString(SkCanvas::SaveFlags flags);
111902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
112902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
113902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of an SkScalar with the text parameter
114902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        at the front of the string.
115902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param x  SkScalar
116902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param text
117902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
11897cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    static SkString* ScalarToString(SkScalar x, const char* text);
119902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
120902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
121902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns a string representation of the char pointer passed in.
122902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param text  const void* that will be cast to a char*
123902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
124428fc4a37b66ac927d5b8c3a2938e578ea70cbb8bungeman@google.com    static SkString* TextToString(const void* text, size_t byteLength,
125428fc4a37b66ac927d5b8c3a2938e578ea70cbb8bungeman@google.com                                  SkPaint::TextEncoding encoding);
126902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com};
127902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
128902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#endif
129