| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkView.h" | 9 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #define CORNER_RADIUS 12 | 23 #define CORNER_RADIUS 12 |
| 24 static SkScalar gPhase; | 24 static SkScalar gPhase; |
| 25 | 25 |
| 26 static const int gXY[] = { | 26 static const int gXY[] = { |
| 27 4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4 | 27 4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4 |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 static SkPathEffect* make_pe(int flags) { | 30 static SkPathEffect* make_pe(int flags) { |
| 31 if (flags == 1) | 31 if (flags == 1) |
| 32 return new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS)); | 32 return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS)); |
| 33 | 33 |
| 34 SkPath path; | 34 SkPath path; |
| 35 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); | 35 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); |
| 36 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) | 36 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) |
| 37 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); | 37 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); |
| 38 path.close(); | 38 path.close(); |
| 39 path.offset(SkIntToScalar(-6), 0); | 39 path.offset(SkIntToScalar(-6), 0); |
| 40 | 40 |
| 41 SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase
, SkPath1DPathEffect::kRotate_Style); | 41 SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12), gP
hase, SkPath1DPathEffect::kRotate_Style); |
| 42 | 42 |
| 43 if (flags == 2) | 43 if (flags == 2) |
| 44 return outer; | 44 return outer; |
| 45 | 45 |
| 46 SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS)); | 46 SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS
)); |
| 47 | 47 |
| 48 SkPathEffect* pe = new SkComposePathEffect(outer, inner); | 48 SkPathEffect* pe = SkComposePathEffect::Create(outer, inner); |
| 49 outer->unref(); | 49 outer->unref(); |
| 50 inner->unref(); | 50 inner->unref(); |
| 51 return pe; | 51 return pe; |
| 52 } | 52 } |
| 53 | 53 |
| 54 static SkPathEffect* make_warp_pe() { | 54 static SkPathEffect* make_warp_pe() { |
| 55 SkPath path; | 55 SkPath path; |
| 56 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); | 56 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); |
| 57 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) | 57 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) |
| 58 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); | 58 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); |
| 59 path.close(); | 59 path.close(); |
| 60 path.offset(SkIntToScalar(-6), 0); | 60 path.offset(SkIntToScalar(-6), 0); |
| 61 | 61 |
| 62 SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase
, SkPath1DPathEffect::kMorph_Style); | 62 SkPathEffect* outer = SkPath1DPathEffect::Create( |
| 63 SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS)); | 63 path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kMorph_Style); |
| 64 SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS
)); |
| 64 | 65 |
| 65 SkPathEffect* pe = new SkComposePathEffect(outer, inner); | 66 SkPathEffect* pe = SkComposePathEffect::Create(outer, inner); |
| 66 outer->unref(); | 67 outer->unref(); |
| 67 inner->unref(); | 68 inner->unref(); |
| 68 return pe; | 69 return pe; |
| 69 } | 70 } |
| 70 | 71 |
| 71 /////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////// |
| 72 | 73 |
| 73 #include "SkColorFilter.h" | 74 #include "SkColorFilter.h" |
| 74 #include "SkLayerRasterizer.h" | 75 #include "SkLayerRasterizer.h" |
| 75 | 76 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 182 } |
| 182 | 183 |
| 183 private: | 184 private: |
| 184 typedef SampleView INHERITED; | 185 typedef SampleView INHERITED; |
| 185 }; | 186 }; |
| 186 | 187 |
| 187 ////////////////////////////////////////////////////////////////////////////// | 188 ////////////////////////////////////////////////////////////////////////////// |
| 188 | 189 |
| 189 static SkView* MyFactory() { return new PathEffectView; } | 190 static SkView* MyFactory() { return new PathEffectView; } |
| 190 static SkViewRegister reg(MyFactory); | 191 static SkViewRegister reg(MyFactory); |
| OLD | NEW |