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 "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 public: | 32 public: |
33 VerticesGM(unsigned alpha) : fShader(NULL), fAlpha(alpha) { | 33 VerticesGM(unsigned alpha) : fShader(NULL), fAlpha(alpha) { |
34 } | 34 } |
35 | 35 |
36 virtual ~VerticesGM() { | 36 virtual ~VerticesGM() { |
37 SkSafeUnref(fShader); | 37 SkSafeUnref(fShader); |
38 } | 38 } |
39 | 39 |
40 protected: | 40 protected: |
41 | 41 |
42 void onOnceBeforeDraw() SK_OVERRIDE { | 42 void onOnceBeforeDraw() override { |
43 const SkScalar X = 150; | 43 const SkScalar X = 150; |
44 const SkScalar Y = 150; | 44 const SkScalar Y = 150; |
45 | 45 |
46 fPts[0].set(0, 0); fPts[1].set(X/2, 10); fPts[2].set(X, 0); | 46 fPts[0].set(0, 0); fPts[1].set(X/2, 10); fPts[2].set(X, 0); |
47 fPts[3].set(10, Y/2); fPts[4].set(X/2, Y/2); fPts[5].set(X-10, Y/2); | 47 fPts[3].set(10, Y/2); fPts[4].set(X/2, Y/2); fPts[5].set(X-10, Y/2); |
48 fPts[6].set(0, Y); fPts[7].set(X/2, Y-10); fPts[8].set(X, Y); | 48 fPts[6].set(0, Y); fPts[7].set(X/2, Y-10); fPts[8].set(X, Y); |
49 | 49 |
50 const SkScalar w = 200; | 50 const SkScalar w = 200; |
51 const SkScalar h = 200; | 51 const SkScalar h = 200; |
52 | 52 |
53 fTexs[0].set(0, 0); fTexs[1].set(w/2, 0); fTexs[2].set(w, 0); | 53 fTexs[0].set(0, 0); fTexs[1].set(w/2, 0); fTexs[2].set(w, 0); |
54 fTexs[3].set(0, h/2); fTexs[4].set(w/2, h/2); fTexs[5].set(w, h/2); | 54 fTexs[3].set(0, h/2); fTexs[4].set(w/2, h/2); fTexs[5].set(w, h/2); |
55 fTexs[6].set(0, h); fTexs[7].set(w/2, h); fTexs[8].set(w, h); | 55 fTexs[6].set(0, h); fTexs[7].set(w/2, h); fTexs[8].set(w, h); |
56 | 56 |
57 fShader = make_shader(w, h); | 57 fShader = make_shader(w, h); |
58 | 58 |
59 SkRandom rand; | 59 SkRandom rand; |
60 for (size_t i = 0; i < SK_ARRAY_COUNT(fColors); ++i) { | 60 for (size_t i = 0; i < SK_ARRAY_COUNT(fColors); ++i) { |
61 fColors[i] = rand.nextU() | 0xFF000000; | 61 fColors[i] = rand.nextU() | 0xFF000000; |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 SkString onShortName() SK_OVERRIDE { | 65 SkString onShortName() override { |
66 SkString name("vertices"); | 66 SkString name("vertices"); |
67 if (0xFF != fAlpha) { | 67 if (0xFF != fAlpha) { |
68 name.appendf("_%02X", fAlpha); | 68 name.appendf("_%02X", fAlpha); |
69 } | 69 } |
70 return name; | 70 return name; |
71 } | 71 } |
72 | 72 |
73 SkISize onISize() SK_OVERRIDE { | 73 SkISize onISize() override { |
74 return SkISize::Make(600, 600); | 74 return SkISize::Make(600, 600); |
75 } | 75 } |
76 | 76 |
77 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 77 void onDraw(SkCanvas* canvas) override { |
78 // start with the center of a 3x3 grid | 78 // start with the center of a 3x3 grid |
79 static const uint16_t fan[] = { | 79 static const uint16_t fan[] = { |
80 4, | 80 4, |
81 0, 1, 2, 5, 8, 7, 6, 3, 0 | 81 0, 1, 2, 5, 8, 7, 6, 3, 0 |
82 }; | 82 }; |
83 | 83 |
84 const struct { | 84 const struct { |
85 const SkColor* fColors; | 85 const SkColor* fColors; |
86 const SkPoint* fTexs; | 86 const SkPoint* fTexs; |
87 } rec[] = { | 87 } rec[] = { |
(...skipping 30 matching lines...) Expand all Loading... |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 typedef skiagm::GM INHERITED; | 121 typedef skiagm::GM INHERITED; |
122 }; | 122 }; |
123 | 123 |
124 ////////////////////////////////////////////////////////////////////////////////
///// | 124 ////////////////////////////////////////////////////////////////////////////////
///// |
125 | 125 |
126 DEF_GM( return SkNEW_ARGS(VerticesGM, (0xFF)); ) | 126 DEF_GM( return SkNEW_ARGS(VerticesGM, (0xFF)); ) |
127 DEF_GM( return SkNEW_ARGS(VerticesGM, (0x80)); ) | 127 DEF_GM( return SkNEW_ARGS(VerticesGM, (0x80)); ) |
OLD | NEW |