Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1272)

Unified Diff: src/core/SkDevice.cpp

Issue 609223003: Revert of Fix SkTextBlob offset semantics. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDevice.cpp
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 935d489892bb1bb25719645321d0ab67258315b3..63a76336482f9f32ddba4c092e476a81a6b64b92 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -96,6 +96,27 @@
const SkPaint &paint) {
SkPaint runPaint = paint;
+ SkMatrix localMatrix;
+ SkDraw localDraw(draw);
+
+ if (x || y) {
+ localMatrix = *draw.fMatrix;
+ localMatrix.preTranslate(x, y);
+ localDraw.fMatrix = &localMatrix;
+
+ if (paint.getShader()) {
+ // FIXME: We need to compensate for the translate above. This is suboptimal but
+ // temporary -- until we get proper derived class drawTextBlob implementations.
+
+ // TODO: pass x,y down to the other methods so they can handle the additional
+ // translate without needing to allocate a new shader.
+ SkMatrix shaderMatrix;
+ shaderMatrix.setTranslate(-x, -y);
+ SkAutoTUnref<SkShader> wrapper(
+ SkShader::CreateLocalMatrixShader(paint.getShader(), shaderMatrix));
+ runPaint.setShader(wrapper);
+ }
+ }
SkTextBlob::RunIterator it(blob);
while (!it.done()) {
@@ -107,15 +128,12 @@
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
- this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offset.y(), runPaint);
+ this->drawText(localDraw, it.glyphs(), textLen, offset.x(), offset.y(), runPaint);
break;
case SkTextBlob::kHorizontal_Positioning:
- this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1,
- SkPoint::Make(x, y + offset.y()), runPaint);
- break;
case SkTextBlob::kFull_Positioning:
- this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 2,
- SkPoint::Make(x, y), runPaint);
+ this->drawPosText(localDraw, it.glyphs(), textLen, it.pos(), offset.y(),
+ SkTextBlob::ScalarsPerGlyph(it.positioning()), runPaint);
break;
default:
SkFAIL("unhandled positioning mode");
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698