-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#56936Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work liste: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsfound in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27Found to occur in 3.27has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team
Description
Steps to reproduce
Put a CustomPaint widget, that paint a shader, into an Opacity widget
Expected results
The Opacity should be applied on the painted shader
Actual results
The Opacity is not applied
Code sample
Code sample
import 'dart:ui' as ui;
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
const MyApp({
super.key,
});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: FutureBuilder(
future: () async {
final imageBytes = await rootBundle.load('lib/assets/img.jpeg');
final image = await decodeImageFromList(imageBytes.buffer.asUint8List());
final program = await ui.FragmentProgram.fromAsset('lib/assets/simple.frag');
return (image, program);
}(),
builder: (context, snapshot) {
if (snapshot.hasData == false) {
return const Center(child: CircularProgressIndicator());
}
final image = snapshot.data!.$1;
final program = snapshot.data!.$2;
return Opacity(
opacity: 0.5,
child: Center(
child: FittedBox(
child: SizedBox(
width: image.width.toDouble(),
height: image.height.toDouble(),
child: CustomPaint(
painter: MyCustomPainter(
image: image,
program: program,
),
),
),
),
),
);
},
),
),
);
}
}
class MyCustomPainter extends CustomPainter {
const MyCustomPainter({
required this.image,
required this.program,
});
final ui.Image image;
final ui.FragmentProgram program;
@override
void paint(Canvas canvas, Size size) {
final shader = program.fragmentShader();
shader.setFloat(0, image.width.toDouble());
shader.setFloat(1, image.height.toDouble());
shader.setImageSampler(0, image);
final paint = Paint()..shader = shader;
canvas.drawRect(Offset.zero & size, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}Shader
#include <flutter/runtime_effect.glsl>
uniform vec2 uSize;
uniform sampler2D uTexture;
out vec4 fragColor;
void main() {
vec2 uv = FlutterFragCoord() / uSize;
fragColor = texture(uTexture, uv);
}Screenshots or Video
Logs
No response
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.5 23F79 darwin-arm64, locale en-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] IntelliJ IDEA Community Edition (version 2024.2.1)
[✓] VS Code (version 1.95.2)
[✓] Connected device (5 available)
! Error: Browsing on the local area network for Giacomo’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• No issues found!Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work liste: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsfound in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27Found to occur in 3.27has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team

