Index: src/effects/gradients/SkRadialGradient.cpp |
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp |
index 1b9e7258c4f54407374d0d1acdd36a09d0445640..bc2ea3b92b988e152d0ad95f3a815fb00e884d50 100644 |
--- a/src/effects/gradients/SkRadialGradient.cpp |
+++ b/src/effects/gradients/SkRadialGradient.cpp |
@@ -157,16 +157,36 @@ SkRadialGradient::SkRadialGradient(const SkPoint& center, SkScalar radius, |
rad_to_unit_matrix(center, radius, &fPtsToUnit); |
} |
-void SkRadialGradient::shadeSpan16(int x, int y, uint16_t* dstCParam, |
- int count) { |
+size_t SkRadialGradient::contextSize() const { |
+ return sizeof(RadialGradientContext); |
+} |
+ |
+SkShader::Context* SkRadialGradient::createContext(const SkBitmap& device, const SkPaint& paint, |
+ const SkMatrix& matrix, void* storage) const { |
+ if (!this->validContext(device, paint, matrix)) { |
+ return NULL; |
+ } |
+ |
+ return SkNEW_PLACEMENT_ARGS(storage, RadialGradientContext, (*this, device, paint, matrix)); |
+} |
+ |
+SkRadialGradient::RadialGradientContext::RadialGradientContext( |
+ const SkRadialGradient& shader, const SkBitmap& device, |
+ const SkPaint& paint, const SkMatrix& matrix) |
+ : INHERITED(shader, device, paint, matrix) {} |
+ |
+void SkRadialGradient::RadialGradientContext::shadeSpan16(int x, int y, uint16_t* dstCParam, |
+ int count) { |
SkASSERT(count > 0); |
+ const SkRadialGradient& radialGradient = static_cast<const SkRadialGradient&>(fShader); |
+ |
uint16_t* SK_RESTRICT dstC = dstCParam; |
SkPoint srcPt; |
SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
- TileProc proc = fTileProc; |
- const uint16_t* SK_RESTRICT cache = this->getCache16(); |
+ TileProc proc = radialGradient.fTileProc; |
+ const uint16_t* SK_RESTRICT cache = fCache->getCache16(); |
int toggle = init_dither_toggle16(x, y); |
if (fDstToIndexClass != kPerspective_MatrixClass) { |
@@ -187,12 +207,12 @@ void SkRadialGradient::shadeSpan16(int x, int y, uint16_t* dstCParam, |
} |
RadialShade16Proc shadeProc = shadeSpan16_radial_repeat; |
- if (SkShader::kClamp_TileMode == fTileMode) { |
+ if (SkShader::kClamp_TileMode == radialGradient.fTileMode) { |
shadeProc = shadeSpan16_radial_clamp; |
- } else if (SkShader::kMirror_TileMode == fTileMode) { |
+ } else if (SkShader::kMirror_TileMode == radialGradient.fTileMode) { |
shadeProc = shadeSpan16_radial_mirror; |
} else { |
- SkASSERT(SkShader::kRepeat_TileMode == fTileMode); |
+ SkASSERT(SkShader::kRepeat_TileMode == radialGradient.fTileMode); |
} |
(*shadeProc)(srcPt.fX, sdx, srcPt.fY, sdy, dstC, |
cache, toggle, count); |
@@ -389,14 +409,16 @@ void shadeSpan_radial_repeat(SkScalar fx, SkScalar dx, SkScalar fy, SkScalar dy, |
} // namespace |
-void SkRadialGradient::shadeSpan(int x, int y, |
- SkPMColor* SK_RESTRICT dstC, int count) { |
+void SkRadialGradient::RadialGradientContext::shadeSpan(int x, int y, |
+ SkPMColor* SK_RESTRICT dstC, int count) { |
SkASSERT(count > 0); |
+ const SkRadialGradient& radialGradient = static_cast<const SkRadialGradient&>(fShader); |
+ |
SkPoint srcPt; |
SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
- TileProc proc = fTileProc; |
- const SkPMColor* SK_RESTRICT cache = this->getCache32(); |
+ TileProc proc = radialGradient.fTileProc; |
+ const SkPMColor* SK_RESTRICT cache = fCache->getCache32(); |
int toggle = init_dither_toggle(x, y); |
if (fDstToIndexClass != kPerspective_MatrixClass) { |
@@ -416,12 +438,12 @@ void SkRadialGradient::shadeSpan(int x, int y, |
} |
RadialShadeProc shadeProc = shadeSpan_radial_repeat; |
- if (SkShader::kClamp_TileMode == fTileMode) { |
+ if (SkShader::kClamp_TileMode == radialGradient.fTileMode) { |
shadeProc = shadeSpan_radial_clamp; |
- } else if (SkShader::kMirror_TileMode == fTileMode) { |
+ } else if (SkShader::kMirror_TileMode == radialGradient.fTileMode) { |
shadeProc = shadeSpan_radial_mirror; |
} else { |
- SkASSERT(SkShader::kRepeat_TileMode == fTileMode); |
+ SkASSERT(SkShader::kRepeat_TileMode == radialGradient.fTileMode); |
} |
(*shadeProc)(srcPt.fX, sdx, srcPt.fY, sdy, dstC, cache, count, toggle); |
} else { // perspective case |