diff options
author | Mike Reed <reed@google.com> | 2018-03-15 13:37:08 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-15 18:14:16 +0000 |
commit | 9c2916e0c7e0a61c0f85384c736247d4fa6d3a7b (patch) | |
tree | b775ac6e26f52d884c444bceb931871e98742a22 /src | |
parent | bdea98cff19c186c1492af9461cd0e0f4ad90541 (diff) |
drawTextRSXform should not apply matrix to shader
drawTextRSXform should draw the same as drawTextOnPath (as regards shaders)
Bug: b/69904791
Change-Id: I393dd8fd7a5bdc6a018b1ca33592b208c7141868
Reviewed-on: https://skia-review.googlesource.com/114468
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkDevice.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index e404d16c8d..210af808c9 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -14,6 +14,7 @@ #include "SkImagePriv.h" #include "SkImage_Base.h" #include "SkLatticeIter.h" +#include "SkLocalMatrixShader.h" #include "SkMatrixPriv.h" #include "SkPatchUtils.h" #include "SkPathMeasure.h" @@ -495,6 +496,9 @@ void SkBaseDevice::drawTextRSXform(const void* text, size_t len, break; } + SkPaint localPaint(paint); + SkShader* shader = paint.getShader(); + SkMatrix localM, currM; const void* stopText = (const char*)text + len; while ((const char*)text < (const char*)stopText) { @@ -502,8 +506,17 @@ void SkBaseDevice::drawTextRSXform(const void* text, size_t len, currM.setConcat(this->ctm(), localM); SkAutoDeviceCTMRestore adc(this, currM); + // We want to rotate each glyph by the rsxform, but we don't want to rotate "space" + // (i.e. the shader that cares about the ctm) so we have to undo our little ctm trick + // with a localmatrixshader so that the shader draws as if there was no change to the ctm. + if (shader) { + SkMatrix inverse; + SkAssertResult(localM.invert(&inverse)); + localPaint.setShader(shader->makeWithLocalMatrix(inverse)); + } + int subLen = proc((const char*)text); - this->drawText(text, subLen, 0, 0, paint); + this->drawText(text, subLen, 0, 0, localPaint); text = (const char*)text + subLen; } } |