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
Prev Previous commit
Next Next commit
update
  • Loading branch information
jonahwilliams committed Jul 11, 2023
commit 8a3a5226cb81a2cd6628741cfc9ef5465b41ea31
1 change: 1 addition & 0 deletions impeller/display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impeller_component("skia_conversions") {
"../geometry",
"//flutter/fml",
"//third_party/skia",
"//third_party/skia/modules/skparagraph",
]
}

Expand Down
3 changes: 1 addition & 2 deletions impeller/display_list/dl_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ void DlDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
Scalar scale = canvas_.GetCurrentTransformation().GetMaxBasisLengthXY();
const auto text_frame = TextFrameFromTextBlob(blob, scale);
if (paint_.style == Paint::Style::kStroke) {
auto path = PathDataFromTextBlob(blob);
auto path = skia_conversions::PathDataFromTextBlob(blob);
auto bounds = text_frame.GetBounds();
if (!bounds.has_value()) {
return;
Expand All @@ -1119,7 +1119,6 @@ void DlDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
return;
}

Scalar scale = canvas_.GetCurrentTransformation().GetMaxBasisLengthXY();
canvas_.DrawTextFrame(text_frame, //
impeller::Point{x, y}, //
paint_ //
Expand Down
9 changes: 9 additions & 0 deletions impeller/display_list/skia_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "impeller/display_list/skia_conversions.h"
#include "third_party/skia/modules/skparagraph/include/Paragraph.h"

namespace impeller {
namespace skia_conversions {
Expand Down Expand Up @@ -159,6 +160,14 @@ std::vector<Matrix> ToRSXForms(const SkRSXform xform[], int count) {
return result;
}

Path PathDataFromTextBlob(const sk_sp<SkTextBlob>& blob) {
if (!blob) {
return {};
}

return ToPath(skia::textlayout::Paragraph::GetPath(blob.get()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'll be damned. That's a lot easier than I was expecting!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I had to wait 3 months for the API to be added so IMO not that easy 😆

}

std::optional<impeller::PixelFormat> ToPixelFormat(SkColorType type) {
switch (type) {
case kRGBA_8888_SkColorType:
Expand Down
3 changes: 3 additions & 0 deletions impeller/display_list/skia_conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkRRect.h"
#include "third_party/skia/include/core/SkRSXform.h"
#include "third_party/skia/include/core/SkTextBlob.h"

namespace impeller {
namespace skia_conversions {
Expand All @@ -40,6 +41,8 @@ Path ToPath(const SkPath& path);

Path ToPath(const SkRRect& rrect);

Path PathDataFromTextBlob(const sk_sp<SkTextBlob>& blob);

std::optional<impeller::PixelFormat> ToPixelFormat(SkColorType type);

} // namespace skia_conversions
Expand Down
11 changes: 0 additions & 11 deletions impeller/typographer/backends/skia/text_frame_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
#include <vector>

#include "flutter/fml/logging.h"
#include "impeller/display_list/skia_conversions.h"
#include "impeller/typographer/backends/skia/typeface_skia.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkRect.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/core/SkFontMetrics.h"
#include "third_party/skia/modules/skparagraph/include/Paragraph.h"
#include "third_party/skia/src/core/SkStrikeSpec.h" // nogncheck
#include "third_party/skia/src/core/SkTextBlobPriv.h" // nogncheck

Expand All @@ -40,15 +38,6 @@ static Rect ToRect(const SkRect& rect) {
return Rect::MakeLTRB(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
}

Path PathDataFromTextBlob(const sk_sp<SkTextBlob>& blob) {
if (!blob) {
return {};
}

return skia_conversions::ToPath(
skia::textlayout::Paragraph::getPaths(blob.get()));
}

TextFrame TextFrameFromTextBlob(const sk_sp<SkTextBlob>& blob, Scalar scale) {
if (!blob) {
return {};
Expand Down
2 changes: 0 additions & 2 deletions impeller/typographer/backends/skia/text_frame_skia.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace impeller {

Path PathDataFromTextBlob(const sk_sp<SkTextBlob>& blob);

TextFrame TextFrameFromTextBlob(const sk_sp<SkTextBlob>& blob,
Scalar scale = 1.0f);

Expand Down