OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDrawCommand.h" | 8 #include "SkDrawCommand.h" |
9 | 9 |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2790 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat(); | 2790 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat(); |
2791 return new SkDrawPosTextHCommand(text, strlen(text), xpos, y, paint); | 2791 return new SkDrawPosTextHCommand(text, strlen(text), xpos, y, paint); |
2792 } | 2792 } |
2793 | 2793 |
2794 static const char* gPositioningLabels[] = { | 2794 static const char* gPositioningLabels[] = { |
2795 "kDefault_Positioning", | 2795 "kDefault_Positioning", |
2796 "kHorizontal_Positioning", | 2796 "kHorizontal_Positioning", |
2797 "kFull_Positioning", | 2797 "kFull_Positioning", |
2798 }; | 2798 }; |
2799 | 2799 |
2800 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, | 2800 SkDrawTextBlobCommand::SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x,
SkScalar y, |
2801 const SkPaint& paint) | 2801 const SkPaint& paint) |
2802 : INHERITED(kDrawTextBlob_OpType) | 2802 : INHERITED(kDrawTextBlob_OpType) |
2803 , fBlob(SkRef(blob)) | 2803 , fBlob(std::move(blob)) |
2804 , fXPos(x) | 2804 , fXPos(x) |
2805 , fYPos(y) | 2805 , fYPos(y) |
2806 , fPaint(paint) { | 2806 , fPaint(paint) { |
2807 | 2807 |
2808 SkAutoTDelete<SkString> runsStr(new SkString); | 2808 SkAutoTDelete<SkString> runsStr(new SkString); |
2809 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); | 2809 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); |
2810 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); | 2810 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); |
2811 fInfo.push(SkObjectParser::RectToString(fBlob->bounds(), "Bounds: ")); | 2811 fInfo.push(SkObjectParser::RectToString(fBlob->bounds(), "Bounds: ")); |
2812 fInfo.push(runsStr); | 2812 fInfo.push(runsStr); |
2813 fInfo.push(SkObjectParser::PaintToString(paint)); | 2813 fInfo.push(SkObjectParser::PaintToString(paint)); |
2814 | 2814 |
2815 unsigned runs = 0; | 2815 unsigned runs = 0; |
2816 SkPaint runPaint(paint); | 2816 SkPaint runPaint(paint); |
2817 SkTextBlobRunIterator iter(blob); | 2817 SkTextBlobRunIterator iter(blob.get()); |
2818 while (!iter.done()) { | 2818 while (!iter.done()) { |
2819 SkAutoTDelete<SkString> tmpStr(new SkString); | 2819 SkAutoTDelete<SkString> tmpStr(new SkString); |
2820 tmpStr->printf("==== Run [%d] ====", runs++); | 2820 tmpStr->printf("==== Run [%d] ====", runs++); |
2821 fInfo.push(tmpStr.release()); | 2821 fInfo.push(tmpStr.release()); |
2822 | 2822 |
2823 fInfo.push(SkObjectParser::IntToString(iter.glyphCount(), "GlyphCount: "
)); | 2823 fInfo.push(SkObjectParser::IntToString(iter.glyphCount(), "GlyphCount: "
)); |
2824 tmpStr.reset(new SkString("GlyphPositioning: ")); | 2824 tmpStr.reset(new SkString("GlyphPositioning: ")); |
2825 tmpStr->append(gPositioningLabels[iter.positioning()]); | 2825 tmpStr->append(gPositioningLabels[iter.positioning()]); |
2826 fInfo.push(tmpStr.release()); | 2826 fInfo.push(tmpStr.release()); |
2827 | 2827 |
(...skipping 12 matching lines...) Expand all Loading... |
2840 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint); | 2840 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint); |
2841 } | 2841 } |
2842 | 2842 |
2843 bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const { | 2843 bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const { |
2844 canvas->clear(SK_ColorWHITE); | 2844 canvas->clear(SK_ColorWHITE); |
2845 canvas->save(); | 2845 canvas->save(); |
2846 | 2846 |
2847 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); | 2847 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); |
2848 xlate_and_scale_to_bounds(canvas, bounds); | 2848 xlate_and_scale_to_bounds(canvas, bounds); |
2849 | 2849 |
2850 canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint); | 2850 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint); |
2851 | 2851 |
2852 canvas->restore(); | 2852 canvas->restore(); |
2853 | 2853 |
2854 return true; | 2854 return true; |
2855 } | 2855 } |
2856 | 2856 |
2857 Json::Value SkDrawTextBlobCommand::toJSON(UrlDataManager& urlDataManager) const
{ | 2857 Json::Value SkDrawTextBlobCommand::toJSON(UrlDataManager& urlDataManager) const
{ |
2858 Json::Value result = INHERITED::toJSON(urlDataManager); | 2858 Json::Value result = INHERITED::toJSON(urlDataManager); |
2859 Json::Value runs(Json::arrayValue); | 2859 Json::Value runs(Json::arrayValue); |
2860 SkTextBlobRunIterator iter(fBlob.get()); | 2860 SkTextBlobRunIterator iter(fBlob.get()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2943 SkTextBlobBuilder::RunBuffer buffer = builder.allocRun(font, count,
x, y, &bounds); | 2943 SkTextBlobBuilder::RunBuffer buffer = builder.allocRun(font, count,
x, y, &bounds); |
2944 for (int j = 0; j < count; j++) { | 2944 for (int j = 0; j < count; j++) { |
2945 buffer.glyphs[j] = glyphs[j].asUInt(); | 2945 buffer.glyphs[j] = glyphs[j].asUInt(); |
2946 } | 2946 } |
2947 } | 2947 } |
2948 } | 2948 } |
2949 SkScalar x = command[SKDEBUGCANVAS_ATTRIBUTE_X].asFloat(); | 2949 SkScalar x = command[SKDEBUGCANVAS_ATTRIBUTE_X].asFloat(); |
2950 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat(); | 2950 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat(); |
2951 SkPaint paint; | 2951 SkPaint paint; |
2952 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2952 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2953 return new SkDrawTextBlobCommand(builder.build(), x, y, paint); | 2953 return new SkDrawTextBlobCommand(builder.make(), x, y, paint); |
2954 } | 2954 } |
2955 | 2955 |
2956 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c
olors[4], | 2956 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c
olors[4], |
2957 const SkPoint texCoords[4], SkXfermode* x
fermode, | 2957 const SkPoint texCoords[4], SkXfermode* x
fermode, |
2958 const SkPaint& paint) | 2958 const SkPaint& paint) |
2959 : INHERITED(kDrawPatch_OpType) { | 2959 : INHERITED(kDrawPatch_OpType) { |
2960 memcpy(fCubics, cubics, sizeof(fCubics)); | 2960 memcpy(fCubics, cubics, sizeof(fCubics)); |
2961 if (colors != nullptr) { | 2961 if (colors != nullptr) { |
2962 memcpy(fColors, colors, sizeof(fColors)); | 2962 memcpy(fColors, colors, sizeof(fColors)); |
2963 fColorsPtr = fColors; | 2963 fColorsPtr = fColors; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3548 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, | 3548 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, |
3549 UrlDataManager& urlDataManager) { | 3549 UrlDataManager& urlDataManager) { |
3550 SkScalar z; | 3550 SkScalar z; |
3551 #ifdef SK_EXPERIMENTAL_SHADOWING | 3551 #ifdef SK_EXPERIMENTAL_SHADOWING |
3552 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); | 3552 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); |
3553 #else | 3553 #else |
3554 z = 0; | 3554 z = 0; |
3555 #endif | 3555 #endif |
3556 return new SkTranslateZCommand(z); | 3556 return new SkTranslateZCommand(z); |
3557 } | 3557 } |
OLD | NEW |