Commit 5a2a001
Fix iOS Metal and Android SVG rendering bugs exposed by PR #5042
Three rendering-layer bugs the SVGStaticScreenshotTest / SVGAnimatedScreenshotTest
captured in their goldens, now fixed at the port level so the goldens can be
retaken on top:
1. iOS Metal clip on arc-decomposed paths -- gradient_circle.svg and
clipped_badge.svg rendered as triangles. setClip(GeneralPath)'s native
side (setNativeClippingShapeMutableImpl and setNativeClippingPolygonGlobalImpl)
ignores the path command stream and treats the raw points buffer as a
flat polygon. For a path with QUADTO segments, every control point
appears as a polygon vertex, and the stencil triangle-fan that
CN1MetalApplyPolygonStencilClip uses produces the degenerate triangle.
Fix at the Java boundary: flatten any non-rect ClipShape via midpoint
subdivision into a polyline GeneralPath before sending it down, so
only true polygon vertices reach the native side. Works for both the
global and mutable-image paths.
2. iOS Metal drawString skips the affine scale -- CoreText shapes the
line and the atlas rasterises glyphs at font.pointSize, so a quad
stretched by a 2x-4x viewBox transform smears the bitmap on the GPU.
CN1MetalDrawString now reads the effective screen scale from
currentTransform (column magnitudes of the 2x2), rasterises the atlas
at font.pointSize * scale via [font fontWithSize:...], and divides
every glyph position / bearing / bbox / slot dimension by the same
factor so the vertex coords stay in caller-side space. The vertex
shader re-applies the same scale via the transform and the result is
a 1:1 atlas sample. Pure rotation / translation keeps the fast
useScaledFont == NO path.
3. Android (and iOS Metal once #1 unmasked it) gradient_circle.svg
double-circle -- the gradient fill landed below the dark-blue
stroke instead of inside it. LinearGradientPaint.paint(g, w, h)
captured g.getTranslateX()/Y(), zeroed them out, and baked them into
t2 via t2.translate(startX + tx, startY + ty). On every active port
(isTranslationSupported() == false) Graphics.setTransform already
conjugates the user matrix with T(xTranslate) so the cell offset
applies at the screen level; baking tx/ty inside a translate that
sits before the SVG scale meant the offset went through that scale
twice (sy * label_Y extra) and slid the gradient fill off the
circle. Drop the dance entirely -- build t2 as
T * Translate(startX, startY) * Rotate * Translate(0, -ph/2) and let
the existing conjugation re-apply the screen-level offset.
Also drops the "Known port-side rendering bugs the goldens encode" block
from SVGStaticScreenshotTest's javadoc -- those items are this PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fd0516d commit 5a2a001
4 files changed
Lines changed: 324 additions & 49 deletions
File tree
- CodenameOne/src/com/codename1/ui
- Ports/iOSPort
- nativeSources
- src/com/codename1/impl/ios
- scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests
Lines changed: 20 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | 184 | | |
186 | 185 | | |
187 | 186 | | |
| |||
200 | 199 | | |
201 | 200 | | |
202 | 201 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
208 | 222 | | |
209 | 223 | | |
210 | 224 | | |
| |||
293 | 307 | | |
294 | 308 | | |
295 | 309 | | |
296 | | - | |
297 | 310 | | |
298 | 311 | | |
299 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
758 | 797 | | |
759 | 798 | | |
760 | 799 | | |
761 | | - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
762 | 823 | | |
763 | 824 | | |
764 | | - | |
| 825 | + | |
765 | 826 | | |
766 | 827 | | |
767 | 828 | | |
| |||
774 | 835 | | |
775 | 836 | | |
776 | 837 | | |
777 | | - | |
| 838 | + | |
778 | 839 | | |
779 | 840 | | |
780 | 841 | | |
| |||
798 | 859 | | |
799 | 860 | | |
800 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
801 | 868 | | |
| 869 | + | |
802 | 870 | | |
803 | 871 | | |
804 | 872 | | |
| |||
838 | 906 | | |
839 | 907 | | |
840 | 908 | | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
846 | 927 | | |
847 | 928 | | |
848 | 929 | | |
| |||
0 commit comments