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
8aa43149
Commit
8aa43149
authored
Mar 20, 2017
by
Jason Simmons
Committed by
GitHub
Mar 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render Material using a PhysicalModel with optional compositing (#8920)
parent
09b68504
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
22 deletions
+52
-22
material.dart
packages/flutter/lib/src/material/material.dart
+24
-7
object.dart
packages/flutter/lib/src/rendering/object.dart
+27
-11
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+1
-4
No files found.
packages/flutter/lib/src/material/material.dart
View file @
8aa43149
...
...
@@ -7,7 +7,6 @@ import 'package:flutter/rendering.dart';
import
'package:flutter/widgets.dart'
;
import
'constants.dart'
;
import
'shadows.dart'
;
import
'theme.dart'
;
/// Signature for the callback used by ink effects to obtain the rectangle for the effect.
...
...
@@ -228,14 +227,33 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
vsync:
this
,
)
);
if
(
config
.
type
==
MaterialType
.
circle
)
{
contents
=
new
ClipOval
(
child:
contents
);
}
else
if
(
kMaterialEdges
[
config
.
type
]
!=
null
)
{
contents
=
new
ClipRRect
(
borderRadius:
radius
,
child:
contents
contents
=
new
PhysicalModel
(
shape:
BoxShape
.
circle
,
elevation:
config
.
elevation
,
color:
backgroundColor
,
child:
contents
,
);
}
else
if
(
config
.
type
==
MaterialType
.
transparency
)
{
if
(
radius
==
null
)
{
contents
=
new
ClipRect
(
child:
contents
);
}
else
{
contents
=
new
ClipRRect
(
borderRadius:
radius
,
child:
contents
);
}
}
else
{
contents
=
new
PhysicalModel
(
shape:
BoxShape
.
rectangle
,
borderRadius:
radius
??
BorderRadius
.
zero
,
elevation:
config
.
elevation
,
color:
backgroundColor
,
child:
contents
,
);
}
if
(
config
.
type
!=
MaterialType
.
transparency
)
{
contents
=
new
AnimatedContainer
(
curve:
Curves
.
fastOutSlowIn
,
...
...
@@ -247,7 +265,6 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
child:
new
Container
(
decoration:
new
BoxDecoration
(
borderRadius:
radius
,
boxShadow:
config
.
elevation
==
0
?
null
:
kElevationToShadow
[
config
.
elevation
],
backgroundColor:
backgroundColor
,
shape:
config
.
type
==
MaterialType
.
circle
?
BoxShape
.
circle
:
BoxShape
.
rectangle
),
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
8aa43149
...
...
@@ -442,19 +442,35 @@ class PaintingContext {
/// * `color` is the background color.
/// * `painter` is a callback that will paint with the `clipRRect` applied. This
/// function calls the `painter` synchronously.
void
pushPhysicalModel
(
Offset
offset
,
Rect
bounds
,
RRect
clipRRect
,
int
elevation
,
Color
color
,
PaintingContextCallback
painter
)
{
void
pushPhysicalModel
(
bool
needsCompositing
,
Offset
offset
,
Rect
bounds
,
RRect
clipRRect
,
int
elevation
,
Color
color
,
PaintingContextCallback
painter
)
{
final
Rect
offsetBounds
=
bounds
.
shift
(
offset
);
final
RRect
offsetClipRRect
=
clipRRect
.
shift
(
offset
);
_stopRecordingIfNeeded
();
final
PhysicalModelLayer
physicalModel
=
new
PhysicalModelLayer
(
clipRRect:
offsetClipRRect
,
elevation:
elevation
,
color:
color
,
);
_appendLayer
(
physicalModel
);
final
PaintingContext
childContext
=
new
PaintingContext
.
_
(
physicalModel
,
offsetBounds
);
painter
(
childContext
,
offset
);
childContext
.
_stopRecordingIfNeeded
();
if
(
needsCompositing
)
{
_stopRecordingIfNeeded
();
final
PhysicalModelLayer
physicalModel
=
new
PhysicalModelLayer
(
clipRRect:
offsetClipRRect
,
elevation:
elevation
,
color:
color
,
);
_appendLayer
(
physicalModel
);
final
PaintingContext
childContext
=
new
PaintingContext
.
_
(
physicalModel
,
offsetBounds
);
painter
(
childContext
,
offset
);
childContext
.
_stopRecordingIfNeeded
();
}
else
{
if
(
elevation
!=
0
)
{
canvas
.
drawShadow
(
new
Path
()..
addRRect
(
offsetClipRRect
),
const
Color
(
0xFF000000
),
elevation
,
color
.
alpha
!=
0xFF
,
);
}
canvas
.
drawRRect
(
offsetClipRRect
,
new
Paint
()..
color
=
color
);
canvas
.
saveLayer
(
offsetBounds
,
_defaultPaint
);
canvas
.
clipRRect
(
offsetClipRRect
);
painter
(
this
,
offset
);
canvas
.
restore
();
}
}
}
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
8aa43149
...
...
@@ -1210,9 +1210,6 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> {
assert
(
_borderRadius
!=
null
);
}
@override
bool
get
alwaysNeedsCompositing
=>
true
;
/// The shape of the layer.
BoxShape
get
shape
=>
_shape
;
BoxShape
_shape
;
...
...
@@ -1285,7 +1282,7 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> {
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
child
!=
null
)
{
_updateClip
();
context
.
pushPhysicalModel
(
offset
,
_clip
.
outerRect
,
_clip
,
_elevation
,
_color
,
super
.
paint
);
context
.
pushPhysicalModel
(
needsCompositing
,
offset
,
_clip
.
outerRect
,
_clip
,
_elevation
,
_color
,
super
.
paint
);
}
}
}
...
...
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