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
005a8e4c
Unverified
Commit
005a8e4c
authored
Nov 02, 2017
by
Mikkel Nygaard Ravn
Committed by
GitHub
Nov 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add backend texture support (eg video, camera) (#12525)
parent
39142146
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
187 additions
and
3 deletions
+187
-3
engine.version
bin/internal/engine.version
+1
-1
rendering.dart
packages/flutter/lib/rendering.dart
+1
-0
layer.dart
packages/flutter/lib/src/rendering/layer.dart
+54
-2
texture.dart
packages/flutter/lib/src/rendering/texture.dart
+80
-0
texture.dart
packages/flutter/lib/src/widgets/texture.dart
+50
-0
widgets.dart
packages/flutter/lib/widgets.dart
+1
-0
No files found.
bin/internal/engine.version
View file @
005a8e4c
88cf09ffe664253e8835dbbef2c2243484f59cb4
ce7202d73cfd183016ce69a2774827ffac82c59b
packages/flutter/lib/rendering.dart
View file @
005a8e4c
...
...
@@ -60,6 +60,7 @@ export 'src/rendering/sliver_persistent_header.dart';
export
'src/rendering/stack.dart'
;
export
'src/rendering/table.dart'
;
export
'src/rendering/table_border.dart'
;
export
'src/rendering/texture.dart'
;
export
'src/rendering/tweens.dart'
;
export
'src/rendering/view.dart'
;
export
'src/rendering/viewport.dart'
;
...
...
packages/flutter/lib/src/rendering/layer.dart
View file @
005a8e4c
...
...
@@ -30,7 +30,7 @@ import 'debug.dart';
/// See also:
///
/// * [RenderView.compositeFrame], which implements this recomposition protocol
/// for painting [RenderObject] trees on the
the
display.
/// for painting [RenderObject] trees on the display.
abstract
class
Layer
extends
AbstractNode
with
DiagnosticableTreeMixin
{
/// This layer's parent in the layer tree.
///
...
...
@@ -128,7 +128,7 @@ class PictureLayer extends Layer {
/// The picture recorded for this layer.
///
/// The picture's coo
dinate system matches this layer's coo
dinate system.
/// The picture's coo
rdinate system matches this layer's coor
dinate system.
///
/// The scene must be explicitly recomposited after this property is changed
/// (as described at [Layer]).
...
...
@@ -167,6 +167,58 @@ class PictureLayer extends Layer {
}
}
/// A composited layer that maps a backend texture to a rectangle.
///
/// Backend textures are images that can be applied (mapped) to an area of the
/// Flutter view. They are created, managed, and updated using a
/// platform-specific texture registry. This is typically done by a plugin
/// that integrates with host platform video player, camera, or OpenGL APIs,
/// or similar image sources.
///
/// A texture layer refers to its backend texture using an integer ID. Texture
/// IDs are obtained from the texture registry and are scoped to the Flutter
/// view. Texture IDs may be reused after deregistration, at the discretion
/// of the registry. The use of texture IDs currently unknown to the registry
/// will silently result in a blank rectangle.
///
/// Once inserted into the layer tree, texture layers are repainted autonomously
/// as dictated by the backend (e.g. on arrival of a video frame). Such
/// repainting generally does not involve executing Dart code.
///
/// Texture layers are always leaves in the layer tree.
///
/// See also:
///
/// * <https://docs.flutter.io/javadoc/io/flutter/view/TextureRegistry.html>
/// for how to create and manage backend textures on Android.
/// * <https://docs.flutter.io/objcdoc/Protocols/FlutterTextureRegistry.html>
/// for how to create and manage backend textures on iOS.
class
TextureLayer
extends
Layer
{
/// Creates a texture layer bounded by [rect] and with backend texture
/// identified by [textureId].
TextureLayer
({
@required
this
.
rect
,
@required
this
.
textureId
,
}):
assert
(
rect
!=
null
),
assert
(
textureId
!=
null
);
/// Bounding rectangle of this layer.
final
Rect
rect
;
/// The identity of the backend texture.
final
int
textureId
;
@override
void
addToScene
(
ui
.
SceneBuilder
builder
,
Offset
layerOffset
)
{
final
Rect
shiftedRect
=
rect
.
shift
(
layerOffset
);
builder
.
addTexture
(
textureId
,
offset:
shiftedRect
.
topLeft
,
width:
shiftedRect
.
width
,
height:
shiftedRect
.
height
,
);
}
}
/// A layer that indicates to the compositor that it should display
/// certain performance statistics within it.
///
...
...
packages/flutter/lib/src/rendering/texture.dart
0 → 100644
View file @
005a8e4c
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'box.dart'
;
import
'layer.dart'
;
import
'object.dart'
;
/// A rectangle upon which a backend texture is mapped.
///
/// Backend textures are images that can be applied (mapped) to an area of the
/// Flutter view. They are created, managed, and updated using a
/// platform-specific texture registry. This is typically done by a plugin
/// that integrates with host platform video player, camera, or OpenGL APIs,
/// or similar image sources.
///
/// A texture box refers to its backend texture using an integer ID. Texture
/// IDs are obtained from the texture registry and are scoped to the Flutter
/// view. Texture IDs may be reused after deregistration, at the discretion
/// of the registry. The use of texture IDs currently unknown to the registry
/// will silently result in a blank rectangle.
///
/// Texture boxes are repainted autonomously as dictated by the backend (e.g. on
/// arrival of a video frame). Such repainting generally does not involve
/// executing Dart code.
///
/// The size of the rectangle is determined by the parent, and the texture is
/// automatically scaled to fit.
///
/// See also:
///
/// * <https://docs.flutter.io/javadoc/io/flutter/view/TextureRegistry.html>
/// for how to create and manage backend textures on Android.
/// * <https://docs.flutter.io/objcdoc/Protocols/FlutterTextureRegistry.html>
/// for how to create and manage backend textures on iOS.
class
TextureBox
extends
RenderBox
{
/// Creates a box backed by the texture identified by [textureId].
TextureBox
({
@required
int
textureId
})
:
assert
(
textureId
!=
null
),
_textureId
=
textureId
;
/// The identity of the backend texture.
int
get
textureId
=>
_textureId
;
int
_textureId
;
set
textureId
(
int
value
)
{
assert
(
value
!=
null
);
if
(
value
!=
_textureId
)
{
_textureId
=
value
;
markNeedsPaint
();
}
}
@override
bool
get
sizedByParent
=>
true
;
@override
bool
get
alwaysNeedsCompositing
=>
true
;
@override
bool
get
isRepaintBoundary
=>
true
;
@override
void
performResize
()
{
size
=
constraints
.
biggest
;
}
@override
bool
hitTestSelf
(
Offset
position
)
{
return
true
;
}
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
_textureId
==
null
)
return
;
context
.
addLayer
(
new
TextureLayer
(
rect:
new
Rect
.
fromLTWH
(
offset
.
dx
,
offset
.
dy
,
size
.
width
,
size
.
height
),
textureId:
_textureId
,
));
}
}
packages/flutter/lib/src/widgets/texture.dart
0 → 100644
View file @
005a8e4c
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/rendering.dart'
;
import
'package:flutter/foundation.dart'
;
import
'framework.dart'
;
/// A rectangle upon which a backend texture is mapped.
///
/// Backend textures are images that can be applied (mapped) to an area of the
/// Flutter view. They are created, managed, and updated using a
/// platform-specific texture registry. This is typically done by a plugin
/// that integrates with host platform video player, camera, or OpenGL APIs,
/// or similar image sources.
///
/// A texture widget refers to its backend texture using an integer ID. Texture
/// IDs are obtained from the texture registry and are scoped to the Flutter
/// view. Texture IDs may be reused after deregistration, at the discretion
/// of the registry. The use of texture IDs currently unknown to the registry
/// will silently result in a blank rectangle.
///
/// Texture widgets are repainted autonomously as dictated by the backend (e.g.
/// on arrival of a video frame). Such repainting generally does not involve
/// executing Dart code.
///
/// The size of the rectangle is determined by its parent widget, and the
/// texture is automatically scaled to fit.
///
/// See also:
///
/// * <https://docs.flutter.io/javadoc/io/flutter/view/TextureRegistry.html>
/// for how to create and manage backend textures on Android.
/// * <https://docs.flutter.io/objcdoc/Protocols/FlutterTextureRegistry.html>
/// for how to create and manage backend textures on iOS.
class
Texture
extends
LeafRenderObjectWidget
{
/// Creates a widget backed by the texture identified by [textureId].
const
Texture
({
Key
key
,
@required
this
.
textureId
}):
assert
(
textureId
!=
null
),
super
(
key:
key
);
/// The identity of the backend texture.
final
int
textureId
;
@override
TextureBox
createRenderObject
(
BuildContext
context
)
=>
new
TextureBox
(
textureId:
textureId
);
@override
void
updateRenderObject
(
BuildContext
context
,
TextureBox
renderObject
)
{
renderObject
.
textureId
=
textureId
;
}
}
packages/flutter/lib/widgets.dart
View file @
005a8e4c
...
...
@@ -87,6 +87,7 @@ export 'src/widgets/status_transitions.dart';
export
'src/widgets/table.dart'
;
export
'src/widgets/text.dart'
;
export
'src/widgets/text_selection.dart'
;
export
'src/widgets/texture.dart'
;
export
'src/widgets/ticker_provider.dart'
;
export
'src/widgets/title.dart'
;
export
'src/widgets/transitions.dart'
;
...
...
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