1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2011 Google Inc. 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */ 876f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDumpCanvas.h" 1076f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com 1176f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com#ifdef SK_DEVELOPER 1282065d667f64e232bcde2ad849756a6096fcbe6freed@google.com#include "SkPicture.h" 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPixelRef.h" 144ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com#include "SkRRect.h" 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkString.h" 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <stdarg.h> 17fab44db294846ff05d837b9cf0bf97a073891da7bungeman@google.com#include <stdio.h> 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// needed just to know that these are all subclassed from SkFlattenable 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkShader.h" 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPathEffect.h" 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkXfermode.h" 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkColorFilter.h" 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPathEffect.h" 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMaskFilter.h" 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkRect& r, SkString* str) { 284258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->appendf("[%g,%g %g:%g]", 294258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), 304258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkIRect& r, SkString* str) { 344258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->appendf("[%d,%d %d:%d]", r.fLeft, r.fTop, r.width(), r.height()); 350becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com} 360becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com 374ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.comstatic void toString(const SkRRect& rrect, SkString* str) { 384ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkRect r = rrect.getBounds(); 394ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->appendf("[%g,%g %g:%g]", 404ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), 414ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); 424ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com if (rrect.isOval()) { 434ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->append("()"); 444ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com } else if (rrect.isSimple()) { 454ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com const SkVector& rad = rrect.getSimpleRadii(); 464ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->appendf("(%g,%g)", rad.x(), rad.y()); 474ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com } else if (rrect.isComplex()) { 484ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkVector radii[4] = { 494ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kUpperLeft_Corner), 504ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kUpperRight_Corner), 514ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kLowerRight_Corner), 524ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kLowerLeft_Corner), 534ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com }; 544ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->appendf("(%g,%g %g,%g %g,%g %g,%g)", 554ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[0].x(), radii[0].y(), 564ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[1].x(), radii[1].y(), 574ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[2].x(), radii[2].y(), 584ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[3].x(), radii[3].y()); 594ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com } 604ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 614ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 620becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.comstatic void dumpVerbs(const SkPath& path, SkString* str) { 630becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com SkPath::Iter iter(path, false); 640becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com SkPoint pts[4]; 650becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com for (;;) { 664a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com switch (iter.next(pts, false)) { 670becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kMove_Verb: 680becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" M%g,%g", pts[0].fX, pts[0].fY); 690becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 700becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kLine_Verb: 710becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" L%g,%g", pts[0].fX, pts[0].fY); 720becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 730becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kQuad_Verb: 740becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" Q%g,%g,%g,%g", pts[1].fX, pts[1].fY, 750becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com pts[2].fX, pts[2].fY); 760becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 770becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kCubic_Verb: 780becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" C%g,%g,%g,%g,%g,%g", pts[1].fX, pts[1].fY, 790becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY); 800becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 810becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kClose_Verb: 82b9682d38c1daa597c4acffd93cbd5ba72735a613vandebo@chromium.org str->append("X"); 830becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 840becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kDone_Verb: 850becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com return; 86277c3f87656c44e0a651ed0dd56efa16c0ab07b4reed@google.com case SkPath::kConic_Verb: 87277c3f87656c44e0a651ed0dd56efa16c0ab07b4reed@google.com SkASSERT(0); 88277c3f87656c44e0a651ed0dd56efa16c0ab07b4reed@google.com break; 890becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com } 900becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com } 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkPath& path, SkString* str) { 948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (path.isEmpty()) { 954258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->append("path:empty"); 968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } else { 97d252db03d9650013b545ef9781fe993c07f8f314reed@android.com toString(path.getBounds(), str); 980becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com#if 1 990becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com SkString s; 1000becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com dumpVerbs(path, &s); 1010becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->append(s.c_str()); 1020becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com#endif 1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->append("]"); 1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->prepend("path:["); 1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic const char* toString(SkRegion::Op op) { 1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const char* gOpNames[] = { 1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com "DIFF", "SECT", "UNION", "XOR", "RDIFF", "REPLACE" 1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return gOpNames[op]; 1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkRegion& rgn, SkString* str) { 1164258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->append("Region:["); 1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(rgn.getBounds(), str); 1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->append("]"); 1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (rgn.isComplex()) { 1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->append(".complex"); 1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic const char* toString(SkCanvas::VertexMode vm) { 1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const char* gVMNames[] = { 1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com "TRIANGLES", "STRIP", "FAN" 1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return gVMNames[vm]; 1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic const char* toString(SkCanvas::PointMode pm) { 1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const char* gPMNames[] = { 1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com "POINTS", "LINES", "POLYGON" 1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return gPMNames[pm]; 1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1388afae61a57f87e4a50578effce6c428031499301tomhudson@google.comstatic void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc, 1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString* str) { 1408afae61a57f87e4a50578effce6c428031499301tomhudson@google.com // FIXME: this code appears to be untested - and probably unused - and probably wrong 1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com switch (enc) { 1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case SkPaint::kUTF8_TextEncoding: 143adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com str->appendf("\"%.*s\"%s", (int)SkTMax<size_t>(byteLen, 32), (const char*) text, 1448afae61a57f87e4a50578effce6c428031499301tomhudson@google.com byteLen > 32 ? "..." : ""); 1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com break; 1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case SkPaint::kUTF16_TextEncoding: 147adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text, 1488afae61a57f87e4a50578effce6c428031499301tomhudson@google.com byteLen > 64 ? "..." : ""); 1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com break; 1506970557055acaed619d7bb89451868e1570249b2robertphillips@google.com case SkPaint::kUTF32_TextEncoding: 151adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text, 1528afae61a57f87e4a50578effce6c428031499301tomhudson@google.com byteLen > 128 ? "..." : ""); 1536970557055acaed619d7bb89451868e1570249b2robertphillips@google.com break; 1548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case SkPaint::kGlyphID_TextEncoding: 1554258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->append("<glyphs>"); 1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com break; 1576970557055acaed619d7bb89451868e1570249b2robertphillips@google.com 1586970557055acaed619d7bb89451868e1570249b2robertphillips@google.com default: 1596970557055acaed619d7bb89451868e1570249b2robertphillips@google.com SkASSERT(false); 1606970557055acaed619d7bb89451868e1570249b2robertphillips@google.com break; 1618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 166e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org#define WIDE_OPEN 16384 16744d498812a6fb0c60a8204e6334564fe518fba33skia.committer@gmail.com 168e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.orgSkDumpCanvas::SkDumpCanvas(Dumper* dumper) : INHERITED(WIDE_OPEN, WIDE_OPEN) { 1696ae24e0f5fa3306054679d0ec8f9d1f5d35c2617reed@google.com fNestLevel = 0; 1706ae24e0f5fa3306054679d0ec8f9d1f5d35c2617reed@google.com SkSafeRef(dumper); 1716ae24e0f5fa3306054679d0ec8f9d1f5d35c2617reed@google.com fDumper = dumper; 1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDumpCanvas::~SkDumpCanvas() { 17582065d667f64e232bcde2ad849756a6096fcbe6freed@google.com SkSafeUnref(fDumper); 1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::dump(Verb verb, const SkPaint* paint, 1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char format[], ...) { 1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const size_t BUFFER_SIZE = 1024; 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com char buffer[BUFFER_SIZE]; 1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com va_list args; 1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com va_start(args, format); 1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com vsnprintf(buffer, BUFFER_SIZE, format, args); 1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com va_end(args); 18782065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (fDumper) { 1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fDumper->dump(this, verb, buffer, paint); 1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 195e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.orgvoid SkDumpCanvas::willSave(SaveFlags flags) { 1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kSave_Verb, NULL, "save(0x%X)", flags); 197e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org this->INHERITED::willSave(flags); 1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 200e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.orgSkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, 201e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org SaveFlags flags) { 2024258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com SkString str; 2034258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.printf("saveLayer(0x%X)", flags); 2044258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (bounds) { 2054258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.append(" bounds"); 2064258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com toString(*bounds, &str); 2074258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2084258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (paint) { 2094258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (paint->getAlpha() != 0xFF) { 2104258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.appendf(" alpha:0x%02X", paint->getAlpha()); 2114258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2124258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (paint->getXfermode()) { 2134258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.appendf(" xfermode:%p", paint->getXfermode()); 2144258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2154258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2164258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com this->dump(kSave_Verb, paint, str.c_str()); 217e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org return this->INHERITED::willSaveLayer(bounds, paint, flags); 2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 220e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.orgvoid SkDumpCanvas::willRestore() { 2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kRestore_Verb, NULL, "restore"); 222e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org this->INHERITED::willRestore(); 2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 22544c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.orgvoid SkDumpCanvas::didConcat(const SkMatrix& matrix) { 2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 227d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org 228d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org switch (matrix.getType()) { 229d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org case SkMatrix::kTranslate_Mask: 230d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org this->dump(kMatrix_Verb, NULL, "translate(%g %g)", 231d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getTranslateX()), 232d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getTranslateY())); 233d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org break; 234d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org case SkMatrix::kScale_Mask: 235d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org this->dump(kMatrix_Verb, NULL, "scale(%g %g)", 236d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getScaleX()), 237d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getScaleY())); 238d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org break; 239d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org default: 240d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org matrix.toString(&str); 241d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str()); 242d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org break; 243d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org } 244d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org 24544c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org this->INHERITED::didConcat(matrix); 2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 24844c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.orgvoid SkDumpCanvas::didSetMatrix(const SkMatrix& matrix) { 2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 25076f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com matrix.toString(&str); 2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kMatrix_Verb, NULL, "setMatrix(%s)", str.c_str()); 25244c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org this->INHERITED::didSetMatrix(matrix); 2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2578f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comconst char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) { 2588f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW"; 259071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com} 260071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com 2618f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(rect, &str); 264071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com this->dump(kClip_Verb, NULL, "clipRect(%s %s %s)", str.c_str(), toString(op), 2658f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com EdgeStyleToAAString(edgeStyle)); 2668f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipRect(rect, op, edgeStyle); 2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2698f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 2704ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkString str; 2714ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com toString(rrect, &str); 2724ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com this->dump(kClip_Verb, NULL, "clipRRect(%s %s %s)", str.c_str(), toString(op), 2738f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com EdgeStyleToAAString(edgeStyle)); 2748f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipRRect(rrect, op, edgeStyle); 2754ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 2764ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 2778f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 2788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(path, &str); 280071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com this->dump(kClip_Verb, NULL, "clipPath(%s %s %s)", str.c_str(), toString(op), 2818f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com EdgeStyleToAAString(edgeStyle)); 2828f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipPath(path, op, edgeStyle); 2838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2858f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 2878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(deviceRgn, &str); 2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(), 2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(op)); 2908f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipRegion(deviceRgn, op); 2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 293210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.orgvoid SkDumpCanvas::onPushCull(const SkRect& cullRect) { 294210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org SkString str; 295210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org toString(cullRect, &str); 296210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org this->dump(kCull_Verb, NULL, "pushCull(%s)", str.c_str()); 297210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org} 298210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org 299210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.orgvoid SkDumpCanvas::onPopCull() { 300210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org this->dump(kCull_Verb, NULL, "popCull()"); 301210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org} 3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawPaint(const SkPaint& paint) { 3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawPaint_Verb, &paint, "drawPaint()"); 3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawPoints(PointMode mode, size_t count, 3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint pts[], const SkPaint& paint) { 3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawPoints_Verb, &paint, "drawPoints(%s, %d)", toString(mode), 3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com count); 3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3144ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.comvoid SkDumpCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { 3154ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkString str; 3164ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com toString(rect, &str); 3174ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com this->dump(kDrawOval_Verb, &paint, "drawOval(%s)", str.c_str()); 3184ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 3194ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 3207ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.comvoid SkDumpCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { 3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(rect, &str); 3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawRect_Verb, &paint, "drawRect(%s)", str.c_str()); 3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3264ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.comvoid SkDumpCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { 3274ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkString str; 3284ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com toString(rrect, &str); 329ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org this->dump(kDrawDRRect_Verb, &paint, "drawRRect(%s)", str.c_str()); 330ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org} 331ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org 332ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.orgvoid SkDumpCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, 333ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org const SkPaint& paint) { 334ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org SkString str0, str1; 335ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org toString(outer, &str0); 336ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org toString(inner, &str0); 337ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org this->dump(kDrawRRect_Verb, &paint, "drawDRRect(%s,%s)", 338ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org str0.c_str(), str1.c_str()); 3394ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 3404ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 3417ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.comvoid SkDumpCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(path, &str); 3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawPath_Verb, &paint, "drawPath(%s)", str.c_str()); 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, 3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint) { 3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 35076f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&str); 3510becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(), 3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(x), SkScalarToFloat(y)); 3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3557112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.comvoid SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 356eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkRect& dst, const SkPaint* paint, 357eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org DrawBitmapRectFlags flags) { 3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString bs, rs; 35976f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&bs); 3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(dst, &rs); 3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // show the src-rect only if its not everything 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (src && (src->fLeft > 0 || src->fTop > 0 || 3637112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com src->fRight < SkIntToScalar(bitmap.width()) || 3647112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com src->fBottom < SkIntToScalar(bitmap.height()))) { 3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString ss; 3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(*src, &ss); 3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com rs.prependf("%s ", ss.c_str()); 3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3707112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)", 3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bs.c_str(), rs.c_str()); 3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, 3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint) { 3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString bs, ms; 37776f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&bs); 37876f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com m.toString(&ms); 3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawBitmap_Verb, paint, "drawBitmapMatrix(%s %s)", 3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bs.c_str(), ms.c_str()); 3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, 3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint) { 3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 38676f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&str); 3870becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawBitmap_Verb, paint, "drawSprite(%s %d %d)", str.c_str(), 3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com x, y); 3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 391e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 392e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint& paint) { 3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 3950becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(), 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com byteLength, SkScalarToFloat(x), SkScalarToFloat(y)); 3978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 399e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 400e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint& paint) { 4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 4030becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawText_Verb, &paint, "drawPosText(%s [%d] %g %g ...)", 4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str.c_str(), byteLength, SkScalarToFloat(pos[0].fX), 4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(pos[0].fY)); 4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 408e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 409e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com SkScalar constY, const SkPaint& paint) { 4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 4120becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)", 4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str.c_str(), byteLength, SkScalarToFloat(xpos[0]), 4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(constY)); 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 417e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 418e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkMatrix* matrix, const SkPaint& paint) { 4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])", 4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str.c_str(), byteLength); 4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4259b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillipsvoid SkDumpCanvas::onDrawPicture(const SkPicture* picture) { 4269b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %d:%d", picture, 4279b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips picture->width(), picture->height()); 4289b46e77ec2b387f4502926c2b9bf09450eec257creed@android.com fNestLevel += 1; 4299b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips this->INHERITED::onDrawPicture(picture); 4309b46e77ec2b387f4502926c2b9bf09450eec257creed@android.com fNestLevel -= 1; 4319b46e77ec2b387f4502926c2b9bf09450eec257creed@android.com this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %d:%d", &picture, 4329b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips picture->width(), picture->height()); 4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount, 4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint vertices[], const SkPoint texs[], 4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkColor colors[], SkXfermode* xmode, 4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const uint16_t indices[], int indexCount, 4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint) { 4400becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", 4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX), 4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(vertices[0].fY)); 4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 445cb60844b34766aad4151df5e87c144d4a57e9abereed@android.comvoid SkDumpCanvas::drawData(const void* data, size_t length) { 446cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com// this->dump(kDrawData_Verb, NULL, "drawData(%d)", length); 447cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com this->dump(kDrawData_Verb, NULL, "drawData(%d) %.*s", length, 448adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com SkTMin<size_t>(length, 64), data); 449cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com} 450cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com 4510a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comvoid SkDumpCanvas::beginCommentGroup(const char* description) { 4520a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com this->dump(kBeginCommentGroup_Verb, NULL, "beginCommentGroup(%s)", description); 4530a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com} 4540a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 4550a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comvoid SkDumpCanvas::addComment(const char* kywd, const char* value) { 4560a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com this->dump(kAddComment_Verb, NULL, "addComment(%s, %s)", kywd, value); 4570a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com} 4580a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 4590a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comvoid SkDumpCanvas::endCommentGroup() { 4600a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com this->dump(kEndCommentGroup_Verb, NULL, "endCommentGroup()"); 4610a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com} 4620a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkFormatDumper::SkFormatDumper(void (*proc)(const char*, void*), void* refcon) { 4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fProc = proc; 4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fRefcon = refcon; 4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void appendPtr(SkString* str, const void* ptr, const char name[]) { 4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (ptr) { 4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->appendf(" %s:%p", name, ptr); 4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void appendFlattenable(SkString* str, const SkFlattenable* ptr, 4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char name[]) { 4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (ptr) { 480a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com str->appendf(" %s:%p", name, ptr); 4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb, 4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char str[], const SkPaint* p) { 4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString msg, tab; 4879b46e77ec2b387f4502926c2b9bf09450eec257creed@android.com const int level = canvas->getNestLevel() + canvas->getSaveCount() - 1; 4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkASSERT(level >= 0); 4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com for (int i = 0; i < level; i++) { 4904258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com#if 0 4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com tab.append("\t"); 4924258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com#else 4934258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com tab.append(" "); // tabs are often too wide to be useful 4944258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com#endif 4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com msg.printf("%s%s", tab.c_str(), str); 49782065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (p) { 4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com msg.appendf(" color:0x%08X flags:%X", p->getColor(), p->getFlags()); 5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getShader(), "shader"); 5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getXfermode(), "xfermode"); 5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); 5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getMaskFilter(), "maskFilter"); 5048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); 5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getColorFilter(), "filter"); 50682065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 5078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (SkDumpCanvas::kDrawText_Verb == verb) { 5088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com msg.appendf(" textSize:%g", SkScalarToFloat(p->getTextSize())); 5098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendPtr(&msg, p->getTypeface(), "typeface"); 5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 51173a4b4f91fac1783b589eead5e82b0c0771644deskia.committer@gmail.com 512b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com if (p->getStyle() != SkPaint::kFill_Style) { 513b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com msg.appendf(" strokeWidth:%g", SkScalarToFloat(p->getStrokeWidth())); 514b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com } 5158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 51682065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fProc(msg.c_str(), fRefcon); 5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void dumpToDebugf(const char text[], void*) { 5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDebugf("%s\n", text); 5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {} 5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 52876f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com#endif 529