Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

The DrawGradient.m implementation on iOS previously rendered gradients using a full power-of-two (POT) quad, which caused the gradient to spill over the requested bounds and overlap neighboring elements. It also used full 0-1 texture coordinates, mapping the entire POT texture (including empty padding) to the quad.

This change:

  1. Modifies the vertex array to use the actual requested width and height instead of p2w/p2h.
  2. Calculates maxS and maxT texture coordinates based on the ratio of content size to texture size.
  3. Updates the texture coordinate array to GLfloat and maps the quad vertices to the valid content region (0,0) to (maxS, maxT).
  4. Updates glVertexAttribPointer to use GL_FLOAT for texture coordinates.
  5. Fixes the GRADIENT_TYPE_HORIZONTAL and GRADIENT_TYPE_VERTICAL cases where the coordinate logic was swapped (Horizontal now varies X, Vertical varies Y).

PR created automatically by Jules for task 6231960715145144739 started by @shai-almog

Fixed gradient drawing in iOS native port to use correct vertex sizes and texture coordinates, preventing overlap and incorrect scaling. Corrected swapped logic for horizontal and vertical gradient directions.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

@github-actions
Copy link

github-actions bot commented Dec 16, 2025

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator

shai-almog commented Dec 16, 2025

iOS screenshot updates

Compared 30 screenshots: 27 matched, 2 updated, 1 missing reference.

  • BrowserComponent — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    BrowserComponent
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as BrowserComponent.png in workflow artifacts.

  • graphics-draw-gradient — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-gradient
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 844x1835.
    Full-resolution PNG saved as graphics-draw-gradient.png in workflow artifacts.

  • graphics-draw-round-rect — missing reference. Reference screenshot missing at /Users/runner/work/CodenameOne/CodenameOne/scripts/ios/screenshots/graphics-draw-round-rect.png.

    graphics-draw-round-rect
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 844x1835.
    Full-resolution PNG saved as graphics-draw-round-rect.png in workflow artifacts.

- Fixed `DrawGradient.m` (OpenGL):
    - Corrected vertex sizes to use requested width/height instead of power-of-two texture dimensions to prevent overflow/overlap.
    - Implemented correct texture coordinate mapping (`maxS`, `maxT`) to avoid including padding.
    - Updated vertex array logic to use `GL_FLOAT` for texture coordinates.
    - Swapped logic for `GRADIENT_TYPE_HORIZONTAL` and `GRADIENT_TYPE_VERTICAL` to match standard coordinate system orientation.

- Fixed `IOSNative.m` (Mutable Images/CoreGraphics):
    - Updated `fillRectRadialGradientMutable` to respect the `x` and `y` arguments for both the fill rect and the radial gradient center point, preventing it from always drawing at (0,0).
- Fixed `DrawGradient.m` (OpenGL):
    - Corrected vertex sizes to use requested width/height instead of power-of-two texture dimensions to prevent overflow/overlap.
    - Implemented correct texture coordinate mapping (`maxS`, `maxT`) to avoid including padding.
    - Updated vertex array logic to use `GL_FLOAT` for texture coordinates.
    - Swapped logic for `GRADIENT_TYPE_HORIZONTAL` and `GRADIENT_TYPE_VERTICAL` to match standard coordinate system orientation.

- Fixed `IOSNative.m` (Mutable Images/CoreGraphics):
    - Updated `fillRectRadialGradientMutable` to respect the `x` and `y` arguments for both the fill rect and the radial gradient center point, preventing it from always drawing at (0,0).
    - Added proper clipping (`CGContextClipToRect`) to `fillRectRadialGradientMutable` to prevent gradients from bleeding outside their bounds.
    - Added missing `CGGradientRelease` to fix a memory leak.
    - Properly wrapped drawing calls in `CGContextSaveGState`/`CGContextRestoreGState` to isolate state changes.
@shai-almog shai-almog marked this pull request as ready for review December 16, 2025 16:52
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@shai-almog shai-almog merged commit e621e15 into master Dec 16, 2025
8 checks passed
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