Remove SK_SUPPORT_LEGACY_TEXTBLOBBUILD_WITH_PAINT (flutter/engine#6971)
* Remove SK_SUPPORT_LEGACY_TEXTBLOBBUILD_WITH_PAINT * Formatting change
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "unicode/utf16.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkFont.h"
|
||||
#include "third_party/skia/include/core/SkMaskFilter.h"
|
||||
#include "third_party/skia/include/core/SkPaint.h"
|
||||
#include "third_party/skia/include/core/SkTextBlob.h"
|
||||
@@ -62,10 +63,10 @@ class GlyphTypeface {
|
||||
|
||||
bool operator!=(GlyphTypeface& other) { return !(*this == other); }
|
||||
|
||||
void apply(SkPaint& paint) {
|
||||
paint.setTypeface(typeface_);
|
||||
paint.setFakeBoldText(fake_bold_);
|
||||
paint.setTextSkewX(fake_italic_ ? -SK_Scalar1 / 4 : 0);
|
||||
void apply(SkFont& font) {
|
||||
font.setTypeface(typeface_);
|
||||
font.setEmbolden(fake_bold_);
|
||||
font.setSkewX(fake_italic_ ? -SK_Scalar1 / 4 : 0);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -435,11 +436,10 @@ void Paragraph::Layout(double width, bool force) {
|
||||
if (!ComputeBidiRuns(&bidi_runs))
|
||||
return;
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||
paint.setSubpixelText(true);
|
||||
paint.setHinting(kSlight_SkFontHinting);
|
||||
SkFont font;
|
||||
font.setEdging(SkFont::Edging::kAntiAlias);
|
||||
font.setSubpixel(true);
|
||||
font.setHinting(kSlight_SkFontHinting);
|
||||
|
||||
records_.clear();
|
||||
line_heights_.clear();
|
||||
@@ -507,10 +507,10 @@ void Paragraph::Layout(double width, bool force) {
|
||||
for (auto line_run_it = line_runs.begin(); line_run_it != line_runs.end();
|
||||
++line_run_it) {
|
||||
const BidiRun& run = *line_run_it;
|
||||
minikin::FontStyle font;
|
||||
minikin::FontStyle minikin_font;
|
||||
minikin::MinikinPaint minikin_paint;
|
||||
GetFontAndMinikinPaint(run.style(), &font, &minikin_paint);
|
||||
paint.setTextSize(run.style().font_size);
|
||||
GetFontAndMinikinPaint(run.style(), &minikin_font, &minikin_paint);
|
||||
font.setSize(run.style().font_size);
|
||||
|
||||
std::shared_ptr<minikin::FontCollection> minikin_font_collection =
|
||||
GetMinikinFontCollectionForStyle(run.style());
|
||||
@@ -531,13 +531,14 @@ void Paragraph::Layout(double width, bool force) {
|
||||
paragraph_style_.unlimited_lines())) {
|
||||
float ellipsis_width = layout.measureText(
|
||||
reinterpret_cast<const uint16_t*>(ellipsis.data()), 0,
|
||||
ellipsis.length(), ellipsis.length(), run.is_rtl(), font,
|
||||
ellipsis.length(), ellipsis.length(), run.is_rtl(), minikin_font,
|
||||
minikin_paint, minikin_font_collection, nullptr);
|
||||
|
||||
std::vector<float> text_advances(text_count);
|
||||
float text_width = layout.measureText(
|
||||
text_ptr, text_start, text_count, text_.size(), run.is_rtl(), font,
|
||||
minikin_paint, minikin_font_collection, text_advances.data());
|
||||
float text_width =
|
||||
layout.measureText(text_ptr, text_start, text_count, text_.size(),
|
||||
run.is_rtl(), minikin_font, minikin_paint,
|
||||
minikin_font_collection, text_advances.data());
|
||||
|
||||
// Truncate characters from the text until the ellipsis fits.
|
||||
size_t truncate_count = 0;
|
||||
@@ -568,7 +569,7 @@ void Paragraph::Layout(double width, bool force) {
|
||||
}
|
||||
|
||||
layout.doLayout(text_ptr, text_start, text_count, text_size, run.is_rtl(),
|
||||
font, minikin_paint, minikin_font_collection);
|
||||
minikin_font, minikin_paint, minikin_font_collection);
|
||||
|
||||
if (layout.nGlyphs() == 0)
|
||||
continue;
|
||||
@@ -585,9 +586,9 @@ void Paragraph::Layout(double width, bool force) {
|
||||
for (const Range<size_t>& glyph_blob : glyph_blobs) {
|
||||
std::vector<GlyphPosition> glyph_positions;
|
||||
|
||||
GetGlyphTypeface(layout, glyph_blob.start).apply(paint);
|
||||
GetGlyphTypeface(layout, glyph_blob.start).apply(font);
|
||||
const SkTextBlobBuilder::RunBuffer& blob_buffer =
|
||||
builder.allocRunPos(paint, glyph_blob.end - glyph_blob.start);
|
||||
builder.allocRunPos(font, glyph_blob.end - glyph_blob.start);
|
||||
|
||||
for (size_t glyph_index = glyph_blob.start;
|
||||
glyph_index < glyph_blob.end;) {
|
||||
@@ -687,7 +688,7 @@ void Paragraph::Layout(double width, bool force) {
|
||||
if (glyph_positions.empty())
|
||||
continue;
|
||||
SkFontMetrics metrics;
|
||||
paint.getFontMetrics(&metrics);
|
||||
font.getMetrics(&metrics);
|
||||
paint_records.emplace_back(run.style(), SkPoint::Make(run_x_offset, 0),
|
||||
builder.make(), metrics, line_number,
|
||||
layout.getAdvance());
|
||||
@@ -770,9 +771,9 @@ void Paragraph::Layout(double width, bool force) {
|
||||
if (paint_records.empty()) {
|
||||
SkFontMetrics metrics;
|
||||
TextStyle style(paragraph_style_.GetTextStyle());
|
||||
paint.setTypeface(GetDefaultSkiaTypeface(style));
|
||||
paint.setTextSize(style.font_size);
|
||||
paint.getFontMetrics(&metrics);
|
||||
font.setTypeface(GetDefaultSkiaTypeface(style));
|
||||
font.setSize(style.font_size);
|
||||
font.getMetrics(&metrics);
|
||||
update_line_metrics(metrics, style);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user