OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkGradientShaderPriv.h" | 8 #include "SkGradientShaderPriv.h" |
9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
10 #include "SkRadialGradient.h" | 10 #include "SkRadialGradient.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 for (int i = 0; i < n; ++i) { | 283 for (int i = 0; i < n; ++i) { |
284 SkColor c = fOrigColors[i]; | 284 SkColor c = fOrigColors[i]; |
285 r += SkColorGetR(c); | 285 r += SkColorGetR(c); |
286 g += SkColorGetG(c); | 286 g += SkColorGetG(c); |
287 b += SkColorGetB(c); | 287 b += SkColorGetB(c); |
288 } | 288 } |
289 *lum = SkColorSetRGB(rounded_divide(r, n), rounded_divide(g, n), rounded_div
ide(b, n)); | 289 *lum = SkColorSetRGB(rounded_divide(r, n), rounded_divide(g, n), rounded_div
ide(b, n)); |
290 return true; | 290 return true; |
291 } | 291 } |
292 | 292 |
293 #define SK_SUPPORT_LEGACY_GRADIENT_DITHERING | |
294 | |
295 SkGradientShaderBase::GradientShaderBaseContext::GradientShaderBaseContext( | 293 SkGradientShaderBase::GradientShaderBaseContext::GradientShaderBaseContext( |
296 const SkGradientShaderBase& shader, const ContextRec& rec) | 294 const SkGradientShaderBase& shader, const ContextRec& rec) |
297 : INHERITED(shader, rec) | 295 : INHERITED(shader, rec) |
298 #ifdef SK_SUPPORT_LEGACY_GRADIENT_DITHERING | 296 #ifdef SK_SUPPORT_LEGACY_GRADIENT_DITHERING |
299 , fDither(true) | 297 , fDither(true) |
300 #else | 298 #else |
301 , fDither(rec.fPaint->isDither()) | 299 , fDither(rec.fPaint->isDither()) |
302 #endif | 300 #endif |
303 , fCache(shader.refCache(getPaintAlpha(), fDither)) | 301 , fCache(shader.refCache(getPaintAlpha(), fDither)) |
304 { | 302 { |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 (*stops)[i] = stop; | 1204 (*stops)[i] = stop; |
1207 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1205 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1208 } | 1206 } |
1209 } | 1207 } |
1210 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1208 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1211 | 1209 |
1212 return outColors; | 1210 return outColors; |
1213 } | 1211 } |
1214 | 1212 |
1215 #endif | 1213 #endif |
OLD | NEW |