Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
91aeda7b
Unverified
Commit
91aeda7b
authored
Nov 22, 2022
by
Jim Graham
Committed by
GitHub
Nov 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new pushImageFilter offset parameter to fix the transform of the children (#113673)
parent
f4ee61a3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
3 deletions
+61
-3
layer.dart
packages/flutter/lib/src/rendering/layer.dart
+3
-1
image_filter.dart
packages/flutter/lib/src/widgets/image_filter.dart
+3
-2
image_filter_test.dart
packages/flutter/test/widgets/image_filter_test.dart
+55
-0
No files found.
packages/flutter/lib/src/rendering/layer.dart
View file @
91aeda7b
...
...
@@ -1816,13 +1816,14 @@ class ColorFilterLayer extends ContainerLayer {
}
/// A composite layer that applies an [ImageFilter] to its children.
class
ImageFilterLayer
extends
Container
Layer
{
class
ImageFilterLayer
extends
Offset
Layer
{
/// Creates a layer that applies an [ImageFilter] to its children.
///
/// The [imageFilter] property must be non-null before the compositing phase
/// of the pipeline.
ImageFilterLayer
({
ui
.
ImageFilter
?
imageFilter
,
super
.
offset
,
})
:
_imageFilter
=
imageFilter
;
/// The image filter to apply to children.
...
...
@@ -1844,6 +1845,7 @@ class ImageFilterLayer extends ContainerLayer {
assert
(
imageFilter
!=
null
);
engineLayer
=
builder
.
pushImageFilter
(
imageFilter
!,
offset:
offset
,
oldLayer:
_engineLayer
as
ui
.
ImageFilterEngineLayer
?,
);
addChildrenToScene
(
builder
);
...
...
packages/flutter/lib/src/widgets/image_filter.dart
View file @
91aeda7b
...
...
@@ -105,12 +105,13 @@ class _ImageFilterRenderObject extends RenderProxyBox {
}
if
(
layer
==
null
)
{
layer
=
ImageFilterLayer
(
imageFilter:
imageFilter
);
layer
=
ImageFilterLayer
(
imageFilter:
imageFilter
,
offset:
offset
);
}
else
{
final
ImageFilterLayer
filterLayer
=
layer
!
as
ImageFilterLayer
;
filterLayer
.
imageFilter
=
imageFilter
;
filterLayer
.
offset
=
offset
;
}
context
.
pushLayer
(
layer
!,
super
.
paint
,
offset
);
context
.
pushLayer
(
layer
!,
super
.
paint
,
Offset
.
zero
);
assert
(()
{
layer
!.
debugCreator
=
debugCreator
;
return
true
;
...
...
packages/flutter/test/widgets/image_filter_test.dart
View file @
91aeda7b
...
...
@@ -6,6 +6,7 @@
// machines.
@Tags
(<
String
>[
'reduced-test-set'
])
import
'dart:math'
;
import
'dart:ui'
;
import
'package:flutter/foundation.dart'
;
...
...
@@ -29,6 +30,24 @@ void main() {
);
});
testWidgets
(
'Image filter - blur with offset'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Transform
.
translate
(
offset:
const
Offset
(
50
,
50
),
child:
ImageFiltered
(
imageFilter:
ImageFilter
.
blur
(
sigmaX:
3.0
,
sigmaY:
3.0
),
child:
const
Placeholder
(),
),
),
),
);
await
expectLater
(
find
.
byType
(
ImageFiltered
),
matchesGoldenFile
(
'image_filter_blur_offset.png'
),
);
});
testWidgets
(
'Image filter - dilate'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
...
...
@@ -97,6 +116,42 @@ void main() {
);
});
testWidgets
(
'Image filter - matrix with offset'
,
(
WidgetTester
tester
)
async
{
final
Matrix4
matrix
=
Matrix4
.
rotationZ
(
pi
/
18
);
final
ImageFilter
matrixFilter
=
ImageFilter
.
matrix
(
matrix
.
storage
);
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Transform
.
translate
(
offset:
const
Offset
(
50
,
50
),
child:
ImageFiltered
(
imageFilter:
matrixFilter
,
child:
MaterialApp
(
title:
'Flutter Demo'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
),
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Matrix ImageFilter Test'
),
),
body:
const
Center
(
child:
Text
(
'Hooray!'
),
),
floatingActionButton:
FloatingActionButton
(
onPressed:
()
{
},
tooltip:
'Increment'
,
child:
const
Icon
(
Icons
.
add
),
),
),
),
),
),
),
);
await
expectLater
(
find
.
byType
(
ImageFiltered
),
matchesGoldenFile
(
'image_filter_matrix_offset.png'
),
);
});
testWidgets
(
'Image filter - reuses its layer'
,
(
WidgetTester
tester
)
async
{
Future
<
void
>
pumpWithSigma
(
double
sigma
)
async
{
await
tester
.
pumpWidget
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment