| 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 "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" |
| 9 #include "SkGradientShaderPriv.h" | 9 #include "SkGradientShaderPriv.h" |
| 10 #include "SkLinearGradient.h" | 10 #include "SkLinearGradient.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 desc.fPos = fOrigPos; | 221 desc.fPos = fOrigPos; |
| 222 desc.fCount = fColorCount; | 222 desc.fCount = fColorCount; |
| 223 desc.fTileMode = fTileMode; | 223 desc.fTileMode = fTileMode; |
| 224 desc.fGradFlags = fGradFlags; | 224 desc.fGradFlags = fGradFlags; |
| 225 | 225 |
| 226 const SkMatrix& m = this->getLocalMatrix(); | 226 const SkMatrix& m = this->getLocalMatrix(); |
| 227 desc.fLocalMatrix = m.isIdentity() ? nullptr : &m; | 227 desc.fLocalMatrix = m.isIdentity() ? nullptr : &m; |
| 228 desc.flatten(buffer); | 228 desc.flatten(buffer); |
| 229 } | 229 } |
| 230 | 230 |
| 231 #if SK_SUPPORT_GPU |
| 232 |
| 231 static inline bool close_to_one_half(const SkFixed& val) { | 233 static inline bool close_to_one_half(const SkFixed& val) { |
| 232 return SkScalarNearlyEqual(SkFixedToScalar(val), SK_ScalarHalf); | 234 return SkScalarNearlyEqual(SkFixedToScalar(val), SK_ScalarHalf); |
| 233 } | 235 } |
| 234 | 236 |
| 235 GrGradientEffect::ColorType GrGradientEffect::determineColorTypeAndNumHardStops( | 237 GrGradientEffect::ColorType GrGradientEffect::determineColorTypeAndNumHardStops( |
| 236 const SkGradientShaderBase& shader) { | 238 const SkGradientShaderBase& shader) { |
| 237 #if GR_GL_USE_ACCURATE_HARD_STOP_GRADIENTS | 239 #if GR_GL_USE_ACCURATE_HARD_STOP_GRADIENTS |
| 238 if (shader.fOrigPos) { | 240 if (shader.fOrigPos) { |
| 239 if (4 == shader.fColorCount) { | 241 if (4 == shader.fColorCount) { |
| 240 if (SkScalarNearlyEqual(shader.fOrigPos[0], 0.0f) && | 242 if (SkScalarNearlyEqual(shader.fOrigPos[0], 0.0f) && |
| (...skipping 23 matching lines...) Expand all Loading... |
| 264 if (2 == shader.fColorCount) { | 266 if (2 == shader.fColorCount) { |
| 265 return kTwo_ColorType; | 267 return kTwo_ColorType; |
| 266 } else if (3 == shader.fColorCount && | 268 } else if (3 == shader.fColorCount && |
| 267 close_to_one_half(shader.getRecs()[1].fPos)) { | 269 close_to_one_half(shader.getRecs()[1].fPos)) { |
| 268 return kThree_ColorType; | 270 return kThree_ColorType; |
| 269 } | 271 } |
| 270 } | 272 } |
| 271 | 273 |
| 272 return kTexture_ColorType; | 274 return kTexture_ColorType; |
| 273 } | 275 } |
| 276 #endif |
| 274 | 277 |
| 275 void SkGradientShaderBase::FlipGradientColors(SkColor* colorDst, Rec* recDst, | 278 void SkGradientShaderBase::FlipGradientColors(SkColor* colorDst, Rec* recDst, |
| 276 SkColor* colorSrc, Rec* recSrc, | 279 SkColor* colorSrc, Rec* recSrc, |
| 277 int count) { | 280 int count) { |
| 278 SkAutoSTArray<8, SkColor> colorsTemp(count); | 281 SkAutoSTArray<8, SkColor> colorsTemp(count); |
| 279 for (int i = 0; i < count; ++i) { | 282 for (int i = 0; i < count; ++i) { |
| 280 int offset = count - i - 1; | 283 int offset = count - i - 1; |
| 281 colorsTemp[i] = colorSrc[offset]; | 284 colorsTemp[i] = colorSrc[offset]; |
| 282 } | 285 } |
| 283 if (count > 2) { | 286 if (count > 2) { |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 (*stops)[i] = stop; | 1426 (*stops)[i] = stop; |
| 1424 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1427 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1425 } | 1428 } |
| 1426 } | 1429 } |
| 1427 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1430 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1428 | 1431 |
| 1429 return outColors; | 1432 return outColors; |
| 1430 } | 1433 } |
| 1431 | 1434 |
| 1432 #endif | 1435 #endif |
| OLD | NEW |