use from/to_srgb
Change-Id: I256dd98e1e918943195772954bc114e54b9325cd Reviewed-on: https://skia-review.googlesource.com/140564 Commit-Queue: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
2267a09235
commit
c3a5419423
@ -41,8 +41,10 @@ SkColorSpaceXformSteps::SkColorSpaceXformSteps(SkColorSpace* src, SkAlphaType sr
|
||||
SkColorSpaceTransferFn srcTF, dstTF;
|
||||
SkAssertResult(src->isNumericalTransferFn(&srcTF));
|
||||
SkAssertResult(dst->isNumericalTransferFn(&dstTF));
|
||||
this->srcTF = srcTF;
|
||||
this->dstTFInv = dstTF.invert();
|
||||
this->srcTF = srcTF;
|
||||
this->dstTFInv = dstTF.invert();
|
||||
this->srcTF_is_sRGB = src->gammaCloseToSRGB();
|
||||
this->dstTF_is_sRGB = dst->gammaCloseToSRGB();
|
||||
|
||||
// If we linearize then immediately reencode with the same transfer function, skip both.
|
||||
if ( this->flags.linearize &&
|
||||
@ -103,19 +105,25 @@ void SkColorSpaceXformSteps::apply(float* rgba) const {
|
||||
void SkColorSpaceXformSteps::apply(SkRasterPipeline* p) const {
|
||||
if (flags.unpremul) { p->append(SkRasterPipeline::unpremul); }
|
||||
if (flags.linearize) {
|
||||
// TODO: missing an opportunity to use from_srgb here.
|
||||
p->append(SkRasterPipeline::parametric_r, &srcTF);
|
||||
p->append(SkRasterPipeline::parametric_g, &srcTF);
|
||||
p->append(SkRasterPipeline::parametric_b, &srcTF);
|
||||
if (srcTF_is_sRGB) {
|
||||
p->append(SkRasterPipeline::from_srgb);
|
||||
} else {
|
||||
p->append(SkRasterPipeline::parametric_r, &srcTF);
|
||||
p->append(SkRasterPipeline::parametric_g, &srcTF);
|
||||
p->append(SkRasterPipeline::parametric_b, &srcTF);
|
||||
}
|
||||
}
|
||||
if (flags.gamut_transform) {
|
||||
p->append(SkRasterPipeline::matrix_3x3, &src_to_dst_matrix);
|
||||
}
|
||||
if (flags.encode) {
|
||||
// TODO: missing an opportunity to use to_srgb here.
|
||||
p->append(SkRasterPipeline::parametric_r, &dstTFInv);
|
||||
p->append(SkRasterPipeline::parametric_g, &dstTFInv);
|
||||
p->append(SkRasterPipeline::parametric_b, &dstTFInv);
|
||||
if (dstTF_is_sRGB) {
|
||||
p->append(SkRasterPipeline::to_srgb);
|
||||
} else {
|
||||
p->append(SkRasterPipeline::parametric_r, &dstTFInv);
|
||||
p->append(SkRasterPipeline::parametric_g, &dstTFInv);
|
||||
p->append(SkRasterPipeline::parametric_b, &dstTFInv);
|
||||
}
|
||||
}
|
||||
if (flags.premul) { p->append(SkRasterPipeline::premul); }
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ struct SkColorSpaceXformSteps {
|
||||
|
||||
Flags flags;
|
||||
|
||||
bool srcTF_is_sRGB,
|
||||
dstTF_is_sRGB;
|
||||
SkColorSpaceTransferFn srcTF, // Apply for linearize.
|
||||
dstTFInv; // Apply for encode.
|
||||
float src_to_dst_matrix[9]; // Apply this 3x3 column-major matrix for gamut_transform.
|
||||
|
Loading…
Reference in New Issue
Block a user