aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkDevice.cpp')
-rw-r--r--src/core/SkDevice.cpp59
1 files changed, 19 insertions, 40 deletions
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 2296d359da..60f8cd861f 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -476,55 +476,34 @@ void SkBaseDevice::drawTextOnPath(const void* text, size_t byteLength,
#include "SkUtils.h"
-void SkBaseDevice::drawTextRSXform(const void* text, size_t len,
- const SkRSXform xform[], const SkPaint& paint) {
- SkPaint::TextEncoding textEncoding = paint.getTextEncoding();
- const char* end = (const char*)text + len;
- SkPaint localPaint(paint);
- SkShader* shader = paint.getShader();
- SkScalar pos[2] = {0.0f, 0.0f};
- SkPoint origin = SkPoint::Make(0, 0);
-
- SkMatrix localM, currM;
- const void* stopText = (const char*)text + len;
- while ((const char*)text < (const char*)stopText) {
- localM.setRSXform(*xform++);
- currM.setConcat(this->ctm(), localM);
- SkAutoDeviceCTMRestore adc(this, currM);
+void SkBaseDevice::drawGlyphRunRSXform(SkGlyphRun* run, const SkRSXform* xform) {
+ const SkMatrix originalCTM = this->ctm();
+ sk_sp<SkShader> shader = sk_ref_sp(run->mutablePaint()->getShader());
+ auto perGlyph = [this, &xform, &originalCTM, shader] (
+ SkGlyphRun* glyphRun, SkPaint* runPaint) {
+ SkMatrix ctm;
+ ctm.setRSXform(*xform++);
// 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;
- if (localM.invert(&inverse)) {
- localPaint.setShader(shader->makeWithLocalMatrix(inverse));
+ if (ctm.invert(&inverse)) {
+ runPaint->setShader(shader->makeWithLocalMatrix(inverse));
} else {
- localPaint.setShader(nullptr); // can't handle this xform
+ runPaint->setShader(nullptr); // can't handle this xform
}
}
- int subLen = 0;
- switch (textEncoding) {
- case SkPaint::kUTF8_TextEncoding:
- subLen = SkUTF8_CountUTF8Bytes((const char*)text);
- break;
- case SkPaint::kUTF16_TextEncoding:
- {
- const uint16_t* ptr = (const uint16_t*)text;
- (void)SkUTF16_NextUnichar(&ptr, (const uint16_t*)end);
- subLen = SkToInt((const char*)ptr - (const char*)text);
- };
- break;
- case SkPaint::kUTF32_TextEncoding:
- subLen = 4;
- break;
- case SkPaint::kGlyphID_TextEncoding:
- subLen = 2;
- break;
- }
- this->drawPosText(text, subLen, pos, 2, origin, localPaint);
- text = (const char*)text + subLen;
- }
+
+ ctm.setConcat(originalCTM, ctm);
+ this->setCTM(ctm);
+ SkGlyphRunList glyphRunList{glyphRun};
+ this->drawGlyphRunList(&glyphRunList);
+ };
+ run->eachGlyphToGlyphRun(perGlyph);
+ run->mutablePaint()->setShader(shader);
+ this->setCTM(originalCTM);
}
//////////////////////////////////////////////////////////////////////////////////////////