fix and test colorfiltershader

Bug: skia:
Change-Id: I02fd77796880b42ce55549a8340b116e1c5f19d6
Reviewed-on: https://skia-review.googlesource.com/18305
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Reed 2017-06-01 09:37:57 -04:00 committed by Skia Commit-Bot
parent 2f4ddf6964
commit a03d407aea
2 changed files with 23 additions and 3 deletions

View File

@ -186,18 +186,24 @@ DEF_SIMPLE_GM(colorfilterimagefilter_layer, canvas, 32, 32) {
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "SkGradientShader.h"
template <typename T> class SkTRefArray : public SkTDArray<T> {
public:
~SkTRefArray() { this->unrefAll(); }
};
DEF_SIMPLE_GM(colorfiltershader, canvas, 610, 450) {
DEF_SIMPLE_GM(colorfiltershader, canvas, 610, 610) {
SkTArray<sk_sp<SkColorFilter>> filters;
sk_gm_get_colorfilters(&filters);
SkTRefArray<SkShader*> shaders;
sk_gm_get_shaders(&shaders);
const SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
*shaders.append() = SkGradientShader::MakeTwoPointConical({0, 0}, 50, {0, 0}, 150,
colors, nullptr, 2,
SkShader::kClamp_TileMode).release();
SkPaint paint;
SkRect r = SkRect::MakeWH(120, 120);

View File

@ -93,10 +93,24 @@ void SkColorFilterShader::FilterShaderContext::shadeSpan(int x, int y, SkPMColor
filterShader.fFilter->filterSpan(result, count, result);
}
#include "SkRasterPipeline.h"
void SkColorFilterShader::FilterShaderContext::shadeSpan4f(int x, int y, SkPM4f result[],
int count) {
// Should never get here, as shadeSpan4f should only be called if stages fails
SkASSERT(false);
const SkColorFilterShader& filterShader = static_cast<const SkColorFilterShader&>(fShader);
fShaderContext->shadeSpan4f(x, y, result, count);
// now apply the filter
SkSTArenaAlloc<128> alloc;
SkRasterPipeline pipeline(&alloc);
const SkPM4f* src = result;
pipeline.append(SkRasterPipeline::load_f32, &src);
filterShader.fFilter->appendStages(&pipeline, nullptr, &alloc, filterShader.isOpaque());
SkPM4f* dst = result;
pipeline.append(SkRasterPipeline::store_f32, &dst);
pipeline.run(0, count);
}
#if SK_SUPPORT_GPU