Index: src/effects/gradients/SkTwoPointConicalGradient.cpp |
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp |
index 91856c88a2eabdeb58f131e6e1d9eadf9dbed541..9284e7cb090a301b63223de5c36337aa1b133462 100644 |
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp |
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp |
@@ -343,6 +343,7 @@ SkShader::GradientType SkTwoPointConicalGradient::asAGradient( |
return kConical_GradientType; |
} |
+#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
SkTwoPointConicalGradient::SkTwoPointConicalGradient( |
SkReadBuffer& buffer) |
: INHERITED(buffer), |
@@ -366,9 +367,47 @@ SkTwoPointConicalGradient::SkTwoPointConicalGradient( |
} |
this->init(); |
}; |
+#endif |
+ |
+SkFlattenable* SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) { |
+ DescriptorScope desc; |
+ if (!desc.unflatten(buffer)) { |
+ return NULL; |
+ } |
+ SkPoint c1 = buffer.readPoint(); |
+ SkPoint c2 = buffer.readPoint(); |
+ SkScalar r1 = buffer.readScalar(); |
+ SkScalar r2 = buffer.readScalar(); |
+ |
+ if (buffer.readBool()) { // flipped |
+ SkTSwap(c1, c2); |
+ SkTSwap(r1, r2); |
+ |
+ SkColor* colors = desc.mutableColors(); |
+ SkScalar* pos = desc.mutablePos(); |
+ const int last = desc.fCount - 1; |
+ const int half = desc.fCount >> 1; |
+ for (int i = 0; i < half; ++i) { |
+ SkTSwap(colors[i], colors[last - i]); |
+ if (pos) { |
+ SkScalar tmp = pos[i]; |
+ pos[i] = SK_Scalar1 - pos[last - i]; |
+ pos[last - i] = SK_Scalar1 - tmp; |
+ } |
+ } |
+ if (pos) { |
+ if (desc.fCount & 1) { |
+ pos[half] = SK_Scalar1 - pos[half]; |
+ } |
+ } |
+ } |
+ |
+ return SkGradientShader::CreateTwoPointConical(c1, r1, c2, r2, desc.fColors, desc.fPos, |
+ desc.fCount, desc.fTileMode, desc.fGradFlags, |
+ desc.fLocalMatrix); |
+} |
-void SkTwoPointConicalGradient::flatten( |
- SkWriteBuffer& buffer) const { |
+void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const { |
this->INHERITED::flatten(buffer); |
buffer.writePoint(fCenter1); |
buffer.writePoint(fCenter2); |