| OLD | NEW | 
|---|
| 1 | 1 | 
| 2 /* | 2 /* | 
| 3  * Copyright 2011 Google Inc. | 3  * Copyright 2011 Google Inc. | 
| 4  * | 4  * | 
| 5  * Use of this source code is governed by a BSD-style license that can be | 5  * Use of this source code is governed by a BSD-style license that can be | 
| 6  * found in the LICENSE file. | 6  * found in the LICENSE file. | 
| 7  */ | 7  */ | 
| 8 | 8 | 
| 9 #include "SkDumpCanvas.h" | 9 #include "SkDumpCanvas.h" | 
| 10 | 10 | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 188     va_end(args); | 188     va_end(args); | 
| 189 | 189 | 
| 190     if (fDumper) { | 190     if (fDumper) { | 
| 191         fDumper->dump(this, verb, buffer, paint); | 191         fDumper->dump(this, verb, buffer, paint); | 
| 192     } | 192     } | 
| 193 } | 193 } | 
| 194 | 194 | 
| 195 /////////////////////////////////////////////////////////////////////////////// | 195 /////////////////////////////////////////////////////////////////////////////// | 
| 196 | 196 | 
| 197 void SkDumpCanvas::willSave() { | 197 void SkDumpCanvas::willSave() { | 
| 198     this->dump(kSave_Verb, NULL, "save()"); | 198     this->dump(kSave_Verb, nullptr, "save()"); | 
| 199     this->INHERITED::willSave(); | 199     this->INHERITED::willSave(); | 
| 200 } | 200 } | 
| 201 | 201 | 
| 202 SkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, co
     nst SkPaint* paint, | 202 SkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, co
     nst SkPaint* paint, | 
