OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. |
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. | 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 namespace blink { | 55 namespace blink { |
56 | 56 |
57 Font::Font() | 57 Font::Font() |
58 { | 58 { |
59 } | 59 } |
60 | 60 |
61 Font::Font(const FontDescription& fd) | 61 Font::Font(const FontDescription& fd) |
62 : m_fontDescription(fd) | 62 : m_fontDescription(fd) |
63 , m_canShapeWordByWord(0) | 63 , m_canShapeWordByWord(0) |
64 , m_shapeWordByWordComputed(0) | 64 , m_shapeWordByWordComputed(0) |
| 65 , m_firstPaintReported(0) |
65 { | 66 { |
66 } | 67 } |
67 | 68 |
68 Font::Font(const Font& other) | 69 Font::Font(const Font& other) |
69 : m_fontDescription(other.m_fontDescription) | 70 : m_fontDescription(other.m_fontDescription) |
70 , m_fontFallbackList(other.m_fontFallbackList) | 71 , m_fontFallbackList(other.m_fontFallbackList) |
71 , m_canShapeWordByWord(0) | 72 , m_canShapeWordByWord(0) |
72 , m_shapeWordByWordComputed(0) | 73 , m_shapeWordByWordComputed(0) |
| 74 , m_firstPaintReported(0) |
73 { | 75 { |
74 } | 76 } |
75 | 77 |
76 Font& Font::operator=(const Font& other) | 78 Font& Font::operator=(const Font& other) |
77 { | 79 { |
78 m_fontDescription = other.m_fontDescription; | 80 m_fontDescription = other.m_fontDescription; |
79 m_fontFallbackList = other.m_fontFallbackList; | 81 m_fontFallbackList = other.m_fontFallbackList; |
80 m_canShapeWordByWord = other.m_canShapeWordByWord; | 82 m_canShapeWordByWord = other.m_canShapeWordByWord; |
81 m_shapeWordByWordComputed = other.m_shapeWordByWordComputed; | 83 m_shapeWordByWordComputed = other.m_shapeWordByWordComputed; |
| 84 m_firstPaintReported = other.m_firstPaintReported; |
82 return *this; | 85 return *this; |
83 } | 86 } |
84 | 87 |
85 bool Font::operator==(const Font& other) const | 88 bool Font::operator==(const Font& other) const |
86 { | 89 { |
87 FontSelector* first = m_fontFallbackList ? m_fontFallbackList->fontSelector(
) : 0; | 90 FontSelector* first = m_fontFallbackList ? m_fontFallbackList->fontSelector(
) : 0; |
88 FontSelector* second = other.m_fontFallbackList ? other.m_fontFallbackList->
fontSelector() : 0; | 91 FontSelector* second = other.m_fontFallbackList ? other.m_fontFallbackList->
fontSelector() : 0; |
89 | 92 |
90 return first == second | 93 return first == second |
91 && m_fontDescription == other.m_fontDescription | 94 && m_fontDescription == other.m_fontDescription |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return width; | 139 return width; |
137 } | 140 } |
138 | 141 |
139 void Font::drawText(SkCanvas* canvas, const TextRunPaintInfo& runInfo, | 142 void Font::drawText(SkCanvas* canvas, const TextRunPaintInfo& runInfo, |
140 const FloatPoint& point, float deviceScaleFactor, const SkPaint& paint) cons
t | 143 const FloatPoint& point, float deviceScaleFactor, const SkPaint& paint) cons
t |
141 { | 144 { |
142 // Don't draw anything while we are using custom fonts that are in the proce
ss of loading. | 145 // Don't draw anything while we are using custom fonts that are in the proce
ss of loading. |
143 if (shouldSkipDrawing()) | 146 if (shouldSkipDrawing()) |
144 return; | 147 return; |
145 | 148 |
| 149 reportFirstTextPaint(); |
| 150 |
146 if (runInfo.cachedTextBlob && runInfo.cachedTextBlob->get()) { | 151 if (runInfo.cachedTextBlob && runInfo.cachedTextBlob->get()) { |
147 // we have a pre-cached blob -- happy joy! | 152 // we have a pre-cached blob -- happy joy! |
148 drawTextBlob(canvas, paint, runInfo.cachedTextBlob->get(), point.data())
; | 153 drawTextBlob(canvas, paint, runInfo.cachedTextBlob->get(), point.data())
; |
149 return; | 154 return; |
150 } | 155 } |
151 | 156 |
152 GlyphBuffer glyphBuffer; | 157 GlyphBuffer glyphBuffer; |
153 buildGlyphBuffer(runInfo, glyphBuffer); | 158 buildGlyphBuffer(runInfo, glyphBuffer); |
154 | 159 |
155 drawGlyphBuffer(canvas, paint, runInfo, glyphBuffer, point, deviceScaleFacto
r); | 160 drawGlyphBuffer(canvas, paint, runInfo, glyphBuffer, point, deviceScaleFacto
r); |
156 } | 161 } |
157 | 162 |
158 void Font::drawBidiText(SkCanvas* canvas, const TextRunPaintInfo& runInfo, const
FloatPoint& point, CustomFontNotReadyAction customFontNotReadyAction, float dev
iceScaleFactor, const SkPaint& paint) const | 163 void Font::drawBidiText(SkCanvas* canvas, const TextRunPaintInfo& runInfo, const
FloatPoint& point, CustomFontNotReadyAction customFontNotReadyAction, float dev
iceScaleFactor, const SkPaint& paint) const |
159 { | 164 { |
160 // Don't draw anything while we are using custom fonts that are in the proce
ss of loading, | 165 // Don't draw anything while we are using custom fonts that are in the proce
ss of loading, |
161 // except if the 'force' argument is set to true (in which case it will use
a fallback | 166 // except if the 'force' argument is set to true (in which case it will use
a fallback |
162 // font). | 167 // font). |
163 if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotRe
ady) | 168 if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotRe
ady) |
164 return; | 169 return; |
165 | 170 |
| 171 reportFirstTextPaint(); |
| 172 |
166 // sub-run painting is not supported for Bidi text. | 173 // sub-run painting is not supported for Bidi text. |
167 const TextRun& run = runInfo.run; | 174 const TextRun& run = runInfo.run; |
168 ASSERT((runInfo.from == 0) && (runInfo.to == run.length())); | 175 ASSERT((runInfo.from == 0) && (runInfo.to == run.length())); |
169 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; | 176 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; |
170 bidiResolver.setStatus(BidiStatus(run.direction(), run.directionalOverride()
)); | 177 bidiResolver.setStatus(BidiStatus(run.direction(), run.directionalOverride()
)); |
171 bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&run, 0)); | 178 bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&run, 0)); |
172 | 179 |
173 // FIXME: This ownership should be reversed. We should pass BidiRunList | 180 // FIXME: This ownership should be reversed. We should pass BidiRunList |
174 // to BidiResolver in createBidiRunsForLine. | 181 // to BidiResolver in createBidiRunsForLine. |
175 BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs(); | 182 BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs(); |
(...skipping 18 matching lines...) Expand all Loading... |
194 float runWidth = buildGlyphBuffer(subrunInfo, glyphBuffer); | 201 float runWidth = buildGlyphBuffer(subrunInfo, glyphBuffer); |
195 drawGlyphBuffer(canvas, paint, subrunInfo, glyphBuffer, currPoint, devic
eScaleFactor); | 202 drawGlyphBuffer(canvas, paint, subrunInfo, glyphBuffer, currPoint, devic
eScaleFactor); |
196 | 203 |
197 bidiRun = bidiRun->next(); | 204 bidiRun = bidiRun->next(); |
198 currPoint.move(runWidth, 0); | 205 currPoint.move(runWidth, 0); |
199 } | 206 } |
200 | 207 |
201 bidiRuns.deleteRuns(); | 208 bidiRuns.deleteRuns(); |
202 } | 209 } |
203 | 210 |
| 211 void Font::reportFirstTextPaint() const |
| 212 { |
| 213 if (m_firstPaintReported || !fontSelector()) |
| 214 return; |
| 215 m_firstPaintReported = true; |
| 216 |
| 217 if (m_fontFallbackList->hasCustomFont()) |
| 218 fontSelector()->reportFirstCustomFontText(); |
| 219 fontSelector()->reportFirstNonBlankText(); |
| 220 } |
| 221 |
204 void Font::drawEmphasisMarks(SkCanvas* canvas, const TextRunPaintInfo& runInfo,
const AtomicString& mark, const FloatPoint& point, float deviceScaleFactor, cons
t SkPaint& paint) const | 222 void Font::drawEmphasisMarks(SkCanvas* canvas, const TextRunPaintInfo& runInfo,
const AtomicString& mark, const FloatPoint& point, float deviceScaleFactor, cons
t SkPaint& paint) const |
205 { | 223 { |
206 if (shouldSkipDrawing()) | 224 if (shouldSkipDrawing()) |
207 return; | 225 return; |
208 | 226 |
209 FontCachePurgePreventer purgePreventer; | 227 FontCachePurgePreventer purgePreventer; |
210 | 228 |
211 GlyphData emphasisGlyphData; | 229 GlyphData emphasisGlyphData; |
212 if (!getEmphasisMarkGlyphData(mark, emphasisGlyphData)) | 230 if (!getEmphasisMarkGlyphData(mark, emphasisGlyphData)) |
213 return; | 231 return; |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 { | 839 { |
822 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); | 840 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); |
823 } | 841 } |
824 | 842 |
825 bool Font::isFallbackValid() const | 843 bool Font::isFallbackValid() const |
826 { | 844 { |
827 return !m_fontFallbackList || m_fontFallbackList->isValid(); | 845 return !m_fontFallbackList || m_fontFallbackList->isValid(); |
828 } | 846 } |
829 | 847 |
830 } // namespace blink | 848 } // namespace blink |
OLD | NEW |