OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 SampleCode::TitleR(evt, "PathUtils"); | 58 SampleCode::TitleR(evt, "PathUtils"); |
59 return true; | 59 return true; |
60 } | 60 } |
61 return this->INHERITED::onQuery(evt); | 61 return this->INHERITED::onQuery(evt); |
62 } | 62 } |
63 | 63 |
64 ///////////////////////////////////////////////////////////// | 64 ///////////////////////////////////////////////////////////// |
65 | 65 |
66 virtual void onDrawContent(SkCanvas* canvas) { | 66 virtual void onDrawContent(SkCanvas* canvas) { |
67 SkScalar intervals[8] = { .5f, .3f, .5f, .3f, .5f, .3f, .5f, .3f }; | 67 SkScalar intervals[8] = { .5f, .3f, .5f, .3f, .5f, .3f, .5f, .3f }; |
68 SkDashPathEffect dash(intervals, 2, fPhase); | 68 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals,
2, fPhase)); |
69 SkCornerPathEffect corner(.25f); | 69 SkAutoTUnref<SkCornerPathEffect> corner(SkCornerPathEffect::Create(.25f)
); |
70 SkComposePathEffect compose(&dash, &corner); | 70 SkAutoTUnref<SkComposePathEffect> compose(SkComposePathEffect::Create(da
sh, corner)); |
71 | 71 |
72 SkPaint outlinePaint; | 72 SkPaint outlinePaint; |
73 outlinePaint.setAntiAlias(true); // dashed paint for bitmap | 73 outlinePaint.setAntiAlias(true); // dashed paint for bitmap |
74 outlinePaint.setStyle(SkPaint::kStroke_Style); | 74 outlinePaint.setStyle(SkPaint::kStroke_Style); |
75 outlinePaint.setPathEffect(&compose); | 75 outlinePaint.setPathEffect(compose); |
76 | 76 |
77 canvas->scale(10.0f, 10.0f); // scales up | 77 canvas->scale(10.0f, 10.0f); // scales up |
78 | 78 |
79 for (int i = 0; i < fNumBits; ++i) { | 79 for (int i = 0; i < fNumBits; ++i) { |
80 canvas->save(); | 80 canvas->save(); |
81 for (size_t j = 0; j < SK_ARRAY_COUNT(gBitsToPath_fns); ++j) { | 81 for (size_t j = 0; j < SK_ARRAY_COUNT(gBitsToPath_fns); ++j) { |
82 SkPath path; | 82 SkPath path; |
83 gBitsToPath_fns[j](&path, (char*) &gBits[i], fW, fH, fRowBytes); | 83 gBitsToPath_fns[j](&path, (char*) &gBits[i], fW, fH, fRowBytes); |
84 | 84 |
85 //draw skPath and outline | 85 //draw skPath and outline |
(...skipping 13 matching lines...) Expand all Loading... |
99 | 99 |
100 private: | 100 private: |
101 typedef SkView INHERITED; | 101 typedef SkView INHERITED; |
102 }; | 102 }; |
103 | 103 |
104 ////////////////////////////////////////////////////////////////////////////// | 104 ////////////////////////////////////////////////////////////////////////////// |
105 | 105 |
106 static SkView* MyFactory() { return new SamplePathUtils; } | 106 static SkView* MyFactory() { return new SamplePathUtils; } |
107 static SkViewRegister reg(MyFactory) | 107 static SkViewRegister reg(MyFactory) |
108 ; | 108 ; |
OLD | NEW |