| 203                                                         SaveFlags flags) { | 203                                                         SaveFlags flags) { | 
| 204     SkString str; | 204     SkString str; | 
| 205     str.printf("saveLayer(0x%X)", flags); | 205     str.printf("saveLayer(0x%X)", flags); | 
| 206     if (bounds) { | 206     if (bounds) { | 
| 207         str.append(" bounds"); | 207         str.append(" bounds"); | 
| 208         toString(*bounds, &str); | 208         toString(*bounds, &str); | 
| 209     } | 209     } | 
| 210     if (paint) { | 210     if (paint) { | 
| 211         if (paint->getAlpha() != 0xFF) { | 211         if (paint->getAlpha() != 0xFF) { | 
| 212             str.appendf(" alpha:0x%02X", paint->getAlpha()); | 212             str.appendf(" alpha:0x%02X", paint->getAlpha()); | 
| 213         } | 213         } | 
| 214         if (paint->getXfermode()) { | 214         if (paint->getXfermode()) { | 
| 215             str.appendf(" xfermode:%p", paint->getXfermode()); | 215             str.appendf(" xfermode:%p", paint->getXfermode()); | 
| 216         } | 216         } | 
| 217     } | 217     } | 
| 218     this->dump(kSave_Verb, paint, str.c_str()); | 218     this->dump(kSave_Verb, paint, str.c_str()); | 
| 219     return this->INHERITED::willSaveLayer(bounds, paint, flags); | 219     return this->INHERITED::willSaveLayer(bounds, paint, flags); | 
| 220 } | 220 } | 
| 221 | 221 | 
| 222 void SkDumpCanvas::willRestore() { | 222 void SkDumpCanvas::willRestore() { | 
| 223     this->dump(kRestore_Verb, NULL, "restore"); | 223     this->dump(kRestore_Verb, nullptr, "restore"); | 
| 224     this->INHERITED::willRestore(); | 224     this->INHERITED::willRestore(); | 
| 225 } | 225 } | 
| 226 | 226 | 
| 227 void SkDumpCanvas::didConcat(const SkMatrix& matrix) { | 227 void SkDumpCanvas::didConcat(const SkMatrix& matrix) { | 
| 228     SkString str; | 228     SkString str; | 
| 229 | 229 | 
| 230     switch (matrix.getType()) { | 230     switch (matrix.getType()) { | 
| 231         case SkMatrix::kTranslate_Mask: | 231         case SkMatrix::kTranslate_Mask: | 
| 232             this->dump(kMatrix_Verb, NULL, "translate(%g %g)", | 232             this->dump(kMatrix_Verb, nullptr, "translate(%g %g)", | 
| 233                        SkScalarToFloat(matrix.getTranslateX()), | 233                        SkScalarToFloat(matrix.getTranslateX()), | 
| 234                        SkScalarToFloat(matrix.getTranslateY())); | 234                        SkScalarToFloat(matrix.getTranslateY())); | 
| 235             break; | 235             break; | 
| 236         case SkMatrix::kScale_Mask: | 236         case SkMatrix::kScale_Mask: | 
| 237             this->dump(kMatrix_Verb, NULL, "scale(%g %g)", | 237             this->dump(kMatrix_Verb, nullptr, "scale(%g %g)", | 
| 238                        SkScalarToFloat(matrix.getScaleX()), | 238                        SkScalarToFloat(matrix.getScaleX()), | 
| 239                        SkScalarToFloat(matrix.getScaleY())); | 239                        SkScalarToFloat(matrix.getScaleY())); | 
| 240             break; | 240             break; | 
| 241         default: | 241         default: | 
| 242             matrix.toString(&str); | 242             matrix.toString(&str); | 
| 243             this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str()); | 243             this->dump(kMatrix_Verb, nullptr, "concat(%s)", str.c_str()); | 
| 244             break; | 244             break; | 
| 245     } | 245     } | 
| 246 | 246 | 
| 247     this->INHERITED::didConcat(matrix); | 247     this->INHERITED::didConcat(matrix); | 
| 248 } | 248 } | 
| 249 | 249 | 
| 250 void SkDumpCanvas::didSetMatrix(const SkMatrix& matrix) { | 250 void SkDumpCanvas::didSetMatrix(const SkMatrix& matrix) { | 
| 251     SkString str; | 251     SkString str; | 
| 252     matrix.toString(&str); | 252     matrix.toString(&str); | 
| 253     this->dump(kMatrix_Verb, NULL, "setMatrix(%s)", str.c_str()); | 253     this->dump(kMatrix_Verb, nullptr, "setMatrix(%s)", str.c_str()); | 
| 254     this->INHERITED::didSetMatrix(matrix); | 254     this->INHERITED::didSetMatrix(matrix); | 
| 255 } | 255 } | 
| 256 | 256 | 
| 257 /////////////////////////////////////////////////////////////////////////////// | 257 /////////////////////////////////////////////////////////////////////////////// | 
| 258 | 258 | 
| 259 const char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) { | 259 const char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) { | 
| 260     return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW"; | 260     return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW"; | 
| 261 } | 261 } | 
| 262 | 262 | 
| 263 void SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle
      edgeStyle) { | 263 void SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle
      edgeStyle) { | 
| 264     SkString str; | 264     SkString str; | 
| 265     toString(rect, &str); | 265     toString(rect, &str); | 
| 266     this->dump(kClip_Verb, NULL, "clipRect(%s %s %s)", str.c_str(), toString(op)
     , | 266     this->dump(kClip_Verb, nullptr, "clipRect(%s %s %s)", str.c_str(), toString(
     op), | 
| 267                EdgeStyleToAAString(edgeStyle)); | 267                EdgeStyleToAAString(edgeStyle)); | 
| 268     this->INHERITED::onClipRect(rect, op, edgeStyle); | 268     this->INHERITED::onClipRect(rect, op, edgeStyle); | 
| 269 } | 269 } | 
| 270 | 270 | 
| 271 void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeSt
     yle edgeStyle) { | 271 void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeSt
     yle edgeStyle) { | 
| 272     SkString str; | 272     SkString str; | 
| 273     toString(rrect, &str); | 273     toString(rrect, &str); | 
| 274     this->dump(kClip_Verb, NULL, "clipRRect(%s %s %s)", str.c_str(), toString(op
     ), | 274     this->dump(kClip_Verb, nullptr, "clipRRect(%s %s %s)", str.c_str(), toString
     (op), | 
| 275                EdgeStyleToAAString(edgeStyle)); | 275                EdgeStyleToAAString(edgeStyle)); | 
| 276     this->INHERITED::onClipRRect(rrect, op, edgeStyle); | 276     this->INHERITED::onClipRRect(rrect, op, edgeStyle); | 
| 277 } | 277 } | 
| 278 | 278 | 
| 279 void SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle
      edgeStyle) { | 279 void SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle
      edgeStyle) { | 
| 280     SkString str; | 280     SkString str; | 
| 281     toString(path, &str); | 281     toString(path, &str); | 
| 282     this->dump(kClip_Verb, NULL, "clipPath(%s %s %s)", str.c_str(), toString(op)
     , | 282     this->dump(kClip_Verb, nullptr, "clipPath(%s %s %s)", str.c_str(), toString(
     op), | 
| 283                EdgeStyleToAAString(edgeStyle)); | 283                EdgeStyleToAAString(edgeStyle)); | 
| 284     this->INHERITED::onClipPath(path, op, edgeStyle); | 284     this->INHERITED::onClipPath(path, op, edgeStyle); | 
| 285 } | 285 } | 
| 286 | 286 | 
| 287 void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { | 287 void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { | 
| 288     SkString str; | 288     SkString str; | 
| 289     toString(deviceRgn, &str); | 289     toString(deviceRgn, &str); | 
| 290     this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(), | 290     this->dump(kClip_Verb, nullptr, "clipRegion(%s %s)", str.c_str(), | 
| 291                toString(op)); | 291                toString(op)); | 
| 292     this->INHERITED::onClipRegion(deviceRgn, op); | 292     this->INHERITED::onClipRegion(deviceRgn, op); | 
| 293 } | 293 } | 
| 294 | 294 | 
| 295 /////////////////////////////////////////////////////////////////////////////// | 295 /////////////////////////////////////////////////////////////////////////////// | 
| 296 | 296 | 
| 297 void SkDumpCanvas::onDrawPaint(const SkPaint& paint) { | 297 void SkDumpCanvas::onDrawPaint(const SkPaint& paint) { | 
| 298     this->dump(kDrawPaint_Verb, &paint, "drawPaint()"); | 298     this->dump(kDrawPaint_Verb, &paint, "drawPaint()"); | 
| 299 } | 299 } | 
| 300 | 300 | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 441 void SkDumpCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y
     , | 441 void SkDumpCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y
     , | 
