| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
| 8 #include "SkView.h" | 8 #include "SkView.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 buffer.writeScalar(fRadius); | 94 buffer.writeScalar(fRadius); |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 SkScalar fRadius; | 98 SkScalar fRadius; |
| 99 SkTDArray<SkPoint>* fPts; | 99 SkTDArray<SkPoint>* fPts; |
| 100 | 100 |
| 101 typedef Sk2DPathEffect INHERITED; | 101 typedef Sk2DPathEffect INHERITED; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 SkFlattenable* Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) { | 104 sk_sp<SkFlattenable> Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 105 SkMatrix matrix; | 105 SkMatrix matrix; |
| 106 buffer.readMatrix(&matrix); | 106 buffer.readMatrix(&matrix); |
| 107 return new Dot2DPathEffect(buffer.readScalar(), matrix, nullptr); | 107 return sk_make_sp<Dot2DPathEffect>(buffer.readScalar(), matrix, nullptr); |
| 108 } | 108 } |
| 109 | 109 |
| 110 class InverseFillPE : public SkPathEffect { | 110 class InverseFillPE : public SkPathEffect { |
| 111 public: | 111 public: |
| 112 InverseFillPE() {} | 112 InverseFillPE() {} |
| 113 virtual bool filterPath(SkPath* dst, const SkPath& src, | 113 virtual bool filterPath(SkPath* dst, const SkPath& src, |
| 114 SkStrokeRec*, const SkRect*) const override { | 114 SkStrokeRec*, const SkRect*) const override { |
| 115 *dst = src; | 115 *dst = src; |
| 116 dst->setFillType(SkPath::kInverseWinding_FillType); | 116 dst->setFillType(SkPath::kInverseWinding_FillType); |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 #ifndef SK_IGNORE_TO_STRING | 120 #ifndef SK_IGNORE_TO_STRING |
| 121 void toString(SkString* str) const override { | 121 void toString(SkString* str) const override { |
| 122 str->appendf("InverseFillPE: ()"); | 122 str->appendf("InverseFillPE: ()"); |
| 123 } | 123 } |
| 124 #endif | 124 #endif |
| 125 | 125 |
| 126 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) | 126 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 typedef SkPathEffect INHERITED; | 129 typedef SkPathEffect INHERITED; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new Inve
rseFillPE; } | 132 sk_sp<SkFlattenable> InverseFillPE::CreateProc(SkReadBuffer& buffer) { |
| 133 return sk_make_sp<InverseFillPE>(); |
| 134 } |
| 133 | 135 |
| 134 static sk_sp<SkPathEffect> makepe(float interp, SkTDArray<SkPoint>* pts) { | 136 static sk_sp<SkPathEffect> makepe(float interp, SkTDArray<SkPoint>* pts) { |
| 135 SkMatrix lattice; | 137 SkMatrix lattice; |
| 136 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); | 138 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); |
| 137 lattice.setScale(rad*2, rad*2, 0, 0); | 139 lattice.setScale(rad*2, rad*2, 0, 0); |
| 138 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); | 140 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); |
| 139 return sk_make_sp<Dot2DPathEffect>(rad, lattice, pts); | 141 return sk_make_sp<Dot2DPathEffect>(rad, lattice, pts); |
| 140 } | 142 } |
| 141 | 143 |
| 142 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int
erp) { | 144 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int
erp) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 251 } |
| 250 | 252 |
| 251 private: | 253 private: |
| 252 typedef SkView INHERITED; | 254 typedef SkView INHERITED; |
| 253 }; | 255 }; |
| 254 | 256 |
| 255 ////////////////////////////////////////////////////////////////////////////// | 257 ////////////////////////////////////////////////////////////////////////////// |
| 256 | 258 |
| 257 static SkView* MyFactory() { return new ClockFaceView; } | 259 static SkView* MyFactory() { return new ClockFaceView; } |
| 258 static SkViewRegister reg(MyFactory); | 260 static SkViewRegister reg(MyFactory); |
| OLD | NEW |