Don't pass a stack address as a pipeline context pointer.

We call isNumericalTransferFn() both to test if an SkColorSpace
is a 7-parameter numerical transfer function, and to get those
parameters if so.  They're passed to the stage functions that
apply that transfer function via a context pointer.

We can't use &srcFn as this pointer, as it's on the stack,
and won't be alive by the time we get around to running the
pipeline.  Instead, copy it to the SkArenaAlloc we thread
through just for this purpose.

This would be a beginner's mistake, except that I wrote
the API myself...

Bug: chromium:794406
Change-Id: I9f9581f07a14ab501762f050e2c26f2e55a0c253
Reviewed-on: https://skia-review.googlesource.com/85340
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2017-12-14 15:33:47 -05:00 committed by Skia Commit-Bot
parent 5cdf667530
commit dbd43481f1

View File

@ -30,9 +30,10 @@ void SkToSRGBColorFilter::onAppendStages(SkRasterPipeline* p,
p->append_from_srgb(shaderIsOpaque ? kOpaque_SkAlphaType
: kPremul_SkAlphaType);
} else if (fSrcColorSpace->isNumericalTransferFn(&srcFn)) {
p->append(SkRasterPipeline::parametric_r, &srcFn);
p->append(SkRasterPipeline::parametric_g, &srcFn);
p->append(SkRasterPipeline::parametric_b, &srcFn);
auto copy = alloc->make<SkColorSpaceTransferFn>(srcFn);
p->append(SkRasterPipeline::parametric_r, copy);
p->append(SkRasterPipeline::parametric_g, copy);
p->append(SkRasterPipeline::parametric_b, copy);
} else {
SkDEBUGFAIL("Looks like we got a table transfer function here, quite unexpectedly.");
// TODO: If we really need to handle this, we can, but I don't think Ganesh does.