Skip to content

feat(Graphics): add isVisible(x,y,w,h) primitive (#3846)#5129

Merged
shai-almog merged 2 commits into
masterfrom
fix-3846-graphics-isvisible
May 31, 2026
Merged

feat(Graphics): add isVisible(x,y,w,h) primitive (#3846)#5129
shai-almog merged 2 commits into
masterfrom
fix-3846-graphics-isvisible

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Add `Graphics#isVisible(int x, int y, int w, int h)` returning whether the rect intersects the current clip (translation-aware).
  • Enables off-screen culling so zoomed canvases skip image decode/scale for content outside the visible window.

Fixes #3846.

Test plan

  • 5 new GraphicsTest cases (inside, intersecting, outside, translated, degenerate). All 22 tests pass.

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.

Native Android coverage

  • 📊 Line coverage: 12.86% (7484/58189 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.45% (37449/358309), branch 4.37% (1474/33720), complexity 5.47% (1775/32474), method 9.53% (1454/15256), class 15.56% (331/2127)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 12.86% (7484/58189 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.45% (37449/358309), branch 4.37% (1474/33720), complexity 5.47% (1775/32474), method 9.53% (1454/15256), class 15.56% (331/2127)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 781.000 ms
Base64 CN1 encode 193.000 ms
Base64 encode ratio (CN1/native) 0.247x (75.3% faster)
Base64 native decode 703.000 ms
Base64 CN1 decode 228.000 ms
Base64 decode ratio (CN1/native) 0.324x (67.6% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.
✅ Native Mac screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 91 seconds

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 607.000 ms
Base64 CN1 encode 1114.000 ms
Base64 encode ratio (CN1/native) 1.835x (83.5% slower)
Base64 native decode 336.000 ms
Base64 CN1 decode 831.000 ms
Base64 decode ratio (CN1/native) 2.473x (147.3% slower)
Base64 SIMD encode 358.000 ms
Base64 encode ratio (SIMD/native) 0.590x (41.0% faster)
Base64 encode ratio (SIMD/CN1) 0.321x (67.9% faster)
Base64 SIMD decode 354.000 ms
Base64 decode ratio (SIMD/native) 1.054x (5.4% slower)
Base64 decode ratio (SIMD/CN1) 0.426x (57.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 56.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.161x (83.9% faster)
Image applyMask (SIMD off) 131.000 ms
Image applyMask (SIMD on) 73.000 ms
Image applyMask ratio (SIMD on/off) 0.557x (44.3% faster)
Image modifyAlpha (SIMD off) 127.000 ms
Image modifyAlpha (SIMD on) 66.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.520x (48.0% faster)
Image modifyAlpha removeColor (SIMD off) 147.000 ms
Image modifyAlpha removeColor (SIMD on) 65.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.442x (55.8% faster)
Image PNG encode (SIMD off) 872.000 ms
Image PNG encode (SIMD on) 716.000 ms
Image PNG encode ratio (SIMD on/off) 0.821x (17.9% faster)
Image JPEG encode 378.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.
✅ Native iOS Metal screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 185 seconds

Build and Run Timing

Metric Duration
Simulator Boot 57000 ms
Simulator Boot (Run) 1000 ms
App Install 12000 ms
App Launch 4000 ms
Test Execution 282000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 640.000 ms
Base64 CN1 encode 1356.000 ms
Base64 encode ratio (CN1/native) 2.119x (111.9% slower)
Base64 native decode 303.000 ms
Base64 CN1 decode 991.000 ms
Base64 decode ratio (CN1/native) 3.271x (227.1% slower)
Base64 SIMD encode 423.000 ms
Base64 encode ratio (SIMD/native) 0.661x (33.9% faster)
Base64 encode ratio (SIMD/CN1) 0.312x (68.8% faster)
Base64 SIMD decode 410.000 ms
Base64 decode ratio (SIMD/native) 1.353x (35.3% slower)
Base64 decode ratio (SIMD/CN1) 0.414x (58.6% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 59.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.153x (84.7% faster)
Image applyMask (SIMD off) 128.000 ms
Image applyMask (SIMD on) 55.000 ms
Image applyMask ratio (SIMD on/off) 0.430x (57.0% faster)
Image modifyAlpha (SIMD off) 120.000 ms
Image modifyAlpha (SIMD on) 82.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.683x (31.7% faster)
Image modifyAlpha removeColor (SIMD off) 140.000 ms
Image modifyAlpha removeColor (SIMD on) 61.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.436x (56.4% faster)
Image PNG encode (SIMD off) 1079.000 ms
Image PNG encode (SIMD on) 1009.000 ms
Image PNG encode ratio (SIMD on/off) 0.935x (6.5% faster)
Image JPEG encode 589.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 224 seconds

Build and Run Timing

Metric Duration
Simulator Boot 75000 ms
Simulator Boot (Run) 1000 ms
App Install 15000 ms
App Launch 6000 ms
Test Execution 361000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 947.000 ms
Base64 CN1 encode 1995.000 ms
Base64 encode ratio (CN1/native) 2.107x (110.7% slower)
Base64 native decode 505.000 ms
Base64 CN1 decode 1342.000 ms
Base64 decode ratio (CN1/native) 2.657x (165.7% slower)
Base64 SIMD encode 503.000 ms
Base64 encode ratio (SIMD/native) 0.531x (46.9% faster)
Base64 encode ratio (SIMD/CN1) 0.252x (74.8% faster)
Base64 SIMD decode 466.000 ms
Base64 decode ratio (SIMD/native) 0.923x (7.7% faster)
Base64 decode ratio (SIMD/CN1) 0.347x (65.3% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 99.000 ms
Image createMask (SIMD on) 11.000 ms
Image createMask ratio (SIMD on/off) 0.111x (88.9% faster)
Image applyMask (SIMD off) 233.000 ms
Image applyMask (SIMD on) 149.000 ms
Image applyMask ratio (SIMD on/off) 0.639x (36.1% faster)
Image modifyAlpha (SIMD off) 287.000 ms
Image modifyAlpha (SIMD on) 106.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.369x (63.1% faster)
Image modifyAlpha removeColor (SIMD off) 279.000 ms
Image modifyAlpha removeColor (SIMD on) 106.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.380x (62.0% faster)
Image PNG encode (SIMD off) 1382.000 ms
Image PNG encode (SIMD on) 1066.000 ms
Image PNG encode ratio (SIMD on/off) 0.771x (22.9% faster)
Image JPEG encode 644.000 ms

…3846)

Adds Graphics#isVisible(x,y,w,h) that returns whether the given
rectangle (in current Graphics coordinates, after translation)
intersects the current clip. Lets callers skip expensive work like
image decode + scale for off-screen content during zoomed/scrolled
canvas rendering.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shai-almog shai-almog force-pushed the fix-3846-graphics-isvisible branch from 6b233ca to ec58e78 Compare May 31, 2026 01:23
@github-actions
Copy link
Copy Markdown
Contributor

Cloudflare Preview

Ant's javac uses US-ASCII for the framework build, so the em-dash in
the isVisible() Javadoc broke Build Android JDK 17 and build-test (17)
with "unmappable character (0xE2)" at line 409.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shai-almog shai-almog merged commit a00496d into master May 31, 2026
24 checks passed
@shai-almog shai-almog deleted the fix-3846-graphics-isvisible branch May 31, 2026 04:50
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.

Add a "is this visible" graphics primitive.

1 participant