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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, NULL, "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::drawPaint(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 |
301 void SkDumpCanvas::drawPoints(PointMode mode, size_t count, | 301 void SkDumpCanvas::onDrawPoints(PointMode mode, size_t count, |
302 const SkPoint pts[], const SkPaint& paint) { | 302 const SkPoint pts[], const SkPaint& paint) { |
303 this->dump(kDrawPoints_Verb, &paint, "drawPoints(%s, %d)", toString(mode), | 303 this->dump(kDrawPoints_Verb, &paint, "drawPoints(%s, %d)", toString(mode), |
304 count); | 304 count); |
305 } | 305 } |
306 | 306 |
307 void SkDumpCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { | 307 void SkDumpCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { |
308 SkString str; | 308 SkString str; |
309 toString(rect, &str); | 309 toString(rect, &str); |
310 this->dump(kDrawOval_Verb, &paint, "drawOval(%s)", str.c_str()); | 310 this->dump(kDrawOval_Verb, &paint, "drawOval(%s)", str.c_str()); |
311 } | 311 } |
312 | 312 |
313 void SkDumpCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { | 313 void SkDumpCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
314 SkString str; | 314 SkString str; |
315 toString(rect, &str); | 315 toString(rect, &str); |
316 this->dump(kDrawRect_Verb, &paint, "drawRect(%s)", str.c_str()); | 316 this->dump(kDrawRect_Verb, &paint, "drawRect(%s)", str.c_str()); |
317 } | 317 } |
318 | 318 |
319 void SkDumpCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { | 319 void SkDumpCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
320 SkString str; | 320 SkString str; |
321 toString(rrect, &str); | 321 toString(rrect, &str); |
322 this->dump(kDrawDRRect_Verb, &paint, "drawRRect(%s)", str.c_str()); | 322 this->dump(kDrawDRRect_Verb, &paint, "drawRRect(%s)", str.c_str()); |
323 } | 323 } |
324 | 324 |
325 void SkDumpCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, | 325 void SkDumpCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
326 const SkPaint& paint) { | 326 const SkPaint& paint) { |
327 SkString str0, str1; | 327 SkString str0, str1; |
328 toString(outer, &str0); | 328 toString(outer, &str0); |
329 toString(inner, &str0); | 329 toString(inner, &str0); |
330 this->dump(kDrawRRect_Verb, &paint, "drawDRRect(%s,%s)", | 330 this->dump(kDrawRRect_Verb, &paint, "drawDRRect(%s,%s)", |
331 str0.c_str(), str1.c_str()); | 331 str0.c_str(), str1.c_str()); |
332 } | 332 } |
333 | 333 |
334 void SkDumpCanvas::drawPath(const SkPath& path, const SkPaint& paint) { | 334 void SkDumpCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { |
335 SkString str; | 335 SkString str; |
336 toString(path, &str); | 336 toString(path, &str); |
337 this->dump(kDrawPath_Verb, &paint, "drawPath(%s)", str.c_str()); | 337 this->dump(kDrawPath_Verb, &paint, "drawPath(%s)", str.c_str()); |
338 } | 338 } |
339 | 339 |
340 void SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, | 340 void SkDumpCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
341 const SkPaint* paint) { | 341 const SkPaint* paint) { |
342 SkString str; | 342 SkString str; |
343 bitmap.toString(&str); | 343 bitmap.toString(&str); |
344 this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(), | 344 this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(), |
345 SkScalarToFloat(x), SkScalarToFloat(y)); | 345 SkScalarToFloat(x), SkScalarToFloat(y)); |
346 } | 346 } |
347 | 347 |
348 void SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* sr
c, | 348 void SkDumpCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, c
onst SkRect& dst, |
349 const SkRect& dst, const SkPaint* paint, | 349 const SkPaint* paint, DrawBitmapRectFlags fl
ags) { |
350 DrawBitmapRectFlags flags) { | |
351 SkString bs, rs; | 350 SkString bs, rs; |
352 bitmap.toString(&bs); | 351 bitmap.toString(&bs); |
353 toString(dst, &rs); | 352 toString(dst, &rs); |
354 // show the src-rect only if its not everything | 353 // show the src-rect only if its not everything |
355 if (src && (src->fLeft > 0 || src->fTop > 0 || | 354 if (src && (src->fLeft > 0 || src->fTop > 0 || |
356 src->fRight < SkIntToScalar(bitmap.width()) || | 355 src->fRight < SkIntToScalar(bitmap.width()) || |
357 src->fBottom < SkIntToScalar(bitmap.height()))) { | 356 src->fBottom < SkIntToScalar(bitmap.height()))) { |
358 SkString ss; | 357 SkString ss; |
359 toString(*src, &ss); | 358 toString(*src, &ss); |
360 rs.prependf("%s ", ss.c_str()); | 359 rs.prependf("%s ", ss.c_str()); |
361 } | 360 } |
362 | 361 |
363 this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)", | 362 this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)", |
364 bs.c_str(), rs.c_str()); | 363 bs.c_str(), rs.c_str()); |
365 } | 364 } |
366 | 365 |
367 void SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, | 366 void SkDumpCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& cente
r, |
368 const SkPaint* paint) { | 367 const SkRect& dst, const SkPaint* paint) { |
| 368 SkString str, centerStr, dstStr; |
| 369 bitmap.toString(&str); |
| 370 toString(center, ¢erStr); |
| 371 toString(dst, &dstStr); |
| 372 this->dump(kDrawBitmap_Verb, paint, "drawBitmapNine(%s %s %s)", str.c_str(), |
| 373 centerStr.c_str(), dstStr.c_str()); |
| 374 } |
| 375 |
| 376 void SkDumpCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, con
st SkPaint* paint) { |
| 377 SkString str; |
| 378 image->toString(&str); |
| 379 this->dump(kDrawBitmap_Verb, paint, "drawImage(%s %g %g)", str.c_str(), |
| 380 SkScalarToFloat(x), SkScalarToFloat(y)); |
| 381 } |
| 382 |
| 383 void SkDumpCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, cons
t SkRect& dst, |
| 384 const SkPaint* paint) { |
| 385 SkString bs, rs; |
| 386 image->toString(&bs); |
| 387 toString(dst, &rs); |
| 388 // show the src-rect only if its not everything |
| 389 if (src && (src->fLeft > 0 || src->fTop > 0 || |
| 390 src->fRight < SkIntToScalar(image->width()) || |
| 391 src->fBottom < SkIntToScalar(image->height()))) { |
| 392 SkString ss; |
| 393 toString(*src, &ss); |
| 394 rs.prependf("%s ", ss.c_str()); |
| 395 } |
| 396 |
| 397 this->dump(kDrawBitmap_Verb, paint, "drawImageRectToRect(%s %s)", |
| 398 bs.c_str(), rs.c_str()); |
| 399 } |
| 400 |
| 401 void SkDumpCanvas::onDrawSprite(const SkBitmap& bitmap, int x, int y, const SkPa
int* paint) { |
369 SkString str; | 402 SkString str; |
370 bitmap.toString(&str); | 403 bitmap.toString(&str); |
371 this->dump(kDrawBitmap_Verb, paint, "drawSprite(%s %d %d)", str.c_str(), | 404 this->dump(kDrawBitmap_Verb, paint, "drawSprite(%s %d %d)", str.c_str(), |
372 x, y); | 405 x, y); |
373 } | 406 } |
374 | 407 |
375 void SkDumpCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, S
kScalar y, | 408 void SkDumpCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, S
kScalar y, |
376 const SkPaint& paint) { | 409 const SkPaint& paint) { |
377 SkString str; | 410 SkString str; |
378 toString(text, byteLength, paint.getTextEncoding(), &str); | 411 toString(text, byteLength, paint.getTextEncoding(), &str); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 picture->cullRect().fLeft, picture->cullRect().fTop, | 453 picture->cullRect().fLeft, picture->cullRect().fTop, |
421 picture->cullRect().fRight, picture->cullRect().fBottom); | 454 picture->cullRect().fRight, picture->cullRect().fBottom); |
422 fNestLevel += 1; | 455 fNestLevel += 1; |
423 this->INHERITED::onDrawPicture(picture, matrix, paint); | 456 this->INHERITED::onDrawPicture(picture, matrix, paint); |
424 fNestLevel -= 1; | 457 fNestLevel -= 1; |
425 this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %f:%f:%f:%f", &picture, | 458 this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %f:%f:%f:%f", &picture, |
426 picture->cullRect().fLeft, picture->cullRect().fTop, | 459 picture->cullRect().fLeft, picture->cullRect().fTop, |
427 picture->cullRect().fRight, picture->cullRect().fBottom); | 460 picture->cullRect().fRight, picture->cullRect().fBottom); |
428 } | 461 } |
429 | 462 |
430 void SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount, | 463 void SkDumpCanvas::onDrawVertices(VertexMode vmode, int vertexCount, |
431 const SkPoint vertices[], const SkPoint texs[], | 464 const SkPoint vertices[], const SkPoint texs[]
, |
432 const SkColor colors[], SkXfermode* xmode, | 465 const SkColor colors[], SkXfermode* xmode, |
433 const uint16_t indices[], int indexCount, | 466 const uint16_t indices[], int indexCount, |
434 const SkPaint& paint) { | 467 const SkPaint& paint) { |
435 this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", | 468 this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)", |
436 toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX), | 469 toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX), |
437 SkScalarToFloat(vertices[0].fY)); | 470 SkScalarToFloat(vertices[0].fY)); |
438 } | 471 } |
439 | 472 |
440 void SkDumpCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4]
, | 473 void SkDumpCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4]
, |
441 const SkPoint texCoords[4], SkXfermode* xmode, | 474 const SkPoint texCoords[4], SkXfermode* xmode, |
442 const SkPaint& paint) { | 475 const SkPaint& paint) { |
443 //dumps corner points and colors in clockwise order starting on upper-left c
orner | 476 //dumps corner points and colors in clockwise order starting on upper-left c
orner |
444 this->dump(kDrawPatch_Verb, &paint, "drawPatch(Vertices{[%f, %f], [%f, %f],
[%f, %f], [%f, %f]}\ | 477 this->dump(kDrawPatch_Verb, &paint, "drawPatch(Vertices{[%f, %f], [%f, %f],
[%f, %f], [%f, %f]}\ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 561 |
529 /////////////////////////////////////////////////////////////////////////////// | 562 /////////////////////////////////////////////////////////////////////////////// |
530 | 563 |
531 static void dumpToDebugf(const char text[], void*) { | 564 static void dumpToDebugf(const char text[], void*) { |
532 SkDebugf("%s\n", text); | 565 SkDebugf("%s\n", text); |
533 } | 566 } |
534 | 567 |
535 SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {} | 568 SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {} |
536 | 569 |
537 #endif | 570 #endif |
OLD | NEW |