Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: src/effects/gradients/Sk4fGradientBase.cpp

Issue 1816883002: Refactor 4f gradients using trait templates (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/Sk4fGradientBase.h ('k') | src/effects/gradients/Sk4fGradientPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/Sk4fGradientBase.cpp
diff --git a/src/effects/gradients/Sk4fGradientBase.cpp b/src/effects/gradients/Sk4fGradientBase.cpp
index 43910108ff79eb3466c7f5ac6ef6579ef5f3c062..e09ba77a04da61e333ab39023c0311ed7fce2230 100644
--- a/src/effects/gradients/Sk4fGradientBase.cpp
+++ b/src/effects/gradients/Sk4fGradientBase.cpp
@@ -276,56 +276,56 @@ GradientShaderBase4fContext::addMirrorIntervals(const SkGradientShaderBase& shad
void SkGradientShaderBase::
GradientShaderBase4fContext::shadeSpan(int x, int y, SkPMColor dst[], int count) {
if (fColorsArePremul) {
- this->shadePremulSpan<SkPMColor, ApplyPremul::False>(x, y, dst, count);
+ this->shadePremulSpan<DstType::L32, ApplyPremul::False>(x, y, dst, count);
} else {
- this->shadePremulSpan<SkPMColor, ApplyPremul::True>(x, y, dst, count);
+ this->shadePremulSpan<DstType::L32, ApplyPremul::True>(x, y, dst, count);
}
}
void SkGradientShaderBase::
GradientShaderBase4fContext::shadeSpan4f(int x, int y, SkPM4f dst[], int count) {
if (fColorsArePremul) {
- this->shadePremulSpan<SkPM4f, ApplyPremul::False>(x, y, dst, count);
+ this->shadePremulSpan<DstType::F32, ApplyPremul::False>(x, y, dst, count);
} else {
- this->shadePremulSpan<SkPM4f, ApplyPremul::True>(x, y, dst, count);
+ this->shadePremulSpan<DstType::F32, ApplyPremul::True>(x, y, dst, count);
}
}
-template<typename DstType, ApplyPremul premul>
+template<DstType dstType, ApplyPremul premul>
void SkGradientShaderBase::
GradientShaderBase4fContext::shadePremulSpan(int x, int y,
- DstType dst[],
+ typename DstTraits<dstType, premul>::Type dst[],
int count) const {
const SkGradientShaderBase& shader =
static_cast<const SkGradientShaderBase&>(fShader);
switch (shader.fTileMode) {
case kClamp_TileMode:
- this->shadeSpanInternal<DstType,
+ this->shadeSpanInternal<dstType,
premul,
kClamp_TileMode>(x, y, dst, count);
break;
case kRepeat_TileMode:
- this->shadeSpanInternal<DstType,
+ this->shadeSpanInternal<dstType,
premul,
kRepeat_TileMode>(x, y, dst, count);
break;
case kMirror_TileMode:
- this->shadeSpanInternal<DstType,
+ this->shadeSpanInternal<dstType,
premul,
kMirror_TileMode>(x, y, dst, count);
break;
}
}
-template<typename DstType, ApplyPremul premul, SkShader::TileMode tileMode>
+template<DstType dstType, ApplyPremul premul, SkShader::TileMode tileMode>
void SkGradientShaderBase::
GradientShaderBase4fContext::shadeSpanInternal(int x, int y,
- DstType dst[],
+ typename DstTraits<dstType, premul>::Type dst[],
int count) const {
static const int kBufSize = 128;
SkScalar ts[kBufSize];
- TSampler<DstType, tileMode> sampler(*this);
+ TSampler<dstType, tileMode> sampler(*this);
SkASSERT(count > 0);
do {
@@ -333,14 +333,14 @@ GradientShaderBase4fContext::shadeSpanInternal(int x, int y,
this->mapTs(x, y, ts, n);
for (int i = 0; i < n; ++i) {
const Sk4f c = sampler.sample(ts[i]);
- store<DstType, kLinear_SkColorProfileType, premul>(c, dst++);
+ DstTraits<dstType, premul>::store(c, dst++);
}
x += n;
count -= n;
} while (count > 0);
}
-template<typename DstType, SkShader::TileMode tileMode>
+template<DstType dstType, SkShader::TileMode tileMode>
class SkGradientShaderBase::GradientShaderBase4fContext::TSampler {
public:
TSampler(const GradientShaderBase4fContext& ctx)
@@ -423,8 +423,8 @@ private:
}
void loadIntervalData(const Interval* i) {
- fCc = scale_for_dest<DstType, kLinear_SkColorProfileType>(dst_swizzle<DstType>(i->fC0));
- fDc = scale_for_dest<DstType, kLinear_SkColorProfileType>(dst_swizzle<DstType>(i->fDc));
+ fCc = DstTraits<dstType>::load(i->fC0);
+ fDc = DstTraits<dstType>::load(i->fDc);
}
const Interval* fFirstInterval;
« no previous file with comments | « src/effects/gradients/Sk4fGradientBase.h ('k') | src/effects/gradients/Sk4fGradientPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698