aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-14 13:53:53 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-14 13:53:53 +0000
commit791f12e6cf558e0dd1689fbb0a6b5eddac9f42ad (patch)
tree9505692c2a103db80fea30c516a7d3057e40542f
parent024e523a5ff78ec4d86d0b373bfb9adf8978ef4d (diff)
Move SkPaint::toString from debugger to SkPaint
-rw-r--r--debugger/SkObjectParser.cpp174
-rw-r--r--include/core/SkPaint.h2
-rw-r--r--src/core/SkComposeShader.cpp2
-rw-r--r--src/core/SkPaint.cpp181
-rw-r--r--src/effects/SkLayerDrawLooper.cpp2
5 files changed, 185 insertions, 176 deletions
diff --git a/debugger/SkObjectParser.cpp b/debugger/SkObjectParser.cpp
index c53d3b5a31..a15a3207d3 100644
--- a/debugger/SkObjectParser.cpp
+++ b/debugger/SkObjectParser.cpp
@@ -92,177 +92,15 @@ SkString* SkObjectParser::IRectToString(const SkIRect& rect) {
}
SkString* SkObjectParser::MatrixToString(const SkMatrix& matrix) {
- SkString* mMatrix = new SkString("SkMatrix: (");
- for (int i = 0; i < 8; i++) {
- mMatrix->appendScalar(matrix.get(i));
- mMatrix->append("), (");
- }
- mMatrix->appendScalar(matrix.get(8));
- mMatrix->append(")");
- return mMatrix;
+ SkString* str = new SkString("SkMatrix: ");
+ matrix.toString(str);
+ return str;
}
SkString* SkObjectParser::PaintToString(const SkPaint& paint) {
- SkString* mPaint = new SkString("<dl><dt>SkPaint:</dt><dd><dl>");
-
- SkTypeface* typeface = paint.getTypeface();
- if (NULL != typeface) {
- SkDynamicMemoryWStream ostream;
- typeface->serialize(&ostream);
- SkAutoTUnref<SkData> data(ostream.copyToData());
-
- SkMemoryStream stream(data);
- SkFontDescriptor descriptor(&stream);
-
- mPaint->append("<dt>Font Family Name:</dt><dd>");
- mPaint->append(descriptor.getFamilyName());
- mPaint->append("</dd><dt>Font Full Name:</dt><dd>");
- mPaint->append(descriptor.getFullName());
- mPaint->append("</dd><dt>Font PS Name:</dt><dd>");
- mPaint->append(descriptor.getPostscriptName());
- mPaint->append("</dd><dt>Font File Name:</dt><dd>");
- mPaint->append(descriptor.getFontFileName());
- mPaint->append("</dd>");
- }
-
- mPaint->append("<dt>TextSize:</dt><dd>");
- mPaint->appendScalar(paint.getTextSize());
- mPaint->append("</dd>");
-
- mPaint->append("<dt>TextScaleX:</dt><dd>");
- mPaint->appendScalar(paint.getTextScaleX());
- mPaint->append("</dd>");
-
- mPaint->append("<dt>TextSkewX:</dt><dd>");
- mPaint->appendScalar(paint.getTextSkewX());
- mPaint->append("</dd>");
-
- SkPathEffect* pathEffect = paint.getPathEffect();
- if (NULL != pathEffect) {
- mPaint->append("<dt>PathEffect:</dt><dd>");
- mPaint->append("</dd>");
- }
-
- SkShader* shader = paint.getShader();
- if (NULL != shader) {
- mPaint->append("<dt>Shader:</dt><dd>");
- SkDEVCODE(shader->toString(mPaint);)
- mPaint->append("</dd>");
- }
-
- SkXfermode* xfer = paint.getXfermode();
- if (NULL != xfer) {
- mPaint->append("<dt>Xfermode:</dt><dd>");
- SkDEVCODE(xfer->toString(mPaint);)
- mPaint->append("</dd>");
- }
-
- SkMaskFilter* maskFilter = paint.getMaskFilter();
- if (NULL != maskFilter) {
- mPaint->append("<dt>MaskFilter:</dt><dd>");
- mPaint->append("</dd>");
- }
-
- SkColorFilter* colorFilter = paint.getColorFilter();
- if (NULL != colorFilter) {
- mPaint->append("<dt>ColorFilter:</dt><dd>");
- mPaint->append("</dd>");
- }
-
- SkRasterizer* rasterizer = paint.getRasterizer();
- if (NULL != rasterizer) {
- mPaint->append("<dt>Rasterizer:</dt><dd>");
- mPaint->append("</dd>");
- }
-
- SkDrawLooper* looper = paint.getLooper();
- if (NULL != looper) {
- mPaint->append("<dt>DrawLooper:</dt><dd>");
- SkDEVCODE(looper->toString(mPaint);)
- mPaint->append("</dd>");
- }
-
- SkImageFilter* imageFilter = paint.getImageFilter();
- if (NULL != imageFilter) {
- mPaint->append("<dt>ImageFilter:</dt><dd>");
- mPaint->append("</dd>");
- }
-
- SkAnnotation* annotation = paint.getAnnotation();
- if (NULL != annotation) {
- mPaint->append("<dt>Annotation:</dt><dd>");
- mPaint->append("</dd>");
- }
-
- mPaint->append("<dt>Color:</dt><dd>0x");
- SkColor color = paint.getColor();
- mPaint->appendHex(color);
- mPaint->append("</dd>");
-
- mPaint->append("<dt>Stroke Width:</dt><dd>");
- mPaint->appendScalar(paint.getStrokeWidth());
- mPaint->append("</dd>");
-
- mPaint->append("<dt>Stroke Miter:</dt><dd>");
- mPaint->appendScalar(paint.getStrokeMiter());
- mPaint->append("</dd>");
-
- mPaint->append("<dt>Flags:</dt><dd>(");
- if (paint.getFlags()) {
- bool needSeparator = false;
- SkAddFlagToString(mPaint, paint.isAntiAlias(), "AntiAlias", &needSeparator);
- SkAddFlagToString(mPaint, paint.isFilterBitmap(), "FilterBitmap", &needSeparator);
- SkAddFlagToString(mPaint, paint.isDither(), "Dither", &needSeparator);
- SkAddFlagToString(mPaint, paint.isUnderlineText(), "UnderlineText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isStrikeThruText(), "StrikeThruText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isFakeBoldText(), "FakeBoldText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isLinearText(), "LinearText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isSubpixelText(), "SubpixelText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isDevKernText(), "DevKernText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isLCDRenderText(), "LCDRenderText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isEmbeddedBitmapText(),
- "EmbeddedBitmapText", &needSeparator);
- SkAddFlagToString(mPaint, paint.isAutohinted(), "Autohinted", &needSeparator);
- SkAddFlagToString(mPaint, paint.isVerticalText(), "VerticalText", &needSeparator);
- SkAddFlagToString(mPaint, SkToBool(paint.getFlags() & SkPaint::kGenA8FromLCD_Flag),
- "GenA8FromLCD", &needSeparator);
- } else {
- mPaint->append("None");
- }
- mPaint->append(")</dd>");
-
- mPaint->append("<dt>TextAlign:</dt><dd>");
- static const char* gTextAlignStrings[SkPaint::kAlignCount] = { "Left", "Center", "Right" };
- mPaint->append(gTextAlignStrings[paint.getTextAlign()]);
- mPaint->append("</dd>");
-
- mPaint->append("<dt>CapType:</dt><dd>");
- static const char* gStrokeCapStrings[SkPaint::kCapCount] = { "Butt", "Round", "Square" };
- mPaint->append(gStrokeCapStrings[paint.getStrokeCap()]);
- mPaint->append("</dd>");
-
- mPaint->append("<dt>JoinType:</dt><dd>");
- static const char* gJoinStrings[SkPaint::kJoinCount] = { "Miter", "Round", "Bevel" };
- mPaint->append(gJoinStrings[paint.getStrokeJoin()]);
- mPaint->append("</dd>");
-
- mPaint->append("<dt>Style:</dt><dd>");
- static const char* gStyleStrings[SkPaint::kStyleCount] = { "Fill", "Stroke", "StrokeAndFill" };
- mPaint->append(gStyleStrings[paint.getStyle()]);
- mPaint->append("</dd>");
-
- mPaint->append("<dt>TextEncoding:</dt><dd>");
- static const char* gTextEncodingStrings[] = { "UTF8", "UTF16", "UTF32", "GlyphID" };
- mPaint->append(gTextEncodingStrings[paint.getTextEncoding()]);
- mPaint->append("</dd>");
-
- mPaint->append("<dt>Hinting:</dt><dd>");
- static const char* gHintingStrings[] = { "None", "Slight", "Normal", "Full" };
- mPaint->append(gHintingStrings[paint.getHinting()]);
- mPaint->append("</dd>");
-
- mPaint->append("</dd></dl></dl>");
- return mPaint;
+ SkString* str = new SkString;
+ paint.toString(str);
+ return str;
}
SkString* SkObjectParser::PathToString(const SkPath& path) {
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index b63845982f..35ce3e60c4 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -925,6 +925,8 @@ public:
const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
Style) const;
+ SkDEVCODE(void toString(SkString*) const;)
+
private:
SkTypeface* fTypeface;
SkScalar fTextSize;
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index fd3b21e2ac..de0ffdb24a 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -183,7 +183,7 @@ void SkComposeShader::toString(SkString* str) const {
str->append(" ShaderB: ");
fShaderB->toString(str);
str->append(" Xfermode: ");
- // TODO: add "fMode->toString(str);" once SkXfermode::toString is added
+ fMode->toString(str);
this->INHERITED::toString(str);
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 8acdd8db28..b715524a42 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -8,27 +8,31 @@
#include "SkPaint.h"
#include "SkAnnotation.h"
+#include "SkAutoKern.h"
#include "SkColorFilter.h"
+#include "SkData.h"
#include "SkDeviceProperties.h"
+#include "SkFontDescriptor.h"
#include "SkFontHost.h"
+#include "SkGlyphCache.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
#include "SkMaskGamma.h"
+#include "SkOrderedReadBuffer.h"
+#include "SkOrderedWriteBuffer.h"
+#include "SkPaintDefaults.h"
#include "SkPathEffect.h"
#include "SkRasterizer.h"
-#include "SkShader.h"
#include "SkScalar.h"
#include "SkScalerContext.h"
+#include "SkShader.h"
+#include "SkStringUtils.h"
#include "SkStroke.h"
#include "SkTextFormatParams.h"
#include "SkTextToPathIter.h"
#include "SkTypeface.h"
#include "SkXfermode.h"
-#include "SkAutoKern.h"
-#include "SkGlyphCache.h"
-#include "SkPaintDefaults.h"
-#include "SkOrderedReadBuffer.h"
-#include "SkOrderedWriteBuffer.h"
+
// define this to get a printf for out-of-range parameter in setters
// e.g. setTextSize(-1)
@@ -2213,6 +2217,171 @@ const SkRect& SkPaint::doComputeFastBounds(const SkRect& origSrc,
return *storage;
}
+#ifdef SK_DEVELOPER
+void SkPaint::toString(SkString* str) const {
+ str->append("<dl><dt>SkPaint:</dt><dd><dl>");
+
+ SkTypeface* typeface = this->getTypeface();
+ if (NULL != typeface) {
+ SkDynamicMemoryWStream ostream;
+ typeface->serialize(&ostream);
+ SkAutoTUnref<SkData> data(ostream.copyToData());
+
+ SkMemoryStream stream(data);
+ SkFontDescriptor descriptor(&stream);
+
+ str->append("<dt>Font Family Name:</dt><dd>");
+ str->append(descriptor.getFamilyName());
+ str->append("</dd><dt>Font Full Name:</dt><dd>");
+ str->append(descriptor.getFullName());
+ str->append("</dd><dt>Font PS Name:</dt><dd>");
+ str->append(descriptor.getPostscriptName());
+ str->append("</dd><dt>Font File Name:</dt><dd>");
+ str->append(descriptor.getFontFileName());
+ str->append("</dd>");
+ }
+
+ str->append("<dt>TextSize:</dt><dd>");
+ str->appendScalar(this->getTextSize());
+ str->append("</dd>");
+
+ str->append("<dt>TextScaleX:</dt><dd>");
+ str->appendScalar(this->getTextScaleX());
+ str->append("</dd>");
+
+ str->append("<dt>TextSkewX:</dt><dd>");
+ str->appendScalar(this->getTextSkewX());
+ str->append("</dd>");
+
+ SkPathEffect* pathEffect = this->getPathEffect();
+ if (NULL != pathEffect) {
+ str->append("<dt>PathEffect:</dt><dd>");
+ str->append("</dd>");
+ }
+
+ SkShader* shader = this->getShader();
+ if (NULL != shader) {
+ str->append("<dt>Shader:</dt><dd>");
+ SkDEVCODE(shader->toString(str);)
+ str->append("</dd>");
+ }
+
+ SkXfermode* xfer = this->getXfermode();
+ if (NULL != xfer) {
+ str->append("<dt>Xfermode:</dt><dd>");
+ SkDEVCODE(xfer->toString(str);)
+ str->append("</dd>");
+ }
+
+ SkMaskFilter* maskFilter = this->getMaskFilter();
+ if (NULL != maskFilter) {
+ str->append("<dt>MaskFilter:</dt><dd>");
+ str->append("</dd>");
+ }
+
+ SkColorFilter* colorFilter = this->getColorFilter();
+ if (NULL != colorFilter) {
+ str->append("<dt>ColorFilter:</dt><dd>");
+ str->append("</dd>");
+ }
+
+ SkRasterizer* rasterizer = this->getRasterizer();
+ if (NULL != rasterizer) {
+ str->append("<dt>Rasterizer:</dt><dd>");
+ str->append("</dd>");
+ }
+
+ SkDrawLooper* looper = this->getLooper();
+ if (NULL != looper) {
+ str->append("<dt>DrawLooper:</dt><dd>");
+ SkDEVCODE(looper->toString(str);)
+ str->append("</dd>");
+ }
+
+ SkImageFilter* imageFilter = this->getImageFilter();
+ if (NULL != imageFilter) {
+ str->append("<dt>ImageFilter:</dt><dd>");
+ str->append("</dd>");
+ }
+
+ SkAnnotation* annotation = this->getAnnotation();
+ if (NULL != annotation) {
+ str->append("<dt>Annotation:</dt><dd>");
+ str->append("</dd>");
+ }
+
+ str->append("<dt>Color:</dt><dd>0x");
+ SkColor color = this->getColor();
+ str->appendHex(color);
+ str->append("</dd>");
+
+ str->append("<dt>Stroke Width:</dt><dd>");
+ str->appendScalar(this->getStrokeWidth());
+ str->append("</dd>");
+
+ str->append("<dt>Stroke Miter:</dt><dd>");
+ str->appendScalar(this->getStrokeMiter());
+ str->append("</dd>");
+
+ str->append("<dt>Flags:</dt><dd>(");
+ if (this->getFlags()) {
+ bool needSeparator = false;
+ SkAddFlagToString(str, this->isAntiAlias(), "AntiAlias", &needSeparator);
+ SkAddFlagToString(str, this->isFilterBitmap(), "FilterBitmap", &needSeparator);
+ SkAddFlagToString(str, this->isDither(), "Dither", &needSeparator);
+ SkAddFlagToString(str, this->isUnderlineText(), "UnderlineText", &needSeparator);
+ SkAddFlagToString(str, this->isStrikeThruText(), "StrikeThruText", &needSeparator);
+ SkAddFlagToString(str, this->isFakeBoldText(), "FakeBoldText", &needSeparator);
+ SkAddFlagToString(str, this->isLinearText(), "LinearText", &needSeparator);
+ SkAddFlagToString(str, this->isSubpixelText(), "SubpixelText", &needSeparator);
+ SkAddFlagToString(str, this->isDevKernText(), "DevKernText", &needSeparator);
+ SkAddFlagToString(str, this->isLCDRenderText(), "LCDRenderText", &needSeparator);
+ SkAddFlagToString(str, this->isEmbeddedBitmapText(),
+ "EmbeddedBitmapText", &needSeparator);
+ SkAddFlagToString(str, this->isAutohinted(), "Autohinted", &needSeparator);
+ SkAddFlagToString(str, this->isVerticalText(), "VerticalText", &needSeparator);
+ SkAddFlagToString(str, SkToBool(this->getFlags() & SkPaint::kGenA8FromLCD_Flag),
+ "GenA8FromLCD", &needSeparator);
+ } else {
+ str->append("None");
+ }
+ str->append(")</dd>");
+
+ str->append("<dt>TextAlign:</dt><dd>");
+ static const char* gTextAlignStrings[SkPaint::kAlignCount] = { "Left", "Center", "Right" };
+ str->append(gTextAlignStrings[this->getTextAlign()]);
+ str->append("</dd>");
+
+ str->append("<dt>CapType:</dt><dd>");
+ static const char* gStrokeCapStrings[SkPaint::kCapCount] = { "Butt", "Round", "Square" };
+ str->append(gStrokeCapStrings[this->getStrokeCap()]);
+ str->append("</dd>");
+
+ str->append("<dt>JoinType:</dt><dd>");
+ static const char* gJoinStrings[SkPaint::kJoinCount] = { "Miter", "Round", "Bevel" };
+ str->append(gJoinStrings[this->getStrokeJoin()]);
+ str->append("</dd>");
+
+ str->append("<dt>Style:</dt><dd>");
+ static const char* gStyleStrings[SkPaint::kStyleCount] = { "Fill", "Stroke", "StrokeAndFill" };
+ str->append(gStyleStrings[this->getStyle()]);
+ str->append("</dd>");
+
+ str->append("<dt>TextEncoding:</dt><dd>");
+ static const char* gTextEncodingStrings[] = { "UTF8", "UTF16", "UTF32", "GlyphID" };
+ str->append(gTextEncodingStrings[this->getTextEncoding()]);
+ str->append("</dd>");
+
+ str->append("<dt>Hinting:</dt><dd>");
+ static const char* gHintingStrings[] = { "None", "Slight", "Normal", "Full" };
+ str->append(gHintingStrings[this->getHinting()]);
+ str->append("</dd>");
+
+ str->append("</dd></dl></dl>");
+}
+#endif
+
+
///////////////////////////////////////////////////////////////////////////////
static bool has_thick_frame(const SkPaint& paint) {
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp
index 0ffc08ecf6..ddd73083ad 100644
--- a/src/effects/SkLayerDrawLooper.cpp
+++ b/src/effects/SkLayerDrawLooper.cpp
@@ -338,7 +338,7 @@ void SkLayerDrawLooper::toString(SkString* str) const {
str->append("false ");
}
- // TODO: add "rec->fPaint.toString(str);" when SkPaint::toString is added
+ rec->fPaint.toString(str);
rec = rec->fNext;
}
}