Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion impeller/toolkit/interop/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

import("//flutter/impeller/tools/impeller.gni")

embed_blob("embedded_icu_data") {
symbol_name = "embedded_icu_data"
blob = "//flutter/third_party/icu/flutter/icudtl.dat"
hdr = "$target_gen_dir/embedded_icu_data.h"
cc = "$target_gen_dir/embedded_icu_data.cc"
deps = []
}

impeller_component("interop") {
sources = [
"color_filter.cc",
Expand All @@ -29,6 +37,12 @@ impeller_component("interop") {
"object.h",
"paint.cc",
"paint.h",
"paragraph.cc",
"paragraph.h",
"paragraph_builder.cc",
"paragraph_builder.h",
"paragraph_style.cc",
"paragraph_style.h",
"path.cc",
"path.h",
"path_builder.cc",
Expand All @@ -37,16 +51,21 @@ impeller_component("interop") {
"surface.h",
"texture.cc",
"texture.h",
"typography_context.cc",
"typography_context.h",
]

deps = [
public_deps = [
"../../base",
"../../display_list",
"../../entity",
"../../renderer/backend",
"//flutter/display_list",
"//flutter/fml",
"//flutter/third_party/txt",
]

deps = [ ":embedded_icu_data" ]
}

impeller_component("library") {
Expand Down
9 changes: 9 additions & 0 deletions impeller/toolkit/interop/dl_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,13 @@ void DisplayListBuilder::DrawTextureRect(const Texture& texture,
);
}

void DisplayListBuilder::DrawParagraph(const Paragraph& paragraph,
Point point) {
const auto& handle = paragraph.GetHandle();
if (!handle) {
return;
}
handle->Paint(&builder_, point.x, point.y);
}

} // namespace impeller::interop
3 changes: 3 additions & 0 deletions impeller/toolkit/interop/dl_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "impeller/toolkit/interop/impeller.h"
#include "impeller/toolkit/interop/object.h"
#include "impeller/toolkit/interop/paint.h"
#include "impeller/toolkit/interop/paragraph.h"
#include "impeller/toolkit/interop/path.h"
#include "impeller/toolkit/interop/texture.h"

Expand Down Expand Up @@ -106,6 +107,8 @@ class DisplayListBuilder final

void DrawDisplayList(const DisplayList& dl, Scalar opacity);

void DrawParagraph(const Paragraph& paragraph, Point point);

ScopedObject<DisplayList> Build();

private:
Expand Down
65 changes: 65 additions & 0 deletions impeller/toolkit/interop/formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#include "flutter/display_list/dl_builder.h"
#include "flutter/display_list/dl_color.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"
#include "impeller/entity/entity.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/matrix.h"
Expand Down Expand Up @@ -418,6 +421,68 @@ constexpr flutter::DlColor ToDisplayListType(ImpellerColor color) {
);
}

constexpr txt::FontWeight ToTxtType(ImpellerFontWeight weight) {
switch (weight) {
case ImpellerFontWeight100:
return txt::FontWeight::w100;
case ImpellerFontWeight200:
return txt::FontWeight::w200;
case ImpellerFontWeight300:
return txt::FontWeight::w300;
case ImpellerFontWeight400:
return txt::FontWeight::w400;
case ImpellerFontWeight500:
return txt::FontWeight::w500;
case ImpellerFontWeight600:
return txt::FontWeight::w600;
case ImpellerFontWeight700:
return txt::FontWeight::w700;
case ImpellerFontWeight800:
return txt::FontWeight::w800;
case ImpellerFontWeight900:
return txt::FontWeight::w900;
}
return txt::FontWeight::w400;
}

constexpr txt::FontStyle ToTxtType(ImpellerFontStyle style) {
switch (style) {
case ImpellerFontStyleNormal:
return txt::FontStyle::normal;
case ImpellerFontStyleItalic:
return txt::FontStyle::italic;
}
return txt::FontStyle::normal;
}

constexpr txt::TextAlign ToTxtType(ImpellerTextAlignment align) {
switch (align) {
case ImpellerTextAlignmentLeft:
return txt::TextAlign::left;
case ImpellerTextAlignmentRight:
return txt::TextAlign::right;
case ImpellerTextAlignmentCenter:
return txt::TextAlign::center;
case ImpellerTextAlignmentJustify:
return txt::TextAlign::justify;
case ImpellerTextAlignmentStart:
return txt::TextAlign::start;
case ImpellerTextAlignmentEnd:
return txt::TextAlign::end;
}
return txt::TextAlign::left;
}

constexpr txt::TextDirection ToTxtType(ImpellerTextDirection direction) {
switch (direction) {
case ImpellerTextDirectionRTL:
return txt::TextDirection::rtl;
case ImpellerTextDirectionLTR:
return txt::TextDirection::ltr;
}
return txt::TextDirection::ltr;
}

} // namespace impeller::interop

#endif // FLUTTER_IMPELLER_TOOLKIT_INTEROP_FORMATS_H_
Loading