reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | #include "SkDumpCanvas.h" |
reed@android.com | 9b46e77 | 2009-06-05 12:24:41 +0000 | [diff] [blame] | 2 | #include "SkPicture.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | #include "SkPixelRef.h" |
| 4 | #include "SkString.h" |
| 5 | #include <stdarg.h> |
| 6 | |
| 7 | // needed just to know that these are all subclassed from SkFlattenable |
| 8 | #include "SkShader.h" |
| 9 | #include "SkPathEffect.h" |
| 10 | #include "SkXfermode.h" |
| 11 | #include "SkColorFilter.h" |
| 12 | #include "SkPathEffect.h" |
| 13 | #include "SkMaskFilter.h" |
| 14 | |
| 15 | static void toString(const SkRect& r, SkString* str) { |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 16 | str->printf("[%g,%g %g:%g]", |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), |
| 18 | SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); |
| 19 | } |
| 20 | |
| 21 | static void toString(const SkIRect& r, SkString* str) { |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 22 | str->printf("[%d,%d %d:%d]", r.fLeft, r.fTop, r.width(), r.height()); |
| 23 | } |
| 24 | |
| 25 | static void dumpVerbs(const SkPath& path, SkString* str) { |
| 26 | SkPath::Iter iter(path, false); |
| 27 | SkPoint pts[4]; |
| 28 | for (;;) { |
| 29 | switch (iter.next(pts)) { |
| 30 | case SkPath::kMove_Verb: |
| 31 | str->appendf(" M%g,%g", pts[0].fX, pts[0].fY); |
| 32 | break; |
| 33 | case SkPath::kLine_Verb: |
| 34 | str->appendf(" L%g,%g", pts[0].fX, pts[0].fY); |
| 35 | break; |
| 36 | case SkPath::kQuad_Verb: |
| 37 | str->appendf(" Q%g,%g,%g,%g", pts[1].fX, pts[1].fY, |
| 38 | pts[2].fX, pts[2].fY); |
| 39 | break; |
| 40 | case SkPath::kCubic_Verb: |
| 41 | str->appendf(" C%g,%g,%g,%g,%g,%g", pts[1].fX, pts[1].fY, |
| 42 | pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY); |
| 43 | break; |
| 44 | case SkPath::kClose_Verb: |
| 45 | str->appendf("X"); |
| 46 | break; |
| 47 | case SkPath::kDone_Verb: |
| 48 | return; |
| 49 | } |
| 50 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | static void toString(const SkPath& path, SkString* str) { |
| 54 | if (path.isEmpty()) { |
| 55 | str->set("path:empty"); |
| 56 | } else { |
reed@android.com | d252db0 | 2009-04-01 18:31:44 +0000 | [diff] [blame] | 57 | toString(path.getBounds(), str); |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 58 | #if 1 |
| 59 | SkString s; |
| 60 | dumpVerbs(path, &s); |
| 61 | str->append(s.c_str()); |
| 62 | #endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 63 | str->append("]"); |
| 64 | str->prepend("path:["); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | static const char* toString(SkRegion::Op op) { |
| 69 | static const char* gOpNames[] = { |
| 70 | "DIFF", "SECT", "UNION", "XOR", "RDIFF", "REPLACE" |
| 71 | }; |
| 72 | return gOpNames[op]; |
| 73 | } |
| 74 | |
| 75 | static void toString(const SkRegion& rgn, SkString* str) { |
| 76 | toString(rgn.getBounds(), str); |
| 77 | str->prepend("Region:["); |
| 78 | str->append("]"); |
| 79 | if (rgn.isComplex()) { |
| 80 | str->append(".complex"); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | static const char* toString(SkCanvas::VertexMode vm) { |
| 85 | static const char* gVMNames[] = { |
| 86 | "TRIANGLES", "STRIP", "FAN" |
| 87 | }; |
| 88 | return gVMNames[vm]; |
| 89 | } |
| 90 | |
| 91 | static const char* toString(SkCanvas::PointMode pm) { |
| 92 | static const char* gPMNames[] = { |
| 93 | "POINTS", "LINES", "POLYGON" |
| 94 | }; |
| 95 | return gPMNames[pm]; |
| 96 | } |
| 97 | |
| 98 | static const char* toString(SkBitmap::Config config) { |
| 99 | static const char* gConfigNames[] = { |
| 100 | "NONE", "A1", "A8", "INDEX8", "565", "4444", "8888", "RLE" |
| 101 | }; |
| 102 | return gConfigNames[config]; |
| 103 | } |
| 104 | |
| 105 | static void toString(const SkBitmap& bm, SkString* str) { |
| 106 | str->printf("bitmap:[%d %d] %s", bm.width(), bm.height(), |
| 107 | toString(bm.config())); |
| 108 | |
| 109 | SkPixelRef* pr = bm.pixelRef(); |
| 110 | if (NULL == pr) { |
| 111 | // show null or the explicit pixel address (rare) |
| 112 | str->appendf(" pixels:%p", bm.getPixels()); |
| 113 | } else { |
| 114 | const char* uri = pr->getURI(); |
| 115 | if (uri) { |
| 116 | str->appendf(" uri:\"%s\"", uri); |
| 117 | } else { |
| 118 | str->appendf(" pixelref:%p", pr); |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | static void toString(const void* text, size_t len, SkPaint::TextEncoding enc, |
| 124 | SkString* str) { |
| 125 | switch (enc) { |
| 126 | case SkPaint::kUTF8_TextEncoding: |
| 127 | str->printf("\"%.*s\"%s", SkMax32(len, 32), text, |
| 128 | len > 32 ? "..." : ""); |
| 129 | break; |
| 130 | case SkPaint::kUTF16_TextEncoding: |
| 131 | str->printf("\"%.*S\"%s", SkMax32(len, 32), text, |
| 132 | len > 64 ? "..." : ""); |
| 133 | break; |
| 134 | case SkPaint::kGlyphID_TextEncoding: |
| 135 | str->set("<glyphs>"); |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /////////////////////////////////////////////////////////////////////////////// |
| 141 | |
reed@android.com | 9b46e77 | 2009-06-05 12:24:41 +0000 | [diff] [blame] | 142 | SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : fNestLevel(0) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 143 | dumper->safeRef(); |
| 144 | fDumper = dumper; |
| 145 | |
| 146 | static const int WIDE_OPEN = 16384; |
| 147 | SkBitmap emptyBitmap; |
| 148 | |
| 149 | emptyBitmap.setConfig(SkBitmap::kNo_Config, WIDE_OPEN, WIDE_OPEN); |
| 150 | this->setBitmapDevice(emptyBitmap); |
| 151 | } |
| 152 | |
| 153 | SkDumpCanvas::~SkDumpCanvas() { |
| 154 | fDumper->safeUnref(); |
| 155 | } |
| 156 | |
| 157 | void SkDumpCanvas::dump(Verb verb, const SkPaint* paint, |
| 158 | const char format[], ...) { |
| 159 | static const size_t BUFFER_SIZE = 1024; |
| 160 | |
| 161 | char buffer[BUFFER_SIZE]; |
| 162 | va_list args; |
| 163 | va_start(args, format); |
| 164 | vsnprintf(buffer, BUFFER_SIZE, format, args); |
| 165 | va_end(args); |
| 166 | |
| 167 | if (fDumper) { |
| 168 | fDumper->dump(this, verb, buffer, paint); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /////////////////////////////////////////////////////////////////////////////// |
| 173 | |
| 174 | int SkDumpCanvas::save(SaveFlags flags) { |
| 175 | this->dump(kSave_Verb, NULL, "save(0x%X)", flags); |
| 176 | return this->INHERITED::save(flags); |
| 177 | } |
| 178 | |
| 179 | int SkDumpCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 180 | SaveFlags flags) { |
| 181 | this->dump(kSave_Verb, paint, "saveLayer(0x%X)", flags); |
| 182 | return this->INHERITED::saveLayer(bounds, paint, flags); |
| 183 | } |
| 184 | |
| 185 | void SkDumpCanvas::restore() { |
| 186 | this->INHERITED::restore(); |
| 187 | this->dump(kRestore_Verb, NULL, "restore"); |
| 188 | } |
| 189 | |
| 190 | bool SkDumpCanvas::translate(SkScalar dx, SkScalar dy) { |
| 191 | this->dump(kMatrix_Verb, NULL, "translate(%g %g)", |
| 192 | SkScalarToFloat(dx), SkScalarToFloat(dy)); |
| 193 | return this->INHERITED::translate(dx, dy); |
| 194 | } |
| 195 | |
| 196 | bool SkDumpCanvas::scale(SkScalar sx, SkScalar sy) { |
| 197 | this->dump(kMatrix_Verb, NULL, "scale(%g %g)", |
| 198 | SkScalarToFloat(sx), SkScalarToFloat(sy)); |
| 199 | return this->INHERITED::scale(sx, sy); |
| 200 | } |
| 201 | |
| 202 | bool SkDumpCanvas::rotate(SkScalar degrees) { |
| 203 | this->dump(kMatrix_Verb, NULL, "rotate(%g)", SkScalarToFloat(degrees)); |
| 204 | return this->INHERITED::rotate(degrees); |
| 205 | } |
| 206 | |
| 207 | bool SkDumpCanvas::skew(SkScalar sx, SkScalar sy) { |
| 208 | this->dump(kMatrix_Verb, NULL, "skew(%g %g)", |
| 209 | SkScalarToFloat(sx), SkScalarToFloat(sy)); |
| 210 | return this->INHERITED::skew(sx, sy); |
| 211 | } |
| 212 | |
| 213 | bool SkDumpCanvas::concat(const SkMatrix& matrix) { |
| 214 | SkString str; |
| 215 | matrix.toDumpString(&str); |
| 216 | this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str()); |
| 217 | return this->INHERITED::concat(matrix); |
| 218 | } |
| 219 | |
| 220 | void SkDumpCanvas::setMatrix(const SkMatrix& matrix) { |
| 221 | SkString str; |
| 222 | matrix.toDumpString(&str); |
| 223 | this->dump(kMatrix_Verb, NULL, "setMatrix(%s)", str.c_str()); |
| 224 | this->INHERITED::setMatrix(matrix); |
| 225 | } |
| 226 | |
| 227 | /////////////////////////////////////////////////////////////////////////////// |
| 228 | |
| 229 | bool SkDumpCanvas::clipRect(const SkRect& rect, SkRegion::Op op) { |
| 230 | SkString str; |
| 231 | toString(rect, &str); |
| 232 | this->dump(kClip_Verb, NULL, "clipRect(%s %s)", str.c_str(), toString(op)); |
| 233 | return this->INHERITED::clipRect(rect, op); |
| 234 | } |
| 235 | |
| 236 | bool SkDumpCanvas::clipPath(const SkPath& path, SkRegion::Op op) { |
| 237 | SkString str; |
| 238 | toString(path, &str); |
| 239 | this->dump(kClip_Verb, NULL, "clipPath(%s %s)", str.c_str(), toString(op)); |
| 240 | return this->INHERITED::clipPath(path, op); |
| 241 | } |
| 242 | |
| 243 | bool SkDumpCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
| 244 | SkString str; |
| 245 | toString(deviceRgn, &str); |
| 246 | this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(), |
| 247 | toString(op)); |
| 248 | return this->INHERITED::clipRegion(deviceRgn, op); |
| 249 | } |
| 250 | |
| 251 | /////////////////////////////////////////////////////////////////////////////// |
| 252 | |
| 253 | void SkDumpCanvas::drawPaint(const SkPaint& paint) { |
| 254 | this->dump(kDrawPaint_Verb, &paint, "drawPaint()"); |
| 255 | } |
| 256 | |
| 257 | void SkDumpCanvas::drawPoints(PointMode mode, size_t count, |
| 258 | const SkPoint pts[], const SkPaint& paint) { |
| 259 | this->dump(kDrawPoints_Verb, &paint, "drawPoints(%s, %d)", toString(mode), |
| 260 | count); |
| 261 | } |
| 262 | |
| 263 | void SkDumpCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
| 264 | SkString str; |
| 265 | toString(rect, &str); |
| 266 | this->dump(kDrawRect_Verb, &paint, "drawRect(%s)", str.c_str()); |
| 267 | } |
| 268 | |
| 269 | void SkDumpCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
| 270 | SkString str; |
| 271 | toString(path, &str); |
| 272 | this->dump(kDrawPath_Verb, &paint, "drawPath(%s)", str.c_str()); |
| 273 | } |
| 274 | |
| 275 | void SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
| 276 | const SkPaint* paint) { |
| 277 | SkString str; |
| 278 | toString(bitmap, &str); |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 279 | this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(), |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 280 | SkScalarToFloat(x), SkScalarToFloat(y)); |
| 281 | } |
| 282 | |
| 283 | void SkDumpCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, |
| 284 | const SkRect& dst, const SkPaint* paint) { |
| 285 | SkString bs, rs; |
| 286 | toString(bitmap, &bs); |
| 287 | toString(dst, &rs); |
| 288 | // show the src-rect only if its not everything |
| 289 | if (src && (src->fLeft > 0 || src->fTop > 0 || |
| 290 | src->fRight < bitmap.width() || |
| 291 | src->fBottom < bitmap.height())) { |
| 292 | SkString ss; |
| 293 | toString(*src, &ss); |
| 294 | rs.prependf("%s ", ss.c_str()); |
| 295 | } |
| 296 | |
| 297 | this->dump(kDrawBitmap_Verb, paint, "drawBitmapRect(%s %s)", |
| 298 | bs.c_str(), rs.c_str()); |
| 299 | } |
| 300 | |
| 301 | void SkDumpCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
| 302 | const SkPaint* paint) { |
| 303 | SkString bs, ms; |
| 304 | toString(bitmap, &bs); |
| 305 | m.toDumpString(&ms); |
| 306 | this->dump(kDrawBitmap_Verb, paint, "drawBitmapMatrix(%s %s)", |
| 307 | bs.c_str(), ms.c_str()); |
| 308 | } |
| 309 | |
| 310 | void SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, |
| 311 | const SkPaint* paint) { |
| 312 | SkString str; |
| 313 | toString(bitmap, &str); |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 314 | this->dump(kDrawBitmap_Verb, paint, "drawSprite(%s %d %d)", str.c_str(), |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 315 | x, y); |
| 316 | } |
| 317 | |
| 318 | void SkDumpCanvas::drawText(const void* text, size_t byteLength, SkScalar x, |
| 319 | SkScalar y, const SkPaint& paint) { |
| 320 | SkString str; |
| 321 | toString(text, byteLength, paint.getTextEncoding(), &str); |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 322 | this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(), |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 323 | byteLength, SkScalarToFloat(x), SkScalarToFloat(y)); |
| 324 | } |
| 325 | |
| 326 | void SkDumpCanvas::drawPosText(const void* text, size_t byteLength, |
| 327 | const SkPoint pos[], const SkPaint& paint) { |
| 328 | SkString str; |
| 329 | toString(text, byteLength, paint.getTextEncoding(), &str); |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 330 | this->dump(kDrawText_Verb, &paint, "drawPosText(%s [%d] %g %g ...)", |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 331 | str.c_str(), byteLength, SkScalarToFloat(pos[0].fX), |
| 332 | SkScalarToFloat(pos[0].fY)); |
| 333 | } |
| 334 | |
| 335 | void SkDumpCanvas::drawPosTextH(const void* text, size_t byteLength, |
| 336 | const SkScalar xpos[], SkScalar constY, |
| 337 | const SkPaint& paint) { |
| 338 | SkString str; |
| 339 | toString(text, byteLength, paint.getTextEncoding(), &str); |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 340 | this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)", |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 341 | str.c_str(), byteLength, SkScalarToFloat(xpos[0]), |
| 342 | SkScalarToFloat(constY)); |
| 343 | } |
| 344 | |
| 345 | void SkDumpCanvas::drawTextOnPath(const void* text, size_t byteLength, |
| 346 | const SkPath& path, const SkMatrix* matrix, |
| 347 | const SkPaint& paint) { |
| 348 | SkString str; |
| 349 | toString(text, byteLength, paint.getTextEncoding(), &str); |
| 350 | this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])", |
| 351 | str.c_str(), byteLength); |
| 352 | } |
| 353 | |
reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 354 | void SkDumpCanvas::drawShape(SkShape* shape) { |
| 355 | this->dump(kDrawShape_Verb, NULL, "drawShape(%p)", shape); |
reed@android.com | 9b46e77 | 2009-06-05 12:24:41 +0000 | [diff] [blame] | 356 | fNestLevel += 1; |
| 357 | this->INHERITED::drawShape(shape); |
| 358 | fNestLevel -= 1; |
| 359 | this->dump(kDrawShape_Verb, NULL, "endShape(%p)", shape); |
reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 360 | } |
| 361 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 362 | void SkDumpCanvas::drawPicture(SkPicture& picture) { |
reed@android.com | 9b46e77 | 2009-06-05 12:24:41 +0000 | [diff] [blame] | 363 | this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %d:%d", &picture, |
| 364 | picture.width(), picture.height()); |
| 365 | fNestLevel += 1; |
| 366 | this->INHERITED::drawPicture(picture); |
| 367 | fNestLevel -= 1; |
| 368 | this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %d:%d", &picture, |
| 369 | picture.width(), picture.height()); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | void SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount, |
| 373 | const SkPoint vertices[], const SkPoint texs[], |
| 374 | const SkColor colors[], SkXfermode* xmode, |
| 375 | const uint16_t indices[], int indexCount, |
| 376 | const SkPaint& paint) { |
reed@android.com | 0becfc5b | 2009-01-13 13:26:44 +0000 | [diff] [blame] | 377 | this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 378 | toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX), |
| 379 | SkScalarToFloat(vertices[0].fY)); |
| 380 | } |
| 381 | |
reed@android.com | cb60844 | 2009-12-04 21:32:27 +0000 | [diff] [blame] | 382 | void SkDumpCanvas::drawData(const void* data, size_t length) { |
| 383 | // this->dump(kDrawData_Verb, NULL, "drawData(%d)", length); |
| 384 | this->dump(kDrawData_Verb, NULL, "drawData(%d) %.*s", length, |
| 385 | SkMin32(length, 64), data); |
| 386 | } |
| 387 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 388 | /////////////////////////////////////////////////////////////////////////////// |
| 389 | /////////////////////////////////////////////////////////////////////////////// |
| 390 | |
| 391 | SkFormatDumper::SkFormatDumper(void (*proc)(const char*, void*), void* refcon) { |
| 392 | fProc = proc; |
| 393 | fRefcon = refcon; |
| 394 | } |
| 395 | |
| 396 | static void appendPtr(SkString* str, const void* ptr, const char name[]) { |
| 397 | if (ptr) { |
| 398 | str->appendf(" %s:%p", name, ptr); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | static void appendFlattenable(SkString* str, const SkFlattenable* ptr, |
| 403 | const char name[]) { |
| 404 | if (ptr) { |
| 405 | SkString info; |
| 406 | if (ptr->toDumpString(&info)) { |
| 407 | str->appendf(" %s", info.c_str()); |
| 408 | } else { |
| 409 | str->appendf(" %s:%p", name, ptr); |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | void SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb, |
| 415 | const char str[], const SkPaint* p) { |
| 416 | SkString msg, tab; |
reed@android.com | 9b46e77 | 2009-06-05 12:24:41 +0000 | [diff] [blame] | 417 | const int level = canvas->getNestLevel() + canvas->getSaveCount() - 1; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 418 | SkASSERT(level >= 0); |
| 419 | for (int i = 0; i < level; i++) { |
| 420 | tab.append("\t"); |
| 421 | } |
| 422 | msg.printf("%s%s", tab.c_str(), str); |
| 423 | |
| 424 | if (p) { |
| 425 | msg.appendf(" color:0x%08X flags:%X", p->getColor(), p->getFlags()); |
| 426 | appendFlattenable(&msg, p->getShader(), "shader"); |
| 427 | appendFlattenable(&msg, p->getXfermode(), "xfermode"); |
| 428 | appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); |
| 429 | appendFlattenable(&msg, p->getMaskFilter(), "maskFilter"); |
| 430 | appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); |
| 431 | appendFlattenable(&msg, p->getColorFilter(), "filter"); |
| 432 | |
| 433 | if (SkDumpCanvas::kDrawText_Verb == verb) { |
| 434 | msg.appendf(" textSize:%g", SkScalarToFloat(p->getTextSize())); |
| 435 | appendPtr(&msg, p->getTypeface(), "typeface"); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | fProc(msg.c_str(), fRefcon); |
| 440 | } |
| 441 | |
| 442 | /////////////////////////////////////////////////////////////////////////////// |
| 443 | |
| 444 | static void dumpToDebugf(const char text[], void*) { |
| 445 | SkDebugf("%s\n", text); |
| 446 | } |
| 447 | |
| 448 | SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {} |
| 449 | |
| 450 | |