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