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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); | 94 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
95 return SkGradientShader::CreateTwoPointConical(center1, 0.0, | 95 return SkGradientShader::CreateTwoPointConical(center1, 0.0, |
96 center0, (pts[1].fX - pts[0].
fX) / 2, | 96 center0, (pts[1].fX - pts[0].
fX) / 2, |
97 data.fColors, data.fPos, data
.fCount, tm); | 97 data.fColors, data.fPos, data
.fCount, tm); |
98 } | 98 } |
99 | 99 |
100 /// Ignores scale | 100 /// Ignores scale |
101 static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data, | 101 static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data, |
102 SkShader::TileMode tm, float scale) { | 102 SkShader::TileMode tm, float scale) { |
103 SkPoint center0, center1; | 103 SkPoint center0, center1; |
104 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; | 104 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); |
105 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; | 105 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
106 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); | 106 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); |
107 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); | 107 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); |
108 return SkGradientShader::CreateTwoPointConical(center0, radius0, | 108 return SkGradientShader::CreateTwoPointConical(center0, radius0, |
109 center1, radius1, | 109 center1, radius1, |
110 data.fColors, data.fPos, | 110 data.fColors, data.fPos, |
111 data.fCount, tm); | 111 data.fCount, tm); |
112 } | 112 } |
113 | 113 |
114 /// Ignores scale | 114 /// Ignores scale |
115 static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData&
data, | 115 static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData&
data, |
116 SkShader::TileMode tm, float scale) { | 116 SkShader::TileMode tm, float scale) { |
117 SkPoint center0, center1; | 117 SkPoint center0, center1; |
118 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; | 118 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); |
119 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; | 119 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
120 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); | 120 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); |
121 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); | 121 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); |
122 return SkGradientShader::CreateTwoPointConical(center0, 0.0, | 122 return SkGradientShader::CreateTwoPointConical(center0, 0.0, |
123 center1, radius1, | 123 center1, radius1, |
124 data.fColors, data.fPos, | 124 data.fColors, data.fPos, |
125 data.fCount, tm); | 125 data.fCount, tm); |
126 } | 126 } |
127 | 127 |
128 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, | 128 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, |
129 SkShader::TileMode tm, float scale); | 129 SkShader::TileMode tm, float scale); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 canvas->drawRect(r, paint); | 361 canvas->drawRect(r, paint); |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 private: | 365 private: |
366 typedef Benchmark INHERITED; | 366 typedef Benchmark INHERITED; |
367 }; | 367 }; |
368 | 368 |
369 DEF_BENCH( return new Gradient2Bench(false); ) | 369 DEF_BENCH( return new Gradient2Bench(false); ) |
370 DEF_BENCH( return new Gradient2Bench(true); ) | 370 DEF_BENCH( return new Gradient2Bench(true); ) |
OLD | NEW |