Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tgfx to the lastest version. #2583

Merged
merged 8 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ if (WEB)
file(GLOB_RECURSE PLATFORM_FILES src/platform/web/*.*)
list(APPEND PAG_FILES ${PLATFORM_FILES})
endif ()
list(APPEND PAG_COMPILE_OPTIONS -fno-rtti -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0)
elseif (IOS)
# finds all required platform libraries.
find_library(UIKit_LIBS UIKit REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"common": [
{
"url": "${PAG_GROUP}/vendor_tools.git",
"commit": "ce1f4d55330727eb3f02595999c1a1b4fab23ebf",
"commit": "b3125b9cf13bcc70e63212de1d0ed95e7beaa2a9",
"dir": "third_party/vendor_tools"
},
{
"url": "${PAG_GROUP}/tgfx.git",
"commit": "57dea46bc27c4815af6fcb14d47eb5faa9cfe360",
"commit": "0ee494ab8246bb051e66b4681832ebcac18b8e39",
"dir": "third_party/tgfx"
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/base/utils/TGFXCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static constexpr std::pair<Enum, tgfx::BlendMode> BlendModeMap[] = {
{BlendMode::Saturation, tgfx::BlendMode::Saturation},
{BlendMode::Color, tgfx::BlendMode::Color},
{BlendMode::Luminosity, tgfx::BlendMode::Luminosity},
{BlendMode::Add, tgfx::BlendMode::Plus}};
{BlendMode::Add, tgfx::BlendMode::PlusLighter}};

tgfx::BlendMode ToTGFXBlend(Enum blendMode) {
for (const auto& pair : BlendModeMap) {
Expand Down
5 changes: 2 additions & 3 deletions src/rendering/graphics/Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ static void ApplyPaintToPath(const tgfx::Paint& paint, tgfx::Path* path) {
return;
}
auto strokePath = *path;
auto strokeEffect = tgfx::PathEffect::MakeStroke(paint.getStroke());
if (strokeEffect) {
strokeEffect->applyTo(&strokePath);
if (const auto stroke = paint.getStroke()) {
stroke->applyToPath(&strokePath);
}
*path = strokePath;
}
Expand Down
16 changes: 3 additions & 13 deletions src/rendering/renderers/ShapeRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void ApplyRoundCorners(RoundCornersElement* roundCorners, const tgfx::Matrix& pa
return;
}
for (auto& path : pathList) {
effect->applyTo(path);
effect->filterPath(path);
}
}

Expand Down Expand Up @@ -828,21 +828,14 @@ std::unique_ptr<tgfx::PathEffect> CreateDashEffect(const std::vector<float>& das
}

void ApplyStrokeToPath(tgfx::Path* path, const StrokePaint& stroke) {
std::vector<std::unique_ptr<tgfx::PathEffect>> effects;
if (!stroke.dashes.empty()) {
auto dashEffect = CreateDashEffect(stroke.dashes, stroke.dashOffset);
if (dashEffect) {
effects.emplace_back(std::move(dashEffect));
dashEffect->filterPath(path);
}
}
auto strokeData = stroke.getStroke();
auto strokeEffect = tgfx::PathEffect::MakeStroke(&strokeData);
if (strokeEffect) {
effects.emplace_back(std::move(strokeEffect));
}
if (effects.empty()) {
return;
}
strokeData.applyToPath(path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这些需要在Transform之后才能应用,顺序错了。

auto applyMatrix = false;
if (!stroke.matrix.isIdentity()) {
auto matrix = tgfx::Matrix::I();
Expand All @@ -851,9 +844,6 @@ void ApplyStrokeToPath(tgfx::Path* path, const StrokePaint& stroke) {
applyMatrix = true;
}
}
for (const auto& effect : effects) {
effect->applyTo(path);
}
if (applyMatrix) {
path->transform(stroke.matrix);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/renderers/TextRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ std::shared_ptr<Graphic> RenderTextBackground(ID assetID,
}
auto effect = tgfx::PathEffect::MakeCorner(maxRadius);
if (effect) {
effect->applyTo(&backgroundPath);
effect->filterPath(&backgroundPath);
}
auto graphic = Shape::MakeFrom(assetID, backgroundPath, ToTGFX(textDocument->backgroundColor));
auto modifier =
Expand Down
5 changes: 1 addition & 4 deletions src/rendering/utils/PathUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ void ExpandPath(tgfx::Path* path, float expansion) {
}
auto strokePath = *path;
tgfx::Stroke stroke(fabsf(expansion) * 2, tgfx::LineCap::Butt, tgfx::LineJoin::Round);
auto effect = tgfx::PathEffect::MakeStroke(&stroke);
if (effect) {
effect->applyTo(&strokePath);
}
stroke.applyToPath(&strokePath);
if (expansion < 0) {
path->addPath(strokePath, tgfx::PathOp::Difference);
} else {
Expand Down
Loading