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
b79f4e31
Commit
b79f4e31
authored
Feb 02, 2018
by
Amir Hardon
Committed by
amirh
Feb 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Use RRects instead of Paths when possible in Material. (#14404)"
This reverts commit
d9ef7df9
.
parent
6494dde3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
68 deletions
+17
-68
material.dart
packages/flutter/lib/src/material/material.dart
+1
-44
ink_well_test.dart
packages/flutter/test/material/ink_well_test.dart
+3
-3
material_test.dart
packages/flutter/test/material/material_test.dart
+13
-13
recording_canvas.dart
packages/flutter/test/rendering/recording_canvas.dart
+0
-8
No files found.
packages/flutter/lib/src/material/material.dart
View file @
b79f4e31
...
...
@@ -305,15 +305,7 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
if
(
widget
.
type
==
MaterialType
.
transparency
)
return
_clipToShape
(
shape:
shape
,
contents:
contents
);
// PhysicalModel performs better than PhysicalShape, so we use it when
// possible.
// This is not expected, and we do this as a temporary workaround until the
// shape performance regression is resolved, see:
// https://github.com/flutter/flutter/issues/14403
if
(
shape
.
runtimeType
==
CircleBorder
||
shape
.
runtimeType
==
RoundedRectangleBorder
)
return
_physicalModelInterior
(
contents
,
shape
,
backgroundColor
);
return
new
_MaterialInterior
(
curve:
Curves
.
fastOutSlowIn
,
duration:
kThemeChangeDuration
,
...
...
@@ -323,45 +315,10 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
shadowColor:
widget
.
shadowColor
,
child:
contents
,
);
}
Widget
_physicalModelInterior
(
Widget
contents
,
ShapeBorder
shape
,
Color
backgroundColor
)
{
assert
(
shape
.
runtimeType
==
CircleBorder
||
shape
.
runtimeType
==
RoundedRectangleBorder
);
BoxShape
boxShape
;
BorderRadius
borderRadius
;
if
(
shape
.
runtimeType
==
CircleBorder
)
{
boxShape
=
BoxShape
.
circle
;
borderRadius
=
BorderRadius
.
zero
;
}
else
{
final
RoundedRectangleBorder
border
=
shape
;
boxShape
=
BoxShape
.
rectangle
;
borderRadius
=
border
.
borderRadius
;
}
return
new
AnimatedPhysicalModel
(
curve:
Curves
.
fastOutSlowIn
,
duration:
kThemeChangeDuration
,
shape:
boxShape
,
borderRadius:
borderRadius
,
elevation:
widget
.
elevation
,
color:
backgroundColor
,
shadowColor:
widget
.
shadowColor
,
animateColor:
false
,
child:
contents
,
);
}
static
Widget
_clipToShape
({
ShapeBorder
shape
,
Widget
contents
})
{
// ClipRRect performs better than ClipPath, so we use it when possible.
// This is not expected, and we do this as a temporary workaround until the
// shape performance regression is resolved, see:
// https://github.com/flutter/flutter/issues/14403
if
(
shape
.
runtimeType
==
RoundedRectangleBorder
)
{
final
RoundedRectangleBorder
border
=
shape
;
return
new
ClipRRect
(
borderRadius:
border
.
borderRadius
,
child:
contents
,
);
}
return
new
ClipPath
(
child:
contents
,
clipper:
new
ShapeBorderClipper
(
...
...
packages/flutter/test/material/ink_well_test.dart
View file @
b79f4e31
...
...
@@ -140,17 +140,17 @@ void main() {
),
),
);
expect
(
tester
.
renderObject
<
RenderProxyBox
>(
find
.
byType
(
Physical
Model
)).
child
,
paintsNothing
);
expect
(
tester
.
renderObject
<
RenderProxyBox
>(
find
.
byType
(
Physical
Shape
)).
child
,
paintsNothing
);
await
tester
.
tap
(
find
.
byType
(
InkWell
));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
tester
.
renderObject
<
RenderProxyBox
>(
find
.
byType
(
Physical
Model
)).
child
,
paints
..
circle
());
expect
(
tester
.
renderObject
<
RenderProxyBox
>(
find
.
byType
(
Physical
Shape
)).
child
,
paints
..
circle
());
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0.0
,
-
1000.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0.0
,
1000.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
tester
.
renderObject
<
RenderProxyBox
>(
find
.
byType
(
Physical
Model
)).
child
,
tester
.
renderObject
<
RenderProxyBox
>(
find
.
byType
(
Physical
Shape
)).
child
,
keepAlive
?
(
paints
..
circle
())
:
paintsNothing
,
);
}
...
...
packages/flutter/test/material/material_test.dart
View file @
b79f4e31
...
...
@@ -29,8 +29,8 @@ Widget buildMaterial(
);
}
RenderPhysical
Model
getShadow
(
WidgetTester
tester
)
{
return
tester
.
renderObject
(
find
.
byType
(
Physical
Model
));
RenderPhysical
Shape
getShadow
(
WidgetTester
tester
)
{
return
tester
.
renderObject
(
find
.
byType
(
Physical
Shape
));
}
class
PaintRecorder
extends
CustomPainter
{
...
...
@@ -122,23 +122,23 @@ void main() {
// a kThemeChangeDuration time interval.
await
tester
.
pumpWidget
(
buildMaterial
(
elevation:
0.0
));
final
RenderPhysical
Model
modelA
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelA
=
getShadow
(
tester
);
expect
(
modelA
.
elevation
,
equals
(
0.0
));
await
tester
.
pumpWidget
(
buildMaterial
(
elevation:
9.0
));
final
RenderPhysical
Model
modelB
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelB
=
getShadow
(
tester
);
expect
(
modelB
.
elevation
,
equals
(
0.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
final
RenderPhysical
Model
modelC
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelC
=
getShadow
(
tester
);
expect
(
modelC
.
elevation
,
closeTo
(
0.0
,
0.001
));
await
tester
.
pump
(
kThemeChangeDuration
~/
2
);
final
RenderPhysical
Model
modelD
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelD
=
getShadow
(
tester
);
expect
(
modelD
.
elevation
,
isNot
(
closeTo
(
0.0
,
0.001
)));
await
tester
.
pump
(
kThemeChangeDuration
);
final
RenderPhysical
Model
modelE
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelE
=
getShadow
(
tester
);
expect
(
modelE
.
elevation
,
equals
(
9.0
));
});
...
...
@@ -147,23 +147,23 @@ void main() {
// a kThemeChangeDuration time interval.
await
tester
.
pumpWidget
(
buildMaterial
(
shadowColor:
const
Color
(
0xFF00FF00
)));
final
RenderPhysical
Model
modelA
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelA
=
getShadow
(
tester
);
expect
(
modelA
.
shadowColor
,
equals
(
const
Color
(
0xFF00FF00
)));
await
tester
.
pumpWidget
(
buildMaterial
(
shadowColor:
const
Color
(
0xFFFF0000
)));
final
RenderPhysical
Model
modelB
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelB
=
getShadow
(
tester
);
expect
(
modelB
.
shadowColor
,
equals
(
const
Color
(
0xFF00FF00
)));
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
final
RenderPhysical
Model
modelC
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelC
=
getShadow
(
tester
);
expect
(
modelC
.
shadowColor
,
within
<
Color
>(
distance:
1
,
from:
const
Color
(
0xFF00FF00
)));
await
tester
.
pump
(
kThemeChangeDuration
~/
2
);
final
RenderPhysical
Model
modelD
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelD
=
getShadow
(
tester
);
expect
(
modelD
.
shadowColor
,
isNot
(
within
<
Color
>(
distance:
1
,
from:
const
Color
(
0xFF00FF00
))));
await
tester
.
pump
(
kThemeChangeDuration
);
final
RenderPhysical
Model
modelE
=
getShadow
(
tester
);
final
RenderPhysical
Shape
modelE
=
getShadow
(
tester
);
expect
(
modelE
.
shadowColor
,
equals
(
const
Color
(
0xFFFF0000
)));
});
...
...
@@ -178,7 +178,7 @@ void main() {
)
);
expect
(
find
.
byKey
(
materialKey
),
clipsWithBoundingR
Rect
(
borderRadius:
BorderRadius
.
zero
)
);
expect
(
find
.
byKey
(
materialKey
),
clipsWithBoundingR
ect
);
});
testWidgets
(
'clips to rounded rect when borderRadius provided'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/rendering/recording_canvas.dart
View file @
b79f4e31
...
...
@@ -110,14 +110,6 @@ class TestRecordingPaintingContext implements PaintingContext {
canvas
.
restore
();
}
@override
void
pushClipRRect
(
bool
needsCompositing
,
Offset
offset
,
Rect
bounds
,
RRect
clipRRect
,
PaintingContextCallback
painter
)
{
canvas
.
save
();
canvas
.
clipRRect
(
clipRRect
.
shift
(
offset
));
painter
(
this
,
offset
);
canvas
.
restore
();
}
@override
void
pushClipPath
(
bool
needsCompositing
,
Offset
offset
,
Rect
bounds
,
Path
clipPath
,
PaintingContextCallback
painter
)
{
canvas
...
...
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