| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 const TextRunPaintInfo& run_info, | 135 const TextRunPaintInfo& run_info, |
| 136 const FloatPoint& point, | 136 const FloatPoint& point, |
| 137 float device_scale_factor, | 137 float device_scale_factor, |
| 138 const PaintFlags& flags) const { | 138 const PaintFlags& flags) const { |
| 139 // Don't draw anything while we are using custom fonts that are in the process | 139 // Don't draw anything while we are using custom fonts that are in the process |
| 140 // of loading. | 140 // of loading. |
| 141 if (ShouldSkipDrawing()) | 141 if (ShouldSkipDrawing()) |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 ShapeResultBloberizer bloberizer(*this, device_scale_factor); | 144 ShapeResultBloberizer bloberizer(*this, device_scale_factor); |
| 145 CachingWordShaper(*this).FillGlyphs(run_info, bloberizer); | 145 CachingWordShaper word_shaper(*this); |
| 146 ShapeResultBuffer buffer; |
| 147 word_shaper.FillResultBuffer(run_info, &buffer); |
| 148 bloberizer.FillGlyphs(run_info, buffer); |
| 146 DrawBlobs(canvas, flags, bloberizer.Blobs(), point); | 149 DrawBlobs(canvas, flags, bloberizer.Blobs(), point); |
| 147 return true; | 150 return true; |
| 148 } | 151 } |
| 149 | 152 |
| 150 bool Font::DrawBidiText(PaintCanvas* canvas, | 153 bool Font::DrawBidiText(PaintCanvas* canvas, |
| 151 const TextRunPaintInfo& run_info, | 154 const TextRunPaintInfo& run_info, |
| 152 const FloatPoint& point, | 155 const FloatPoint& point, |
| 153 CustomFontNotReadyAction custom_font_not_ready_action, | 156 CustomFontNotReadyAction custom_font_not_ready_action, |
| 154 float device_scale_factor, | 157 float device_scale_factor, |
| 155 const PaintFlags& flags) const { | 158 const PaintFlags& flags) const { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 171 | 174 |
| 172 // FIXME: This ownership should be reversed. We should pass BidiRunList | 175 // FIXME: This ownership should be reversed. We should pass BidiRunList |
| 173 // to BidiResolver in createBidiRunsForLine. | 176 // to BidiResolver in createBidiRunsForLine. |
| 174 BidiRunList<BidiCharacterRun>& bidi_runs = bidi_resolver.Runs(); | 177 BidiRunList<BidiCharacterRun>& bidi_runs = bidi_resolver.Runs(); |
| 175 bidi_resolver.CreateBidiRunsForLine(TextRunIterator(&run, run.length())); | 178 bidi_resolver.CreateBidiRunsForLine(TextRunIterator(&run, run.length())); |
| 176 if (!bidi_runs.RunCount()) | 179 if (!bidi_runs.RunCount()) |
| 177 return true; | 180 return true; |
| 178 | 181 |
| 179 FloatPoint curr_point = point; | 182 FloatPoint curr_point = point; |
| 180 BidiCharacterRun* bidi_run = bidi_runs.FirstRun(); | 183 BidiCharacterRun* bidi_run = bidi_runs.FirstRun(); |
| 184 CachingWordShaper word_shaper(*this); |
| 181 while (bidi_run) { | 185 while (bidi_run) { |
| 182 TextRun subrun = | 186 TextRun subrun = |
| 183 run.SubRun(bidi_run->Start(), bidi_run->Stop() - bidi_run->Start()); | 187 run.SubRun(bidi_run->Start(), bidi_run->Stop() - bidi_run->Start()); |
| 184 bool is_rtl = bidi_run->Level() % 2; | 188 bool is_rtl = bidi_run->Level() % 2; |
| 185 subrun.SetDirection(is_rtl ? TextDirection::kRtl : TextDirection::kLtr); | 189 subrun.SetDirection(is_rtl ? TextDirection::kRtl : TextDirection::kLtr); |
| 186 subrun.SetDirectionalOverride(bidi_run->DirOverride(false)); | 190 subrun.SetDirectionalOverride(bidi_run->DirOverride(false)); |
| 187 | 191 |
| 188 TextRunPaintInfo subrun_info(subrun); | 192 TextRunPaintInfo subrun_info(subrun); |
| 189 subrun_info.bounds = run_info.bounds; | 193 subrun_info.bounds = run_info.bounds; |
| 190 | 194 |
| 191 ShapeResultBloberizer bloberizer(*this, device_scale_factor); | 195 ShapeResultBloberizer bloberizer(*this, device_scale_factor); |
| 192 float run_width = | 196 ShapeResultBuffer buffer; |
| 193 CachingWordShaper(*this).FillGlyphs(subrun_info, bloberizer); | 197 word_shaper.FillResultBuffer(subrun_info, &buffer); |
| 198 float run_width = bloberizer.FillGlyphs(subrun_info, buffer); |
| 194 DrawBlobs(canvas, flags, bloberizer.Blobs(), curr_point); | 199 DrawBlobs(canvas, flags, bloberizer.Blobs(), curr_point); |
| 195 | 200 |
| 196 bidi_run = bidi_run->Next(); | 201 bidi_run = bidi_run->Next(); |
| 197 curr_point.Move(run_width, 0); | 202 curr_point.Move(run_width, 0); |
| 198 } | 203 } |
| 199 | 204 |
| 200 bidi_runs.DeleteRuns(); | 205 bidi_runs.DeleteRuns(); |
| 201 return true; | 206 return true; |
| 202 } | 207 } |
| 203 | 208 |
| 204 void Font::DrawEmphasisMarks(PaintCanvas* canvas, | 209 void Font::DrawEmphasisMarks(PaintCanvas* canvas, |
| 205 const TextRunPaintInfo& run_info, | 210 const TextRunPaintInfo& run_info, |
| 206 const AtomicString& mark, | 211 const AtomicString& mark, |
| 207 const FloatPoint& point, | 212 const FloatPoint& point, |
| 208 float device_scale_factor, | 213 float device_scale_factor, |
| 209 const PaintFlags& flags) const { | 214 const PaintFlags& flags) const { |
| 210 if (ShouldSkipDrawing()) | 215 if (ShouldSkipDrawing()) |
| 211 return; | 216 return; |
| 212 | 217 |
| 213 FontCachePurgePreventer purge_preventer; | 218 FontCachePurgePreventer purge_preventer; |
| 214 | 219 |
| 215 const auto emphasis_glyph_data = GetEmphasisMarkGlyphData(mark); | 220 const auto emphasis_glyph_data = GetEmphasisMarkGlyphData(mark); |
| 216 if (!emphasis_glyph_data.font_data) | 221 if (!emphasis_glyph_data.font_data) |
| 217 return; | 222 return; |
| 218 | 223 |
| 219 ShapeResultBloberizer bloberizer(*this, device_scale_factor); | 224 ShapeResultBloberizer bloberizer(*this, device_scale_factor); |
| 220 CachingWordShaper(*this).FillTextEmphasisGlyphs(run_info, emphasis_glyph_data, | 225 CachingWordShaper word_shaper(*this); |
| 221 bloberizer); | 226 ShapeResultBuffer buffer; |
| 227 word_shaper.FillResultBuffer(run_info, &buffer); |
| 228 bloberizer.FillTextEmphasisGlyphs(run_info, emphasis_glyph_data, buffer); |
| 222 DrawBlobs(canvas, flags, bloberizer.Blobs(), point); | 229 DrawBlobs(canvas, flags, bloberizer.Blobs(), point); |
| 223 } | 230 } |
| 224 | 231 |
| 225 float Font::Width(const TextRun& run, | 232 float Font::Width(const TextRun& run, |
| 226 HashSet<const SimpleFontData*>* fallback_fonts, | 233 HashSet<const SimpleFontData*>* fallback_fonts, |
| 227 FloatRect* glyph_bounds) const { | 234 FloatRect* glyph_bounds) const { |
| 228 FontCachePurgePreventer purge_preventer; | 235 FontCachePurgePreventer purge_preventer; |
| 229 CachingWordShaper shaper(*this); | 236 CachingWordShaper shaper(*this); |
| 230 return shaper.Width(run, fallback_fonts, glyph_bounds); | 237 return shaper.Width(run, fallback_fonts, glyph_bounds); |
| 231 } | 238 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 260 void Font::GetTextIntercepts(const TextRunPaintInfo& run_info, | 267 void Font::GetTextIntercepts(const TextRunPaintInfo& run_info, |
| 261 float device_scale_factor, | 268 float device_scale_factor, |
| 262 const PaintFlags& flags, | 269 const PaintFlags& flags, |
| 263 const std::tuple<float, float>& bounds, | 270 const std::tuple<float, float>& bounds, |
| 264 Vector<TextIntercept>& intercepts) const { | 271 Vector<TextIntercept>& intercepts) const { |
| 265 if (ShouldSkipDrawing()) | 272 if (ShouldSkipDrawing()) |
| 266 return; | 273 return; |
| 267 | 274 |
| 268 ShapeResultBloberizer bloberizer( | 275 ShapeResultBloberizer bloberizer( |
| 269 *this, device_scale_factor, ShapeResultBloberizer::Type::kTextIntercepts); | 276 *this, device_scale_factor, ShapeResultBloberizer::Type::kTextIntercepts); |
| 270 CachingWordShaper(*this).FillGlyphs(run_info, bloberizer); | 277 |
| 278 CachingWordShaper word_shaper(*this); |
| 279 ShapeResultBuffer buffer; |
| 280 word_shaper.FillResultBuffer(run_info, &buffer); |
| 281 bloberizer.FillGlyphs(run_info, buffer); |
| 282 |
| 271 const auto& blobs = bloberizer.Blobs(); | 283 const auto& blobs = bloberizer.Blobs(); |
| 272 | 284 |
| 273 // Get the number of intervals, without copying the actual values by | 285 // Get the number of intervals, without copying the actual values by |
| 274 // specifying nullptr for the buffer, following the Skia allocation model for | 286 // specifying nullptr for the buffer, following the Skia allocation model for |
| 275 // retrieving text intercepts. | 287 // retrieving text intercepts. |
| 276 SkPaint paint(ToSkPaint(flags)); | 288 SkPaint paint(ToSkPaint(flags)); |
| 277 int num_intervals = GetInterceptsFromBlobs(blobs, paint, bounds, nullptr); | 289 int num_intervals = GetInterceptsFromBlobs(blobs, paint, bounds, nullptr); |
| 278 if (!num_intervals) | 290 if (!num_intervals) |
| 279 return; | 291 return; |
| 280 DCHECK_EQ(num_intervals % 2, 0); | 292 DCHECK_EQ(num_intervals % 2, 0); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 431 |
| 420 bool Font::LoadingCustomFonts() const { | 432 bool Font::LoadingCustomFonts() const { |
| 421 return font_fallback_list_ && font_fallback_list_->LoadingCustomFonts(); | 433 return font_fallback_list_ && font_fallback_list_->LoadingCustomFonts(); |
| 422 } | 434 } |
| 423 | 435 |
| 424 bool Font::IsFallbackValid() const { | 436 bool Font::IsFallbackValid() const { |
| 425 return !font_fallback_list_ || font_fallback_list_->IsValid(); | 437 return !font_fallback_list_ || font_fallback_list_->IsValid(); |
| 426 } | 438 } |
| 427 | 439 |
| 428 } // namespace blink | 440 } // namespace blink |
| OLD | NEW |