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 "gm.h" | 8 #include "gm.h" |
9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 SkIntToScalar(1000), | 91 SkIntToScalar(1000), |
92 colors, | 92 colors, |
93 pos, | 93 pos, |
94 SK_ARRAY_COUNT(colors), | 94 SK_ARRAY_COUNT(colors), |
95 SkShader::kClamp_TileMode); | 95 SkShader::kClamp_TileMode); |
96 bkgnrd.setShader(s)->unref(); | 96 bkgnrd.setShader(s)->unref(); |
97 canvas->save(); | 97 canvas->save(); |
98 canvas->translate(SkIntToScalar(100), SkIntToScalar(100)); | 98 canvas->translate(SkIntToScalar(100), SkIntToScalar(100)); |
99 SkMatrix mat; | 99 SkMatrix mat; |
100 mat.reset(); | 100 mat.reset(); |
101 mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 1000)); | 101 mat.setPerspY(SK_Scalar1 / 1000); |
102 canvas->concat(mat); | 102 canvas->concat(mat); |
103 canvas->drawPaint(bkgnrd); | 103 canvas->drawPaint(bkgnrd); |
104 canvas->restore(); | 104 canvas->restore(); |
105 | 105 |
106 // draw the paths in perspective | 106 // draw the paths in perspective |
107 SkMatrix persp; | 107 SkMatrix persp; |
108 persp.reset(); | 108 persp.reset(); |
109 persp.setPerspX(SkScalarToPersp(-SK_Scalar1 / 1800)); | 109 persp.setPerspX(-SK_Scalar1 / 1800); |
110 persp.setPerspY(SkScalarToPersp(SK_Scalar1 / 500)); | 110 persp.setPerspY(SK_Scalar1 / 500); |
111 canvas->concat(persp); | 111 canvas->concat(persp); |
112 | 112 |
113 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); | 113 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); |
114 const SkScalar scale = SkIntToScalar(5)/4; | 114 const SkScalar scale = SkIntToScalar(5)/4; |
115 | 115 |
116 showFour(canvas, SK_Scalar1, false); | 116 showFour(canvas, SK_Scalar1, false); |
117 canvas->translate(SkIntToScalar(450), 0); | 117 canvas->translate(SkIntToScalar(450), 0); |
118 showFour(canvas, scale, false); | 118 showFour(canvas, scale, false); |
119 | 119 |
120 canvas->translate(SkIntToScalar(-450), SkIntToScalar(450)); | 120 canvas->translate(SkIntToScalar(-450), SkIntToScalar(450)); |
121 showFour(canvas, SK_Scalar1, true); | 121 showFour(canvas, SK_Scalar1, true); |
122 canvas->translate(SkIntToScalar(450), 0); | 122 canvas->translate(SkIntToScalar(450), 0); |
123 showFour(canvas, scale, true); | 123 showFour(canvas, scale, true); |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
127 typedef GM INHERITED; | 127 typedef GM INHERITED; |
128 }; | 128 }; |
129 | 129 |
130 ////////////////////////////////////////////////////////////////////////////// | 130 ////////////////////////////////////////////////////////////////////////////// |
131 | 131 |
132 static GM* MyFactory(void*) { return new FillTypePerspGM; } | 132 static GM* MyFactory(void*) { return new FillTypePerspGM; } |
133 static GMRegistry reg(MyFactory); | 133 static GMRegistry reg(MyFactory); |
134 | 134 |
135 } | 135 } |
OLD | NEW |