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

Side by Side Diff: src/core/SkTextBlob.cpp

Issue 496773002: [SkTextBlob] Merge run font data at draw time. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review comments Created 6 years, 4 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 unified diff | Download patch
« src/core/SkCanvas.cpp ('K') | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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));
reed1 2014/08/22 15:36:41 Does font.getFlags() return equivalent bit flags t
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
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
OLDNEW
« src/core/SkCanvas.cpp ('K') | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698