aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-04-04 14:17:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-04 18:54:28 +0000
commit325ea327ff6106f5f35df437a2bbb88f566bb3c4 (patch)
tree7d28868b905eb60d3e9fd3a020df1475d4bd0608 /src/shaders
parent1efe3224735046db153ffff6691b1f741f371794 (diff)
Fix SkLocalMatrixShader nesting semantics
Inherited/outer local matrices are supposed to compose to the right of (preconcat) other/nested local matrices. BUG=skia:7781 Change-Id: Icd3c24f226845427be849a8be3d78293aef176b3 Reviewed-on: https://skia-review.googlesource.com/118344 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'src/shaders')
-rw-r--r--src/shaders/SkLocalMatrixShader.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/shaders/SkLocalMatrixShader.cpp b/src/shaders/SkLocalMatrixShader.cpp
index a08fea14a5..e352d31299 100644
--- a/src/shaders/SkLocalMatrixShader.cpp
+++ b/src/shaders/SkLocalMatrixShader.cpp
@@ -6,6 +6,7 @@
*/
#include "SkLocalMatrixShader.h"
+#include "SkTLazy.h"
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
@@ -42,14 +43,14 @@ void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
SkShaderBase::Context* SkLocalMatrixShader::onMakeContext(
const ContextRec& rec, SkArenaAlloc* alloc) const
{
- ContextRec newRec(rec);
- SkMatrix tmp;
+ SkTCopyOnFirstWrite<SkMatrix> lm(this->getLocalMatrix());
if (rec.fLocalMatrix) {
- tmp.setConcat(*rec.fLocalMatrix, this->getLocalMatrix());
- newRec.fLocalMatrix = &tmp;
- } else {
- newRec.fLocalMatrix = &this->getLocalMatrix();
+ lm.writable()->preConcat(*rec.fLocalMatrix);
}
+
+ ContextRec newRec(rec);
+ newRec.fLocalMatrix = lm;
+
return as_SB(fProxyShader)->makeContext(newRec, alloc);
}
@@ -65,12 +66,13 @@ SkImage* SkLocalMatrixShader::onIsAImage(SkMatrix* outMatrix, enum TileMode* mod
}
bool SkLocalMatrixShader::onAppendStages(const StageRec& rec) const {
- SkMatrix tmp;
+ SkTCopyOnFirstWrite<SkMatrix> lm(this->getLocalMatrix());
if (rec.fLocalM) {
- tmp.setConcat(*rec.fLocalM, this->getLocalMatrix());
+ lm.writable()->preConcat(*rec.fLocalM);
}
+
StageRec newRec = rec;
- newRec.fLocalM = rec.fLocalM ? &tmp : &this->getLocalMatrix();
+ newRec.fLocalM = lm;
return as_SB(fProxyShader)->appendStages(newRec);
}