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 /** 2380af64519b9ba9bbbf07feb8d72968460bfa1422robertphillips Returns a string about a bitmap's 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 /** 2980af64519b9ba9bbbf07feb8d72968460bfa1422robertphillips Returns a string about a image 3080af64519b9ba9bbbf07feb8d72968460bfa1422robertphillips @param image SkImage 3180af64519b9ba9bbbf07feb8d72968460bfa1422robertphillips */ 3280af64519b9ba9bbbf07feb8d72968460bfa1422robertphillips static SkString* ImageToString(const SkImage* image); 3380af64519b9ba9bbbf07feb8d72968460bfa1422robertphillips 3480af64519b9ba9bbbf07feb8d72968460bfa1422robertphillips /** 35902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of a boolean. 36902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param doAA boolean 37902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 3897cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* BoolToString(bool doAA); 3997cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com 4097cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com /** 4197cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com Returns a string representation of the text pointer passed in. 4297cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com */ 4397cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* CustomTextToString(const char* text); 44902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 45902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 46902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of an integer with the text parameter 47902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com at the front of the string. 48902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param x integer 49902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param text 50902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 5197cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* IntToString(int x, const char* text); 52902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 53902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of the SkIRects coordinates. 54902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param rect SkIRect 55902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 5697cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* IRectToString(const SkIRect& rect); 57902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 58902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 59902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of an SkMatrix's contents 60902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param matrix SkMatrix 61902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 6297cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* MatrixToString(const SkMatrix& matrix); 63902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 64902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 65902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of an SkPaint's color 66902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param paint SkPaint 67902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 6897cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* PaintToString(const SkPaint& paint); 69902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 70902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 71902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of a SkPath's points. 72902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param path SkPath 73902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 7497cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* PathToString(const SkPath& path); 75902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 76902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 77902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of the points in the point array. 78902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param pts[] Array of SkPoints 79902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param count 80902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 8197cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* PointsToString(const SkPoint pts[], size_t count); 82902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 83902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 8492b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com Returns a string representation of the SkCanvas PointMode enum. 8592b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com */ 8697cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* PointModeToString(SkCanvas::PointMode mode); 8792b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com 8892b11f610376dea7192ade22dde31c8bb8ede76cchudy@google.com /** 89902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of the SkRects coordinates. 90902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param rect SkRect 91902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 9296fcdcc219d2a0d3579719b84b28bede76efba64halcanary static SkString* RectToString(const SkRect& rect, const char* title = nullptr); 9367baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com 9467baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com /** 9567baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com Returns a string representation of an SkRRect. 9667baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com @param rrect SkRRect 9767baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com */ 9896fcdcc219d2a0d3579719b84b28bede76efba64halcanary static SkString* RRectToString(const SkRRect& rrect, const char* title = nullptr); 99902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 100902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 101902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of the SkRegion enum. 102902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param op SkRegion::op enum 103902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 10497cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* RegionOpToString(SkRegion::Op op); 105902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 106902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 107902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of the SkRegion. 108902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param region SkRegion 109902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 11097cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* RegionToString(const SkRegion& region); 111902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 112902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 1134960eeec4a1f2a772654883d7f3615d47bcd5dc3reed Returns a string representation of the SkCanvas::SaveLayerFlags enum. 1144960eeec4a1f2a772654883d7f3615d47bcd5dc3reed @param flags SkCanvas::SaveLayerFlags enum 115902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 1164960eeec4a1f2a772654883d7f3615d47bcd5dc3reed static SkString* SaveLayerFlagsToString(uint32_t saveLayerFlags); 117902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 118902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 119902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of an SkScalar with the text parameter 120902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com at the front of the string. 121902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param x SkScalar 122902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param text 123902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 12497cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com static SkString* ScalarToString(SkScalar x, const char* text); 125902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 126902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com /** 127902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com Returns a string representation of the char pointer passed in. 128902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com @param text const void* that will be cast to a char* 129902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */ 130428fc4a37b66ac927d5b8c3a2938e578ea70cbb8bungeman@google.com static SkString* TextToString(const void* text, size_t byteLength, 131428fc4a37b66ac927d5b8c3a2938e578ea70cbb8bungeman@google.com SkPaint::TextEncoding encoding); 132902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com}; 133902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com 134902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#endif 135