Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: debugger/SkDrawCommand.cpp

Issue 12989030: SkDrawCommand cleanup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 9
10 #include "SkDrawCommand.h" 10 #include "SkDrawCommand.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 void DrawBitmapRect::execute(SkCanvas* canvas) { 277 void DrawBitmapRect::execute(SkCanvas* canvas) {
278 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr); 278 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr);
279 } 279 }
280 280
281 const SkBitmap* DrawBitmapRect::getBitmap() const { 281 const SkBitmap* DrawBitmapRect::getBitmap() const {
282 return &fResizedBitmap; 282 return &fResizedBitmap;
283 } 283 }
284 284
285 DrawData::DrawData(const void* data, size_t length) { 285 DrawData::DrawData(const void* data, size_t length) {
286 this->fData = data; 286 fData = new char[length];
287 this->fLength = length; 287 memcpy(fData, data, length);
288 this->fDrawType = DRAW_DATA; 288 fLength = length;
289 // TODO(chudy): See if we can't display data and length. 289 fDrawType = DRAW_DATA;
290
291 // TODO: add display of actual data?
292 SkString* str = new SkString;
293 str->appendf("length: %d", length);
294 fInfo.push(str);
290 } 295 }
291 296
292 void DrawData::execute(SkCanvas* canvas) { 297 void DrawData::execute(SkCanvas* canvas) {
293 canvas->drawData(this->fData, this->fLength); 298 canvas->drawData(fData, fLength);
294 } 299 }
295 300
296 DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) { 301 DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) {
297 fOval = oval; 302 fOval = oval;
298 fPaint = paint; 303 fPaint = paint;
299 fDrawType = DRAW_OVAL; 304 fDrawType = DRAW_OVAL;
300 305
301 fInfo.push(SkObjectParser::RectToString(oval)); 306 fInfo.push(SkObjectParser::RectToString(oval));
302 fInfo.push(SkObjectParser::PaintToString(paint)); 307 fInfo.push(SkObjectParser::PaintToString(paint));
303 } 308 }
(...skipping 24 matching lines...) Expand all
328 } 333 }
329 334
330 void DrawPath::execute(SkCanvas* canvas) { 335 void DrawPath::execute(SkCanvas* canvas) {
331 canvas->drawPath(fPath, fPaint); 336 canvas->drawPath(fPath, fPaint);
332 } 337 }
333 338
334 const SkBitmap* DrawPath::getBitmap() const { 339 const SkBitmap* DrawPath::getBitmap() const {
335 return &fBitmap; 340 return &fBitmap;
336 } 341 }
337 342
338 DrawPicture::DrawPicture(SkPicture& picture) { 343 DrawPicture::DrawPicture(SkPicture& picture) :
339 this->fPicture = &picture; 344 fPicture(picture) {
340 this->fDrawType = DRAW_PICTURE; 345 fDrawType = DRAW_PICTURE;
341 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); 346 fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
342 } 347 }
343 348
344 void DrawPicture::execute(SkCanvas* canvas) { 349 void DrawPicture::execute(SkCanvas* canvas) {
345 canvas->drawPicture(*this->fPicture); 350 canvas->drawPicture(fPicture);
346 } 351 }
347 352
348 DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count, 353 DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
349 const SkPoint pts[], const SkPaint& paint) { 354 const SkPoint pts[], const SkPaint& paint) {
350 fMode = mode; 355 fMode = mode;
351 fCount = count; 356 fCount = count;
352 fPts = new SkPoint[count]; 357 fPts = new SkPoint[count];
353 memcpy(fPts, pts, count * sizeof(SkPoint)); 358 memcpy(fPts, pts, count * sizeof(SkPoint));
354 fPaint = paint; 359 fPaint = paint;
355 fDrawType = DRAW_POINTS; 360 fDrawType = DRAW_POINTS;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 428
424 fInfo.push(SkObjectParser::RectToString(rect)); 429 fInfo.push(SkObjectParser::RectToString(rect));
425 fInfo.push(SkObjectParser::PaintToString(paint)); 430 fInfo.push(SkObjectParser::PaintToString(paint));
426 } 431 }
427 432
428 void DrawRectC::execute(SkCanvas* canvas) { 433 void DrawRectC::execute(SkCanvas* canvas) {
429 canvas->drawRect(fRect, fPaint); 434 canvas->drawRect(fRect, fPaint);
430 } 435 }
431 436
432 DrawRRect::DrawRRect(const SkRRect& rrect, const SkPaint& paint) { 437 DrawRRect::DrawRRect(const SkRRect& rrect, const SkPaint& paint) {
433 this->fRRect = rrect; 438 fRRect = rrect;
434 this->fPaint = paint; 439 fPaint = paint;
435 this->fDrawType = DRAW_RRECT; 440 fDrawType = DRAW_RRECT;
436 441
437 this->fInfo.push(SkObjectParser::RRectToString(rrect)); 442 fInfo.push(SkObjectParser::RRectToString(rrect));
438 this->fInfo.push(SkObjectParser::PaintToString(paint)); 443 fInfo.push(SkObjectParser::PaintToString(paint));
439 } 444 }
440 445
441 void DrawRRect::execute(SkCanvas* canvas) { 446 void DrawRRect::execute(SkCanvas* canvas) {
442 canvas->drawRRect(fRRect, fPaint); 447 canvas->drawRRect(fRRect, fPaint);
443 } 448 }
444 449
445 DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top, 450 DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top,
446 const SkPaint* paint, SkBitmap& resizedBitmap) { 451 const SkPaint* paint, SkBitmap& resizedBitmap) {
447 this->fBitmap = &bitmap; 452 fBitmap = bitmap;
448 this->fLeft = left; 453 fLeft = left;
449 this->fTop = top; 454 fTop = top;
450 this->fPaint = paint; 455 if (NULL != paint) {
451 this->fDrawType = DRAW_SPRITE; 456 fPaint = *paint;
452 this->fResizedBitmap = resizedBitmap; 457 fPaintPtr = &fPaint;
458 } else {
459 fPaintPtr = NULL;
460 }
461 fDrawType = DRAW_SPRITE;
462 fResizedBitmap = resizedBitmap;
453 463
454 this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); 464 fInfo.push(SkObjectParser::BitmapToString(bitmap));
455 this->fInfo.push(SkObjectParser::IntToString(left, "Left: ")); 465 fInfo.push(SkObjectParser::IntToString(left, "Left: "));
456 this->fInfo.push(SkObjectParser::IntToString(top, "Top: ")); 466 fInfo.push(SkObjectParser::IntToString(top, "Top: "));
467 if (NULL != paint) {
468 fInfo.push(SkObjectParser::PaintToString(*paint));
469 }
457 } 470 }
458 471
459 void DrawSprite::execute(SkCanvas* canvas) { 472 void DrawSprite::execute(SkCanvas* canvas) {
460 canvas->drawSprite(*this->fBitmap, this->fLeft, this->fTop, this->fPaint); 473 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr);
461 } 474 }
462 475
463 const SkBitmap* DrawSprite::getBitmap() const { 476 const SkBitmap* DrawSprite::getBitmap() const {
464 return &fResizedBitmap; 477 return &fResizedBitmap;
465 } 478 }
466 479
467 DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y , 480 DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y ,
468 const SkPaint& paint) { 481 const SkPaint& paint) {
469 this->fText = text; 482 fText = new char[byteLength];
470 this->fByteLength = byteLength; 483 memcpy(fText, text, byteLength);
471 this->fX = x; 484 fByteLength = byteLength;
472 this->fY = y; 485 fX = x;
473 this->fPaint = &paint; 486 fY = y;
474 this->fDrawType = DRAW_TEXT; 487 fPaint = paint;
488 fDrawType = DRAW_TEXT;
475 489
476 this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTex tEncoding())); 490 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod ing()));
477 this->fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); 491 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
478 this->fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); 492 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
479 this->fInfo.push(SkObjectParser::PaintToString(paint)); 493 fInfo.push(SkObjectParser::PaintToString(paint));
480 } 494 }
481 495
482 void DrawTextC::execute(SkCanvas* canvas) { 496 void DrawTextC::execute(SkCanvas* canvas) {
483 canvas->drawText(this->fText, this->fByteLength, this->fX, this->fY, *this-> fPaint); 497 canvas->drawText(fText, fByteLength, fX, fY, fPaint);
484 } 498 }
485 499
486 DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength, 500 DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength,
487 const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { 501 const SkPath& path, const SkMatrix* matrix,
488 this->fText = text; 502 const SkPaint& paint) {
489 this->fByteLength = byteLength; 503 fText = new char[byteLength];
490 this->fPath = &path; 504 memcpy(fText, text, byteLength);
491 this->fMatrix = matrix; 505 fByteLength = byteLength;
492 this->fPaint = &paint; 506 fPath = path;
493 this->fDrawType = DRAW_TEXT_ON_PATH; 507 if (NULL != matrix) {
508 fMatrix = *matrix;
509 } else {
510 fMatrix.setIdentity();
511 }
512 fPaint = paint;
513 fDrawType = DRAW_TEXT_ON_PATH;
494 514
495 this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTex tEncoding())); 515 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod ing()));
496 this->fInfo.push(SkObjectParser::PathToString(path)); 516 fInfo.push(SkObjectParser::PathToString(path));
497 if (matrix) this->fInfo.push(SkObjectParser::MatrixToString(*matrix)); 517 if (NULL != matrix) {
498 this->fInfo.push(SkObjectParser::PaintToString(paint)); 518 fInfo.push(SkObjectParser::MatrixToString(*matrix));
519 }
520 fInfo.push(SkObjectParser::PaintToString(paint));
499 } 521 }
500 522
501 void DrawTextOnPath::execute(SkCanvas* canvas) { 523 void DrawTextOnPath::execute(SkCanvas* canvas) {
502 canvas->drawTextOnPath(this->fText, this->fByteLength, *this->fPath, 524 canvas->drawTextOnPath(fText, fByteLength, fPath,
503 this->fMatrix, *this->fPaint); 525 fMatrix.isIdentity() ? NULL : &fMatrix,
526 fPaint);
504 } 527 }
505 528
506 DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount, 529 DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
507 const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], 530 const SkPoint vertices[], const SkPoint texs[],
508 SkXfermode* xfermode, const uint16_t indices[], int indexCount, 531 const SkColor colors[], SkXfermode* xfermode,
509 const SkPaint& paint) { 532 const uint16_t indices[], int indexCount,
510 this->fVmode = vmode; 533 const SkPaint& paint) {
511 this->fVertexCount = vertexCount; 534 fVmode = vmode;
512 this->fTexs = texs; 535
513 this->fColors = colors; 536 fVertexCount = vertexCount;
514 this->fXfermode = xfermode; 537
515 this->fIndices = indices; 538 fVertices = new SkPoint[vertexCount];
516 this->fIndexCount = indexCount; 539 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint));
517 this->fPaint = &paint; 540
518 this->fDrawType = DRAW_VERTICES; 541 if (NULL != texs) {
542 fTexs = new SkPoint[vertexCount];
543 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint));
544 } else {
545 fTexs = NULL;
546 }
547
548 if (NULL != colors) {
549 fColors = new SkColor[vertexCount];
550 memcpy(fColors, colors, vertexCount * sizeof(SkColor));
551 } else {
552 fColors = NULL;
553 }
554
555 fXfermode = xfermode;
556 if (NULL != fXfermode) {
557 fXfermode->ref();
558 }
559
560 if (indexCount > 0) {
561 fIndices = new uint16_t[indexCount];
562 memcpy(fIndices, indices, indexCount * sizeof(uint16_t));
563 } else {
564 fIndices = NULL;
565 }
566
567 fIndexCount = indexCount;
568 fPaint = paint;
569 fDrawType = DRAW_VERTICES;
570
519 // TODO(chudy) 571 // TODO(chudy)
520 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); 572 fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
573 fInfo.push(SkObjectParser::PaintToString(paint));
574 }
575
576 DrawVertices::~DrawVertices() {
577 delete [] fVertices;
578 delete [] fTexs;
579 delete [] fColors;
580 SkSafeUnref(fXfermode);
581 delete [] fIndices;
521 } 582 }
522 583
523 void DrawVertices::execute(SkCanvas* canvas) { 584 void DrawVertices::execute(SkCanvas* canvas) {
524 canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices, 585 canvas->drawVertices(fVmode, fVertexCount, fVertices,
525 this->fTexs, this->fColors, this->fXfermode, this->fIndices, 586 fTexs, fColors, fXfermode, fIndices,
526 this->fIndexCount, *this->fPaint); 587 fIndexCount, fPaint);
527 } 588 }
528 589
529 Restore::Restore() { 590 Restore::Restore() {
530 fDrawType = RESTORE; 591 fDrawType = RESTORE;
531 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); 592 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
532 } 593 }
533 594
534 void Restore::execute(SkCanvas* canvas) { 595 void Restore::execute(SkCanvas* canvas) {
535 canvas->restore(); 596 canvas->restore();
536 } 597 }
537 598
538 void Restore::trackSaveState(int* state) { 599 void Restore::trackSaveState(int* state) {
539 (*state)--; 600 (*state)--;
540 } 601 }
541 602
542 Rotate::Rotate(SkScalar degrees) { 603 Rotate::Rotate(SkScalar degrees) {
543 this->fDegrees = degrees; 604 fDegrees = degrees;
544 this->fDrawType = ROTATE; 605 fDrawType = ROTATE;
545 606
546 this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); 607 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
547 } 608 }
548 609
549 void Rotate::execute(SkCanvas* canvas) { 610 void Rotate::execute(SkCanvas* canvas) {
550 canvas->rotate(this->fDegrees); 611 canvas->rotate(fDegrees);
551 } 612 }
552 613
553 Save::Save(SkCanvas::SaveFlags flags) { 614 Save::Save(SkCanvas::SaveFlags flags) {
554 fFlags = flags; 615 fFlags = flags;
555 fDrawType = SAVE; 616 fDrawType = SAVE;
556 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); 617 fInfo.push(SkObjectParser::SaveFlagsToString(flags));
557 } 618 }
558 619
559 void Save::execute(SkCanvas* canvas) { 620 void Save::execute(SkCanvas* canvas) {
560 canvas->save(fFlags); 621 canvas->save(fFlags);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, 655 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds,
595 fPaintPtr, 656 fPaintPtr,
596 fFlags); 657 fFlags);
597 } 658 }
598 659
599 void SaveLayer::trackSaveState(int* state) { 660 void SaveLayer::trackSaveState(int* state) {
600 (*state)++; 661 (*state)++;
601 } 662 }
602 663
603 Scale::Scale(SkScalar sx, SkScalar sy) { 664 Scale::Scale(SkScalar sx, SkScalar sy) {
604 this->fSx = sx; 665 fSx = sx;
605 this->fSy = sy; 666 fSy = sy;
606 this->fDrawType = SCALE; 667 fDrawType = SCALE;
607 668
608 this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); 669 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
609 this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); 670 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
610 } 671 }
611 672
612 void Scale::execute(SkCanvas* canvas) { 673 void Scale::execute(SkCanvas* canvas) {
613 canvas->scale(this->fSx, this->fSy); 674 canvas->scale(fSx, fSy);
614 } 675 }
615 676
616 SetMatrix::SetMatrix(const SkMatrix& matrix) { 677 SetMatrix::SetMatrix(const SkMatrix& matrix) {
617 this->fMatrix = matrix; 678 fMatrix = matrix;
618 this->fDrawType = SET_MATRIX; 679 fDrawType = SET_MATRIX;
619 680
620 this->fInfo.push(SkObjectParser::MatrixToString(matrix)); 681 fInfo.push(SkObjectParser::MatrixToString(matrix));
621 } 682 }
622 683
623 void SetMatrix::execute(SkCanvas* canvas) { 684 void SetMatrix::execute(SkCanvas* canvas) {
624 canvas->setMatrix(this->fMatrix); 685 canvas->setMatrix(fMatrix);
625 } 686 }
626 687
627 Skew::Skew(SkScalar sx, SkScalar sy) { 688 Skew::Skew(SkScalar sx, SkScalar sy) {
628 this->fSx = sx; 689 fSx = sx;
629 this->fSy = sy; 690 fSy = sy;
630 this->fDrawType = SKEW; 691 fDrawType = SKEW;
631 692
632 this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); 693 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
633 this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); 694 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
634 } 695 }
635 696
636 void Skew::execute(SkCanvas* canvas) { 697 void Skew::execute(SkCanvas* canvas) {
637 canvas->skew(this->fSx, this->fSy); 698 canvas->skew(fSx, fSy);
638 } 699 }
639 700
640 Translate::Translate(SkScalar dx, SkScalar dy) { 701 Translate::Translate(SkScalar dx, SkScalar dy) {
641 this->fDx = dx; 702 fDx = dx;
642 this->fDy = dy; 703 fDy = dy;
643 this->fDrawType = TRANSLATE; 704 fDrawType = TRANSLATE;
644 705
645 this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); 706 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
646 this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); 707 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
647 } 708 }
648 709
649 void Translate::execute(SkCanvas* canvas) { 710 void Translate::execute(SkCanvas* canvas) {
650 canvas->translate(this->fDx, this->fDy); 711 canvas->translate(fDx, fDy);
651 } 712 }
OLDNEW
« no previous file with comments | « debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698