| 442                                   const SkPaint& paint) { | 442                                   const SkPaint& paint) { | 
| 443     SkString str; | 443     SkString str; | 
| 444     toString(blob->bounds(), &str); | 444     toString(blob->bounds(), &str); | 
| 445     this->dump(kDrawText_Verb, &paint, "drawTextBlob(%p) [%s]", blob, str.c_str(
     )); | 445     this->dump(kDrawText_Verb, &paint, "drawTextBlob(%p) [%s]", blob, str.c_str(
     )); | 
| 446     // FIXME: dump the actual blob content? | 446     // FIXME: dump the actual blob content? | 
| 447 } | 447 } | 
| 448 | 448 | 
| 449 void SkDumpCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matri
     x, | 449 void SkDumpCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matri
     x, | 
| 450                                  const SkPaint* paint) { | 450                                  const SkPaint* paint) { | 
| 451     this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %f:%f:%f:%f", picture, | 451     this->dump(kDrawPicture_Verb, nullptr, "drawPicture(%p) %f:%f:%f:%f", pictur
     e, | 
| 452                picture->cullRect().fLeft, picture->cullRect().fTop, | 452                picture->cullRect().fLeft, picture->cullRect().fTop, | 
| 453                picture->cullRect().fRight, picture->cullRect().fBottom); | 453                picture->cullRect().fRight, picture->cullRect().fBottom); | 
| 454     fNestLevel += 1; | 454     fNestLevel += 1; | 
| 455     this->INHERITED::onDrawPicture(picture, matrix, paint); | 455     this->INHERITED::onDrawPicture(picture, matrix, paint); | 
| 456     fNestLevel -= 1; | 456     fNestLevel -= 1; | 
| 457     this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %f:%f:%f:%f", &picture, | 457     this->dump(kDrawPicture_Verb, nullptr, "endPicture(%p) %f:%f:%f:%f", &pictur
     e, | 
| 458                picture->cullRect().fLeft, picture->cullRect().fTop, | 458                picture->cullRect().fLeft, picture->cullRect().fTop, | 
| 459                picture->cullRect().fRight, picture->cullRect().fBottom); | 459                picture->cullRect().fRight, picture->cullRect().fBottom); | 
| 460 } | 460 } | 
| 461 | 461 | 
| 462 void SkDumpCanvas::onDrawVertices(VertexMode vmode, int vertexCount, | 462 void SkDumpCanvas::onDrawVertices(VertexMode vmode, int vertexCount, | 
| 463                                   const SkPoint vertices[], const SkPoint texs[]
     , | 463                                   const SkPoint vertices[], const SkPoint texs[]
     , | 
| 464                                   const SkColor colors[], SkXfermode* xmode, | 464                                   const SkColor colors[], SkXfermode* xmode, | 
| 465                                   const uint16_t indices[], int indexCount, | 465                                   const uint16_t indices[], int indexCount, | 
| 466                                   const SkPaint& paint) { | 466                                   const SkPaint& paint) { | 
| 467     this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", | 467     this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 545 | 545 | 
| 546     fProc(msg.c_str(), fRefcon); | 546     fProc(msg.c_str(), fRefcon); | 
| 547 } | 547 } | 
| 548 | 548 | 
| 549 /////////////////////////////////////////////////////////////////////////////// | 549 /////////////////////////////////////////////////////////////////////////////// | 
| 550 | 550 | 
| 551 static void dumpToDebugf(const char text[], void*) { | 551 static void dumpToDebugf(const char text[], void*) { | 
| 552     SkDebugf("%s\n", text); | 552     SkDebugf("%s\n", text); | 
| 553 } | 553 } | 
| 554 | 554 | 
| 555 SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {} | 555 SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, nullptr) {} | 
| 556 | 556 | 
| 557 #endif | 557 #endif | 
| OLD | NEW | 
|---|