Skip to content

Conversation

YGaurora
Copy link
Collaborator

修复渲染极度细的描边会断断续续的问题

  • OpsCompositor中将过细的描边StyledShape和Fill转为Hairline和透明度调整
  • ShapeLayer中根据globalMatrix计算当前描边宽度,过细的话,就按stroke paint渲染,并忽略内外描边属性直接渲染

@Copilot Copilot AI review requested due to automatic review settings September 18, 2025 08:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where extremely thin strokes would appear broken or discontinuous during rendering. The fix involves treating very thin strokes as hairline strokes with alpha adjustments to simulate their appearance.

  • Adds detection logic to identify strokes that are too thin after transformation and treat them as hairlines
  • Implements alpha adjustment for thin strokes to maintain visual fidelity
  • Refactors stroke utility functions from ApplyStrokeToBounds.h to StrokeUtils.h for better organization

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/core/utils/StrokeUtils.h Adds TreatStrokeAsHairline function declaration and Matrix include
src/core/utils/StrokeUtils.cpp Implements logic to detect thin strokes that should be treated as hairlines
src/core/StyledShape.h Adds convertToHairlineIfNecessary method declaration
src/core/StyledShape.cpp Implements hairline conversion with alpha adjustment for thin strokes
src/layers/ShapeLayer.cpp Updates stroke rendering to use new thin stroke detection logic
src/gpu/OpsCompositor.cpp Integrates hairline conversion into the rendering pipeline
include/tgfx/layers/ShapeLayer.h Updates createStrokeShape method signature
include/tgfx/layers/Layer.h Makes getGlobalMatrix method public
Multiple files Updates include statements to use new StrokeUtils.h header
Test files Adds regression tests for extremely thin stroke rendering

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

std::vector<Paint> strokePaints = {};
std::shared_ptr<Shape> strokeShape = nullptr;
if (!_strokeStyles.empty()) {
bool isHairlineRender = stroke.isHairline() || TreatStrokeAsHairline(stroke, getGlobalMatrix());
Copy link
Collaborator

Choose a reason for hiding this comment

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

创建图层内容的时候不能通过getGlobalMatrix来判断,图层的矩阵是一直会变化的,而图层内容不会更新。

@domchen domchen closed this Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants