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 12b3c9d1c33caf325aada244204215eb790c228c12dandov#include "SkPatchUtils.h" 1382065d667f64e232bcde2ad849756a6096fcbe6freed@google.com#include "SkPicture.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPixelRef.h" 154ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com#include "SkRRect.h" 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkString.h" 17b7425173f96e93b090787e2386ba5f022b6c2869fmalita#include "SkTextBlob.h" 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <stdarg.h> 19fab44db294846ff05d837b9cf0bf97a073891da7bungeman@google.com#include <stdio.h> 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// needed just to know that these are all subclassed from SkFlattenable 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkShader.h" 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPathEffect.h" 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkXfermode.h" 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkColorFilter.h" 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPathEffect.h" 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMaskFilter.h" 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkRect& r, SkString* str) { 304258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->appendf("[%g,%g %g:%g]", 314258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), 324258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkIRect& r, SkString* str) { 364258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->appendf("[%d,%d %d:%d]", r.fLeft, r.fTop, r.width(), r.height()); 370becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com} 380becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com 394ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.comstatic void toString(const SkRRect& rrect, SkString* str) { 404ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkRect r = rrect.getBounds(); 414ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->appendf("[%g,%g %g:%g]", 424ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), 434ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); 444ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com if (rrect.isOval()) { 454ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->append("()"); 464ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com } else if (rrect.isSimple()) { 474ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com const SkVector& rad = rrect.getSimpleRadii(); 484ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->appendf("(%g,%g)", rad.x(), rad.y()); 494ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com } else if (rrect.isComplex()) { 504ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkVector radii[4] = { 514ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kUpperLeft_Corner), 524ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kUpperRight_Corner), 534ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kLowerRight_Corner), 544ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com rrect.radii(SkRRect::kLowerLeft_Corner), 554ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com }; 564ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com str->appendf("(%g,%g %g,%g %g,%g %g,%g)", 574ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[0].x(), radii[0].y(), 584ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[1].x(), radii[1].y(), 594ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[2].x(), radii[2].y(), 604ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com radii[3].x(), radii[3].y()); 614ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com } 624ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 634ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 640becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.comstatic void dumpVerbs(const SkPath& path, SkString* str) { 650becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com SkPath::Iter iter(path, false); 660becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com SkPoint pts[4]; 670becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com for (;;) { 684a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com switch (iter.next(pts, false)) { 690becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kMove_Verb: 700becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" M%g,%g", pts[0].fX, pts[0].fY); 710becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 720becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kLine_Verb: 730becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" L%g,%g", pts[0].fX, pts[0].fY); 740becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 750becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kQuad_Verb: 760becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" Q%g,%g,%g,%g", pts[1].fX, pts[1].fY, 770becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com pts[2].fX, pts[2].fY); 780becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 790becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kCubic_Verb: 800becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->appendf(" C%g,%g,%g,%g,%g,%g", pts[1].fX, pts[1].fY, 810becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY); 820becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 830becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kClose_Verb: 84b9682d38c1daa597c4acffd93cbd5ba72735a613vandebo@chromium.org str->append("X"); 850becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com break; 860becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com case SkPath::kDone_Verb: 870becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com return; 88277c3f87656c44e0a651ed0dd56efa16c0ab07b4reed@google.com case SkPath::kConic_Verb: 89277c3f87656c44e0a651ed0dd56efa16c0ab07b4reed@google.com SkASSERT(0); 90277c3f87656c44e0a651ed0dd56efa16c0ab07b4reed@google.com break; 910becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com } 920becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com } 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkPath& path, SkString* str) { 968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (path.isEmpty()) { 974258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->append("path:empty"); 988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } else { 99d252db03d9650013b545ef9781fe993c07f8f314reed@android.com toString(path.getBounds(), str); 1000becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com#if 1 1010becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com SkString s; 1020becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com dumpVerbs(path, &s); 1030becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com str->append(s.c_str()); 1040becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com#endif 1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->append("]"); 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->prepend("path:["); 1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic const char* toString(SkRegion::Op op) { 1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const char* gOpNames[] = { 1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com "DIFF", "SECT", "UNION", "XOR", "RDIFF", "REPLACE" 1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return gOpNames[op]; 1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void toString(const SkRegion& rgn, SkString* str) { 1184258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->append("Region:["); 1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(rgn.getBounds(), str); 1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->append("]"); 1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (rgn.isComplex()) { 1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->append(".complex"); 1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic const char* toString(SkCanvas::VertexMode vm) { 1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const char* gVMNames[] = { 1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com "TRIANGLES", "STRIP", "FAN" 1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return gVMNames[vm]; 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic const char* toString(SkCanvas::PointMode pm) { 1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const char* gPMNames[] = { 1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com "POINTS", "LINES", "POLYGON" 1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return gPMNames[pm]; 1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1408afae61a57f87e4a50578effce6c428031499301tomhudson@google.comstatic void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc, 1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString* str) { 1428afae61a57f87e4a50578effce6c428031499301tomhudson@google.com // FIXME: this code appears to be untested - and probably unused - and probably wrong 1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com switch (enc) { 1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case SkPaint::kUTF8_TextEncoding: 145adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com str->appendf("\"%.*s\"%s", (int)SkTMax<size_t>(byteLen, 32), (const char*) text, 1468afae61a57f87e4a50578effce6c428031499301tomhudson@google.com byteLen > 32 ? "..." : ""); 1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com break; 1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case SkPaint::kUTF16_TextEncoding: 149adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text, 1508afae61a57f87e4a50578effce6c428031499301tomhudson@google.com byteLen > 64 ? "..." : ""); 1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com break; 1526970557055acaed619d7bb89451868e1570249b2robertphillips@google.com case SkPaint::kUTF32_TextEncoding: 153adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text, 1548afae61a57f87e4a50578effce6c428031499301tomhudson@google.com byteLen > 128 ? "..." : ""); 1556970557055acaed619d7bb89451868e1570249b2robertphillips@google.com break; 1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case SkPaint::kGlyphID_TextEncoding: 1574258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str->append("<glyphs>"); 1588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com break; 1596970557055acaed619d7bb89451868e1570249b2robertphillips@google.com 1606970557055acaed619d7bb89451868e1570249b2robertphillips@google.com default: 1616970557055acaed619d7bb89451868e1570249b2robertphillips@google.com SkASSERT(false); 1626970557055acaed619d7bb89451868e1570249b2robertphillips@google.com break; 1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 168e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org#define WIDE_OPEN 16384 16944d498812a6fb0c60a8204e6334564fe518fba33skia.committer@gmail.com 170e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.orgSkDumpCanvas::SkDumpCanvas(Dumper* dumper) : INHERITED(WIDE_OPEN, WIDE_OPEN) { 1716ae24e0f5fa3306054679d0ec8f9d1f5d35c2617reed@google.com fNestLevel = 0; 1726ae24e0f5fa3306054679d0ec8f9d1f5d35c2617reed@google.com SkSafeRef(dumper); 1736ae24e0f5fa3306054679d0ec8f9d1f5d35c2617reed@google.com fDumper = dumper; 1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDumpCanvas::~SkDumpCanvas() { 17782065d667f64e232bcde2ad849756a6096fcbe6freed@google.com SkSafeUnref(fDumper); 1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::dump(Verb verb, const SkPaint* paint, 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char format[], ...) { 1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static const size_t BUFFER_SIZE = 1024; 1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com char buffer[BUFFER_SIZE]; 1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com va_list args; 1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com va_start(args, format); 1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com vsnprintf(buffer, BUFFER_SIZE, format, args); 1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com va_end(args); 18982065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (fDumper) { 1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fDumper->dump(this, verb, buffer, paint); 1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1975f6102d07982043542343ff0a6c67b1319ac9fc7Florin Malitavoid SkDumpCanvas::willSave() { 1985f6102d07982043542343ff0a6c67b1319ac9fc7Florin Malita this->dump(kSave_Verb, NULL, "save()"); 1995f6102d07982043542343ff0a6c67b1319ac9fc7Florin Malita this->INHERITED::willSave(); 2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 202e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.orgSkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, 203e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org SaveFlags flags) { 2044258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com SkString str; 2054258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.printf("saveLayer(0x%X)", flags); 2064258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (bounds) { 2074258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.append(" bounds"); 2084258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com toString(*bounds, &str); 2094258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2104258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (paint) { 2114258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (paint->getAlpha() != 0xFF) { 2124258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.appendf(" alpha:0x%02X", paint->getAlpha()); 2134258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2144258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com if (paint->getXfermode()) { 2154258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com str.appendf(" xfermode:%p", paint->getXfermode()); 2164258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2174258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com } 2184258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com this->dump(kSave_Verb, paint, str.c_str()); 219e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org return this->INHERITED::willSaveLayer(bounds, paint, flags); 2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 222e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.orgvoid SkDumpCanvas::willRestore() { 2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kRestore_Verb, NULL, "restore"); 224e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org this->INHERITED::willRestore(); 2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 22744c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.orgvoid SkDumpCanvas::didConcat(const SkMatrix& matrix) { 2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 229d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org 230d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org switch (matrix.getType()) { 231d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org case SkMatrix::kTranslate_Mask: 232d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org this->dump(kMatrix_Verb, NULL, "translate(%g %g)", 233d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getTranslateX()), 234d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getTranslateY())); 235d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org break; 236d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org case SkMatrix::kScale_Mask: 237d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org this->dump(kMatrix_Verb, NULL, "scale(%g %g)", 238d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getScaleX()), 239d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org SkScalarToFloat(matrix.getScaleY())); 240d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org break; 241d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org default: 242d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org matrix.toString(&str); 243d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str()); 244d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org break; 245d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org } 246d9ea09e1f29b303e6fa36079e99729d2951925b9commit-bot@chromium.org 24744c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org this->INHERITED::didConcat(matrix); 2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 25044c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.orgvoid SkDumpCanvas::didSetMatrix(const SkMatrix& matrix) { 2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 25276f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com matrix.toString(&str); 2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kMatrix_Verb, NULL, "setMatrix(%s)", str.c_str()); 25444c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org this->INHERITED::didSetMatrix(matrix); 2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2598f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comconst char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) { 2608f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW"; 261071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com} 262071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com 2638f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(rect, &str); 266071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com this->dump(kClip_Verb, NULL, "clipRect(%s %s %s)", str.c_str(), toString(op), 2678f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com EdgeStyleToAAString(edgeStyle)); 2688f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipRect(rect, op, edgeStyle); 2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2718f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 2724ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkString str; 2734ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com toString(rrect, &str); 2744ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com this->dump(kClip_Verb, NULL, "clipRRect(%s %s %s)", str.c_str(), toString(op), 2758f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com EdgeStyleToAAString(edgeStyle)); 2768f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipRRect(rrect, op, edgeStyle); 2774ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 2784ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 2798f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(path, &str); 282071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com this->dump(kClip_Verb, NULL, "clipPath(%s %s %s)", str.c_str(), toString(op), 2838f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com EdgeStyleToAAString(edgeStyle)); 2848f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipPath(path, op, edgeStyle); 2858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2878f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.comvoid SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(deviceRgn, &str); 2908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(), 2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(op)); 2928f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->INHERITED::onClipRegion(deviceRgn, op); 2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 295210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.orgvoid SkDumpCanvas::onPushCull(const SkRect& cullRect) { 296210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org SkString str; 297210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org toString(cullRect, &str); 298210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org this->dump(kCull_Verb, NULL, "pushCull(%s)", str.c_str()); 299210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org} 300210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org 301210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.orgvoid SkDumpCanvas::onPopCull() { 302210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org this->dump(kCull_Verb, NULL, "popCull()"); 303210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org} 3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawPaint(const SkPaint& paint) { 3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawPaint_Verb, &paint, "drawPaint()"); 3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawPoints(PointMode mode, size_t count, 3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint pts[], const SkPaint& paint) { 3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawPoints_Verb, &paint, "drawPoints(%s, %d)", toString(mode), 3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com count); 3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3164ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.comvoid SkDumpCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { 3174ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkString str; 3184ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com toString(rect, &str); 3194ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com this->dump(kDrawOval_Verb, &paint, "drawOval(%s)", str.c_str()); 3204ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 3214ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 3227ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.comvoid SkDumpCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { 3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(rect, &str); 3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawRect_Verb, &paint, "drawRect(%s)", str.c_str()); 3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3284ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.comvoid SkDumpCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { 3294ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com SkString str; 3304ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com toString(rrect, &str); 331ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org this->dump(kDrawDRRect_Verb, &paint, "drawRRect(%s)", str.c_str()); 332ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org} 333ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org 334ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.orgvoid SkDumpCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, 335ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org const SkPaint& paint) { 336ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org SkString str0, str1; 337ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org toString(outer, &str0); 338ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org toString(inner, &str0); 339ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org this->dump(kDrawRRect_Verb, &paint, "drawDRRect(%s,%s)", 340ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org str0.c_str(), str1.c_str()); 3414ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com} 3424ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 3437ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.comvoid SkDumpCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(path, &str); 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawPath_Verb, &paint, "drawPath(%s)", str.c_str()); 3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, 3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint) { 3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 35276f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&str); 3530becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(), 3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(x), SkScalarToFloat(y)); 3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3577112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.comvoid SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 358eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkRect& dst, const SkPaint* paint, 359eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org DrawBitmapRectFlags flags) { 3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString bs, rs; 36176f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&bs); 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(dst, &rs); 3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // show the src-rect only if its not everything 3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (src && (src->fLeft > 0 || src->fTop > 0 || 3657112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com src->fRight < SkIntToScalar(bitmap.width()) || 3667112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com src->fBottom < SkIntToScalar(bitmap.height()))) { 3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString ss; 3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(*src, &ss); 3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com rs.prependf("%s ", ss.c_str()); 3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3727112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)", 3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bs.c_str(), rs.c_str()); 3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, 3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint) { 3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString bs, ms; 37976f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&bs); 38076f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com m.toString(&ms); 3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawBitmap_Verb, paint, "drawBitmapMatrix(%s %s)", 3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bs.c_str(), ms.c_str()); 3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, 3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint) { 3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 38876f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com bitmap.toString(&str); 3890becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawBitmap_Verb, paint, "drawSprite(%s %d %d)", str.c_str(), 3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com x, y); 3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 393e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 394e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint& paint) { 3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 3970becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(), 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com byteLength, SkScalarToFloat(x), SkScalarToFloat(y)); 3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 401e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 402e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint& paint) { 4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 4050becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawText_Verb, &paint, "drawPosText(%s [%d] %g %g ...)", 4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str.c_str(), byteLength, SkScalarToFloat(pos[0].fX), 4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(pos[0].fY)); 4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 410e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 411e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com SkScalar constY, const SkPaint& paint) { 4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 4140becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)", 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str.c_str(), byteLength, SkScalarToFloat(xpos[0]), 4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(constY)); 4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 419e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkDumpCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 420e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkMatrix* matrix, const SkPaint& paint) { 4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString str; 4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(text, byteLength, paint.getTextEncoding(), &str); 4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])", 4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str.c_str(), byteLength); 4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 427b7425173f96e93b090787e2386ba5f022b6c2869fmalitavoid SkDumpCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 428b7425173f96e93b090787e2386ba5f022b6c2869fmalita const SkPaint& paint) { 429b7425173f96e93b090787e2386ba5f022b6c2869fmalita SkString str; 430b7425173f96e93b090787e2386ba5f022b6c2869fmalita toString(blob->bounds(), &str); 431b7425173f96e93b090787e2386ba5f022b6c2869fmalita this->dump(kDrawText_Verb, &paint, "drawTextBlob(%p) [%s]", blob, str.c_str()); 432b7425173f96e93b090787e2386ba5f022b6c2869fmalita // FIXME: dump the actual blob content? 433b7425173f96e93b090787e2386ba5f022b6c2869fmalita} 434b7425173f96e93b090787e2386ba5f022b6c2869fmalita 435d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reedvoid SkDumpCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, 436d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reed const SkPaint* paint) { 437a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %f:%f:%f:%f", picture, 438a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips picture->cullRect().fLeft, picture->cullRect().fTop, 439a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips picture->cullRect().fRight, picture->cullRect().fBottom); 4409b46e77ec2b387f4502926c2b9bf09450eec257creed@android.com fNestLevel += 1; 441d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reed this->INHERITED::onDrawPicture(picture, matrix, paint); 4429b46e77ec2b387f4502926c2b9bf09450eec257creed@android.com fNestLevel -= 1; 443a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %f:%f:%f:%f", &picture, 444a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips picture->cullRect().fLeft, picture->cullRect().fTop, 445a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips picture->cullRect().fRight, picture->cullRect().fBottom); 4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount, 4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint vertices[], const SkPoint texs[], 4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkColor colors[], SkXfermode* xmode, 4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const uint16_t indices[], int indexCount, 4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint) { 4530becfc5b7608ba67a4c98721cd61939e89ac5653reed@android.com this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", 4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX), 4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalarToFloat(vertices[0].fY)); 4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 458b3c9d1c33caf325aada244204215eb790c228c12dandovvoid SkDumpCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 459b3c9d1c33caf325aada244204215eb790c228c12dandov const SkPoint texCoords[4], SkXfermode* xmode, 460b3c9d1c33caf325aada244204215eb790c228c12dandov const SkPaint& paint) { 461963137b75c0a1fe91f35e9826742f36309f5e65ddandov //dumps corner points and colors in clockwise order starting on upper-left corner 462963137b75c0a1fe91f35e9826742f36309f5e65ddandov this->dump(kDrawPatch_Verb, &paint, "drawPatch(Vertices{[%f, %f], [%f, %f], [%f, %f], [%f, %f]}\ 463b3c9d1c33caf325aada244204215eb790c228c12dandov | Colors{[0x%x], [0x%x], [0x%x], [0x%x]} | TexCoords{[%f,%f], [%f,%f], [%f,%f], \ 464b3c9d1c33caf325aada244204215eb790c228c12dandov [%f,%f]})", 465b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kTopP0_CubicCtrlPts].fX, 466b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kTopP0_CubicCtrlPts].fY, 467b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kTopP3_CubicCtrlPts].fX, 468b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kTopP3_CubicCtrlPts].fY, 469b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kBottomP3_CubicCtrlPts].fX, 470b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kBottomP3_CubicCtrlPts].fY, 471b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kBottomP0_CubicCtrlPts].fX, 472b3c9d1c33caf325aada244204215eb790c228c12dandov cubics[SkPatchUtils::kBottomP0_CubicCtrlPts].fY, 473b3c9d1c33caf325aada244204215eb790c228c12dandov colors[0], colors[1], colors[2], colors[3], 474b3c9d1c33caf325aada244204215eb790c228c12dandov texCoords[0].x(), texCoords[0].y(), texCoords[1].x(), texCoords[1].y(), 475b3c9d1c33caf325aada244204215eb790c228c12dandov texCoords[2].x(), texCoords[2].y(), texCoords[3].x(), texCoords[3].y()); 476963137b75c0a1fe91f35e9826742f36309f5e65ddandov} 477963137b75c0a1fe91f35e9826742f36309f5e65ddandov 478cb60844b34766aad4151df5e87c144d4a57e9abereed@android.comvoid SkDumpCanvas::drawData(const void* data, size_t length) { 479cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com// this->dump(kDrawData_Verb, NULL, "drawData(%d)", length); 480cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com this->dump(kDrawData_Verb, NULL, "drawData(%d) %.*s", length, 481adacc7067ad617cdc7bbef39192ca80f4b4d27f9robertphillips@google.com SkTMin<size_t>(length, 64), data); 482cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com} 483cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com 4840a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comvoid SkDumpCanvas::beginCommentGroup(const char* description) { 4850a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com this->dump(kBeginCommentGroup_Verb, NULL, "beginCommentGroup(%s)", description); 4860a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com} 4870a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 4880a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comvoid SkDumpCanvas::addComment(const char* kywd, const char* value) { 4890a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com this->dump(kAddComment_Verb, NULL, "addComment(%s, %s)", kywd, value); 4900a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com} 4910a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 4920a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comvoid SkDumpCanvas::endCommentGroup() { 4930a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com this->dump(kEndCommentGroup_Verb, NULL, "endCommentGroup()"); 4940a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com} 4950a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkFormatDumper::SkFormatDumper(void (*proc)(const char*, void*), void* refcon) { 5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fProc = proc; 5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fRefcon = refcon; 5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void appendPtr(SkString* str, const void* ptr, const char name[]) { 5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (ptr) { 5068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com str->appendf(" %s:%p", name, ptr); 5078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 5088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 5098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void appendFlattenable(SkString* str, const SkFlattenable* ptr, 5118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char name[]) { 5128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (ptr) { 513a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com str->appendf(" %s:%p", name, ptr); 5148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 5158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 5168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb, 5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char str[], const SkPaint* p) { 5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkString msg, tab; 5209b46e77ec2b387f4502926c2b9bf09450eec257creed@android.com const int level = canvas->getNestLevel() + canvas->getSaveCount() - 1; 5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkASSERT(level >= 0); 5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com for (int i = 0; i < level; i++) { 5234258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com#if 0 5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com tab.append("\t"); 5254258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com#else 5264258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com tab.append(" "); // tabs are often too wide to be useful 5274258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccbreed@google.com#endif 5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com msg.printf("%s%s", tab.c_str(), str); 53082065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (p) { 5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com msg.appendf(" color:0x%08X flags:%X", p->getColor(), p->getFlags()); 5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getShader(), "shader"); 5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getXfermode(), "xfermode"); 5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); 5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getMaskFilter(), "maskFilter"); 5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); 5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendFlattenable(&msg, p->getColorFilter(), "filter"); 53982065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (SkDumpCanvas::kDrawText_Verb == verb) { 5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com msg.appendf(" textSize:%g", SkScalarToFloat(p->getTextSize())); 5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com appendPtr(&msg, p->getTypeface(), "typeface"); 5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 54473a4b4f91fac1783b589eead5e82b0c0771644deskia.committer@gmail.com 545b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com if (p->getStyle() != SkPaint::kFill_Style) { 546b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com msg.appendf(" strokeWidth:%g", SkScalarToFloat(p->getStrokeWidth())); 547b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com } 5488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 54982065d667f64e232bcde2ad849756a6096fcbe6freed@google.com 5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fProc(msg.c_str(), fRefcon); 5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/////////////////////////////////////////////////////////////////////////////// 5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstatic void dumpToDebugf(const char text[], void*) { 5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDebugf("%s\n", text); 5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 5588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {} 5608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 56176f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com#endif 562