| OLD | NEW |
| 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" |
| 11 #include "SkObjectParser.h" | 11 #include "SkObjectParser.h" |
| 12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
| 13 #include "SkTextBlob.h" | 13 #include "SkTextBlob.h" |
| 14 #include "SkTextBlobRunIterator.h" |
| 14 | 15 |
| 15 // TODO(chudy): Refactor into non subclass model. | 16 // TODO(chudy): Refactor into non subclass model. |
| 16 | 17 |
| 17 SkDrawCommand::SkDrawCommand(OpType type) | 18 SkDrawCommand::SkDrawCommand(OpType type) |
| 18 : fOpType(type) | 19 : fOpType(type) |
| 19 , fVisible(true) { | 20 , fVisible(true) { |
| 20 } | 21 } |
| 21 | 22 |
| 22 SkDrawCommand::~SkDrawCommand() { | 23 SkDrawCommand::~SkDrawCommand() { |
| 23 fInfo.deleteAll(); | 24 fInfo.deleteAll(); |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 fInfo.push(SkObjectParser::PaintToString(paint)); | 672 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 672 } | 673 } |
| 673 | 674 |
| 674 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { | 675 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { |
| 675 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); | 676 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
| 676 } | 677 } |
| 677 | 678 |
| 678 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, | 679 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, |
| 679 const SkPaint& paint) | 680 const SkPaint& paint) |
| 680 : INHERITED(kDrawTextBlob_OpType) | 681 : INHERITED(kDrawTextBlob_OpType) |
| 681 , fBlob(blob) | 682 , fBlob(SkRef(blob)) |
| 682 , fXPos(x) | 683 , fXPos(x) |
| 683 , fYPos(y) | 684 , fYPos(y) |
| 684 , fPaint(paint) { | 685 , fPaint(paint) { |
| 685 | 686 |
| 686 blob->ref(); | 687 SkAutoTDelete<SkString> runsStr(new SkString); |
| 687 | |
| 688 // FIXME: push blob info | |
| 689 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); | 688 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); |
| 690 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); | 689 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); |
| 691 fInfo.push(SkObjectParser::RectToString(fBlob->bounds(), "Bounds: ")); | 690 fInfo.push(SkObjectParser::RectToString(fBlob->bounds(), "Bounds: ")); |
| 691 fInfo.push(runsStr); |
| 692 fInfo.push(SkObjectParser::PaintToString(paint)); | 692 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 693 |
| 694 unsigned runs = 0; |
| 695 SkPaint runPaint(paint); |
| 696 SkTextBlobRunIterator iter(blob); |
| 697 while (!iter.done()) { |
| 698 SkAutoTDelete<SkString> label(new SkString); |
| 699 label->printf("==== Run [%d] ====", runs++); |
| 700 fInfo.push(label.release()); |
| 701 |
| 702 fInfo.push(SkObjectParser::IntToString(iter.glyphCount(), "GlyphCount: "
)); |
| 703 iter.applyFontToPaint(&runPaint); |
| 704 fInfo.push(SkObjectParser::PaintToString(runPaint)); |
| 705 |
| 706 iter.next(); |
| 707 } |
| 708 |
| 709 runsStr->printf("Runs: %d", runs); |
| 710 // runStr is owned by fInfo at this point. |
| 711 runsStr.release(); |
| 693 } | 712 } |
| 694 | 713 |
| 695 void SkDrawTextBlobCommand::execute(SkCanvas* canvas) const { | 714 void SkDrawTextBlobCommand::execute(SkCanvas* canvas) const { |
| 696 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint); | 715 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint); |
| 697 } | 716 } |
| 698 | 717 |
| 699 bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const { | 718 bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const { |
| 700 canvas->clear(SK_ColorWHITE); | 719 canvas->clear(SK_ColorWHITE); |
| 701 canvas->save(); | 720 canvas->save(); |
| 702 | 721 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 | 1002 |
| 984 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 1003 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
| 985 fUserMatrix = userMatrix; | 1004 fUserMatrix = userMatrix; |
| 986 } | 1005 } |
| 987 | 1006 |
| 988 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 1007 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
| 989 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 1008 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
| 990 canvas->setMatrix(temp); | 1009 canvas->setMatrix(temp); |
| 991 } | 1010 } |
| 992 | 1011 |
| OLD | NEW |