/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkObjectParser.h"
/* TODO(chudy): Replace all std::strings with char */
std::string SkObjectParser::BitmapToString(const SkBitmap& bitmap) {
const char* mBitmap("SkBitmap: Data unavailable");
return mBitmap;
}
std::string SkObjectParser::BoolToString(bool doAA) {
if (doAA) {
return "bool doAA: True";
} else {
return "bool doAA: False";
}
}
std::string SkObjectParser::IntToString(int x, const char* text) {
std::stringstream ss;
ss << text << x;
return ss.str();
}
std::string SkObjectParser::IRectToString(const SkIRect& rect) {
std::stringstream ss;
ss << "SkIRect: ";
ss << "L: " << rect.left() << ",";
ss << "T: " << rect.top() << ",";
ss << "R: " << rect.right() << ",";
ss << "B: " << rect.bottom();
return ss.str();
}
std::string SkObjectParser::MatrixToString(const SkMatrix& matrix) {
std::stringstream ss;
/* NOTE(chudy): Cleaner looking than loops. */
/* TODO(chudy): Decide whether to remove html part in order to really
* seperate view / model. */
ss << "SkMatrix:
(";
ss << matrix.get(0) << "), (";
ss << matrix.get(1) << "), (";
ss << matrix.get(2) << "),
(";
ss << matrix.get(3) << "), (";
ss << matrix.get(4) << "), (";
ss << matrix.get(5) << "),
(";
ss << matrix.get(6) << "), (";
ss << matrix.get(7) << "), (";
ss << matrix.get(8) << ")";
return ss.str();
}
std::string SkObjectParser::PaintToString(const SkPaint& paint) {
std::stringstream ss;
SkColor color = paint.getColor();
ss << "SkPaint: 0x" << std::hex << std::uppercase << color;
return ss.str();
}
std::string SkObjectParser::PathToString(const SkPath& path) {
std::string mPath;
std::stringstream ss;
mPath.append("SkPath: ");
for (int i=0; i