| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 #include "Sk2DPathEffect.h" | 66 #include "Sk2DPathEffect.h" |
| 67 | 67 |
| 68 class Dot2DPathEffect : public Sk2DPathEffect { | 68 class Dot2DPathEffect : public Sk2DPathEffect { |
| 69 public: | 69 public: |
| 70 Dot2DPathEffect(SkScalar radius, const SkMatrix& matrix, | 70 Dot2DPathEffect(SkScalar radius, const SkMatrix& matrix, |
| 71 SkTDArray<SkPoint>* pts) | 71 SkTDArray<SkPoint>* pts) |
| 72 : Sk2DPathEffect(matrix), fRadius(radius), fPts(pts) {} | 72 : Sk2DPathEffect(matrix), fRadius(radius), fPts(pts) {} |
| 73 | 73 |
| 74 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Dot2DPathEffect) | 74 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Dot2DPathEffect) |
| 75 | 75 class Registrar { |
| 76 public: |
| 77 Registrar() { |
| 78 SkFlattenable::Register("Dot2DPathEffect", |
| 79 Dot2DPathEffect::CreateProc, |
| 80 Dot2DPathEffect::GetFlattenableType()); |
| 81 } |
| 82 }; |
| 76 protected: | 83 protected: |
| 77 void begin(const SkIRect& uvBounds, SkPath* dst) const override { | 84 void begin(const SkIRect& uvBounds, SkPath* dst) const override { |
| 78 if (fPts) { | 85 if (fPts) { |
| 79 fPts->reset(); | 86 fPts->reset(); |
| 80 } | 87 } |
| 81 this->INHERITED::begin(uvBounds, dst); | 88 this->INHERITED::begin(uvBounds, dst); |
| 82 } | 89 } |
| 83 | 90 |
| 84 virtual void next(const SkPoint& loc, int u, int v, | 91 virtual void next(const SkPoint& loc, int u, int v, |
| 85 SkPath* dst) const override { | 92 SkPath* dst) const override { |
| 86 if (fPts) { | 93 if (fPts) { |
| 87 *fPts->append() = loc; | 94 *fPts->append() = loc; |
| 88 } | 95 } |
| 89 dst->addCircle(loc.fX, loc.fY, fRadius); | 96 dst->addCircle(loc.fX, loc.fY, fRadius); |
| 90 } | 97 } |
| 91 | 98 |
| 92 void flatten(SkWriteBuffer& buffer) const override { | 99 void flatten(SkWriteBuffer& buffer) const override { |
| 93 buffer.writeMatrix(this->getMatrix()); | 100 buffer.writeMatrix(this->getMatrix()); |
| 94 buffer.writeScalar(fRadius); | 101 buffer.writeScalar(fRadius); |
| 95 } | 102 } |
| 96 | 103 |
| 97 private: | 104 private: |
| 98 SkScalar fRadius; | 105 SkScalar fRadius; |
| 99 SkTDArray<SkPoint>* fPts; | 106 SkTDArray<SkPoint>* fPts; |
| 100 | 107 |
| 101 typedef Sk2DPathEffect INHERITED; | 108 typedef Sk2DPathEffect INHERITED; |
| 102 }; | 109 }; |
| 103 | 110 |
| 111 static Dot2DPathEffect::Registrar gReg0; |
| 112 |
| 104 sk_sp<SkFlattenable> Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) { | 113 sk_sp<SkFlattenable> Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 105 SkMatrix matrix; | 114 SkMatrix matrix; |
| 106 buffer.readMatrix(&matrix); | 115 buffer.readMatrix(&matrix); |
| 107 return sk_make_sp<Dot2DPathEffect>(buffer.readScalar(), matrix, nullptr); | 116 return sk_make_sp<Dot2DPathEffect>(buffer.readScalar(), matrix, nullptr); |
| 108 } | 117 } |
| 109 | 118 |
| 110 class InverseFillPE : public SkPathEffect { | 119 class InverseFillPE : public SkPathEffect { |
| 111 public: | 120 public: |
| 112 InverseFillPE() {} | 121 InverseFillPE() {} |
| 113 virtual bool filterPath(SkPath* dst, const SkPath& src, | 122 virtual bool filterPath(SkPath* dst, const SkPath& src, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 256 } |
| 248 | 257 |
| 249 private: | 258 private: |
| 250 typedef SkView INHERITED; | 259 typedef SkView INHERITED; |
| 251 }; | 260 }; |
| 252 | 261 |
| 253 ////////////////////////////////////////////////////////////////////////////// | 262 ////////////////////////////////////////////////////////////////////////////// |
| 254 | 263 |
| 255 static SkView* MyFactory() { return new ClockFaceView; } | 264 static SkView* MyFactory() { return new ClockFaceView; } |
| 256 static SkViewRegister reg(MyFactory); | 265 static SkViewRegister reg(MyFactory); |
| OLD | NEW |