| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "Sk4fGradientBase.h" | 8 #include "Sk4fGradientBase.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 SkGradientShaderBase::GradientShaderBase4fContext:: | 22 SkGradientShaderBase::GradientShaderBase4fContext:: |
| 23 Interval::Interval(SkPMColor c0, SkScalar p0, | 23 Interval::Interval(SkPMColor c0, SkScalar p0, |
| 24 SkPMColor c1, SkScalar p1, | 24 SkPMColor c1, SkScalar p1, |
| 25 const Sk4f& componentScale) | 25 const Sk4f& componentScale) |
| 26 : fP0(p0) | 26 : fP0(p0) |
| 27 , fP1(p1) | 27 , fP1(p1) |
| 28 , fZeroRamp(c0 == c1) { | 28 , fZeroRamp(c0 == c1) { |
| 29 SkASSERT(p0 != p1); | 29 SkASSERT(p0 != p1); |
| 30 | 30 |
| 31 const Sk4f c4f0 = SkNx_cast<float>(Sk4b::Load(&c0)) * componentScale; | 31 const Sk4f c4f0 = SkPM4f::FromPMColor(c0).to4f() * componentScale; |
| 32 const Sk4f c4f1 = SkNx_cast<float>(Sk4b::Load(&c1)) * componentScale; | 32 const Sk4f c4f1 = SkPM4f::FromPMColor(c1).to4f() * componentScale; |
| 33 const Sk4f dc4f = (c4f1 - c4f0) / (p1 - p0); | 33 const Sk4f dc4f = (c4f1 - c4f0) / (p1 - p0); |
| 34 | 34 |
| 35 c4f0.store(&fC0.fVec); | 35 c4f0.store(&fC0.fVec); |
| 36 dc4f.store(&fDc.fVec); | 36 dc4f.store(&fDc.fVec); |
| 37 } | 37 } |
| 38 | 38 |
| 39 SkGradientShaderBase::GradientShaderBase4fContext:: | |
| 40 Interval::Interval(const Sk4f& c0, const Sk4f& dc, | |
| 41 SkScalar p0, SkScalar p1) | |
| 42 : fP0(p0) | |
| 43 , fP1(p1) | |
| 44 , fZeroRamp((dc == 0).allTrue()) { | |
| 45 c0.store(fC0.fVec); | |
| 46 dc.store(fDc.fVec); | |
| 47 } | |
| 48 | |
| 49 bool SkGradientShaderBase::GradientShaderBase4fContext:: | 39 bool SkGradientShaderBase::GradientShaderBase4fContext:: |
| 50 Interval::contains(SkScalar fx) const { | 40 Interval::contains(SkScalar fx) const { |
| 51 return in_range(fx, fP0, fP1); | 41 return in_range(fx, fP0, fP1); |
| 52 } | 42 } |
| 53 | 43 |
| 54 SkGradientShaderBase:: | 44 SkGradientShaderBase:: |
| 55 GradientShaderBase4fContext::GradientShaderBase4fContext(const SkGradientShaderB
ase& shader, | 45 GradientShaderBase4fContext::GradientShaderBase4fContext(const SkGradientShaderB
ase& shader, |
| 56 const ContextRec& rec) | 46 const ContextRec& rec) |
| 57 : INHERITED(shader, rec) | 47 : INHERITED(shader, rec) |
| 58 , fFlags(this->INHERITED::getFlags()) | 48 , fFlags(this->INHERITED::getFlags()) |
| 59 #ifdef SK_SUPPORT_LEGACY_GRADIENT_DITHERING | 49 #ifdef SK_SUPPORT_LEGACY_GRADIENT_DITHERING |
| 60 , fDither(true) | 50 , fDither(true) |
| 61 #else | 51 #else |
| 62 , fDither(rec.fPaint->isDither()) | 52 , fDither(rec.fPaint->isDither()) |
| 63 #endif | 53 #endif |
| 64 { | 54 { |
| 65 const SkMatrix& inverse = this->getTotalInverse(); | 55 const SkMatrix& inverse = this->getTotalInverse(); |
| 66 fDstToPos.setConcat(shader.fPtsToUnit, inverse); | 56 fDstToPos.setConcat(shader.fPtsToUnit, inverse); |
| 67 fDstToPosProc = fDstToPos.getMapXYProc(); | 57 fDstToPosProc = fDstToPos.getMapXYProc(); |
| 68 fDstToPosClass = static_cast<uint8_t>(INHERITED::ComputeMatrixClass(fDstToPo
s)); | 58 fDstToPosClass = static_cast<uint8_t>(INHERITED::ComputeMatrixClass(fDstToPo
s)); |
| 69 | 59 |
| 70 if (shader.fColorsAreOpaque && this->getPaintAlpha() == SK_AlphaOPAQUE) { | 60 if (shader.fColorsAreOpaque && this->getPaintAlpha() == SK_AlphaOPAQUE) { |
| 71 fFlags |= kOpaqueAlpha_Flag; | 61 fFlags |= kOpaqueAlpha_Flag; |
| 72 } | 62 } |
| 73 | 63 |
| 74 fColorsArePremul = | 64 fColorsArePremul = |
| 75 (shader.fGradFlags & SkGradientShader::kInterpolateColorsInPremul_Flag) | 65 (shader.fGradFlags & SkGradientShader::kInterpolateColorsInPremul_Flag) |
| 76 || shader.fColorsAreOpaque; | 66 || shader.fColorsAreOpaque; |
| 77 } | 67 } |
| OLD | NEW |