Skip to content

Commit

Permalink
Update tgfx to the lastest version. (#2583)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hparty authored Nov 12, 2024
1 parent f9bef34 commit 7d78a48
Show file tree
Hide file tree
Showing 8 changed files with 2,778 additions and 2,791 deletions.
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
26 changes: 8 additions & 18 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,6 @@ 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));
}
}
auto strokeData = stroke.getStroke();
auto strokeEffect = tgfx::PathEffect::MakeStroke(&strokeData);
if (strokeEffect) {
effects.emplace_back(std::move(strokeEffect));
}
if (effects.empty()) {
return;
}
auto applyMatrix = false;
if (!stroke.matrix.isIdentity()) {
auto matrix = tgfx::Matrix::I();
Expand All @@ -851,9 +836,14 @@ void ApplyStrokeToPath(tgfx::Path* path, const StrokePaint& stroke) {
applyMatrix = true;
}
}
for (const auto& effect : effects) {
effect->applyTo(path);
if (!stroke.dashes.empty()) {
auto dashEffect = CreateDashEffect(stroke.dashes, stroke.dashOffset);
if (dashEffect) {
dashEffect->filterPath(path);
}
}
auto strokeData = stroke.getStroke();
strokeData.applyToPath(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

0 comments on commit 7d78a48

Please sign in to comment.