OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2219 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, | 2219 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
2220 const SkPaint& paint) { | 2220 const SkPaint& paint) { |
2221 SkASSERT(blob); | 2221 SkASSERT(blob); |
2222 | 2222 |
2223 // FIXME: dispatch to the device instead | 2223 // FIXME: dispatch to the device instead |
2224 | 2224 |
2225 if (x || y) { | 2225 if (x || y) { |
2226 this->translate(x, y); | 2226 this->translate(x, y); |
2227 } | 2227 } |
2228 | 2228 |
| 2229 SkPaint runPaint = paint; |
2229 SkTextBlob::RunIterator it(blob); | 2230 SkTextBlob::RunIterator it(blob); |
2230 while (!it.done()) { | 2231 while (!it.done()) { |
2231 size_t textLen = it.glyphCount() * sizeof(uint16_t); | 2232 size_t textLen = it.glyphCount() * sizeof(uint16_t); |
2232 const SkPoint& offset = it.offset(); | 2233 const SkPoint& offset = it.offset(); |
| 2234 // applyFontToPaint() always overwrites the exact same attributes, |
| 2235 // so it is safe to not re-seed the paint. |
| 2236 it.applyFontToPaint(&runPaint); |
2233 | 2237 |
2234 switch (it.positioning()) { | 2238 switch (it.positioning()) { |
2235 case SkTextBlob::kDefault_Positioning: | 2239 case SkTextBlob::kDefault_Positioning: |
2236 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), paint); | 2240 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), runPain
t); |
2237 break; | 2241 break; |
2238 case SkTextBlob::kHorizontal_Positioning: | 2242 case SkTextBlob::kHorizontal_Positioning: |
2239 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), paint
); | 2243 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), runPa
int); |
2240 break; | 2244 break; |
2241 case SkTextBlob::kFull_Positioning: | 2245 case SkTextBlob::kFull_Positioning: |
2242 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), pa
int); | 2246 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), ru
nPaint); |
2243 break; | 2247 break; |
2244 default: | 2248 default: |
2245 SkFAIL("unhandled positioning mode"); | 2249 SkFAIL("unhandled positioning mode"); |
2246 } | 2250 } |
2247 | 2251 |
2248 it.next(); | 2252 it.next(); |
2249 } | 2253 } |
2250 | 2254 |
2251 if (x || y) { | 2255 if (x || y) { |
2252 this->translate(-x, -y); | 2256 this->translate(-x, -y); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 } | 2594 } |
2591 | 2595 |
2592 if (NULL != matrix) { | 2596 if (NULL != matrix) { |
2593 canvas->concat(*matrix); | 2597 canvas->concat(*matrix); |
2594 } | 2598 } |
2595 } | 2599 } |
2596 | 2600 |
2597 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2601 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2598 fCanvas->restoreToCount(fSaveCount); | 2602 fCanvas->restoreToCount(fSaveCount); |
2599 } | 2603 } |
OLD | NEW |