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
665ac49b
Commit
665ac49b
authored
Apr 02, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for backdrop filters
For example, to implement backdrop blur effects.
parent
055fd00d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
4 deletions
+84
-4
engine.version
bin/cache/engine.version
+1
-1
layer.dart
packages/flutter/lib/src/rendering/layer.dart
+16
-1
object.dart
packages/flutter/lib/src/rendering/object.dart
+14
-1
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+30
-0
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+23
-1
No files found.
bin/cache/engine.version
View file @
665ac49b
b8151a8d9bb2fd2c1d67e8007a53eba5489f3d0d
13f67343d008c9673f528ec2451c7d5a0528605c
packages/flutter/lib/src/rendering/layer.dart
View file @
665ac49b
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
Picture
,
SceneBuilder
;
import
'dart:ui'
as
ui
show
ImageFilter
,
Picture
,
SceneBuilder
;
import
'dart:ui'
show
Offset
;
import
'package:flutter/painting.dart'
;
...
...
@@ -448,3 +448,18 @@ class ShaderMaskLayer extends ContainerLayer {
description
.
add
(
'transferMode:
$transferMode
'
);
}
}
/// A composited layer that applies a filter to the existing contents of the scene.
class
BackdropFilterLayer
extends
ContainerLayer
{
BackdropFilterLayer
({
this
.
filter
});
/// The filter to apply to the existing contents of the scene.
ui
.
ImageFilter
filter
;
@override
void
addToScene
(
ui
.
SceneBuilder
builder
,
Offset
layerOffset
)
{
builder
.
pushBackdropFilter
(
filter
);
addChildrenToScene
(
builder
,
layerOffset
);
builder
.
pop
();
}
}
packages/flutter/lib/src/rendering/object.dart
View file @
665ac49b
...
...
@@ -3,7 +3,7 @@
// found in the LICENSE file.
import
'dart:developer'
;
import
'dart:ui'
as
ui
show
PictureRecorder
;
import
'dart:ui'
as
ui
show
ImageFilter
,
PictureRecorder
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/painting.dart'
;
...
...
@@ -333,6 +333,19 @@ class PaintingContext {
painter
(
childContext
,
offset
);
childContext
.
_stopRecordingIfNeeded
();
}
/// Push a backdrop filter.
///
/// This function applies a filter to the existing painted content and then
/// synchronously calls the painter to paint on top of the filtered backdrop.
void
pushBackdropFilter
(
Offset
offset
,
ui
.
ImageFilter
filter
,
PaintingContextCallback
painter
)
{
_stopRecordingIfNeeded
();
BackdropFilterLayer
backdropFilterLayer
=
new
BackdropFilterLayer
(
filter:
filter
);
_appendLayer
(
backdropFilterLayer
);
PaintingContext
childContext
=
new
PaintingContext
.
_
(
backdropFilterLayer
,
_paintBounds
);
painter
(
childContext
,
offset
);
childContext
.
_stopRecordingIfNeeded
();
}
}
/// An encapsulation of a renderer and a paint() method.
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
665ac49b
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
ImageFilter
;
import
'package:flutter/gestures.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
...
@@ -673,6 +675,34 @@ class RenderShaderMask extends RenderProxyBox {
}
}
class
RenderBackdropFilter
extends
RenderProxyBox
{
RenderBackdropFilter
({
RenderBox
child
,
ui
.
ImageFilter
filter
})
:
_filter
=
filter
,
super
(
child
)
{
assert
(
filter
!=
null
);
}
ui
.
ImageFilter
get
filter
=>
_filter
;
ui
.
ImageFilter
_filter
;
void
set
filter
(
ui
.
ImageFilter
newFilter
)
{
assert
(
newFilter
!=
null
);
if
(
_filter
==
newFilter
)
return
;
_filter
=
newFilter
;
markNeedsPaint
();
}
@override
bool
get
alwaysNeedsCompositing
=>
child
!=
null
;
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
child
!=
null
)
{
assert
(
needsCompositing
);
context
.
pushBackdropFilter
(
offset
,
_filter
,
super
.
paint
);
}
}
}
/// A class that provides custom clips.
abstract
class
CustomClipper
<
T
>
{
/// Returns a description of the clip given that the render object being
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
665ac49b
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
Image
;
import
'dart:ui'
as
ui
show
Image
,
ImageFilter
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -122,6 +122,28 @@ class ShaderMask extends SingleChildRenderObjectWidget {
}
}
class
BackdropFilter
extends
SingleChildRenderObjectWidget
{
BackdropFilter
({
Key
key
,
this
.
filter
,
Widget
child
})
:
super
(
key:
key
,
child:
child
)
{
assert
(
filter
!=
null
);
}
final
ui
.
ImageFilter
filter
;
@override
RenderBackdropFilter
createRenderObject
(
BuildContext
context
)
{
return
new
RenderBackdropFilter
(
filter:
filter
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderBackdropFilter
renderObject
)
{
renderObject
.
filter
=
filter
;
}
}
/// Paints a [Decoration] either before or after its child paints.
/// Container insets its child by the widths of the borders, this Widget does not.
///
...
...
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