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
9b6d267e
Unverified
Commit
9b6d267e
authored
Feb 22, 2021
by
nt4f04uNd
Committed by
GitHub
Feb 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding freeze parameter to Texture and TextureBox (#75738)
parent
934c3c70
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
8 deletions
+55
-8
layer.dart
packages/flutter/lib/src/rendering/layer.dart
+2
-2
texture.dart
packages/flutter/lib/src/rendering/texture.dart
+18
-4
texture.dart
packages/flutter/lib/src/widgets/texture.dart
+6
-1
texture_test.dart
packages/flutter/test/widgets/texture_test.dart
+29
-1
No files found.
packages/flutter/lib/src/rendering/layer.dart
View file @
9b6d267e
...
...
@@ -559,9 +559,9 @@ class TextureLayer extends Layer {
/// The identity of the backend texture.
final
int
textureId
;
/// When true the texture
that
will not be updated with new frames.
/// When true the texture will not be updated with new frames.
///
/// This is used
when resizing an embedded Android views: W
hen resizing there
/// This is used
for resizing embedded Android views: w
hen resizing there
/// is a short period during which the framework cannot tell if the newest
/// texture frame has the previous or new size, to workaround this the
/// framework "freezes" the texture just before resizing the Android view and
...
...
packages/flutter/lib/src/rendering/texture.dart
View file @
9b6d267e
...
...
@@ -38,9 +38,11 @@ class TextureBox extends RenderBox {
/// [filterQuality] to set texture's [FilterQuality].
TextureBox
({
required
int
textureId
,
bool
freeze
=
false
,
FilterQuality
filterQuality
=
FilterQuality
.
low
,
})
:
assert
(
textureId
!=
null
),
_textureId
=
textureId
,
_freeze
=
freeze
,
_filterQuality
=
filterQuality
;
/// The identity of the backend texture.
...
...
@@ -54,15 +56,26 @@ class TextureBox extends RenderBox {
}
}
/// When true the texture will not be updated with new frames.
bool
get
freeze
=>
_freeze
;
bool
_freeze
;
set
freeze
(
bool
value
)
{
assert
(
value
!=
null
);
if
(
value
!=
_freeze
)
{
_freeze
=
value
;
markNeedsPaint
();
}
}
/// {@macro flutter.widgets.Texture.filterQuality}
FilterQuality
get
filterQuality
=>
_filterQuality
;
FilterQuality
_filterQuality
;
set
filterQuality
(
FilterQuality
value
)
{
assert
(
value
!=
null
);
if
(
value
==
_filterQuality
)
return
;
_filterQuality
=
value
;
markNeedsPaint
();
if
(
value
!=
_filterQuality
)
{
_filterQuality
=
value
;
markNeedsPaint
()
;
}
}
@override
...
...
@@ -87,6 +100,7 @@ class TextureBox extends RenderBox {
context
.
addLayer
(
TextureLayer
(
rect:
Rect
.
fromLTWH
(
offset
.
dx
,
offset
.
dy
,
size
.
width
,
size
.
height
),
textureId:
_textureId
,
freeze:
freeze
,
filterQuality:
_filterQuality
,
));
}
...
...
packages/flutter/lib/src/widgets/texture.dart
View file @
9b6d267e
...
...
@@ -38,6 +38,7 @@ class Texture extends LeafRenderObjectWidget {
const
Texture
({
Key
?
key
,
required
this
.
textureId
,
this
.
freeze
=
false
,
this
.
filterQuality
=
FilterQuality
.
low
,
})
:
assert
(
textureId
!=
null
),
super
(
key:
key
);
...
...
@@ -45,6 +46,9 @@ class Texture extends LeafRenderObjectWidget {
/// The identity of the backend texture.
final
int
textureId
;
/// When true the texture will not be updated with new frames.
final
bool
freeze
;
/// {@template flutter.widgets.Texture.filterQuality}
/// The quality of sampling the texture and rendering it on screen.
///
...
...
@@ -56,11 +60,12 @@ class Texture extends LeafRenderObjectWidget {
final
FilterQuality
filterQuality
;
@override
TextureBox
createRenderObject
(
BuildContext
context
)
=>
TextureBox
(
textureId:
textureId
,
filterQuality:
filterQuality
);
TextureBox
createRenderObject
(
BuildContext
context
)
=>
TextureBox
(
textureId:
textureId
,
f
reeze:
freeze
,
f
ilterQuality:
filterQuality
);
@override
void
updateRenderObject
(
BuildContext
context
,
TextureBox
renderObject
)
{
renderObject
.
textureId
=
textureId
;
renderObject
.
freeze
=
freeze
;
renderObject
.
filterQuality
=
filterQuality
;
}
}
packages/flutter/test/widgets/texture_test.dart
View file @
9b6d267e
...
...
@@ -7,9 +7,37 @@ import 'package:flutter/rendering.dart';
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
testWidgets
(
'Texture with freeze set to true'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Center
(
child:
Texture
(
textureId:
1
,
freeze:
true
))
);
final
Texture
texture
=
tester
.
firstWidget
(
find
.
byType
(
Texture
));
expect
(
texture
,
isNotNull
);
expect
(
texture
.
textureId
,
1
);
expect
(
texture
.
freeze
,
true
);
final
RenderObject
renderObject
=
tester
.
firstRenderObject
(
find
.
byType
(
Texture
));
expect
(
renderObject
,
isNotNull
);
final
TextureBox
textureBox
=
renderObject
as
TextureBox
;
expect
(
textureBox
,
isNotNull
);
expect
(
textureBox
.
textureId
,
1
);
expect
(
textureBox
.
freeze
,
true
);
final
ContainerLayer
containerLayer
=
ContainerLayer
();
final
PaintingContext
paintingContext
=
PaintingContext
(
containerLayer
,
Rect
.
zero
);
textureBox
.
paint
(
paintingContext
,
Offset
.
zero
);
final
Layer
layer
=
containerLayer
.
lastChild
!;
expect
(
layer
,
isNotNull
);
final
TextureLayer
textureLayer
=
layer
as
TextureLayer
;
expect
(
textureLayer
,
isNotNull
);
expect
(
textureLayer
.
textureId
,
1
);
expect
(
textureLayer
.
freeze
,
true
);
});
testWidgets
(
'Texture with default FilterQuality'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Center
(
child:
Texture
(
textureId:
1
,
))
const
Center
(
child:
Texture
(
textureId:
1
))
);
final
Texture
texture
=
tester
.
firstWidget
(
find
.
byType
(
Texture
));
...
...
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