1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/utils/SkDumpCanvas.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,537 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 +#include "SkDumpCanvas.h" 1.13 + 1.14 +#ifdef SK_DEVELOPER 1.15 +#include "SkPicture.h" 1.16 +#include "SkPixelRef.h" 1.17 +#include "SkRRect.h" 1.18 +#include "SkString.h" 1.19 +#include <stdarg.h> 1.20 +#include <stdio.h> 1.21 + 1.22 +// needed just to know that these are all subclassed from SkFlattenable 1.23 +#include "SkShader.h" 1.24 +#include "SkPathEffect.h" 1.25 +#include "SkXfermode.h" 1.26 +#include "SkColorFilter.h" 1.27 +#include "SkPathEffect.h" 1.28 +#include "SkMaskFilter.h" 1.29 + 1.30 +static void toString(const SkRect& r, SkString* str) { 1.31 + str->appendf("[%g,%g %g:%g]", 1.32 + SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), 1.33 + SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); 1.34 +} 1.35 + 1.36 +static void toString(const SkIRect& r, SkString* str) { 1.37 + str->appendf("[%d,%d %d:%d]", r.fLeft, r.fTop, r.width(), r.height()); 1.38 +} 1.39 + 1.40 +static void toString(const SkRRect& rrect, SkString* str) { 1.41 + SkRect r = rrect.getBounds(); 1.42 + str->appendf("[%g,%g %g:%g]", 1.43 + SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), 1.44 + SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); 1.45 + if (rrect.isOval()) { 1.46 + str->append("()"); 1.47 + } else if (rrect.isSimple()) { 1.48 + const SkVector& rad = rrect.getSimpleRadii(); 1.49 + str->appendf("(%g,%g)", rad.x(), rad.y()); 1.50 + } else if (rrect.isComplex()) { 1.51 + SkVector radii[4] = { 1.52 + rrect.radii(SkRRect::kUpperLeft_Corner), 1.53 + rrect.radii(SkRRect::kUpperRight_Corner), 1.54 + rrect.radii(SkRRect::kLowerRight_Corner), 1.55 + rrect.radii(SkRRect::kLowerLeft_Corner), 1.56 + }; 1.57 + str->appendf("(%g,%g %g,%g %g,%g %g,%g)", 1.58 + radii[0].x(), radii[0].y(), 1.59 + radii[1].x(), radii[1].y(), 1.60 + radii[2].x(), radii[2].y(), 1.61 + radii[3].x(), radii[3].y()); 1.62 + } 1.63 +} 1.64 + 1.65 +static void dumpVerbs(const SkPath& path, SkString* str) { 1.66 + SkPath::Iter iter(path, false); 1.67 + SkPoint pts[4]; 1.68 + for (;;) { 1.69 + switch (iter.next(pts, false)) { 1.70 + case SkPath::kMove_Verb: 1.71 + str->appendf(" M%g,%g", pts[0].fX, pts[0].fY); 1.72 + break; 1.73 + case SkPath::kLine_Verb: 1.74 + str->appendf(" L%g,%g", pts[0].fX, pts[0].fY); 1.75 + break; 1.76 + case SkPath::kQuad_Verb: 1.77 + str->appendf(" Q%g,%g,%g,%g", pts[1].fX, pts[1].fY, 1.78 + pts[2].fX, pts[2].fY); 1.79 + break; 1.80 + case SkPath::kCubic_Verb: 1.81 + str->appendf(" C%g,%g,%g,%g,%g,%g", pts[1].fX, pts[1].fY, 1.82 + pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY); 1.83 + break; 1.84 + case SkPath::kClose_Verb: 1.85 + str->append("X"); 1.86 + break; 1.87 + case SkPath::kDone_Verb: 1.88 + return; 1.89 + case SkPath::kConic_Verb: 1.90 + SkASSERT(0); 1.91 + break; 1.92 + } 1.93 + } 1.94 +} 1.95 + 1.96 +static void toString(const SkPath& path, SkString* str) { 1.97 + if (path.isEmpty()) { 1.98 + str->append("path:empty"); 1.99 + } else { 1.100 + toString(path.getBounds(), str); 1.101 +#if 1 1.102 + SkString s; 1.103 + dumpVerbs(path, &s); 1.104 + str->append(s.c_str()); 1.105 +#endif 1.106 + str->append("]"); 1.107 + str->prepend("path:["); 1.108 + } 1.109 +} 1.110 + 1.111 +static const char* toString(SkRegion::Op op) { 1.112 + static const char* gOpNames[] = { 1.113 + "DIFF", "SECT", "UNION", "XOR", "RDIFF", "REPLACE" 1.114 + }; 1.115 + return gOpNames[op]; 1.116 +} 1.117 + 1.118 +static void toString(const SkRegion& rgn, SkString* str) { 1.119 + str->append("Region:["); 1.120 + toString(rgn.getBounds(), str); 1.121 + str->append("]"); 1.122 + if (rgn.isComplex()) { 1.123 + str->append(".complex"); 1.124 + } 1.125 +} 1.126 + 1.127 +static const char* toString(SkCanvas::VertexMode vm) { 1.128 + static const char* gVMNames[] = { 1.129 + "TRIANGLES", "STRIP", "FAN" 1.130 + }; 1.131 + return gVMNames[vm]; 1.132 +} 1.133 + 1.134 +static const char* toString(SkCanvas::PointMode pm) { 1.135 + static const char* gPMNames[] = { 1.136 + "POINTS", "LINES", "POLYGON" 1.137 + }; 1.138 + return gPMNames[pm]; 1.139 +} 1.140 + 1.141 +static void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc, 1.142 + SkString* str) { 1.143 + // FIXME: this code appears to be untested - and probably unused - and probably wrong 1.144 + switch (enc) { 1.145 + case SkPaint::kUTF8_TextEncoding: 1.146 + str->appendf("\"%.*s\"%s", (int)SkTMax<size_t>(byteLen, 32), (const char*) text, 1.147 + byteLen > 32 ? "..." : ""); 1.148 + break; 1.149 + case SkPaint::kUTF16_TextEncoding: 1.150 + str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text, 1.151 + byteLen > 64 ? "..." : ""); 1.152 + break; 1.153 + case SkPaint::kUTF32_TextEncoding: 1.154 + str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text, 1.155 + byteLen > 128 ? "..." : ""); 1.156 + break; 1.157 + case SkPaint::kGlyphID_TextEncoding: 1.158 + str->append("<glyphs>"); 1.159 + break; 1.160 + 1.161 + default: 1.162 + SkASSERT(false); 1.163 + break; 1.164 + } 1.165 +} 1.166 + 1.167 +/////////////////////////////////////////////////////////////////////////////// 1.168 + 1.169 +#define WIDE_OPEN 16384 1.170 + 1.171 +SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : INHERITED(WIDE_OPEN, WIDE_OPEN) { 1.172 + fNestLevel = 0; 1.173 + SkSafeRef(dumper); 1.174 + fDumper = dumper; 1.175 +} 1.176 + 1.177 +SkDumpCanvas::~SkDumpCanvas() { 1.178 + SkSafeUnref(fDumper); 1.179 +} 1.180 + 1.181 +void SkDumpCanvas::dump(Verb verb, const SkPaint* paint, 1.182 + const char format[], ...) { 1.183 + static const size_t BUFFER_SIZE = 1024; 1.184 + 1.185 + char buffer[BUFFER_SIZE]; 1.186 + va_list args; 1.187 + va_start(args, format); 1.188 + vsnprintf(buffer, BUFFER_SIZE, format, args); 1.189 + va_end(args); 1.190 + 1.191 + if (fDumper) { 1.192 + fDumper->dump(this, verb, buffer, paint); 1.193 + } 1.194 +} 1.195 + 1.196 +/////////////////////////////////////////////////////////////////////////////// 1.197 + 1.198 +void SkDumpCanvas::willSave(SaveFlags flags) { 1.199 + this->dump(kSave_Verb, NULL, "save(0x%X)", flags); 1.200 + this->INHERITED::willSave(flags); 1.201 +} 1.202 + 1.203 +SkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, 1.204 + SaveFlags flags) { 1.205 + SkString str; 1.206 + str.printf("saveLayer(0x%X)", flags); 1.207 + if (bounds) { 1.208 + str.append(" bounds"); 1.209 + toString(*bounds, &str); 1.210 + } 1.211 + if (paint) { 1.212 + if (paint->getAlpha() != 0xFF) { 1.213 + str.appendf(" alpha:0x%02X", paint->getAlpha()); 1.214 + } 1.215 + if (paint->getXfermode()) { 1.216 + str.appendf(" xfermode:%p", paint->getXfermode()); 1.217 + } 1.218 + } 1.219 + this->dump(kSave_Verb, paint, str.c_str()); 1.220 + return this->INHERITED::willSaveLayer(bounds, paint, flags); 1.221 +} 1.222 + 1.223 +void SkDumpCanvas::willRestore() { 1.224 + this->dump(kRestore_Verb, NULL, "restore"); 1.225 + this->INHERITED::willRestore(); 1.226 +} 1.227 + 1.228 +void SkDumpCanvas::didTranslate(SkScalar dx, SkScalar dy) { 1.229 + this->dump(kMatrix_Verb, NULL, "translate(%g %g)", 1.230 + SkScalarToFloat(dx), SkScalarToFloat(dy)); 1.231 + this->INHERITED::didTranslate(dx, dy); 1.232 +} 1.233 + 1.234 +void SkDumpCanvas::didScale(SkScalar sx, SkScalar sy) { 1.235 + this->dump(kMatrix_Verb, NULL, "scale(%g %g)", 1.236 + SkScalarToFloat(sx), SkScalarToFloat(sy)); 1.237 + this->INHERITED::didScale(sx, sy); 1.238 +} 1.239 + 1.240 +void SkDumpCanvas::didRotate(SkScalar degrees) { 1.241 + this->dump(kMatrix_Verb, NULL, "rotate(%g)", SkScalarToFloat(degrees)); 1.242 + this->INHERITED::didRotate(degrees); 1.243 +} 1.244 + 1.245 +void SkDumpCanvas::didSkew(SkScalar sx, SkScalar sy) { 1.246 + this->dump(kMatrix_Verb, NULL, "skew(%g %g)", 1.247 + SkScalarToFloat(sx), SkScalarToFloat(sy)); 1.248 + this->INHERITED::didSkew(sx, sy); 1.249 +} 1.250 + 1.251 +void SkDumpCanvas::didConcat(const SkMatrix& matrix) { 1.252 + SkString str; 1.253 + matrix.toString(&str); 1.254 + this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str()); 1.255 + this->INHERITED::didConcat(matrix); 1.256 +} 1.257 + 1.258 +void SkDumpCanvas::didSetMatrix(const SkMatrix& matrix) { 1.259 + SkString str; 1.260 + matrix.toString(&str); 1.261 + this->dump(kMatrix_Verb, NULL, "setMatrix(%s)", str.c_str()); 1.262 + this->INHERITED::didSetMatrix(matrix); 1.263 +} 1.264 + 1.265 +/////////////////////////////////////////////////////////////////////////////// 1.266 + 1.267 +const char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) { 1.268 + return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW"; 1.269 +} 1.270 + 1.271 +void SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 1.272 + SkString str; 1.273 + toString(rect, &str); 1.274 + this->dump(kClip_Verb, NULL, "clipRect(%s %s %s)", str.c_str(), toString(op), 1.275 + EdgeStyleToAAString(edgeStyle)); 1.276 + this->INHERITED::onClipRect(rect, op, edgeStyle); 1.277 +} 1.278 + 1.279 +void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 1.280 + SkString str; 1.281 + toString(rrect, &str); 1.282 + this->dump(kClip_Verb, NULL, "clipRRect(%s %s %s)", str.c_str(), toString(op), 1.283 + EdgeStyleToAAString(edgeStyle)); 1.284 + this->INHERITED::onClipRRect(rrect, op, edgeStyle); 1.285 +} 1.286 + 1.287 +void SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 1.288 + SkString str; 1.289 + toString(path, &str); 1.290 + this->dump(kClip_Verb, NULL, "clipPath(%s %s %s)", str.c_str(), toString(op), 1.291 + EdgeStyleToAAString(edgeStyle)); 1.292 + this->INHERITED::onClipPath(path, op, edgeStyle); 1.293 +} 1.294 + 1.295 +void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 1.296 + SkString str; 1.297 + toString(deviceRgn, &str); 1.298 + this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(), 1.299 + toString(op)); 1.300 + this->INHERITED::onClipRegion(deviceRgn, op); 1.301 +} 1.302 + 1.303 +void SkDumpCanvas::onPushCull(const SkRect& cullRect) { 1.304 + SkString str; 1.305 + toString(cullRect, &str); 1.306 + this->dump(kCull_Verb, NULL, "pushCull(%s)", str.c_str()); 1.307 +} 1.308 + 1.309 +void SkDumpCanvas::onPopCull() { 1.310 + this->dump(kCull_Verb, NULL, "popCull()"); 1.311 +} 1.312 +/////////////////////////////////////////////////////////////////////////////// 1.313 + 1.314 +void SkDumpCanvas::drawPaint(const SkPaint& paint) { 1.315 + this->dump(kDrawPaint_Verb, &paint, "drawPaint()"); 1.316 +} 1.317 + 1.318 +void SkDumpCanvas::drawPoints(PointMode mode, size_t count, 1.319 + const SkPoint pts[], const SkPaint& paint) { 1.320 + this->dump(kDrawPoints_Verb, &paint, "drawPoints(%s, %d)", toString(mode), 1.321 + count); 1.322 +} 1.323 + 1.324 +void SkDumpCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { 1.325 + SkString str; 1.326 + toString(rect, &str); 1.327 + this->dump(kDrawOval_Verb, &paint, "drawOval(%s)", str.c_str()); 1.328 +} 1.329 + 1.330 +void SkDumpCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { 1.331 + SkString str; 1.332 + toString(rect, &str); 1.333 + this->dump(kDrawRect_Verb, &paint, "drawRect(%s)", str.c_str()); 1.334 +} 1.335 + 1.336 +void SkDumpCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { 1.337 + SkString str; 1.338 + toString(rrect, &str); 1.339 + this->dump(kDrawDRRect_Verb, &paint, "drawRRect(%s)", str.c_str()); 1.340 +} 1.341 + 1.342 +void SkDumpCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, 1.343 + const SkPaint& paint) { 1.344 + SkString str0, str1; 1.345 + toString(outer, &str0); 1.346 + toString(inner, &str0); 1.347 + this->dump(kDrawRRect_Verb, &paint, "drawDRRect(%s,%s)", 1.348 + str0.c_str(), str1.c_str()); 1.349 +} 1.350 + 1.351 +void SkDumpCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 1.352 + SkString str; 1.353 + toString(path, &str); 1.354 + this->dump(kDrawPath_Verb, &paint, "drawPath(%s)", str.c_str()); 1.355 +} 1.356 + 1.357 +void SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, 1.358 + const SkPaint* paint) { 1.359 + SkString str; 1.360 + bitmap.toString(&str); 1.361 + this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(), 1.362 + SkScalarToFloat(x), SkScalarToFloat(y)); 1.363 +} 1.364 + 1.365 +void SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 1.366 + const SkRect& dst, const SkPaint* paint, 1.367 + DrawBitmapRectFlags flags) { 1.368 + SkString bs, rs; 1.369 + bitmap.toString(&bs); 1.370 + toString(dst, &rs); 1.371 + // show the src-rect only if its not everything 1.372 + if (src && (src->fLeft > 0 || src->fTop > 0 || 1.373 + src->fRight < SkIntToScalar(bitmap.width()) || 1.374 + src->fBottom < SkIntToScalar(bitmap.height()))) { 1.375 + SkString ss; 1.376 + toString(*src, &ss); 1.377 + rs.prependf("%s ", ss.c_str()); 1.378 + } 1.379 + 1.380 + this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)", 1.381 + bs.c_str(), rs.c_str()); 1.382 +} 1.383 + 1.384 +void SkDumpCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, 1.385 + const SkPaint* paint) { 1.386 + SkString bs, ms; 1.387 + bitmap.toString(&bs); 1.388 + m.toString(&ms); 1.389 + this->dump(kDrawBitmap_Verb, paint, "drawBitmapMatrix(%s %s)", 1.390 + bs.c_str(), ms.c_str()); 1.391 +} 1.392 + 1.393 +void SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, 1.394 + const SkPaint* paint) { 1.395 + SkString str; 1.396 + bitmap.toString(&str); 1.397 + this->dump(kDrawBitmap_Verb, paint, "drawSprite(%s %d %d)", str.c_str(), 1.398 + x, y); 1.399 +} 1.400 + 1.401 +void SkDumpCanvas::drawText(const void* text, size_t byteLength, SkScalar x, 1.402 + SkScalar y, const SkPaint& paint) { 1.403 + SkString str; 1.404 + toString(text, byteLength, paint.getTextEncoding(), &str); 1.405 + this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(), 1.406 + byteLength, SkScalarToFloat(x), SkScalarToFloat(y)); 1.407 +} 1.408 + 1.409 +void SkDumpCanvas::drawPosText(const void* text, size_t byteLength, 1.410 + const SkPoint pos[], const SkPaint& paint) { 1.411 + SkString str; 1.412 + toString(text, byteLength, paint.getTextEncoding(), &str); 1.413 + this->dump(kDrawText_Verb, &paint, "drawPosText(%s [%d] %g %g ...)", 1.414 + str.c_str(), byteLength, SkScalarToFloat(pos[0].fX), 1.415 + SkScalarToFloat(pos[0].fY)); 1.416 +} 1.417 + 1.418 +void SkDumpCanvas::drawPosTextH(const void* text, size_t byteLength, 1.419 + const SkScalar xpos[], SkScalar constY, 1.420 + const SkPaint& paint) { 1.421 + SkString str; 1.422 + toString(text, byteLength, paint.getTextEncoding(), &str); 1.423 + this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)", 1.424 + str.c_str(), byteLength, SkScalarToFloat(xpos[0]), 1.425 + SkScalarToFloat(constY)); 1.426 +} 1.427 + 1.428 +void SkDumpCanvas::drawTextOnPath(const void* text, size_t byteLength, 1.429 + const SkPath& path, const SkMatrix* matrix, 1.430 + const SkPaint& paint) { 1.431 + SkString str; 1.432 + toString(text, byteLength, paint.getTextEncoding(), &str); 1.433 + this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])", 1.434 + str.c_str(), byteLength); 1.435 +} 1.436 + 1.437 +void SkDumpCanvas::drawPicture(SkPicture& picture) { 1.438 + this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %d:%d", &picture, 1.439 + picture.width(), picture.height()); 1.440 + fNestLevel += 1; 1.441 + this->INHERITED::drawPicture(picture); 1.442 + fNestLevel -= 1; 1.443 + this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %d:%d", &picture, 1.444 + picture.width(), picture.height()); 1.445 +} 1.446 + 1.447 +void SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount, 1.448 + const SkPoint vertices[], const SkPoint texs[], 1.449 + const SkColor colors[], SkXfermode* xmode, 1.450 + const uint16_t indices[], int indexCount, 1.451 + const SkPaint& paint) { 1.452 + this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", 1.453 + toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX), 1.454 + SkScalarToFloat(vertices[0].fY)); 1.455 +} 1.456 + 1.457 +void SkDumpCanvas::drawData(const void* data, size_t length) { 1.458 +// this->dump(kDrawData_Verb, NULL, "drawData(%d)", length); 1.459 + this->dump(kDrawData_Verb, NULL, "drawData(%d) %.*s", length, 1.460 + SkTMin<size_t>(length, 64), data); 1.461 +} 1.462 + 1.463 +void SkDumpCanvas::beginCommentGroup(const char* description) { 1.464 + this->dump(kBeginCommentGroup_Verb, NULL, "beginCommentGroup(%s)", description); 1.465 +} 1.466 + 1.467 +void SkDumpCanvas::addComment(const char* kywd, const char* value) { 1.468 + this->dump(kAddComment_Verb, NULL, "addComment(%s, %s)", kywd, value); 1.469 +} 1.470 + 1.471 +void SkDumpCanvas::endCommentGroup() { 1.472 + this->dump(kEndCommentGroup_Verb, NULL, "endCommentGroup()"); 1.473 +} 1.474 + 1.475 +/////////////////////////////////////////////////////////////////////////////// 1.476 +/////////////////////////////////////////////////////////////////////////////// 1.477 + 1.478 +SkFormatDumper::SkFormatDumper(void (*proc)(const char*, void*), void* refcon) { 1.479 + fProc = proc; 1.480 + fRefcon = refcon; 1.481 +} 1.482 + 1.483 +static void appendPtr(SkString* str, const void* ptr, const char name[]) { 1.484 + if (ptr) { 1.485 + str->appendf(" %s:%p", name, ptr); 1.486 + } 1.487 +} 1.488 + 1.489 +static void appendFlattenable(SkString* str, const SkFlattenable* ptr, 1.490 + const char name[]) { 1.491 + if (ptr) { 1.492 + str->appendf(" %s:%p", name, ptr); 1.493 + } 1.494 +} 1.495 + 1.496 +void SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb, 1.497 + const char str[], const SkPaint* p) { 1.498 + SkString msg, tab; 1.499 + const int level = canvas->getNestLevel() + canvas->getSaveCount() - 1; 1.500 + SkASSERT(level >= 0); 1.501 + for (int i = 0; i < level; i++) { 1.502 +#if 0 1.503 + tab.append("\t"); 1.504 +#else 1.505 + tab.append(" "); // tabs are often too wide to be useful 1.506 +#endif 1.507 + } 1.508 + msg.printf("%s%s", tab.c_str(), str); 1.509 + 1.510 + if (p) { 1.511 + msg.appendf(" color:0x%08X flags:%X", p->getColor(), p->getFlags()); 1.512 + appendFlattenable(&msg, p->getShader(), "shader"); 1.513 + appendFlattenable(&msg, p->getXfermode(), "xfermode"); 1.514 + appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); 1.515 + appendFlattenable(&msg, p->getMaskFilter(), "maskFilter"); 1.516 + appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); 1.517 + appendFlattenable(&msg, p->getColorFilter(), "filter"); 1.518 + 1.519 + if (SkDumpCanvas::kDrawText_Verb == verb) { 1.520 + msg.appendf(" textSize:%g", SkScalarToFloat(p->getTextSize())); 1.521 + appendPtr(&msg, p->getTypeface(), "typeface"); 1.522 + } 1.523 + 1.524 + if (p->getStyle() != SkPaint::kFill_Style) { 1.525 + msg.appendf(" strokeWidth:%g", SkScalarToFloat(p->getStrokeWidth())); 1.526 + } 1.527 + } 1.528 + 1.529 + fProc(msg.c_str(), fRefcon); 1.530 +} 1.531 + 1.532 +/////////////////////////////////////////////////////////////////////////////// 1.533 + 1.534 +static void dumpToDebugf(const char text[], void*) { 1.535 + SkDebugf("%s\n", text); 1.536 +} 1.537 + 1.538 +SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {} 1.539 + 1.540 +#endif