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"); |