OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
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 #include "SkTextBlob.h" | 8 #include "SkTextBlob.h" |
9 | 9 |
10 SkTextBlob::SkTextBlob(uint16_t *glyphs, SkScalar *pos, const SkTArray<Run> *run
s, | 10 SkTextBlob::SkTextBlob(uint16_t *glyphs, SkScalar *pos, const SkTArray<Run> *run
s, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 const SkScalar* SkTextBlob::RunIterator::pos() const { | 54 const SkScalar* SkTextBlob::RunIterator::pos() const { |
55 SkASSERT(!this->done()); | 55 SkASSERT(!this->done()); |
56 return fBlob->fPosBuffer.get() + (*fBlob->fRuns)[fIndex].posStart; | 56 return fBlob->fPosBuffer.get() + (*fBlob->fRuns)[fIndex].posStart; |
57 } | 57 } |
58 | 58 |
59 const SkPoint& SkTextBlob::RunIterator::offset() const { | 59 const SkPoint& SkTextBlob::RunIterator::offset() const { |
60 SkASSERT(!this->done()); | 60 SkASSERT(!this->done()); |
61 return (*fBlob->fRuns)[fIndex].offset; | 61 return (*fBlob->fRuns)[fIndex].offset; |
62 } | 62 } |
63 | 63 |
64 const SkPaint& SkTextBlob::RunIterator::font() const { | |
65 SkASSERT(!this->done()); | |
66 return (*fBlob->fRuns)[fIndex].font; | |
67 } | |
68 | |
69 SkTextBlob::GlyphPositioning SkTextBlob::RunIterator::positioning() const { | 64 SkTextBlob::GlyphPositioning SkTextBlob::RunIterator::positioning() const { |
70 SkASSERT(!this->done()); | 65 SkASSERT(!this->done()); |
71 return (*fBlob->fRuns)[fIndex].positioning; | 66 return (*fBlob->fRuns)[fIndex].positioning; |
72 } | 67 } |
73 | 68 |
| 69 void SkTextBlob::RunIterator::applyFontToPaint(SkPaint* paint) const { |
| 70 SkASSERT(!this->done()); |
| 71 |
| 72 const SkPaint& font = (*fBlob->fRuns)[fIndex].font; |
| 73 |
| 74 paint->setTypeface(font.getTypeface()); |
| 75 paint->setTextEncoding(font.getTextEncoding()); |
| 76 paint->setTextSize(font.getTextSize()); |
| 77 paint->setTextScaleX(font.getTextScaleX()); |
| 78 paint->setTextSkewX(font.getTextSkewX()); |
| 79 paint->setHinting(font.getHinting()); |
| 80 |
| 81 uint32_t flagsMask = SkPaint::kAntiAlias_Flag |
| 82 | SkPaint::kUnderlineText_Flag |
| 83 | SkPaint::kStrikeThruText_Flag |
| 84 | SkPaint::kFakeBoldText_Flag |
| 85 | SkPaint::kLinearText_Flag |
| 86 | SkPaint::kSubpixelText_Flag |
| 87 | SkPaint::kDevKernText_Flag |
| 88 | SkPaint::kLCDRenderText_Flag |
| 89 | SkPaint::kEmbeddedBitmapText_Flag |
| 90 | SkPaint::kAutoHinting_Flag |
| 91 | SkPaint::kVerticalText_Flag |
| 92 | SkPaint::kGenA8FromLCD_Flag |
| 93 | SkPaint::kDistanceFieldTextTEMP_Flag; |
| 94 paint->setFlags((paint->getFlags() & ~flagsMask) | (font.getFlags() & flagsM
ask)); |
| 95 } |
| 96 |
74 SkTextBlobBuilder::SkTextBlobBuilder(unsigned runs) | 97 SkTextBlobBuilder::SkTextBlobBuilder(unsigned runs) |
75 : fRuns(NULL) | 98 : fRuns(NULL) |
76 , fDeferredBounds(false) { | 99 , fDeferredBounds(false) { |
77 | 100 |
78 if (runs > 0) { | 101 if (runs > 0) { |
79 // if the number of runs is known, size our run storage accordingly. | 102 // if the number of runs is known, size our run storage accordingly. |
80 fRuns = SkNEW(SkTArray<SkTextBlob::Run>(runs)); | 103 fRuns = SkNEW(SkTArray<SkTextBlob::Run>(runs)); |
81 } | 104 } |
82 fBounds.setEmpty(); | 105 fBounds.setEmpty(); |
83 } | 106 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // empty blob | 235 // empty blob |
213 SkASSERT(NULL == fRuns || fRuns->empty()); | 236 SkASSERT(NULL == fRuns || fRuns->empty()); |
214 SkASSERT(fBounds.isEmpty()); | 237 SkASSERT(fBounds.isEmpty()); |
215 | 238 |
216 blob = SkNEW_ARGS(SkTextBlob, (NULL, NULL, NULL, SkRect::MakeEmpty())); | 239 blob = SkNEW_ARGS(SkTextBlob, (NULL, NULL, NULL, SkRect::MakeEmpty())); |
217 } | 240 } |
218 | 241 |
219 return blob; | 242 return blob; |
220 } | 243 } |
221 | 244 |
OLD | NEW |