Concatenate matrices when GrMatrixEffect wraps another GrMatrixEffect
Bug: skia:11844 Change-Id: I13165fb17b06371854a4911c5d91bf2415d4df2a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396017 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
52b9e815eb
commit
4bbb29070c
@ -35,6 +35,23 @@ private:
|
||||
UniformHandle fMatrixVar;
|
||||
};
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrMatrixEffect::Make(
|
||||
const SkMatrix& matrix, std::unique_ptr<GrFragmentProcessor> child) {
|
||||
if (matrix.isIdentity()) {
|
||||
return child;
|
||||
}
|
||||
if (child->classID() == kGrMatrixEffect_ClassID) {
|
||||
auto me = static_cast<GrMatrixEffect*>(child.get());
|
||||
// registerChild's sample usage records whether the matrix used has perspective or not,
|
||||
// so we can't add perspective to 'me' if it doesn't already have it.
|
||||
if (me->matrix().hasPerspective() || !matrix.hasPerspective()) {
|
||||
me->fMatrix.preConcat(matrix);
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrMatrixEffect(matrix, std::move(child)));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrGLSLFragmentProcessor> GrMatrixEffect::onMakeProgramImpl() const {
|
||||
return std::make_unique<GrGLSLMatrixEffect>();
|
||||
}
|
||||
|
@ -16,12 +16,7 @@
|
||||
class GrMatrixEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const SkMatrix& matrix,
|
||||
std::unique_ptr<GrFragmentProcessor> child) {
|
||||
if (matrix.isIdentity()) {
|
||||
return child;
|
||||
}
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrMatrixEffect(matrix, std::move(child)));
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> child);
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "MatrixEffect"; }
|
||||
|
Loading…
Reference in New Issue
Block a user