Fix sweep gradient tiling w/ makeColorSpace

Change-Id: If989c2262b174af042af13cda991b999d9b6d596
Reviewed-on: https://skia-review.googlesource.com/29881
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Florin Malita 2017-08-02 10:42:41 -04:00 committed by Skia Commit-Bot
parent 63f76cc8fb
commit 545630b899

View File

@ -29,6 +29,10 @@ SkShader::GradientType SkSweepGradient::asAGradient(GradientInfo* info) const {
return kSweep_GradientType;
}
static std::tuple<SkScalar, SkScalar> angles_from_t_coeff(SkScalar tBias, SkScalar tScale) {
return std::make_tuple(-tBias * 360, (1 / tScale - tBias) * 360);
}
sk_sp<SkFlattenable> SkSweepGradient::CreateProc(SkReadBuffer& buffer) {
DescriptorScope desc;
if (!desc.unflatten(buffer)) {
@ -41,8 +45,7 @@ sk_sp<SkFlattenable> SkSweepGradient::CreateProc(SkReadBuffer& buffer) {
if (!buffer.isVersionLT(SkReadBuffer::kTileInfoInSweepGradient_Version)) {
const auto tBias = buffer.readScalar(),
tScale = buffer.readScalar();
startAngle = -tBias * 360;
endAngle = (1 / tScale - tBias) * 360;
std::tie(startAngle, endAngle) = angles_from_t_coeff(tBias, tScale);
}
return SkGradientShader::MakeSweep(center.x(), center.y(), desc.fColors,
@ -258,8 +261,13 @@ sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(const AsFPArgs&
sk_sp<SkShader> SkSweepGradient::onMakeColorSpace(SkColorSpaceXformer* xformer) const {
SkSTArray<8, SkColor> xformedColors(fColorCount);
xformer->apply(xformedColors.begin(), fOrigColors, fColorCount);
SkScalar startAngle, endAngle;
std::tie(startAngle, endAngle) = angles_from_t_coeff(fTBias, fTScale);
return SkGradientShader::MakeSweep(fCenter.fX, fCenter.fY, xformedColors.begin(), fOrigPos,
fColorCount, fGradFlags, &this->getLocalMatrix());
fColorCount, fTileMode, startAngle, endAngle,
fGradFlags, &this->getLocalMatrix());
}
#ifndef SK_IGNORE_TO_STRING