<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->
Optimize the loadFontFromList method of SkiaFontCollection. Reduce the
generation of unnecessary FontMgr.
issue: https://github.com/flutter/flutter/issues/181439
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Co-authored-by: Mouad Debbar <mdebbar@google.com>
Adds wide gamut color support to macOS (matching iOS), upgrades the
surface pixel format from 10-bit BGRA10_XR to 16-bit float RGBA16Float
on both iOS and macOS when enabled, and fixes Impeller's blur filter P3
clamping on macOS.
**macOS Wide Gamut Support**
- Added DoesHardwareSupportWideGamut() hardware capability check
(MTLGPUFamilyApple2 or MTLGPUFamilyMac2)
- Wide gamut enabled when both hardware supports it and
FLTEnableWideGamut plist flag is YES
- Dynamic wide gamut switching when windows move between P3 and sRGB
displays
- Added flutter/screenshot method channel on macOS for integration
testing
**RGBA16Float Surface Format (iOS + macOS)**
- macOS IOSurface: kCVPixelFormatType_64RGBAHalf +
MTLPixelFormatRGBA16Float
- iOS CAMetalLayer: MTLPixelFormatRGBA16Float
- Image decoder: always uses kRGBA_F16_SkColorType for all wide gamut
images (previously only transparent images used 16-bit)
**Fix Blur P3 Clamping on macOS**
macOS uses the compositor/embedder path, not GPUSurfaceMetalImpeller, so
UpdateOffscreenLayerPixelFormat was never called. Added the call in
embedder.cc after wrapping the Metal resolve texture.
**Why RGBA16Float over BGRA10_XR?**
BGRA10_XR has only 10 bits per channel — values outside sRGB gamut get
clamped in intermediate render targets (e.g. blur filters). RGBA16Float
has 16 bits per channel with full floating-point range, preventing P3
color clamping in multi-pass rendering.
**Tests**
- 9 new iOS FlutterView unit tests verifying RGBA16Float pixel format
and extended sRGB color space
- Updated macOS FlutterSurfaceManagerTest for RGBA16Float, dynamic
switching, color space, and pixel format verification
- Updated image decoder and Impeller display list tests for
kR16G16B16A16Float
- 11 macOS/iOS integration tests: image, saveLayer, codecImage, none,
blur, drawnImage, container, linearGradient, radialGradient,
conicalGradient, sweepGradient
### Issues
https://github.com/flutter/flutter/issues/164557
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.
ASan had been disabled due to issues that were seen when the LUCI bots
were upgraded to Ubuntu 24. That upgrade was reverted, and ASan can be
run on the current Ubuntu 22 bots.
Fixes https://github.com/flutter/flutter/issues/181639
No bug
Gemini code review suggestion on a cp that should instead be made on
master.
https://github.com/flutter/flutter/pull/181732/files#r2747693178
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
https://github.com/flutter/flutter/pull/181157 introduced a call to the
glDebugMessageCallback API using a lambda as the argument. On Windows
builds this produces a warning about a nonstandard implicit conversion
when the Impeller GL API wrappers try to log the callback argument.
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->
### Problem
The P3-to-sRGB color conversion applies an affine matrix directly to
gamma-encoded values in both the C++ engine (`dl_color.cc`) and Dart
(`painting.dart`). This is mathematically incorrect — color space
conversion matrices must operate in linear light. The result is P3
colors that appear nearly identical to sRGB instead of showing the full
gamut difference.
For example, P3 `#1ECAD3` (30/255, 202/255, 211/255) converts to:
- **Old (wrong):** extendedSRGB (-0.12, 0.86, 0.87)
- **New (correct):** extendedSRGB (-0.38, 0.81, 0.84)
The red channel error of 0.26 is clearly visible — colors appear washed
out instead of vivid.
### Fix
Replace the single affine matrix multiply with the correct 3-step
pipeline:
1. **Linearize** — decode gamma via sRGB EOTF
2. **Transform** — apply 3x3 P3-to-sRGB matrix in linear space
3. **Encode** — re-apply gamma via sRGB OETF
Extended range (negative values from out-of-gamut colors) is handled by
mirroring the transfer function.
**C++ (`dl_color.cc`):** Replace affine matrix with `p3ToExtendedSrgb()`
using `double` precision.
**Dart (`painting.dart`):** Replace `_MatrixColorTransform` with
`_P3ToSrgbTransform` and `_SrgbToP3Transform` classes. Also fixes the
sRGB-to-P3 direction.
### Performance
Negligible. The C++ conversion runs once per paint setup in `ReadColor`,
not per frame or per pixel. The Dart conversion runs once per
`Color.withValues()` call.
### Tests
- **C++:** Added `ColorSpaceP3ToExtendedSRGBLinearLight` test in
`dl_color_unittests.cc`
- **Dart:** Added 3 tests in `colors_test.dart`: mid-range
P3→extendedSRGB, P3 green→extendedSRGB, sRGB→P3 round-trip
All new tests fail with the old code and pass with the fix. Existing
tests continue to pass.
## Issue:
https://github.com/flutter/flutter/issues/181717
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing. **New tests pass, can't
run golden tests!**
---------
Co-authored-by: gaaclarke <30870216+gaaclarke@users.noreply.github.com>
While testing with a different add-to-app
https://github.com/flutter/samples/pull/2787, an exception is sometimes
thrown when the resize is attempted because the callback comes from a
different thread. It is expected that the raster thread calls this but
with previous
[testing](https://github.com/mboetger/test-add-to-app/tree/content-sizing)
never caused this exception.
This PR ensures the resize happens on the UI thread. It also a flag to
ensure content sizing is disabled.
Fixes: https://github.com/flutter/flutter/issues/181573
## Pre-launch Checklist
- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.
Add ccache support when building the engine using a custom toolchain.
Fixes#180736
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
Updates the GLFW dependency to master and uses the EGL context creation
API on Linux. This allows Linux users to select an OpenGL implementation
when running the impeller playground tests by defining
`__EGL_VENDOR_LIBRARY_FILENAMES`.
For example, running
```
$ impeller_unittests --gtest_filter=Play/AiksTest.ToImageFromImage/OpenGLES
```
gives, in `description_gles.cc` ,
```
gl_version_string_ // OpenGL ES 3.2 NVIDIA 590.48.01
```
Then running
```
$ __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json impeller_unittests --gtest_filter=Play/AiksTest.ToImageFromImage/OpenGLES
```
```
gl_version_string_ // OpenGL ES 3.2 Mesa 25.3.3-arch1.3
```
Fixes#181258
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Adds support for backtraces when requested in host builds
### Before:
```
Note: Google Test filter = Play/RendererTest.BabysFirstTriangle/OpenGLES
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Play/RendererTest
[ RUN ] Play/RendererTest.BabysFirstTriangle/OpenGLES
...
Segmentation fault (core dumped) __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json ./out/host_debug_unopt/exe.unstripped/impeller_unittests --enable_playground --gtest_filter='Play/RendererTest.BabysFirstTriangle/OpenGLES'
```
### After:
```
Note: Google Test filter = Play/RendererTest.BabysFirstTriangle/OpenGLES
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Play/RendererTest
[ RUN ] Play/RendererTest.BabysFirstTriangle/OpenGLES
...
[symbolize_elf.inc : 379] RAW: Unable to get high fd: rc=0, limit=1024
[ERROR:flutter/fml/backtrace.cc(108)] Caught signal SIGSEGV during program execution.
Frame 0: 0x55831f19fbc4 impeller::DeviceBufferGLES::GetBufferData()
Frame 1: 0x55831f186cd3 impeller::BufferBindingsGLES::BindUniformBufferV2()
Frame 2: 0x55831f186b66 impeller::BufferBindingsGLES::BindUniformBufferV3()
Frame 3: 0x55831f1861da impeller::BufferBindingsGLES::BindUniformBuffer()
Frame 4: 0x55831f185fea impeller::BufferBindingsGLES::BindUniformData()
Frame 5: 0x55831f1cb112 impeller::EncodeCommandsInReactor()
...
Segmentation fault (core dumped) __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json ./out/host_debug_unopt/exe.unstripped/impeller_unittests --enable_playground --gtest_filter='Play/RendererTest.BabysFirstTriangle/OpenGLES'
```
Fixes#181156
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->
Enables improved OpenGLES debug support in the playground tests if
[KHR_DEBUG](https://registry.khronos.org/OpenGL/extensions/KHR/KHR_debug.txt)
is available. Only activated on unoptimized builds (where `NDEBUG` is
not defined)
Example:
Before:
```
[FATAL:flutter/impeller/renderer/backend/gles/proc_table_gles.h(44)] Fatal GL Error GL_INVALID_ENUM(1280) encountered on call to glBindBuffer
```
After:
```
[ERROR:flutter/impeller/playground/backend/gles/playground_impl_gles.cc(146)] GL Error: GL_INVALID_ENUM error generated. Invalid buffer target enum.
[FATAL:flutter/impeller/renderer/backend/gles/proc_table_gles.h(44)] Fatal GL Error GL_INVALID_ENUM(1280) encountered on call to glBindBuffer
```
Closes#179329
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
RenderPass holds a list of BufferViews that may hold raw pointers to
DeviceBuffers. HostBuffers and the underlying DeviceBuffers must not be
deleted until the RenderPass is no longer using them.
See https://github.com/flutter/flutter/issues/181287
Fixes#178619
Uses defensive null check (?.) instead of null assertion (!) when
calling focusWithoutScroll() on focusedFormElement in
GloballyPositionedTextEditingStrategy.placeElement().
This prevents a crash that can occur due to a race condition where
hasAutofillGroup returns true but focusedFormElement is null by the time
it's accessed.
Does what it says on the tin!
This PR adds struct member information to the runtime flatbuffer format.
This allows dart code to introspect structs at runtime.
Also modifies the runtime_stage tests to verify formats for all
supported uniform types.
Bubbles up struct member information to dart, and uses that information
to grab struct members in `getUniformX` related functions. This is
necessary on Vulkan because all uniforms are packaged into a single
struct. Also re-enables tests
## Pre-launch Checklist
- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.
Instead of using fake touch events.
Before this patch `FlutterViewController` sends two fake touch events
(down and up), at `(0, 0)` to the framework to signal that the status
bar is tapped on iOS. The scaffold widget and the cupertino page
scaffold widget set up gesture detectors to listen for these fake taps,
and scroll the "primary" scrollable container to the top in response.
This messaging mechanism is sometimes ambiguous, as the framework may
interpret that as a pair of regular pointer tap events (for instance in
#177992 the modal barrier claims the tap gesture and as a result the
modal barrier is dismissed by the fake touch events). This PR changes
that to communicate the status bar tap event via a new system channel,
and dispatch the events via `WidgetsBindingObserver`s in the framework.
See also
https://github.com/flutter/flutter/issues/177992#issuecomment-3499913265Fixes#177992, fixes#175606
It appears that UIKit also has access to the coordinates of the touch
events to determine which scrollable view(s?) to dispatch the scroll to
top event to.
```objc
* frame #0: 0x00000001032f6520 UIPlayground.debug.dylib`MyScrollViewController.scrollViewShouldScrollToTop(scrollView=0x0000000106014800) at UIScrollView.swift:13:3
frame #2: 0x00000001867c9300 UIKitCore`-[UIScrollView _scrollToTopIfPossible:] + 316
frame #3: 0x00000001867c9604 UIKitCore`-[UIScrollView _scrollToTopFromTouchAtScreenLocation:resultHandler:] + 40
frame #4: 0x0000000186299bbc UIKitCore`__71-[UIWindow _scrollToTopViewsUnderScreenPointIfNecessary:resultHandler:]_block_invoke.358 + 168
frame #5: 0x000000018629981c UIKitCore`-[UIWindow _scrollToTopViewsUnderScreenPointIfNecessary:resultHandler:] + 1212
frame #6: 0x000000018581ed8c UIKitCore`-[UIStatusBarManager _handleScrollToTopAtXPosition:] + 192
frame #7: 0x000000018581eb60 UIKitCore`-[UIStatusBarManager handleTapAction:] + 60
```
Unfortunately that information is not available to user application. The
iOS accessibility bridge currently does create dummy UIScrollViews for
each scrollable in the accessibility tree so may be we can take
advantage of that in the future.
## Pre-launch Checklist
- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
The driver on PIxel 10 requires Flutter to set the `engine` version to
something higher than 1.0. We had previous set the application version
without effect. With this change, I see we can get a valid vulkan
context.
- ran some testing against reported errors (saw none)
- compiled and ran wonderous with validation layers (runs)
- still researching
towards: #179812
> On a pixel 10, the Vulkan engine version must be bumped up past 1.0
and any other additional checks gating Vulkan removed. It must be
confirmed that Impeller is able to create a Vulkan context.
Pixel 10 gets a Vulkan context with just the engine version bump.
> The usual sample applications must render accurately.
wonderous and failing code passes and renders correctly
> The reduced test cases in the internal doc must be tested.
it does.
> If testing is successful, the engine version update may be committed.
This is necessary for enabling Vulkan on Pixel 10 but not sufficient to
ensure stability of newer Vulkan enabled Impeller applications on Pixel
10 devices that have not yet been updated.
This PR does that.
> Impeller must detect the driver version and self-reject Vulkan on
device older than the current Pixel 10 GPU driver version. The IHV
reports that a safe conservative driver version is >= 25.1 and any
verification must happen on versions past this. Impeller should still
base its checks on the driver version that we verify correctness on.
What we have today works well and it is not advised to introduce
instability for the sake of enabling Vulkan on this device.
Done - driver_version appears to be a build number, so monotonically
increasing.
Fixes: https://github.com/flutter/flutter/issues/173104
We were precomputing the perspective adjustment inside the clipping
vertex shader, which prevented the GPU from performing correct clipping
against the camera plane.
We had been interpolating the points backwards in the
`Rect::TransformAndClipBounds` code.
When we transform a rectangle under a perspective transform, some of the
points may generate a homogenous bias (W) that is less than 0. This is a
special condition that means that the point was transformed "behind the
camera" (this is one way of looking at it and helps explain why we avoid
such values). In order for it to contribute properly to the bounds in
front of the "camera", it needs to be moved back into the positive (W>0)
space. We do this by interpolating from that out of bounds coordinate to
either of its adjacent neighbors which are in bounds (i.e. their W>0) to
move the point to a bias value that is just slightly in the "in bounds"
half-space - we choose W=(1/2^14) as our "in bounds" bias value.
Unfortunately, the code to interpolate the 2 coordinates was written
with conflicting definitions of which direction we computed the `t`
value and which direction we applied it to the 2 coordinates - thus
generating nonsensical values.
This turned up while debugging a fix for
https://github.com/flutter/flutter/issues/173104 where we fixed the
transform logic in the clip code, but the rectangle was still partially
clipped due to a bad result from the `GetCoverage` method of the rect
geometry code. Note that this fix alone does not correct the problem in
that Issue, it merely fixes a needed utility method that the fix will
rely on.
- The
[shader](3b20617345/engine/src/flutter/lib/ui/fixtures/shaders/general_shaders/vec3_uniform.frag)
has `uniform vec3[4] color_array;` and sets `fragColor =
vec4(color_array[3].xyz, 1);`. Update the test to use the correct
indexes for `color_array[3]`: 9, 10, 11 instead of 12, 13, 14.
- Skip the test for metal. Metal seems like it has some weird index
padding issue. From testing it out:
- `color_array[0].xyz` is set when setting indexes 0, 1, 2, as expected.
- `color_array[1].xyz` should use indexes 3, 4, 5. But it seems to use
indexes 4, 5, 6. Maybe there's some incorrect math making it skip index
3.
- `color_array[2].xyz` should use indexes 6, 7, 8. But it seems to use
indexes 8, 9, 10. Maybe there's some incorrect math making it skip
indexes 3 and 7.
- `color_array[3].xyz` should use indexes 9, 10, 11. But it seems to be
impossible to set. Maybe it skips indexes 3, 7, and 11 and then tries to
look at out-of-bounds indexes 12, 13, 14?
- Fix incorrect logic in the `_expectShaderRendersColor()` method.
- The 4 bytes for each pixel of an image are in the format `0xRRGGBBAA`.
- This method used to use `renderedBytes.buffer.asUint32List()`. This
reads 4 bytes to a Uint32, but uses `Endian.host` endianness. Maybe this
differs on different platforms, but on my Mac this is little endian. So
the image's `0xRRGGBBAA` bytes are read into a Uint32 as `0xAABBGGRR`.
- This is then compared to the target `Color.value`, which is in ARGB32
format: `0xAARRGGBB`.
- So it's comparing the each image's pixel as `0xAABBGGRR` to the target
color as `0xAARRGGBB`. It switches the RR and BB channels for every
comparison.
- This did not result in any test failures because
`_expectShaderRendersColor()` is only ever used as a helper function for
`_expectShaderRendersGreen()` and `_expectShaderRendersBlack()`. And
(un)luckily, those perfectly ignore the RR and BB channels.
- Fix the logic by reading each pixel's bytes with separate `getUint8()`
calls and parsing them into a `Color` with `fromARGB()`, using the
correct byte offsets for each channel.
Partially addresses #180932. Re-enables the test for Vulkan, but it's
still disabled for Metal.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
* Set byte_length to the total byte length of all array elements
* The runtime stage flatbuffer will represent an unspecified
array_elements value as the default value of zero. Convert that to an
empty std::optional in the metadata.
Fixes https://github.com/flutter/flutter/issues/180068
See the conversation at
https://github.com/dart-lang/sdk/issues/59764#issuecomment-3599823329
for more context.
Prior to this, these `Color` fix_data rules would only be visible to
users that explicitly import `package: flutter/painting.dart`. This PR
broadens the applicability of these rules so they are visible for users
that import `dart:ui`, or import any one of the `flutter/` packages that
expose `Color`.
#### Enabling `Color` fix_data fixes for `dart:ui`:
- Adds a `fix_data.yaml` file for `'dart:ui'` fixes to
`engine/src/flutter/lib/ui/`. This contains `Color` fixes copied from
`packages/flutter/lib/fix_data/fix_painting.yaml`.
- Typically `fix_data` files go in a Dart package's `lib/` directory.
But `dart:ui` is not a standard Dart package and doesn't have a typical
`lib` directory. This directory is the closest thing to a `lib`
directory for the `dart:ui` package that I can find. It contains the
Dart code that implements the `dart:ui` package.
- The actual Dart package for `dart:ui` is generated by
`engine/src/flutter/sky/packages/sky_engine/BUILD.gn` with the package
name `sky_engine`. I updated the build rule to copy the new
`fix_data.yaml` file into the generated `sky_engine/lib/` directory.
#### Enabling `Color` fix_data fixes for `package:flutter/` libraries:
- The `Color` fixes from
`packages/flutter/lib/fix_data/fix_painting.yaml` are remove, and copied
to over to a new `packages/flutter/lib/fix_data/fix_dart_ui.yaml` file.
- This fix_data file specifies all the `flutter/` libraries which export
`Color`. With this change, importing any of these libraries will surface
the `Color` fixes, rather than only surfacing the fixes only when
`package:flutter/painting.dart` is specifically imported.
#### Other related changes
- Updates some entries in `fix_cupertino.yaml` and `fix_material.yaml`
which used the old `Color.withOpacity` method.
- Updates existing flutter package `test_fixes` tests.
- The color tests from the `painting` `test_fixes` test are moved to a
new `dart_ui` test. Note that this only runs the test with only one of
the `flutter/` libraries specified in `fix_dart_ui.yaml`
(`animation.dart`). Ideally I think we should run this test while
independently importing each one of the `flutter/` libraries specified
in `fix_dart_ui.yaml`. But AFAICT there's no easy way to do this without
creating a lot of duplicate code.
- There is no `fix_data` test for `dart:ui`. Because this isn't a
standard Dart library, I don't think there's an easy way to test its
`fix_data.yaml` in a similar way to the `flutter/` library fixes.
Somewhat fixes#180933 (makes the fixes more broadly available).
Somewhat addresses
https://github.com/dart-lang/sdk/issues/59764#issuecomment-3599823329
(establishes a way to use `fix_data.yaml` files for `dart:X` libraries).
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md