Raster pipeline support for SkLocalMatrixShader composition
Plumb a local matrix arg to onAppendStages, similar to onCreateContext's ContextRec::fLocalMatrix. Change-Id: I6db3706918733b35eb7a3ae2cc65503223d0cf2d Reviewed-on: https://skia-review.googlesource.com/7653 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
dbd44c78ec
commit
882ccafee0
@ -502,7 +502,8 @@ protected:
|
||||
}
|
||||
|
||||
virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
|
||||
const SkMatrix&, const SkPaint&) const {
|
||||
const SkMatrix&, const SkPaint&,
|
||||
const SkMatrix* /*local matrix*/) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -312,8 +312,9 @@ bool SkColor4Shader::Color4Context::onChooseBlitProcs(const SkImageInfo& info, B
|
||||
bool SkColorShader::onAppendStages(SkRasterPipeline* p,
|
||||
SkColorSpace* dst,
|
||||
SkArenaAlloc* scratch,
|
||||
const SkMatrix& ctm,
|
||||
const SkPaint&) const {
|
||||
const SkMatrix&,
|
||||
const SkPaint&,
|
||||
const SkMatrix*) const {
|
||||
auto color = scratch->make<SkPM4f>(SkPM4f_from_SkColor(fColor, dst));
|
||||
p->append(SkRasterPipeline::constant_color, color);
|
||||
return append_gamut_transform(p, scratch,
|
||||
@ -323,8 +324,9 @@ bool SkColorShader::onAppendStages(SkRasterPipeline* p,
|
||||
bool SkColor4Shader::onAppendStages(SkRasterPipeline* p,
|
||||
SkColorSpace* dst,
|
||||
SkArenaAlloc* scratch,
|
||||
const SkMatrix& ctm,
|
||||
const SkPaint&) const {
|
||||
const SkMatrix&,
|
||||
const SkPaint&,
|
||||
const SkMatrix*) const {
|
||||
auto color = scratch->make<SkPM4f>(fColor4.premul());
|
||||
p->append(SkRasterPipeline::constant_color, color);
|
||||
return append_gamut_transform(p, scratch, fColorSpace.get(), dst);
|
||||
|
@ -66,7 +66,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
|
||||
const SkMatrix& ctm, const SkPaint&) const override;
|
||||
const SkMatrix& ctm, const SkPaint&, const SkMatrix*) const override;
|
||||
|
||||
private:
|
||||
SkColor fColor;
|
||||
@ -122,7 +122,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
|
||||
const SkMatrix& ctm, const SkPaint&) const override;
|
||||
const SkMatrix& ctm, const SkPaint&, const SkMatrix*) const override;
|
||||
|
||||
private:
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
|
@ -50,6 +50,21 @@ SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec,
|
||||
return fProxyShader->createContext(newRec, storage);
|
||||
}
|
||||
|
||||
bool SkLocalMatrixShader::onAppendStages(SkRasterPipeline* p,
|
||||
SkColorSpace* dst,
|
||||
SkArenaAlloc* scratch,
|
||||
const SkMatrix& ctm,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix* localM) const {
|
||||
SkMatrix tmp;
|
||||
if (localM) {
|
||||
tmp.setConcat(*localM, this->getLocalMatrix());
|
||||
}
|
||||
|
||||
return fProxyShader->onAppendStages(p, dst, scratch, ctm, paint,
|
||||
localM ? &tmp : &this->getLocalMatrix());
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void SkLocalMatrixShader::toString(SkString* str) const {
|
||||
str->append("SkLocalMatrixShader: (");
|
||||
|
@ -51,6 +51,9 @@ protected:
|
||||
return fProxyShader->isAImage(matrix, mode);
|
||||
}
|
||||
|
||||
bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
|
||||
const SkMatrix&, const SkPaint&, const SkMatrix*) const override;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
|
||||
bool onIsABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* mode) const override {
|
||||
return fProxyShader->isABitmap(bitmap, matrix, mode);
|
||||
|
@ -259,7 +259,7 @@ bool SkShader::appendStages(SkRasterPipeline* pipeline,
|
||||
SkArenaAlloc* scratch,
|
||||
const SkMatrix& ctm,
|
||||
const SkPaint& paint) const {
|
||||
return this->onAppendStages(pipeline, dst, scratch, ctm, paint);
|
||||
return this->onAppendStages(pipeline, dst, scratch, ctm, paint, nullptr);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -95,14 +95,18 @@ SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void
|
||||
// * linear_gradient_2stops (lerp c0/c1)
|
||||
// * optional premul
|
||||
//
|
||||
bool SkLinearGradient::onAppendStages(SkRasterPipeline* p, SkColorSpace* cs, SkArenaAlloc* alloc,
|
||||
const SkMatrix& ctm, const SkPaint& paint) const {
|
||||
bool SkLinearGradient::onAppendStages(SkRasterPipeline* p,
|
||||
SkColorSpace* cs,
|
||||
SkArenaAlloc* alloc,
|
||||
const SkMatrix& ctm,
|
||||
const SkPaint&,
|
||||
const SkMatrix* localM) const {
|
||||
if (fColorCount > 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Local matrix not supported currently. Remove once we have a generic RP wrapper.
|
||||
if (!getLocalMatrix().isIdentity()) {
|
||||
if (localM || !getLocalMatrix().isIdentity()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ protected:
|
||||
Context* onCreateContext(const ContextRec&, void* storage) const override;
|
||||
|
||||
bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
|
||||
const SkMatrix&, const SkPaint&) const override;
|
||||
const SkMatrix&, const SkPaint&, const SkMatrix*) const override;
|
||||
|
||||
private:
|
||||
class LinearGradient4fContext;
|
||||
|
@ -228,8 +228,13 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
||||
|
||||
bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkArenaAlloc* scratch,
|
||||
const SkMatrix& ctm, const SkPaint& paint) const {
|
||||
const SkMatrix& ctm, const SkPaint& paint,
|
||||
const SkMatrix* localM) const {
|
||||
auto matrix = SkMatrix::Concat(ctm, this->getLocalMatrix());
|
||||
if (localM) {
|
||||
matrix.preConcat(*localM);
|
||||
}
|
||||
|
||||
if (!matrix.invert(&matrix)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ protected:
|
||||
SkImage* onIsAImage(SkMatrix*, TileMode*) const override;
|
||||
|
||||
bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
|
||||
const SkMatrix& ctm, const SkPaint&) const override;
|
||||
const SkMatrix& ctm, const SkPaint&, const SkMatrix*) const override;
|
||||
|
||||
sk_sp<SkImage> fImage;
|
||||
const TileMode fTileModeX;
|
||||
|
Loading…
Reference in New Issue
Block a user