Remove Blink code (flutter/engine#5218)
Fixes https://github.com/flutter/flutter/issues/12212
This commit is contained in:
@@ -52,7 +52,6 @@ group("flutter") {
|
||||
"$flutter_root/fml:fml_unittests",
|
||||
"$flutter_root/runtime:runtime_unittests",
|
||||
"$flutter_root/shell/common:shell_unittests",
|
||||
"$flutter_root/sky/engine/wtf:wtf_unittests",
|
||||
"$flutter_root/synchronization:synchronization_unittests",
|
||||
"$flutter_root/third_party/txt:txt_unittests",
|
||||
"//garnet/public/lib/fxl:fxl_unittests",
|
||||
|
||||
@@ -39,7 +39,6 @@ std::string Settings::ToString() const {
|
||||
stream << "use_test_fonts: " << use_test_fonts << std::endl;
|
||||
stream << "enable_software_rendering: " << enable_software_rendering
|
||||
<< std::endl;
|
||||
stream << "using_blink: " << using_blink << std::endl;
|
||||
stream << "log_tag: " << log_tag << std::endl;
|
||||
stream << "icu_data_path: " << icu_data_path << std::endl;
|
||||
stream << "assets_dir: " << assets_dir << std::endl;
|
||||
|
||||
@@ -68,7 +68,6 @@ struct Settings {
|
||||
// call is made.
|
||||
fxl::Closure root_isolate_shutdown_callback;
|
||||
bool enable_software_rendering = false;
|
||||
bool using_blink = false;
|
||||
bool skia_deterministic_rendering_on_cpu = false;
|
||||
bool verbose_logging = false;
|
||||
std::string log_tag = "flutter";
|
||||
|
||||
@@ -62,8 +62,6 @@ source_set("ui") {
|
||||
"text/paragraph_builder.h",
|
||||
"text/paragraph_impl.cc",
|
||||
"text/paragraph_impl.h",
|
||||
"text/paragraph_impl_blink.cc",
|
||||
"text/paragraph_impl_blink.h",
|
||||
"text/paragraph_impl_txt.cc",
|
||||
"text/paragraph_impl_txt.h",
|
||||
"text/text_box.cc",
|
||||
@@ -94,11 +92,11 @@ source_set("ui") {
|
||||
"$flutter_root/fml",
|
||||
"$flutter_root/glue",
|
||||
"$flutter_root/runtime:test_font",
|
||||
"$flutter_root/sky/engine",
|
||||
"$flutter_root/third_party/txt",
|
||||
"//third_party/dart/runtime/bin:embedded_dart_io",
|
||||
"//third_party/rapidjson",
|
||||
"//third_party/skia",
|
||||
"//third_party/skia:effects",
|
||||
"//third_party/skia:gpu",
|
||||
"//topaz/lib/tonic",
|
||||
]
|
||||
|
||||
@@ -145,13 +145,13 @@ void Logger_PrintString(Dart_NativeArguments args) {
|
||||
std::stringstream stream;
|
||||
const auto& logger_prefix = UIDartState::Current()->logger_prefix();
|
||||
|
||||
#if !OS(ANDROID)
|
||||
#if !OS_ANDROID
|
||||
// Prepend all logs with the isolate debug name except on Android where that
|
||||
// prefix is specified in the log tag.
|
||||
if (logger_prefix.size() > 0) {
|
||||
stream << logger_prefix << ": ";
|
||||
}
|
||||
#endif // !OS(ANDROID)
|
||||
#endif // !OS_ANDROID
|
||||
|
||||
// Append the log buffer obtained from Dart code.
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ sk_sp<SkData> EncodeImage(sk_sp<SkImage> image, ImageByteFormat format) {
|
||||
return SkData::MakeWithCopy(pixmap.addr(), pixmap.computeByteSize());
|
||||
}
|
||||
|
||||
ASSERT(format == kRawRGBA);
|
||||
FXL_CHECK(format == kRawRGBA);
|
||||
if (pixmap.colorType() != kRGBA_8888_SkColorType) {
|
||||
TRACE_EVENT0("flutter", "ConvertToRGBA");
|
||||
|
||||
|
||||
@@ -6,14 +6,6 @@
|
||||
|
||||
#include "flutter/common/settings.h"
|
||||
#include "flutter/common/task_runners.h"
|
||||
#include "flutter/sky/engine/core/rendering/PaintInfo.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderParagraph.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderText.h"
|
||||
#include "flutter/sky/engine/core/rendering/style/RenderStyle.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontCache.h"
|
||||
#include "flutter/sky/engine/platform/graphics/GraphicsContext.h"
|
||||
#include "flutter/sky/engine/platform/text/TextBoundaries.h"
|
||||
#include "flutter/sky/engine/wtf/PassOwnPtr.h"
|
||||
#include "lib/fxl/logging.h"
|
||||
#include "lib/fxl/tasks/task_runner.h"
|
||||
#include "lib/tonic/converter/dart_converter.h"
|
||||
@@ -43,20 +35,11 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Paragraph);
|
||||
|
||||
DART_BIND_ALL(Paragraph, FOR_EACH_BINDING)
|
||||
|
||||
Paragraph::Paragraph(PassOwnPtr<RenderView> renderView)
|
||||
: m_paragraphImpl(std::make_unique<ParagraphImplBlink>(renderView)) {}
|
||||
|
||||
Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph)
|
||||
: m_paragraphImpl(
|
||||
std::make_unique<ParagraphImplTxt>(std::move(paragraph))) {}
|
||||
|
||||
Paragraph::~Paragraph() {
|
||||
if (m_renderView) {
|
||||
RenderView* renderView = m_renderView.leakPtr();
|
||||
destruction_task_runner_->PostTask(
|
||||
[renderView]() { renderView->destroy(); });
|
||||
}
|
||||
}
|
||||
Paragraph::~Paragraph() = default;
|
||||
|
||||
size_t Paragraph::GetAllocationSize() {
|
||||
// We don't have an accurate accounting of the paragraph's memory consumption,
|
||||
|
||||
@@ -8,11 +8,8 @@
|
||||
#include "flutter/fml/message_loop.h"
|
||||
#include "flutter/lib/ui/painting/canvas.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl_blink.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl_txt.h"
|
||||
#include "flutter/lib/ui/text/text_box.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderView.h"
|
||||
#include "flutter/sky/engine/wtf/PassOwnPtr.h"
|
||||
#include "flutter/third_party/txt/src/txt/paragraph.h"
|
||||
#include "lib/tonic/dart_wrappable.h"
|
||||
|
||||
@@ -28,10 +25,6 @@ class Paragraph : public fxl::RefCountedThreadSafe<Paragraph>,
|
||||
FRIEND_MAKE_REF_COUNTED(Paragraph);
|
||||
|
||||
public:
|
||||
static fxl::RefPtr<Paragraph> Create(PassOwnPtr<RenderView> renderView) {
|
||||
return fxl::MakeRefCounted<Paragraph>(renderView);
|
||||
}
|
||||
|
||||
static fxl::RefPtr<Paragraph> Create(
|
||||
std::unique_ptr<txt::Paragraph> paragraph) {
|
||||
return fxl::MakeRefCounted<Paragraph>(std::move(paragraph));
|
||||
@@ -54,8 +47,6 @@ class Paragraph : public fxl::RefCountedThreadSafe<Paragraph>,
|
||||
Dart_Handle getPositionForOffset(double dx, double dy);
|
||||
Dart_Handle getWordBoundary(unsigned offset);
|
||||
|
||||
RenderView* renderView() const { return m_renderView.get(); }
|
||||
|
||||
virtual size_t GetAllocationSize() override;
|
||||
|
||||
static void RegisterNatives(tonic::DartLibraryNatives* natives);
|
||||
@@ -63,15 +54,7 @@ class Paragraph : public fxl::RefCountedThreadSafe<Paragraph>,
|
||||
private:
|
||||
std::unique_ptr<ParagraphImpl> m_paragraphImpl;
|
||||
|
||||
explicit Paragraph(PassOwnPtr<RenderView> renderView);
|
||||
|
||||
explicit Paragraph(std::unique_ptr<txt::Paragraph> paragraph);
|
||||
|
||||
// TODO: This can be removed when the render view association for the legacy
|
||||
// runtime is removed.
|
||||
fxl::RefPtr<fxl::TaskRunner> destruction_task_runner_ =
|
||||
UIDartState::Current()->GetTaskRunners().GetUITaskRunner();
|
||||
OwnPtr<RenderView> m_renderView;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
#include "flutter/common/task_runners.h"
|
||||
#include "flutter/lib/ui/text/font_collection.h"
|
||||
#include "flutter/lib/ui/ui_dart_state.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderInline.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderParagraph.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderText.h"
|
||||
#include "flutter/sky/engine/core/rendering/style/RenderStyle.h"
|
||||
#include "flutter/sky/engine/platform/text/LocaleToScriptMapping.h"
|
||||
#include "flutter/third_party/txt/src/txt/font_style.h"
|
||||
#include "flutter/third_party/txt/src/txt/font_weight.h"
|
||||
#include "flutter/third_party/txt/src/txt/paragraph_style.h"
|
||||
@@ -23,6 +18,7 @@
|
||||
#include "lib/tonic/dart_args.h"
|
||||
#include "lib/tonic/dart_binding_macros.h"
|
||||
#include "lib/tonic/dart_library_natives.h"
|
||||
#include "third_party/icu/source/common/unicode/ustring.h"
|
||||
|
||||
namespace blink {
|
||||
namespace {
|
||||
@@ -83,102 +79,6 @@ const int psLineHeightMask = 1 << psLineHeightIndex;
|
||||
const int psEllipsisMask = 1 << psEllipsisIndex;
|
||||
const int psLocaleMask = 1 << psLocaleIndex;
|
||||
|
||||
float getComputedSizeFromSpecifiedSize(float specifiedSize) {
|
||||
if (specifiedSize < std::numeric_limits<float>::epsilon())
|
||||
return 0.0f;
|
||||
return specifiedSize;
|
||||
}
|
||||
|
||||
void createFontForDocument(RenderStyle* style) {
|
||||
FontDescription fontDescription = FontDescription();
|
||||
fontDescription.setScript(
|
||||
localeToScriptCodeForFontSelection(style->locale()));
|
||||
|
||||
// Using 14px default to match Material Design English Body1:
|
||||
// http://www.google.com/design/spec/style/typography.html#typography-typeface
|
||||
const float defaultFontSize = 14.0;
|
||||
|
||||
fontDescription.setSpecifiedSize(defaultFontSize);
|
||||
fontDescription.setComputedSize(defaultFontSize);
|
||||
|
||||
FontOrientation fontOrientation = Horizontal;
|
||||
NonCJKGlyphOrientation glyphOrientation = NonCJKGlyphOrientationVerticalRight;
|
||||
|
||||
fontDescription.setOrientation(fontOrientation);
|
||||
fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
|
||||
style->setFontDescription(fontDescription);
|
||||
style->font().update(UIDartState::Current()->font_selector());
|
||||
}
|
||||
|
||||
PassRefPtr<RenderStyle> decodeParagraphStyle(RenderStyle* parentStyle,
|
||||
tonic::Int32List& encoded,
|
||||
const std::string& fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
const std::u16string& ellipsis) {
|
||||
FXL_DCHECK(encoded.num_elements() == 6); // also update text.dart
|
||||
|
||||
RefPtr<RenderStyle> style = RenderStyle::create();
|
||||
style->inheritFrom(parentStyle);
|
||||
style->setDisplay(PARAGRAPH);
|
||||
|
||||
int32_t mask = encoded[0];
|
||||
|
||||
if (mask & psTextAlignMask)
|
||||
style->setTextAlign(static_cast<ETextAlign>(encoded[psTextAlignIndex]));
|
||||
|
||||
if (mask & psTextDirectionMask)
|
||||
style->setDirection(
|
||||
static_cast<TextDirection>(encoded[psTextDirectionIndex]));
|
||||
|
||||
if (mask & (psFontWeightMask | psFontStyleMask | psFontFamilyMask |
|
||||
psFontSizeMask)) {
|
||||
FontDescription fontDescription = style->fontDescription();
|
||||
|
||||
if (mask & psFontWeightMask)
|
||||
fontDescription.setWeight(
|
||||
static_cast<FontWeight>(encoded[psFontWeightIndex]));
|
||||
|
||||
if (mask & psFontStyleMask)
|
||||
fontDescription.setStyle(
|
||||
static_cast<FontStyle>(encoded[psFontStyleIndex]));
|
||||
|
||||
if (mask & psFontFamilyMask) {
|
||||
FontFamily family;
|
||||
family.setFamily(String::fromUTF8(fontFamily));
|
||||
fontDescription.setFamily(family);
|
||||
}
|
||||
|
||||
if (mask & psFontSizeMask) {
|
||||
fontDescription.setSpecifiedSize(fontSize);
|
||||
fontDescription.setIsAbsoluteSize(true);
|
||||
fontDescription.setComputedSize(
|
||||
getComputedSizeFromSpecifiedSize(fontSize));
|
||||
}
|
||||
|
||||
style->setFontDescription(fontDescription);
|
||||
style->font().update(UIDartState::Current()->font_selector());
|
||||
}
|
||||
|
||||
if (mask & psLineHeightMask)
|
||||
style->setLineHeight(Length(lineHeight * 100.0, Percent));
|
||||
|
||||
if (mask & psMaxLinesMask)
|
||||
style->setMaxLines(encoded[psMaxLinesIndex]);
|
||||
|
||||
if (mask & psEllipsisMask) {
|
||||
style->setEllipsis(
|
||||
AtomicString(reinterpret_cast<const UChar*>(ellipsis.c_str())));
|
||||
}
|
||||
|
||||
return style.release();
|
||||
}
|
||||
|
||||
Color getColorFromARGB(int argb) {
|
||||
return Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8,
|
||||
(argb & 0x000000FF) >> 0, (argb & 0xFF000000) >> 24);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
static void ParagraphBuilder_constructor(Dart_NativeArguments args) {
|
||||
@@ -207,11 +107,9 @@ fxl::RefPtr<ParagraphBuilder> ParagraphBuilder::create(
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
const std::u16string& ellipsis,
|
||||
const std::string& locale,
|
||||
bool use_blink) {
|
||||
const std::string& locale) {
|
||||
return fxl::MakeRefCounted<ParagraphBuilder>(
|
||||
encoded, fontFamily, fontSize, lineHeight, ellipsis, locale,
|
||||
UIDartState::Current()->use_blink());
|
||||
encoded, fontFamily, fontSize, lineHeight, ellipsis, locale);
|
||||
}
|
||||
|
||||
ParagraphBuilder::ParagraphBuilder(tonic::Int32List& encoded,
|
||||
@@ -219,72 +117,47 @@ ParagraphBuilder::ParagraphBuilder(tonic::Int32List& encoded,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
const std::u16string& ellipsis,
|
||||
const std::string& locale,
|
||||
bool use_blink)
|
||||
: m_useBlink(use_blink) {
|
||||
if (!m_useBlink) {
|
||||
int32_t mask = encoded[0];
|
||||
txt::ParagraphStyle style;
|
||||
if (mask & psTextAlignMask)
|
||||
style.text_align = txt::TextAlign(encoded[psTextAlignIndex]);
|
||||
const std::string& locale) {
|
||||
int32_t mask = encoded[0];
|
||||
txt::ParagraphStyle style;
|
||||
if (mask & psTextAlignMask)
|
||||
style.text_align = txt::TextAlign(encoded[psTextAlignIndex]);
|
||||
|
||||
if (mask & psTextDirectionMask)
|
||||
style.text_direction = txt::TextDirection(encoded[psTextDirectionIndex]);
|
||||
if (mask & psTextDirectionMask)
|
||||
style.text_direction = txt::TextDirection(encoded[psTextDirectionIndex]);
|
||||
|
||||
if (mask & psFontWeightMask)
|
||||
style.font_weight =
|
||||
static_cast<txt::FontWeight>(encoded[psFontWeightIndex]);
|
||||
if (mask & psFontWeightMask)
|
||||
style.font_weight =
|
||||
static_cast<txt::FontWeight>(encoded[psFontWeightIndex]);
|
||||
|
||||
if (mask & psFontStyleMask)
|
||||
style.font_style = static_cast<txt::FontStyle>(encoded[psFontStyleIndex]);
|
||||
if (mask & psFontStyleMask)
|
||||
style.font_style = static_cast<txt::FontStyle>(encoded[psFontStyleIndex]);
|
||||
|
||||
if (mask & psFontFamilyMask)
|
||||
style.font_family = fontFamily;
|
||||
if (mask & psFontFamilyMask)
|
||||
style.font_family = fontFamily;
|
||||
|
||||
if (mask & psFontSizeMask)
|
||||
style.font_size = fontSize;
|
||||
if (mask & psFontSizeMask)
|
||||
style.font_size = fontSize;
|
||||
|
||||
if (mask & psLineHeightMask)
|
||||
style.line_height = lineHeight;
|
||||
if (mask & psLineHeightMask)
|
||||
style.line_height = lineHeight;
|
||||
|
||||
if (mask & psMaxLinesMask)
|
||||
style.max_lines = encoded[psMaxLinesIndex];
|
||||
if (mask & psMaxLinesMask)
|
||||
style.max_lines = encoded[psMaxLinesIndex];
|
||||
|
||||
if (mask & psEllipsisMask) {
|
||||
style.ellipsis = ellipsis;
|
||||
}
|
||||
|
||||
if (mask & psLocaleMask) {
|
||||
style.locale = locale;
|
||||
}
|
||||
|
||||
m_paragraphBuilder = std::make_unique<txt::ParagraphBuilder>(
|
||||
style, blink::FontCollection::ForProcess().GetFontCollection());
|
||||
} else {
|
||||
// Blink version.
|
||||
createRenderView();
|
||||
|
||||
RefPtr<RenderStyle> paragraphStyle =
|
||||
decodeParagraphStyle(m_renderView->style(), encoded, fontFamily,
|
||||
fontSize, lineHeight, ellipsis);
|
||||
encoded.Release();
|
||||
|
||||
m_renderParagraph = new RenderParagraph();
|
||||
m_renderParagraph->setStyle(paragraphStyle.release());
|
||||
|
||||
m_currentRenderObject = m_renderParagraph;
|
||||
m_renderView->addChild(m_currentRenderObject);
|
||||
if (mask & psEllipsisMask) {
|
||||
style.ellipsis = ellipsis;
|
||||
}
|
||||
|
||||
if (mask & psLocaleMask) {
|
||||
style.locale = locale;
|
||||
}
|
||||
|
||||
m_paragraphBuilder = std::make_unique<txt::ParagraphBuilder>(
|
||||
style, blink::FontCollection::ForProcess().GetFontCollection());
|
||||
} // namespace blink
|
||||
|
||||
ParagraphBuilder::~ParagraphBuilder() {
|
||||
if (m_renderView) {
|
||||
RenderView* renderView = m_renderView.leakPtr();
|
||||
destruction_task_runner_->PostTask(
|
||||
[renderView]() { renderView->destroy(); });
|
||||
}
|
||||
}
|
||||
ParagraphBuilder::~ParagraphBuilder() = default;
|
||||
|
||||
void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
|
||||
const std::string& fontFamily,
|
||||
@@ -299,154 +172,74 @@ void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
|
||||
|
||||
int32_t mask = encoded[0];
|
||||
|
||||
if (!m_useBlink) {
|
||||
// Set to use the properties of the previous style if the property is not
|
||||
// explicitly given.
|
||||
txt::TextStyle style = m_paragraphBuilder->PeekStyle();
|
||||
// Set to use the properties of the previous style if the property is not
|
||||
// explicitly given.
|
||||
txt::TextStyle style = m_paragraphBuilder->PeekStyle();
|
||||
|
||||
if (mask & tsColorMask)
|
||||
style.color = encoded[tsColorIndex];
|
||||
if (mask & tsColorMask)
|
||||
style.color = encoded[tsColorIndex];
|
||||
|
||||
if (mask & tsTextDecorationMask) {
|
||||
style.decoration =
|
||||
static_cast<txt::TextDecoration>(encoded[tsTextDecorationIndex]);
|
||||
}
|
||||
|
||||
if (mask & tsTextDecorationColorMask)
|
||||
style.decoration_color = encoded[tsTextDecorationColorIndex];
|
||||
|
||||
if (mask & tsTextDecorationStyleMask)
|
||||
style.decoration_style = static_cast<txt::TextDecorationStyle>(
|
||||
encoded[tsTextDecorationStyleIndex]);
|
||||
|
||||
if (mask & tsTextBaselineMask) {
|
||||
// TODO(abarth): Implement TextBaseline. The CSS version of this
|
||||
// property wasn't wired up either.
|
||||
}
|
||||
|
||||
if (mask & (tsFontWeightMask | tsFontStyleMask | tsFontFamilyMask |
|
||||
tsFontSizeMask | tsLetterSpacingMask | tsWordSpacingMask)) {
|
||||
if (mask & tsFontWeightMask)
|
||||
style.font_weight =
|
||||
static_cast<txt::FontWeight>(encoded[tsFontWeightIndex]);
|
||||
|
||||
if (mask & tsFontStyleMask)
|
||||
style.font_style =
|
||||
static_cast<txt::FontStyle>(encoded[tsFontStyleIndex]);
|
||||
|
||||
if (mask & tsFontFamilyMask)
|
||||
style.font_family = fontFamily;
|
||||
|
||||
if (mask & tsFontSizeMask)
|
||||
style.font_size = fontSize;
|
||||
|
||||
if (mask & tsLetterSpacingMask)
|
||||
style.letter_spacing = letterSpacing;
|
||||
|
||||
if (mask & tsWordSpacingMask)
|
||||
style.word_spacing = wordSpacing;
|
||||
}
|
||||
|
||||
if (mask & tsHeightMask) {
|
||||
style.height = height;
|
||||
}
|
||||
|
||||
if (mask & tsLocaleMask) {
|
||||
style.locale = locale;
|
||||
}
|
||||
|
||||
if (mask & tsBackgroundMask) {
|
||||
Paint background(background_objects, background_data);
|
||||
if (background.paint()) {
|
||||
style.has_background = true;
|
||||
style.background = *background.paint();
|
||||
}
|
||||
}
|
||||
|
||||
m_paragraphBuilder->PushStyle(style);
|
||||
} else {
|
||||
// Blink Version.
|
||||
RefPtr<RenderStyle> style = RenderStyle::create();
|
||||
style->inheritFrom(m_currentRenderObject->style());
|
||||
|
||||
if (mask & tsColorMask)
|
||||
style->setColor(getColorFromARGB(encoded[tsColorIndex]));
|
||||
|
||||
if (mask & tsTextDecorationMask) {
|
||||
style->setTextDecoration(
|
||||
static_cast<TextDecoration>(encoded[tsTextDecorationIndex]));
|
||||
style->applyTextDecorations();
|
||||
}
|
||||
|
||||
if (mask & tsTextDecorationColorMask)
|
||||
style->setTextDecorationColor(
|
||||
StyleColor(getColorFromARGB(encoded[tsTextDecorationColorIndex])));
|
||||
|
||||
if (mask & tsTextDecorationStyleMask)
|
||||
style->setTextDecorationStyle(static_cast<TextDecorationStyle>(
|
||||
encoded[tsTextDecorationStyleIndex]));
|
||||
|
||||
if (mask & tsTextBaselineMask) {
|
||||
// TODO(abarth): Implement TextBaseline. The CSS version of this
|
||||
// property wasn't wired up either.
|
||||
}
|
||||
|
||||
if (mask & (tsFontWeightMask | tsFontStyleMask | tsFontFamilyMask |
|
||||
tsFontSizeMask | tsLetterSpacingMask | tsWordSpacingMask)) {
|
||||
FontDescription fontDescription = style->fontDescription();
|
||||
|
||||
if (mask & tsFontWeightMask)
|
||||
fontDescription.setWeight(
|
||||
static_cast<FontWeight>(encoded[tsFontWeightIndex]));
|
||||
|
||||
if (mask & tsFontStyleMask)
|
||||
fontDescription.setStyle(
|
||||
static_cast<FontStyle>(encoded[tsFontStyleIndex]));
|
||||
|
||||
if (mask & tsFontFamilyMask) {
|
||||
FontFamily family;
|
||||
family.setFamily(String::fromUTF8(fontFamily));
|
||||
fontDescription.setFamily(family);
|
||||
}
|
||||
|
||||
if (mask & tsFontSizeMask) {
|
||||
fontDescription.setSpecifiedSize(fontSize);
|
||||
fontDescription.setIsAbsoluteSize(true);
|
||||
fontDescription.setComputedSize(
|
||||
getComputedSizeFromSpecifiedSize(fontSize));
|
||||
}
|
||||
|
||||
if (mask & tsLetterSpacingMask)
|
||||
fontDescription.setLetterSpacing(letterSpacing);
|
||||
|
||||
if (mask & tsWordSpacingMask)
|
||||
fontDescription.setWordSpacing(wordSpacing);
|
||||
|
||||
style->setFontDescription(fontDescription);
|
||||
style->font().update(UIDartState::Current()->font_selector());
|
||||
}
|
||||
|
||||
if (mask & tsHeightMask) {
|
||||
style->setLineHeight(Length(height * 100.0, Percent));
|
||||
}
|
||||
|
||||
encoded.Release();
|
||||
|
||||
RenderObject* span = new RenderInline();
|
||||
span->setStyle(style.release());
|
||||
m_currentRenderObject->addChild(span);
|
||||
m_currentRenderObject = span;
|
||||
if (mask & tsTextDecorationMask) {
|
||||
style.decoration =
|
||||
static_cast<txt::TextDecoration>(encoded[tsTextDecorationIndex]);
|
||||
}
|
||||
|
||||
if (mask & tsTextDecorationColorMask)
|
||||
style.decoration_color = encoded[tsTextDecorationColorIndex];
|
||||
|
||||
if (mask & tsTextDecorationStyleMask)
|
||||
style.decoration_style = static_cast<txt::TextDecorationStyle>(
|
||||
encoded[tsTextDecorationStyleIndex]);
|
||||
|
||||
if (mask & tsTextBaselineMask) {
|
||||
// TODO(abarth): Implement TextBaseline. The CSS version of this
|
||||
// property wasn't wired up either.
|
||||
}
|
||||
|
||||
if (mask & (tsFontWeightMask | tsFontStyleMask | tsFontFamilyMask |
|
||||
tsFontSizeMask | tsLetterSpacingMask | tsWordSpacingMask)) {
|
||||
if (mask & tsFontWeightMask)
|
||||
style.font_weight =
|
||||
static_cast<txt::FontWeight>(encoded[tsFontWeightIndex]);
|
||||
|
||||
if (mask & tsFontStyleMask)
|
||||
style.font_style =
|
||||
static_cast<txt::FontStyle>(encoded[tsFontStyleIndex]);
|
||||
|
||||
if (mask & tsFontFamilyMask)
|
||||
style.font_family = fontFamily;
|
||||
|
||||
if (mask & tsFontSizeMask)
|
||||
style.font_size = fontSize;
|
||||
|
||||
if (mask & tsLetterSpacingMask)
|
||||
style.letter_spacing = letterSpacing;
|
||||
|
||||
if (mask & tsWordSpacingMask)
|
||||
style.word_spacing = wordSpacing;
|
||||
}
|
||||
|
||||
if (mask & tsHeightMask) {
|
||||
style.height = height;
|
||||
}
|
||||
|
||||
if (mask & tsLocaleMask) {
|
||||
style.locale = locale;
|
||||
}
|
||||
|
||||
if (mask & tsBackgroundMask) {
|
||||
Paint background(background_objects, background_data);
|
||||
if (background.paint()) {
|
||||
style.has_background = true;
|
||||
style.background = *background.paint();
|
||||
}
|
||||
}
|
||||
|
||||
m_paragraphBuilder->PushStyle(style);
|
||||
}
|
||||
|
||||
void ParagraphBuilder::pop() {
|
||||
if (!m_useBlink) {
|
||||
m_paragraphBuilder->Pop();
|
||||
} else {
|
||||
// Blink Version.
|
||||
if (m_currentRenderObject)
|
||||
m_currentRenderObject = m_currentRenderObject->parent();
|
||||
}
|
||||
m_paragraphBuilder->Pop();
|
||||
}
|
||||
|
||||
Dart_Handle ParagraphBuilder::addText(const std::u16string& text) {
|
||||
@@ -462,41 +255,13 @@ Dart_Handle ParagraphBuilder::addText(const std::u16string& text) {
|
||||
if (error_code != U_BUFFER_OVERFLOW_ERROR)
|
||||
return tonic::ToDart("string is not well-formed UTF-16");
|
||||
|
||||
if (!m_useBlink) {
|
||||
m_paragraphBuilder->AddText(text);
|
||||
} else {
|
||||
// Blink Version.
|
||||
if (!m_currentRenderObject)
|
||||
return tonic::ToDart("paragraph has already been built");
|
||||
RenderText* renderText =
|
||||
new RenderText(String(text_ptr, text.size()).impl());
|
||||
RefPtr<RenderStyle> style = RenderStyle::create();
|
||||
style->inheritFrom(m_currentRenderObject->style());
|
||||
renderText->setStyle(style.release());
|
||||
m_currentRenderObject->addChild(renderText);
|
||||
}
|
||||
m_paragraphBuilder->AddText(text);
|
||||
|
||||
return Dart_Null();
|
||||
}
|
||||
|
||||
fxl::RefPtr<Paragraph> ParagraphBuilder::build() {
|
||||
m_currentRenderObject = nullptr;
|
||||
if (!m_useBlink) {
|
||||
return Paragraph::Create(m_paragraphBuilder->Build());
|
||||
} else {
|
||||
return Paragraph::Create(m_renderView.release());
|
||||
}
|
||||
}
|
||||
|
||||
void ParagraphBuilder::createRenderView() {
|
||||
RefPtr<RenderStyle> style = RenderStyle::create();
|
||||
style->setRTLOrdering(LogicalOrder);
|
||||
style->setZIndex(0);
|
||||
style->setUserModify(READ_ONLY);
|
||||
createFontForDocument(style.get());
|
||||
|
||||
m_renderView = adoptPtr(new RenderView());
|
||||
m_renderView->setStyle(style.release());
|
||||
return Paragraph::Create(m_paragraphBuilder->Build());
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include <memory>
|
||||
#include "flutter/lib/ui/painting/paint.h"
|
||||
#include "flutter/lib/ui/text/paragraph.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderObject.h"
|
||||
#include "flutter/sky/engine/wtf/OwnPtr.h"
|
||||
#include "flutter/third_party/txt/src/txt/paragraph_builder.h"
|
||||
#include "lib/tonic/dart_wrappable.h"
|
||||
#include "lib/tonic/typed_data/int32_list.h"
|
||||
@@ -33,8 +31,7 @@ class ParagraphBuilder : public fxl::RefCountedThreadSafe<ParagraphBuilder>,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
const std::u16string& ellipsis,
|
||||
const std::string& locale,
|
||||
bool use_blink);
|
||||
const std::string& locale);
|
||||
|
||||
~ParagraphBuilder() override;
|
||||
|
||||
@@ -62,20 +59,9 @@ class ParagraphBuilder : public fxl::RefCountedThreadSafe<ParagraphBuilder>,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
const std::u16string& ellipsis,
|
||||
const std::string& locale,
|
||||
bool use_blink);
|
||||
const std::string& locale);
|
||||
|
||||
void createRenderView();
|
||||
|
||||
// TODO: This can be removed when the render view association for the legacy
|
||||
// runtime is removed.
|
||||
fxl::RefPtr<fxl::TaskRunner> destruction_task_runner_ =
|
||||
UIDartState::Current()->GetTaskRunners().GetUITaskRunner();
|
||||
OwnPtr<RenderView> m_renderView;
|
||||
RenderObject* m_renderParagraph;
|
||||
RenderObject* m_currentRenderObject;
|
||||
std::unique_ptr<txt::ParagraphBuilder> m_paragraphBuilder;
|
||||
bool m_useBlink;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/lib/ui/text/paragraph_impl_blink.h"
|
||||
|
||||
#include "flutter/lib/ui/text/paragraph.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl.h"
|
||||
#include "flutter/sky/engine/core/rendering/PaintInfo.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderParagraph.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderText.h"
|
||||
#include "flutter/sky/engine/core/rendering/style/RenderStyle.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontCache.h"
|
||||
#include "flutter/sky/engine/platform/graphics/GraphicsContext.h"
|
||||
#include "flutter/sky/engine/platform/text/TextBoundaries.h"
|
||||
#include "lib/fxl/tasks/task_runner.h"
|
||||
#include "lib/tonic/converter/dart_converter.h"
|
||||
#include "lib/tonic/dart_args.h"
|
||||
#include "lib/tonic/dart_binding_macros.h"
|
||||
#include "lib/tonic/dart_library_natives.h"
|
||||
|
||||
using tonic::ToDart;
|
||||
|
||||
namespace blink {
|
||||
|
||||
ParagraphImplBlink::ParagraphImplBlink(PassOwnPtr<RenderView> renderView)
|
||||
: m_renderView(renderView) {}
|
||||
|
||||
ParagraphImplBlink::~ParagraphImplBlink() {
|
||||
if (m_renderView) {
|
||||
RenderView* renderView = m_renderView.leakPtr();
|
||||
destruction_task_runner_->PostTask(
|
||||
[renderView]() { renderView->destroy(); });
|
||||
}
|
||||
}
|
||||
|
||||
double ParagraphImplBlink::width() {
|
||||
return firstChildBox()->width();
|
||||
}
|
||||
|
||||
double ParagraphImplBlink::height() {
|
||||
return firstChildBox()->height();
|
||||
}
|
||||
|
||||
double ParagraphImplBlink::minIntrinsicWidth() {
|
||||
return firstChildBox()->minPreferredLogicalWidth();
|
||||
}
|
||||
|
||||
double ParagraphImplBlink::maxIntrinsicWidth() {
|
||||
return firstChildBox()->maxPreferredLogicalWidth();
|
||||
}
|
||||
|
||||
double ParagraphImplBlink::alphabeticBaseline() {
|
||||
return firstChildBox()->firstLineBoxBaseline(
|
||||
FontBaselineOrAuto(AlphabeticBaseline));
|
||||
}
|
||||
|
||||
double ParagraphImplBlink::ideographicBaseline() {
|
||||
return firstChildBox()->firstLineBoxBaseline(
|
||||
FontBaselineOrAuto(IdeographicBaseline));
|
||||
}
|
||||
|
||||
bool ParagraphImplBlink::didExceedMaxLines() {
|
||||
RenderBox* box = firstChildBox();
|
||||
ASSERT(box->isRenderParagraph());
|
||||
RenderParagraph* paragraph = static_cast<RenderParagraph*>(box);
|
||||
return paragraph->didExceedMaxLines();
|
||||
}
|
||||
|
||||
void ParagraphImplBlink::layout(double width) {
|
||||
FontCachePurgePreventer fontCachePurgePreventer;
|
||||
|
||||
int maxWidth = LayoutUnit(width); // Handles infinity properly.
|
||||
m_renderView->setFrameViewSize(IntSize(maxWidth, intMaxForLayoutUnit));
|
||||
m_renderView->layout();
|
||||
}
|
||||
|
||||
void ParagraphImplBlink::paint(Canvas* canvas, double x, double y) {
|
||||
SkCanvas* skCanvas = canvas->canvas();
|
||||
if (!skCanvas)
|
||||
return;
|
||||
|
||||
FontCachePurgePreventer fontCachePurgePreventer;
|
||||
|
||||
// Very simplified painting to allow painting an arbitrary (layer-less)
|
||||
// subtree.
|
||||
RenderBox* box = firstChildBox();
|
||||
skCanvas->translate(x, y);
|
||||
|
||||
GraphicsContext context(skCanvas);
|
||||
Vector<RenderBox*> layers;
|
||||
LayoutRect bounds = box->absoluteBoundingBoxRect();
|
||||
FXL_DCHECK(bounds.x() == 0 && bounds.y() == 0);
|
||||
PaintInfo paintInfo(&context, enclosingIntRect(bounds), box);
|
||||
box->paint(paintInfo, LayoutPoint(), layers);
|
||||
// Note we're ignoring any layers encountered.
|
||||
// TODO(abarth): Remove the concept of RenderLayers.
|
||||
|
||||
skCanvas->translate(-x, -y);
|
||||
}
|
||||
|
||||
std::vector<TextBox> ParagraphImplBlink::getRectsForRange(unsigned start,
|
||||
unsigned end) {
|
||||
if (end <= start || start == end)
|
||||
return std::vector<TextBox>();
|
||||
|
||||
unsigned offset = 0;
|
||||
std::vector<TextBox> boxes;
|
||||
for (RenderObject* object = m_renderView.get(); object;
|
||||
object = object->nextInPreOrder()) {
|
||||
if (!object->isText())
|
||||
continue;
|
||||
RenderText* text = toRenderText(object);
|
||||
unsigned length = text->textLength();
|
||||
if (offset + length > start) {
|
||||
unsigned startOffset = offset > start ? 0 : start - offset;
|
||||
unsigned endOffset = end - offset;
|
||||
text->appendAbsoluteTextBoxesForRange(boxes, startOffset, endOffset);
|
||||
}
|
||||
offset += length;
|
||||
if (offset >= end)
|
||||
break;
|
||||
}
|
||||
|
||||
return boxes;
|
||||
}
|
||||
|
||||
int ParagraphImplBlink::absoluteOffsetForPosition(
|
||||
const PositionWithAffinity& position) {
|
||||
FXL_DCHECK(position.renderer());
|
||||
unsigned offset = 0;
|
||||
for (RenderObject* object = m_renderView.get(); object;
|
||||
object = object->nextInPreOrder()) {
|
||||
if (object == position.renderer())
|
||||
return offset + position.offset();
|
||||
if (object->isText()) {
|
||||
RenderText* text = toRenderText(object);
|
||||
offset += text->textLength();
|
||||
}
|
||||
}
|
||||
FXL_DCHECK(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Dart_Handle ParagraphImplBlink::getPositionForOffset(double dx, double dy) {
|
||||
LayoutPoint point(dx, dy);
|
||||
PositionWithAffinity position = m_renderView->positionForPoint(point);
|
||||
Dart_Handle result = Dart_NewListOf(Dart_CoreType_Int, 2);
|
||||
Dart_ListSetAt(result, 0, ToDart(absoluteOffsetForPosition(position)));
|
||||
Dart_ListSetAt(result, 1, ToDart(static_cast<int>(position.affinity())));
|
||||
return result;
|
||||
}
|
||||
|
||||
Dart_Handle ParagraphImplBlink::getWordBoundary(unsigned offset) {
|
||||
String text;
|
||||
int start = 0, end = 0;
|
||||
|
||||
for (RenderObject* object = m_renderView.get(); object;
|
||||
object = object->nextInPreOrder()) {
|
||||
if (!object->isText())
|
||||
continue;
|
||||
RenderText* renderText = toRenderText(object);
|
||||
text.append(renderText->text());
|
||||
}
|
||||
|
||||
TextBreakIterator* it = wordBreakIterator(text, 0, text.length());
|
||||
if (it) {
|
||||
end = it->following(offset);
|
||||
if (end < 0)
|
||||
end = it->last();
|
||||
start = it->previous();
|
||||
}
|
||||
|
||||
Dart_Handle result = Dart_NewListOf(Dart_CoreType_Int, 2);
|
||||
Dart_ListSetAt(result, 0, ToDart(start));
|
||||
Dart_ListSetAt(result, 1, ToDart(end));
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_BLINK_H_
|
||||
#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_BLINK_H_
|
||||
|
||||
#include "flutter/fml/message_loop.h"
|
||||
#include "flutter/lib/ui/painting/canvas.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl.h"
|
||||
#include "flutter/lib/ui/text/text_box.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderView.h"
|
||||
#include "flutter/third_party/txt/src/txt/paragraph.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class ParagraphImplBlink : public ParagraphImpl {
|
||||
public:
|
||||
~ParagraphImplBlink() override;
|
||||
|
||||
explicit ParagraphImplBlink(PassOwnPtr<RenderView> renderView);
|
||||
|
||||
double width() override;
|
||||
double height() override;
|
||||
double minIntrinsicWidth() override;
|
||||
double maxIntrinsicWidth() override;
|
||||
double alphabeticBaseline() override;
|
||||
double ideographicBaseline() override;
|
||||
bool didExceedMaxLines() override;
|
||||
|
||||
void layout(double width) override;
|
||||
void paint(Canvas* canvas, double x, double y) override;
|
||||
|
||||
std::vector<TextBox> getRectsForRange(unsigned start, unsigned end) override;
|
||||
Dart_Handle getPositionForOffset(double dx, double dy) override;
|
||||
Dart_Handle getWordBoundary(unsigned offset) override;
|
||||
|
||||
RenderView* renderView() const { return m_renderView.get(); }
|
||||
|
||||
private:
|
||||
RenderBox* firstChildBox() const { return m_renderView->firstChildBox(); }
|
||||
|
||||
int absoluteOffsetForPosition(const PositionWithAffinity& position);
|
||||
|
||||
// TODO: This can be removed when the render view association for the legacy
|
||||
// runtime is removed.
|
||||
fxl::RefPtr<fxl::TaskRunner> destruction_task_runner_ =
|
||||
UIDartState::Current()->GetTaskRunners().GetUITaskRunner();
|
||||
OwnPtr<RenderView> m_renderView;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_BLINK_H_
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "flutter/lib/ui/painting/canvas.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl_blink.h"
|
||||
#include "flutter/lib/ui/text/text_box.h"
|
||||
#include "flutter/third_party/txt/src/txt/paragraph.h"
|
||||
|
||||
|
||||
@@ -26,14 +26,12 @@ Dart_Handle GetTextBoxType() {
|
||||
} // anonymous namespace
|
||||
|
||||
Dart_Handle DartConverter<TextBox>::ToDart(const TextBox& val) {
|
||||
if (val.is_null)
|
||||
return Dart_Null();
|
||||
constexpr int argc = 5;
|
||||
Dart_Handle argv[argc] = {
|
||||
tonic::ToDart(val.sk_rect.fLeft),
|
||||
tonic::ToDart(val.sk_rect.fTop),
|
||||
tonic::ToDart(val.sk_rect.fRight),
|
||||
tonic::ToDart(val.sk_rect.fBottom),
|
||||
tonic::ToDart(val.rect.fLeft),
|
||||
tonic::ToDart(val.rect.fTop),
|
||||
tonic::ToDart(val.rect.fRight),
|
||||
tonic::ToDart(val.rect.fBottom),
|
||||
tonic::ToDart(static_cast<int>(val.direction)),
|
||||
};
|
||||
return Dart_New(GetTextBoxType(), tonic::ToDart("_"), argc, argv);
|
||||
|
||||
@@ -5,9 +5,25 @@
|
||||
#ifndef FLUTTER_LIB_UI_TEXT_TEXT_BOX_H_
|
||||
#define FLUTTER_LIB_UI_TEXT_TEXT_BOX_H_
|
||||
|
||||
#include "flutter/sky/engine/platform/text/TextBox.h"
|
||||
#include "lib/tonic/converter/dart_converter.h"
|
||||
#include "third_party/dart/runtime/include/dart_api.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
enum class TextDirection {
|
||||
rtl,
|
||||
ltr,
|
||||
};
|
||||
|
||||
struct TextBox {
|
||||
SkRect rect;
|
||||
TextDirection direction;
|
||||
|
||||
TextBox(SkRect r, TextDirection d) : rect(r), direction(d) {}
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
namespace tonic {
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "flutter/fml/message_loop.h"
|
||||
#include "flutter/lib/ui/window/window.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontSelector.h"
|
||||
#include "lib/tonic/converter/dart_converter.h"
|
||||
|
||||
using tonic::ToDart;
|
||||
@@ -57,14 +56,6 @@ UIDartState* UIDartState::Current() {
|
||||
return static_cast<UIDartState*>(DartState::Current());
|
||||
}
|
||||
|
||||
void UIDartState::set_font_selector(PassRefPtr<FontSelector> selector) {
|
||||
font_selector_ = selector;
|
||||
}
|
||||
|
||||
PassRefPtr<FontSelector> UIDartState::font_selector() {
|
||||
return font_selector_;
|
||||
}
|
||||
|
||||
void UIDartState::SetWindow(std::unique_ptr<Window> window) {
|
||||
window_ = std::move(window);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "flutter/common/task_runners.h"
|
||||
#include "flutter/flow/skia_gpu_object.h"
|
||||
#include "flutter/fml/memory/weak_ptr.h"
|
||||
#include "flutter/sky/engine/wtf/RefPtr.h"
|
||||
#include "lib/fxl/build_config.h"
|
||||
#include "lib/tonic/dart_microtask_queue.h"
|
||||
#include "lib/tonic/dart_persistent_value.h"
|
||||
@@ -37,12 +36,6 @@ class UIDartState : public tonic::DartState {
|
||||
|
||||
Window* window() const { return window_.get(); }
|
||||
|
||||
void set_font_selector(PassRefPtr<FontSelector> selector);
|
||||
|
||||
PassRefPtr<FontSelector> font_selector();
|
||||
|
||||
bool use_blink() const { return use_blink_; }
|
||||
|
||||
const TaskRunners& GetTaskRunners() const;
|
||||
|
||||
void ScheduleMicrotask(Dart_Handle handle);
|
||||
@@ -78,8 +71,6 @@ class UIDartState : public tonic::DartState {
|
||||
|
||||
void SetWindow(std::unique_ptr<Window> window);
|
||||
|
||||
void set_use_blink(bool use_blink) { use_blink_ = use_blink; }
|
||||
|
||||
const std::string& GetAdvisoryScriptURI() const;
|
||||
|
||||
const std::string& GetAdvisoryScriptEntrypoint() const;
|
||||
@@ -97,13 +88,10 @@ class UIDartState : public tonic::DartState {
|
||||
Dart_Port main_port_ = ILLEGAL_PORT;
|
||||
std::string debug_name_;
|
||||
std::unique_ptr<Window> window_;
|
||||
RefPtr<FontSelector> font_selector_;
|
||||
fxl::RefPtr<flow::SkiaUnrefQueue> skia_unref_queue_;
|
||||
tonic::DartMicrotaskQueue microtask_queue_;
|
||||
|
||||
void AddOrRemoveTaskObserver(bool add);
|
||||
|
||||
bool use_blink_ = false;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@@ -61,8 +61,6 @@ source_set("test_font") {
|
||||
|
||||
source_set("runtime") {
|
||||
sources = [
|
||||
"asset_font_selector.cc",
|
||||
"asset_font_selector.h",
|
||||
"dart_isolate.cc",
|
||||
"dart_isolate.h",
|
||||
"dart_service_isolate.cc",
|
||||
@@ -75,8 +73,6 @@ source_set("runtime") {
|
||||
"dart_vm.h",
|
||||
"embedder_resources.cc",
|
||||
"embedder_resources.h",
|
||||
"platform_impl.cc",
|
||||
"platform_impl.h",
|
||||
"runtime_controller.cc",
|
||||
"runtime_controller.h",
|
||||
"runtime_delegate.cc",
|
||||
@@ -85,8 +81,6 @@ source_set("runtime") {
|
||||
"service_protocol.h",
|
||||
"start_up.cc",
|
||||
"start_up.h",
|
||||
"test_font_selector.cc",
|
||||
"test_font_selector.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
@@ -99,7 +93,6 @@ source_set("runtime") {
|
||||
"$flutter_root/glue",
|
||||
"$flutter_root/lib/io",
|
||||
"$flutter_root/lib/ui",
|
||||
"$flutter_root/sky/engine/platform",
|
||||
"$flutter_root/third_party/txt",
|
||||
"//garnet/public/lib/fxl",
|
||||
"//third_party/dart/runtime:dart_api",
|
||||
@@ -118,6 +111,12 @@ source_set("runtime") {
|
||||
if (!flutter_aot && !is_fuchsia) {
|
||||
deps += [ "$flutter_root/lib/snapshot" ]
|
||||
}
|
||||
|
||||
if (flutter_runtime_mode != "release" && !is_fuchsia) {
|
||||
# Only link in Observatory in non-release modes on non-Fuchsia. Fuchsia
|
||||
# instead puts Observatory into the runner's package.
|
||||
deps += [ "//third_party/dart/runtime/observatory:embedded_observatory_archive" ]
|
||||
}
|
||||
}
|
||||
|
||||
test_fixtures("runtime_fixtures") {
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/runtime/asset_font_selector.h"
|
||||
|
||||
#include "flutter/assets/directory_asset_bundle.h"
|
||||
#include "flutter/lib/ui/ui_dart_state.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontData.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontFaceCreationParams.h"
|
||||
#include "flutter/sky/engine/platform/fonts/SimpleFontData.h"
|
||||
#include "lib/fxl/arraysize.h"
|
||||
#include "third_party/rapidjson/rapidjson/document.h"
|
||||
#include "third_party/skia/include/core/SkStream.h"
|
||||
#include "third_party/skia/include/core/SkTypeface.h"
|
||||
#include "third_party/skia/include/ports/SkFontMgr.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
// Style attributes of a Flutter font asset.
|
||||
struct AssetFontSelector::FlutterFontAttributes {
|
||||
FlutterFontAttributes(const std::string& path);
|
||||
~FlutterFontAttributes();
|
||||
std::string asset_path;
|
||||
int weight;
|
||||
FontStyle style;
|
||||
};
|
||||
|
||||
// A Skia typeface along with a buffer holding the raw typeface asset data.
|
||||
struct AssetFontSelector::TypefaceAsset {
|
||||
TypefaceAsset();
|
||||
~TypefaceAsset();
|
||||
sk_sp<SkTypeface> typeface;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
const char kFontManifestAssetPath[] = "FontManifest.json";
|
||||
|
||||
// Weight values corresponding to the members of the FontWeight enum.
|
||||
const int kFontWeightValue[] = {100, 200, 300, 400, 500, 600, 700, 800, 900};
|
||||
|
||||
const int kFontWeightNormal = kFontWeightValue[FontWeight::FontWeightNormal];
|
||||
|
||||
int getFontWeightValue(FontWeight weight) {
|
||||
size_t weight_index = weight;
|
||||
return (weight_index < arraysize(kFontWeightValue))
|
||||
? kFontWeightValue[weight_index]
|
||||
: kFontWeightNormal;
|
||||
}
|
||||
|
||||
// Compares fonts within a family to determine which one most closely matches
|
||||
// a FontDescription.
|
||||
struct FontMatcher {
|
||||
using FlutterFontAttributes = AssetFontSelector::FlutterFontAttributes;
|
||||
|
||||
FontMatcher(const FontDescription& description)
|
||||
: description_(description),
|
||||
target_weight_(getFontWeightValue(description.weight())) {}
|
||||
|
||||
bool operator()(const FlutterFontAttributes& font1,
|
||||
const FlutterFontAttributes& font2) {
|
||||
if (font1.style != font2.style) {
|
||||
if (font1.style == description_.style())
|
||||
return true;
|
||||
if (font2.style == description_.style())
|
||||
return false;
|
||||
}
|
||||
|
||||
int weight_delta1 = abs(font1.weight - target_weight_);
|
||||
int weight_delta2 = abs(font2.weight - target_weight_);
|
||||
return weight_delta1 < weight_delta2;
|
||||
}
|
||||
|
||||
private:
|
||||
const FontDescription& description_;
|
||||
int target_weight_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void AssetFontSelector::Install(fxl::RefPtr<AssetManager> asset_manager) {
|
||||
RefPtr<AssetFontSelector> font_selector =
|
||||
adoptRef(new AssetFontSelector(std::move(asset_manager)));
|
||||
font_selector->parseFontManifest();
|
||||
UIDartState::Current()->set_font_selector(font_selector);
|
||||
}
|
||||
|
||||
AssetFontSelector::AssetFontSelector(fxl::RefPtr<AssetManager> asset_manager)
|
||||
: asset_manager_(std::move(asset_manager)) {}
|
||||
|
||||
AssetFontSelector::~AssetFontSelector() {}
|
||||
|
||||
AssetFontSelector::TypefaceAsset::TypefaceAsset() {}
|
||||
|
||||
AssetFontSelector::TypefaceAsset::~TypefaceAsset() {}
|
||||
|
||||
AssetFontSelector::FlutterFontAttributes::FlutterFontAttributes(
|
||||
const std::string& path)
|
||||
: asset_path(path),
|
||||
weight(kFontWeightNormal),
|
||||
style(FontStyle::FontStyleNormal) {}
|
||||
|
||||
AssetFontSelector::FlutterFontAttributes::~FlutterFontAttributes() {}
|
||||
|
||||
void AssetFontSelector::parseFontManifest() {
|
||||
std::vector<uint8_t> font_manifest_data;
|
||||
if (!asset_manager_->GetAsBuffer(kFontManifestAssetPath,
|
||||
&font_manifest_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
rapidjson::Document document;
|
||||
document.Parse(reinterpret_cast<const char*>(font_manifest_data.data()),
|
||||
font_manifest_data.size());
|
||||
|
||||
if (document.HasParseError())
|
||||
return;
|
||||
|
||||
if (!document.IsArray())
|
||||
return;
|
||||
|
||||
for (auto& family : document.GetArray()) {
|
||||
if (!family.IsObject())
|
||||
continue;
|
||||
|
||||
auto family_name = family.FindMember("family");
|
||||
if (family_name == family.MemberEnd() || !family_name->value.IsString())
|
||||
continue;
|
||||
|
||||
auto font_list = family.FindMember("fonts");
|
||||
if (font_list == family.MemberEnd() || !font_list->value.IsArray())
|
||||
continue;
|
||||
|
||||
AtomicString family_key =
|
||||
AtomicString::fromUTF8(family_name->value.GetString());
|
||||
auto set_result =
|
||||
font_family_map_.set(family_key, std::vector<FlutterFontAttributes>());
|
||||
std::vector<FlutterFontAttributes>& family_assets =
|
||||
set_result.storedValue->value;
|
||||
|
||||
for (auto& list_entry : font_list->value.GetArray()) {
|
||||
if (!list_entry.IsObject())
|
||||
continue;
|
||||
|
||||
auto asset_path = list_entry.FindMember("asset");
|
||||
if (asset_path == list_entry.MemberEnd() || !asset_path->value.IsString())
|
||||
continue;
|
||||
|
||||
FlutterFontAttributes attributes(asset_path->value.GetString());
|
||||
|
||||
auto weight = list_entry.FindMember("weight");
|
||||
if (weight != list_entry.MemberEnd() && weight->value.IsInt())
|
||||
attributes.weight = weight->value.GetInt();
|
||||
|
||||
auto style = list_entry.FindMember("style");
|
||||
if (style != list_entry.MemberEnd() && style->value.IsString()) {
|
||||
if (std::string(style->value.GetString()) == "italic")
|
||||
attributes.style = FontStyle::FontStyleItalic;
|
||||
}
|
||||
|
||||
family_assets.push_back(attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PassRefPtr<FontData> AssetFontSelector::getFontData(
|
||||
const FontDescription& font_description,
|
||||
const AtomicString& family_name) {
|
||||
FontFaceCreationParams creationParams(family_name);
|
||||
FontCacheKey key = font_description.cacheKey(creationParams);
|
||||
RefPtr<SimpleFontData> font_data = font_platform_data_cache_.get(key);
|
||||
|
||||
if (font_data == nullptr) {
|
||||
sk_sp<SkTypeface> typeface =
|
||||
getTypefaceAsset(font_description, family_name);
|
||||
if (!typeface)
|
||||
return nullptr;
|
||||
|
||||
bool synthetic_bold =
|
||||
(font_description.weight() >= FontWeight600 && !typeface->isBold()) ||
|
||||
font_description.isSyntheticBold();
|
||||
bool synthetic_italic =
|
||||
(font_description.style() && !typeface->isItalic()) ||
|
||||
font_description.isSyntheticItalic();
|
||||
FontPlatformData platform_data(typeface, family_name.utf8().data(),
|
||||
font_description.effectiveFontSize(),
|
||||
synthetic_bold, synthetic_italic,
|
||||
font_description.orientation(),
|
||||
font_description.useSubpixelPositioning());
|
||||
|
||||
font_data = SimpleFontData::create(platform_data, CustomFontData::create());
|
||||
font_platform_data_cache_.set(key, font_data);
|
||||
}
|
||||
|
||||
return font_data;
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> AssetFontSelector::getTypefaceAsset(
|
||||
const FontDescription& font_description,
|
||||
const AtomicString& family_name) {
|
||||
auto family_iter = font_family_map_.find(family_name);
|
||||
if (family_iter == font_family_map_.end())
|
||||
return nullptr;
|
||||
|
||||
const std::vector<FlutterFontAttributes>& fonts = family_iter->value;
|
||||
if (fonts.empty())
|
||||
return nullptr;
|
||||
|
||||
std::vector<FlutterFontAttributes>::const_iterator font_iter;
|
||||
if (fonts.size() == 1) {
|
||||
font_iter = fonts.begin();
|
||||
} else {
|
||||
font_iter = std::min_element(fonts.begin(), fonts.end(),
|
||||
FontMatcher(font_description));
|
||||
}
|
||||
|
||||
const std::string& asset_path = font_iter->asset_path;
|
||||
auto typeface_iter = typeface_cache_.find(asset_path);
|
||||
if (typeface_iter != typeface_cache_.end()) {
|
||||
const TypefaceAsset* cache_asset = typeface_iter->second.get();
|
||||
return cache_asset ? cache_asset->typeface : nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<TypefaceAsset> typeface_asset(new TypefaceAsset);
|
||||
if (!asset_manager_->GetAsBuffer(asset_path, &typeface_asset->data)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkFontMgr> font_mgr(SkFontMgr::RefDefault());
|
||||
std::unique_ptr<SkStreamAsset> typeface_stream =
|
||||
std::make_unique<SkMemoryStream>(typeface_asset->data.data(),
|
||||
typeface_asset->data.size());
|
||||
typeface_asset->typeface =
|
||||
font_mgr->makeFromStream(std::move(typeface_stream));
|
||||
if (typeface_asset->typeface == nullptr) {
|
||||
typeface_cache_.insert(std::make_pair(asset_path, nullptr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> result = typeface_asset->typeface;
|
||||
typeface_cache_.insert(std::make_pair(asset_path, std::move(typeface_asset)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void AssetFontSelector::willUseFontData(const FontDescription& font_description,
|
||||
const AtomicString& family,
|
||||
UChar32 character) {}
|
||||
|
||||
unsigned AssetFontSelector::version() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AssetFontSelector::fontCacheInvalidated() {}
|
||||
|
||||
} // namespace blink
|
||||
@@ -1,68 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_RUNTIME_ASSET_FONT_SELECTOR_H_
|
||||
#define FLUTTER_RUNTIME_ASSET_FONT_SELECTOR_H_
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/assets/asset_manager.h"
|
||||
#include "flutter/assets/zip_asset_store.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontCacheKey.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontSelector.h"
|
||||
#include "flutter/sky/engine/platform/fonts/SimpleFontData.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
// A FontSelector implementation that resolves custon font names to assets
|
||||
// loaded from the asset directory.
|
||||
class AssetFontSelector : public FontSelector {
|
||||
public:
|
||||
struct FlutterFontAttributes;
|
||||
|
||||
~AssetFontSelector() override;
|
||||
|
||||
static void Install(fxl::RefPtr<AssetManager> asset_manager);
|
||||
|
||||
PassRefPtr<FontData> getFontData(const FontDescription& font_description,
|
||||
const AtomicString& family_name) override;
|
||||
|
||||
void willUseFontData(const FontDescription& font_description,
|
||||
const AtomicString& family,
|
||||
UChar32 character) override;
|
||||
|
||||
unsigned version() const override;
|
||||
|
||||
void fontCacheInvalidated() override;
|
||||
|
||||
private:
|
||||
struct TypefaceAsset;
|
||||
|
||||
explicit AssetFontSelector(fxl::RefPtr<AssetManager> asset_manager);
|
||||
|
||||
void parseFontManifest();
|
||||
|
||||
sk_sp<SkTypeface> getTypefaceAsset(const FontDescription& font_description,
|
||||
const AtomicString& family_name);
|
||||
|
||||
fxl::RefPtr<AssetManager> asset_manager_;
|
||||
|
||||
HashMap<AtomicString, std::vector<FlutterFontAttributes>> font_family_map_;
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<TypefaceAsset>>
|
||||
typeface_cache_;
|
||||
|
||||
typedef HashMap<FontCacheKey,
|
||||
RefPtr<SimpleFontData>,
|
||||
FontCacheKeyHash,
|
||||
FontCacheKeyTraits>
|
||||
FontPlatformDataCache;
|
||||
|
||||
FontPlatformDataCache font_platform_data_cache_;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // FLUTTER_RUNTIME_ASSET_FONT_SELECTOR_H_
|
||||
@@ -85,7 +85,6 @@ fml::WeakPtr<DartIsolate> DartIsolate::CreateRootIsolate(
|
||||
if (embedder_isolate) {
|
||||
// Only root isolates can interact with windows.
|
||||
embedder_isolate->SetWindow(std::move(window));
|
||||
embedder_isolate->set_use_blink(vm->GetSettings().using_blink);
|
||||
}
|
||||
|
||||
root_embedder_data.release();
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
namespace dart {
|
||||
namespace observatory {
|
||||
|
||||
#if !OS(FUCHSIA) && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE)
|
||||
#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE)
|
||||
|
||||
// These two symbols are defined in |observatory_archive.cc| which is generated
|
||||
// by the |//third_party/dart/runtime/observatory:archive_observatory| rule.
|
||||
@@ -48,7 +48,7 @@ namespace observatory {
|
||||
extern unsigned int observatory_assets_archive_len;
|
||||
extern const uint8_t* observatory_assets_archive;
|
||||
|
||||
#endif // !OS(FUCHSIA) && (FLUTTER_RUNTIME_MODE !=
|
||||
#endif // !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE !=
|
||||
// FLUTTER_RUNTIME_MODE_RELEASE)
|
||||
|
||||
} // namespace observatory
|
||||
@@ -148,7 +148,7 @@ void ThreadExitCallback() {}
|
||||
Dart_Handle GetVMServiceAssetsArchiveCallback() {
|
||||
#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE)
|
||||
return nullptr;
|
||||
#elif OS(FUCHSIA)
|
||||
#elif OS_FUCHSIA
|
||||
std::vector<uint8_t> observatory_assets_archive;
|
||||
if (!files::ReadFileToVector("pkg/data/observatory.tar",
|
||||
&observatory_assets_archive)) {
|
||||
@@ -323,11 +323,11 @@ DartVM::DartVM(const Settings& settings,
|
||||
// precompiled code only in the debug product mode.
|
||||
bool use_checked_mode = !settings.dart_non_checked_mode;
|
||||
|
||||
#if !OS(FUCHSIA)
|
||||
#if !OS_FUCHSIA
|
||||
if (IsRunningPrecompiledCode()) {
|
||||
use_checked_mode = false;
|
||||
}
|
||||
#endif // !OS(FUCHSIA)
|
||||
#endif // !OS_FUCHSIA
|
||||
|
||||
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
|
||||
// Debug mode uses the JIT, disable code page write protection to avoid
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/runtime/platform_impl.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
PlatformImpl::PlatformImpl() {}
|
||||
|
||||
PlatformImpl::~PlatformImpl() {}
|
||||
|
||||
std::string PlatformImpl::defaultLocale() {
|
||||
return "en-US";
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_RUNTIME_PLATFORM_IMPL_H_
|
||||
#define FLUTTER_RUNTIME_PLATFORM_IMPL_H_
|
||||
|
||||
#include "flutter/sky/engine/public/platform/Platform.h"
|
||||
#include "lib/fxl/macros.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class PlatformImpl : public Platform {
|
||||
public:
|
||||
explicit PlatformImpl();
|
||||
~PlatformImpl() override;
|
||||
|
||||
// blink::Platform methods:
|
||||
std::string defaultLocale() override;
|
||||
|
||||
private:
|
||||
FXL_DISALLOW_COPY_AND_ASSIGN(PlatformImpl);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // FLUTTER_RUNTIME_PLATFORM_IMPL_H_
|
||||
@@ -1,50 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/runtime/test_font_selector.h"
|
||||
#include "flutter/lib/ui/ui_dart_state.h"
|
||||
#include "flutter/runtime/test_font_data.h"
|
||||
#include "flutter/sky/engine/platform/fonts/SimpleFontData.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
void TestFontSelector::Install() {
|
||||
auto font_selector = adoptRef(new TestFontSelector());
|
||||
UIDartState::Current()->set_font_selector(font_selector);
|
||||
}
|
||||
|
||||
TestFontSelector::TestFontSelector() = default;
|
||||
|
||||
TestFontSelector::~TestFontSelector() = default;
|
||||
|
||||
PassRefPtr<FontData> TestFontSelector::getFontData(
|
||||
const FontDescription& fontDescription,
|
||||
const AtomicString& familyName) {
|
||||
if (!test_typeface_) {
|
||||
test_typeface_ = SkTypeface::MakeFromStream(GetTestFontData().release());
|
||||
}
|
||||
|
||||
bool syntheticBold = (fontDescription.weight() >= FontWeight600 ||
|
||||
fontDescription.isSyntheticBold());
|
||||
bool syntheticItalic =
|
||||
(fontDescription.style() || fontDescription.isSyntheticItalic());
|
||||
FontPlatformData platform_data(
|
||||
test_typeface_, GetTestFontFamilyName().c_str(),
|
||||
fontDescription.effectiveFontSize(), syntheticBold, syntheticItalic,
|
||||
fontDescription.orientation(), fontDescription.useSubpixelPositioning());
|
||||
|
||||
return SimpleFontData::create(platform_data, CustomFontData::create());
|
||||
}
|
||||
|
||||
void TestFontSelector::willUseFontData(const FontDescription&,
|
||||
const AtomicString& familyName,
|
||||
UChar32) {}
|
||||
|
||||
unsigned TestFontSelector::version() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TestFontSelector::fontCacheInvalidated() {}
|
||||
|
||||
} // namespace blink
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_RUNTIME_TEST_FONT_SELECTOR_H_
|
||||
#define FLUTTER_RUNTIME_TEST_FONT_SELECTOR_H_
|
||||
|
||||
#include "flutter/sky/engine/platform/fonts/FontSelector.h"
|
||||
#include "flutter/sky/engine/wtf/RefPtr.h"
|
||||
#include "lib/fxl/macros.h"
|
||||
#include "third_party/skia/include/core/SkTypeface.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class TestFontSelector : public FontSelector {
|
||||
public:
|
||||
static void Install();
|
||||
|
||||
~TestFontSelector() override;
|
||||
|
||||
PassRefPtr<FontData> getFontData(const FontDescription&,
|
||||
const AtomicString& familyName) override;
|
||||
|
||||
void willUseFontData(const FontDescription&,
|
||||
const AtomicString& familyName,
|
||||
UChar32) override;
|
||||
|
||||
unsigned version() const override;
|
||||
|
||||
void fontCacheInvalidated() override;
|
||||
|
||||
private:
|
||||
sk_sp<SkTypeface> test_typeface_;
|
||||
|
||||
TestFontSelector();
|
||||
|
||||
FXL_DISALLOW_COPY_AND_ASSIGN(TestFontSelector);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // FLUTTER_RUNTIME_TEST_FONT_SELECTOR_H_
|
||||
@@ -99,8 +99,6 @@ source_set("common") {
|
||||
"$flutter_root/glue",
|
||||
"$flutter_root/lib/ui",
|
||||
"$flutter_root/runtime",
|
||||
"$flutter_root/sky/engine/platform",
|
||||
"$flutter_root/sky/engine/wtf",
|
||||
"$flutter_root/synchronization",
|
||||
"$flutter_root/third_party/txt",
|
||||
"//garnet/public/lib/fxl",
|
||||
|
||||
@@ -11,14 +11,9 @@
|
||||
#include "flutter/glue/trace_event.h"
|
||||
#include "flutter/lib/snapshot/snapshot.h"
|
||||
#include "flutter/lib/ui/text/font_collection.h"
|
||||
#include "flutter/runtime/asset_font_selector.h"
|
||||
#include "flutter/runtime/platform_impl.h"
|
||||
#include "flutter/runtime/test_font_selector.h"
|
||||
#include "flutter/shell/common/animator.h"
|
||||
#include "flutter/shell/common/platform_view.h"
|
||||
#include "flutter/shell/common/shell.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontFallbackList.h"
|
||||
#include "flutter/sky/engine/public/web/Sky.h"
|
||||
#include "lib/fxl/files/eintr_wrapper.h"
|
||||
#include "lib/fxl/files/file.h"
|
||||
#include "lib/fxl/files/path.h"
|
||||
@@ -51,19 +46,10 @@ Engine::Engine(Delegate& delegate,
|
||||
: delegate_(delegate),
|
||||
settings_(std::move(settings)),
|
||||
animator_(std::move(animator)),
|
||||
legacy_sky_platform_(settings_.using_blink ? new blink::PlatformImpl()
|
||||
: nullptr),
|
||||
load_script_error_(tonic::kNoError),
|
||||
activity_running_(false),
|
||||
have_surface_(false),
|
||||
weak_factory_(this) {
|
||||
if (legacy_sky_platform_) {
|
||||
// TODO: Remove this legacy call along with the platform. This is what makes
|
||||
// the engine unable to run from multiple threads in the legacy
|
||||
// configuration.
|
||||
blink::InitEngine(legacy_sky_platform_.get());
|
||||
}
|
||||
|
||||
// Runtime controller is initialized here because it takes a reference to this
|
||||
// object as its delegate. The delegate may be called in the constructor and
|
||||
// we want to be fully initilazed by that point.
|
||||
@@ -77,11 +63,7 @@ Engine::Engine(Delegate& delegate,
|
||||
);
|
||||
}
|
||||
|
||||
Engine::~Engine() {
|
||||
if (legacy_sky_platform_) {
|
||||
blink::ShutdownEngine(/* legacy_sky_platform_ */);
|
||||
}
|
||||
}
|
||||
Engine::~Engine() = default;
|
||||
|
||||
fml::WeakPtr<Engine> Engine::GetWeakPtr() const {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
@@ -99,16 +81,11 @@ bool Engine::UpdateAssetManager(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (settings_.using_blink) {
|
||||
// Using blink as the text engine.
|
||||
blink::FontFallbackList::SetUseTestFonts(settings_.use_test_fonts);
|
||||
// Using libTXT as the text engine.
|
||||
if (settings_.use_test_fonts) {
|
||||
blink::FontCollection::ForProcess().RegisterTestFonts();
|
||||
} else {
|
||||
// Using libTXT as the text engine.
|
||||
if (settings_.use_test_fonts) {
|
||||
blink::FontCollection::ForProcess().RegisterTestFonts();
|
||||
} else {
|
||||
blink::FontCollection::ForProcess().RegisterFonts(*asset_manager_.get());
|
||||
}
|
||||
blink::FontCollection::ForProcess().RegisterFonts(*asset_manager_.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -151,15 +128,6 @@ bool Engine::Run(RunConfiguration configuration) {
|
||||
isolate->AddIsolateShutdownCallback(
|
||||
settings_.root_isolate_shutdown_callback);
|
||||
}
|
||||
|
||||
// Blink uses a per isolate font selector.
|
||||
if (settings_.using_blink) {
|
||||
if (settings_.use_test_fonts) {
|
||||
blink::TestFontSelector::Install();
|
||||
} else {
|
||||
blink::AssetFontSelector::Install(asset_manager_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isolate_running;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "flutter/lib/ui/window/platform_message.h"
|
||||
#include "flutter/lib/ui/window/viewport_metrics.h"
|
||||
#include "flutter/runtime/dart_vm.h"
|
||||
#include "flutter/runtime/platform_impl.h"
|
||||
#include "flutter/runtime/runtime_controller.h"
|
||||
#include "flutter/runtime/runtime_delegate.h"
|
||||
#include "flutter/shell/common/animator.h"
|
||||
@@ -103,7 +102,6 @@ class Engine final : public blink::RuntimeDelegate {
|
||||
const blink::Settings settings_;
|
||||
std::unique_ptr<Animator> animator_;
|
||||
std::unique_ptr<blink::RuntimeController> runtime_controller_;
|
||||
std::unique_ptr<blink::PlatformImpl> legacy_sky_platform_;
|
||||
tonic::DartErrorHandleType load_script_error_;
|
||||
std::string initial_route_;
|
||||
blink::ViewportMetrics viewport_metrics_;
|
||||
|
||||
@@ -27,7 +27,6 @@ TEST(ShellTest, InitializeWithInvalidThreads) {
|
||||
blink::Settings settings = {};
|
||||
settings.task_observer_add = [](intptr_t, fxl::Closure) {};
|
||||
settings.task_observer_remove = [](intptr_t) {};
|
||||
settings.using_blink = false;
|
||||
blink::TaskRunners task_runners("test", nullptr, nullptr, nullptr, nullptr);
|
||||
auto shell = Shell::Create(
|
||||
std::move(task_runners), settings,
|
||||
@@ -44,7 +43,6 @@ TEST(ShellTest, InitializeWithDifferentThreads) {
|
||||
blink::Settings settings = {};
|
||||
settings.task_observer_add = [](intptr_t, fxl::Closure) {};
|
||||
settings.task_observer_remove = [](intptr_t) {};
|
||||
settings.using_blink = false;
|
||||
ThreadHost thread_host("io.flutter.test." + CURRENT_TEST_NAME + ".",
|
||||
ThreadHost::Type::Platform | ThreadHost::Type::GPU |
|
||||
ThreadHost::Type::IO | ThreadHost::Type::UI);
|
||||
@@ -68,7 +66,6 @@ TEST(ShellTest, InitializeWithSingleThread) {
|
||||
blink::Settings settings = {};
|
||||
settings.task_observer_add = [](intptr_t, fxl::Closure) {};
|
||||
settings.task_observer_remove = [](intptr_t) {};
|
||||
settings.using_blink = false;
|
||||
ThreadHost thread_host("io.flutter.test." + CURRENT_TEST_NAME + ".",
|
||||
ThreadHost::Type::Platform);
|
||||
auto task_runner = thread_host.platform_thread->GetTaskRunner();
|
||||
@@ -89,7 +86,6 @@ TEST(ShellTest, InitializeWithSingleThreadWhichIsTheCallingThread) {
|
||||
blink::Settings settings = {};
|
||||
settings.task_observer_add = [](intptr_t, fxl::Closure) {};
|
||||
settings.task_observer_remove = [](intptr_t) {};
|
||||
settings.using_blink = false;
|
||||
fml::MessageLoop::EnsureInitializedForCurrentThread();
|
||||
auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
|
||||
blink::TaskRunners task_runners("test", task_runner, task_runner, task_runner,
|
||||
@@ -109,7 +105,6 @@ TEST(ShellTest, InitializeWithMultipleThreadButCallingThreadAsPlatformThread) {
|
||||
blink::Settings settings = {};
|
||||
settings.task_observer_add = [](intptr_t, fxl::Closure) {};
|
||||
settings.task_observer_remove = [](intptr_t) {};
|
||||
settings.using_blink = false;
|
||||
ThreadHost thread_host(
|
||||
"io.flutter.test." + CURRENT_TEST_NAME + ".",
|
||||
ThreadHost::Type::GPU | ThreadHost::Type::IO | ThreadHost::Type::UI);
|
||||
|
||||
@@ -144,9 +144,6 @@ blink::Settings SettingsFromCommandLine(const fxl::CommandLine& command_line) {
|
||||
settings.enable_software_rendering =
|
||||
command_line.HasOption(FlagForSwitch(Switch::EnableSoftwareRendering));
|
||||
|
||||
settings.using_blink =
|
||||
command_line.HasOption(FlagForSwitch(Switch::EnableBlink));
|
||||
|
||||
settings.endless_trace_buffer =
|
||||
command_line.HasOption(FlagForSwitch(Switch::EndlessTraceBuffer));
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ source_set("flutter_channels") {
|
||||
"$flutter_root/runtime",
|
||||
"$flutter_root/shell/common",
|
||||
"$flutter_root/shell/gpu",
|
||||
"$flutter_root/sky/engine/wtf",
|
||||
"//garnet/public/lib/fxl",
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
@@ -21,7 +21,6 @@ source_set("common") {
|
||||
"$flutter_root/runtime",
|
||||
"$flutter_root/shell/common",
|
||||
"$flutter_root/shell/gpu",
|
||||
"$flutter_root/sky/engine/wtf",
|
||||
"//garnet/public/lib/fxl",
|
||||
"//third_party/dart/runtime:dart_api",
|
||||
"//third_party/skia",
|
||||
|
||||
@@ -115,8 +115,6 @@ static std::string CreateThreadLabel() {
|
||||
[[NSBundle mainBundle] pathForResource:@"icudtl.dat" ofType:@""].UTF8String;
|
||||
}
|
||||
|
||||
settings.using_blink = false;
|
||||
|
||||
settings.task_observer_add = [](intptr_t key, fxl::Closure callback) {
|
||||
fml::MessageLoop::GetCurrent().AddTaskObserver(key, std::move(callback));
|
||||
};
|
||||
|
||||
@@ -81,6 +81,7 @@ shared_library("create_flutter_framework_dylib") {
|
||||
sources += _flutter_framework_headers
|
||||
|
||||
deps = [
|
||||
"$flutter_root/common",
|
||||
"$flutter_root/flow",
|
||||
"$flutter_root/fml",
|
||||
"$flutter_root/glue",
|
||||
@@ -89,10 +90,9 @@ shared_library("create_flutter_framework_dylib") {
|
||||
"$flutter_root/shell/common",
|
||||
"$flutter_root/shell/gpu",
|
||||
"$flutter_root/shell/platform/darwin/common",
|
||||
"$flutter_root/sky/engine/platform",
|
||||
"$flutter_root/sky/engine/wtf",
|
||||
"//garnet/public/lib/fxl",
|
||||
"//third_party/skia",
|
||||
"//third_party/skia:gpu",
|
||||
]
|
||||
if (flutter_runtime_mode == "debug") {
|
||||
deps += [
|
||||
|
||||
@@ -16,7 +16,6 @@ import("//third_party/dart/sdk/lib/typed_data/typed_data_sources.gni")
|
||||
|
||||
import("$flutter_root/build/dart/rules.gni")
|
||||
import("$flutter_root/lib/ui/dart_ui.gni")
|
||||
import("$flutter_root/sky/engine/core/core.gni")
|
||||
|
||||
if (!is_fuchsia) {
|
||||
copy("copy_sky_engine_authors") {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user