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
9f5febc8
Commit
9f5febc8
authored
Mar 21, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ChildView after Mojo roll
The Mozart API has changed.
parent
da88f1d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
49 deletions
+107
-49
engine.version
bin/cache/engine.version
+1
-1
child_view.dart
packages/flutter/lib/src/rendering/child_view.dart
+86
-36
layer.dart
packages/flutter/lib/src/rendering/layer.dart
+11
-9
object.dart
packages/flutter/lib/src/rendering/object.dart
+9
-3
No files found.
bin/cache/engine.version
View file @
9f5febc8
56bca69d7a9112af22e6873599b57b5b2fe90395
b7419de14af49f61b67b290a2b66a3416f94cb62
packages/flutter/lib/src/rendering/child_view.dart
View file @
9f5febc8
...
@@ -3,12 +3,15 @@
...
@@ -3,12 +3,15 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:async'
;
import
'dart:collection'
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
as
ui
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:mojo_services/mojo/gfx/composition/scene_token.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/gfx/composition/scene_token.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/layouts.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/layouts.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/view_containers.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/view_provider.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/view_provider.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/view_token.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/views.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/ui/views.mojom.dart'
as
mojom
;
import
'package:mojo/application.dart'
;
import
'package:mojo/application.dart'
;
import
'package:mojo/core.dart'
as
core
;
import
'package:mojo/core.dart'
as
core
;
...
@@ -32,6 +35,37 @@ mojom.ViewProxy _initViewProxy() {
...
@@ -32,6 +35,37 @@ mojom.ViewProxy _initViewProxy() {
final
mojom
.
ViewProxy
_viewProxy
=
_initViewProxy
();
final
mojom
.
ViewProxy
_viewProxy
=
_initViewProxy
();
final
mojom
.
View
_view
=
_viewProxy
?.
ptr
;
final
mojom
.
View
_view
=
_viewProxy
?.
ptr
;
mojom
.
ViewContainer
_initViewContainer
(
)
{
mojom
.
ViewContainerProxy
viewContainerProxy
=
new
mojom
.
ViewContainerProxy
.
unbound
();
_view
.
getContainer
(
viewContainerProxy
);
viewContainerProxy
.
ptr
.
setListener
(
new
mojom
.
ViewContainerListenerStub
.
unbound
()..
impl
=
_ViewContainerListenerImpl
.
instance
);
return
viewContainerProxy
.
ptr
;
}
final
mojom
.
ViewContainer
_viewContainer
=
_initViewContainer
();
typedef
dynamic
_ResponseFactory
(
);
class
_ViewContainerListenerImpl
extends
mojom
.
ViewContainerListener
{
static
final
_ViewContainerListenerImpl
instance
=
new
_ViewContainerListenerImpl
();
@override
dynamic
onChildAttached
(
int
childKey
,
mojom
.
ViewInfo
childViewInfo
,
[
_ResponseFactory
responseFactory
=
null
])
{
ChildViewConnection
connection
=
_connections
[
childKey
];
connection
?.
_onAttachedToContainer
(
childViewInfo
);
return
responseFactory
();
}
@override
dynamic
onChildUnavailable
(
int
childKey
,
[
_ResponseFactory
responseFactory
=
null
])
{
ChildViewConnection
connection
=
_connections
[
childKey
];
connection
?.
_onUnavailable
();
return
responseFactory
();
}
final
Map
<
int
,
ChildViewConnection
>
_connections
=
new
HashMap
<
int
,
ChildViewConnection
>();
}
/// (mojo-only) A connection with a child view.
/// (mojo-only) A connection with a child view.
///
///
/// Used with the [ChildView] widget to display a child view.
/// Used with the [ChildView] widget to display a child view.
...
@@ -66,22 +100,42 @@ class ChildViewConnection {
...
@@ -66,22 +100,42 @@ class ChildViewConnection {
static
int
_nextViewKey
=
1
;
static
int
_nextViewKey
=
1
;
int
_viewKey
;
int
_viewKey
;
VoidCallback
_onViewInfoAvailable
;
mojom
.
ViewInfo
_viewInfo
;
void
_onAttachedToContainer
(
mojom
.
ViewInfo
viewInfo
)
{
assert
(
_viewInfo
==
null
);
_viewInfo
=
viewInfo
;
if
(
_onViewInfoAvailable
!=
null
)
_onViewInfoAvailable
();
}
void
_onUnavailable
()
{
_viewInfo
=
null
;
}
void
_addChildToViewHost
()
{
void
_addChildToViewHost
()
{
assert
(
_attached
);
assert
(
_attached
);
assert
(
_viewOwner
!=
null
);
assert
(
_viewOwner
!=
null
);
assert
(
_viewKey
==
null
);
assert
(
_viewKey
==
null
);
_viewKey
=
_nextViewKey
++;
_viewKey
=
_nextViewKey
++;
_view
?.
addChild
(
_viewKey
,
_viewOwner
.
impl
);
_viewInfo
=
null
;
_viewContainer
?.
addChild
(
_viewKey
,
_viewOwner
.
impl
);
_viewOwner
=
null
;
_viewOwner
=
null
;
assert
(!
_ViewContainerListenerImpl
.
instance
.
_connections
.
containsKey
(
_viewKey
));
_ViewContainerListenerImpl
.
instance
.
_connections
[
_viewKey
]
=
this
;
}
}
void
_removeChildFromViewHost
()
{
void
_removeChildFromViewHost
()
{
assert
(!
_attached
);
assert
(!
_attached
);
assert
(
_viewOwner
==
null
);
assert
(
_viewOwner
==
null
);
assert
(
_viewKey
!=
null
);
assert
(
_viewKey
!=
null
);
assert
(
_ViewContainerListenerImpl
.
instance
.
_connections
[
_viewKey
]
==
this
);
_ViewContainerListenerImpl
.
instance
.
_connections
.
remove
(
_viewKey
);
_viewOwner
=
new
mojom
.
ViewOwnerProxy
.
unbound
();
_viewOwner
=
new
mojom
.
ViewOwnerProxy
.
unbound
();
_view
?.
removeChild
(
_viewKey
,
_viewOwner
);
_view
Container
?.
removeChild
(
_viewKey
,
_viewOwner
);
_viewKey
=
null
;
_viewKey
=
null
;
_viewInfo
=
null
;
}
}
// The number of render objects attached to this view. In between frames, we
// The number of render objects attached to this view. In between frames, we
...
@@ -110,26 +164,24 @@ class ChildViewConnection {
...
@@ -110,26 +164,24 @@ class ChildViewConnection {
_removeChildFromViewHost
();
_removeChildFromViewHost
();
}
}
Future
<
mojom
.
ViewLayoutInfo
>
_layout
({
Size
size
,
double
scale
})
async
{
void
_layout
({
int
physicalWidth
,
int
physicalHeight
,
double
devicePixelRatio
})
{
assert
(
_attached
);
assert
(
_attached
);
assert
(
_attachments
==
1
);
assert
(
_attachments
==
1
);
assert
(
_viewKey
!=
null
);
assert
(
_viewKey
!=
null
);
if
(
_view
==
null
)
if
(
_view
==
null
)
return
new
Future
<
mojom
.
ViewLayoutInfo
>.
value
(
null
);
return
;
int
width
=
(
size
.
width
*
scale
).
round
();
int
height
=
(
size
.
height
*
scale
).
round
();
// TODO(abarth): Ideally we would propagate our actual constraints to be
// TODO(abarth): Ideally we would propagate our actual constraints to be
// able to support rich cross-app layout. For now, we give the child tight
// able to support rich cross-app layout. For now, we give the child tight
// constraints for simplicity.
// constraints for simplicity.
mojom
.
BoxConstraints
childConstraints
=
new
mojom
.
BoxConstraints
()
mojom
.
BoxConstraints
childConstraints
=
new
mojom
.
BoxConstraints
()
..
minWidth
=
w
idth
..
minWidth
=
physicalW
idth
..
maxWidth
=
w
idth
..
maxWidth
=
physicalW
idth
..
minHeight
=
h
eight
..
minHeight
=
physicalH
eight
..
maxHeight
=
h
eight
;
..
maxHeight
=
physicalH
eight
;
mojom
.
ViewLayoutParams
layoutParams
=
new
mojom
.
ViewLayoutParams
()
mojom
.
ViewLayoutParams
layoutParams
=
new
mojom
.
ViewLayoutParams
()
..
constraints
=
childConstraints
..
constraints
=
childConstraints
..
devicePixelRatio
=
scale
;
..
devicePixelRatio
=
devicePixelRatio
;
return
(
await
_view
.
layoutChild
(
_viewKey
,
layoutParams
)).
info
;
_viewContainer
.
layoutChild
(
_viewKey
,
layoutParams
)
;
}
}
}
}
...
@@ -138,7 +190,9 @@ class RenderChildView extends RenderBox {
...
@@ -138,7 +190,9 @@ class RenderChildView extends RenderBox {
RenderChildView
({
RenderChildView
({
ChildViewConnection
child
,
ChildViewConnection
child
,
double
scale
double
scale
})
:
_child
=
child
,
_scale
=
scale
;
})
:
_scale
=
scale
{
this
.
child
=
child
;
}
/// The child to display.
/// The child to display.
ChildViewConnection
get
child
=>
_child
;
ChildViewConnection
get
child
=>
_child
;
...
@@ -146,12 +200,17 @@ class RenderChildView extends RenderBox {
...
@@ -146,12 +200,17 @@ class RenderChildView extends RenderBox {
void
set
child
(
ChildViewConnection
value
)
{
void
set
child
(
ChildViewConnection
value
)
{
if
(
value
==
_child
)
if
(
value
==
_child
)
return
;
return
;
if
(
attached
)
if
(
attached
&&
_child
!=
null
)
{
_child
?.
_detach
();
_child
.
_detach
();
assert
(
_child
.
_onViewInfoAvailable
!=
null
);
_child
.
_onViewInfoAvailable
=
null
;
}
_child
=
value
;
_child
=
value
;
_layoutInfo
=
null
;
if
(
attached
&&
_child
!=
null
)
{
if
(
attached
)
_child
.
_attach
();
_child
?.
_attach
();
assert
(
_child
.
_onViewInfoAvailable
==
null
);
_child
.
_onViewInfoAvailable
=
markNeedsPaint
;
}
if
(
_child
==
null
)
{
if
(
_child
==
null
)
{
markNeedsPaint
();
markNeedsPaint
();
}
else
{
}
else
{
...
@@ -185,20 +244,18 @@ class RenderChildView extends RenderBox {
...
@@ -185,20 +244,18 @@ class RenderChildView extends RenderBox {
@override
@override
bool
get
alwaysNeedsCompositing
=>
true
;
bool
get
alwaysNeedsCompositing
=>
true
;
@override
bool
get
sizedByParent
=>
true
;
@override
void
performResize
()
{
size
=
constraints
.
biggest
;
}
TextPainter
_debugErrorMessage
;
TextPainter
_debugErrorMessage
;
int
_physicalWidth
;
int
_physicalHeight
;
@override
@override
void
performLayout
()
{
void
performLayout
()
{
size
=
constraints
.
biggest
;
if
(
_child
!=
null
)
{
if
(
_child
!=
null
)
{
_child
.
_layout
(
size:
size
,
scale:
scale
).
then
(
_handleLayoutInfoChanged
);
_physicalWidth
=
(
size
.
width
*
scale
).
round
();
_physicalHeight
=
(
size
.
height
*
scale
).
round
();
_child
.
_layout
(
physicalWidth:
_physicalWidth
,
physicalHeight:
_physicalHeight
,
devicePixelRatio:
scale
);
assert
(()
{
assert
(()
{
if
(
_view
==
null
)
{
if
(
_view
==
null
)
{
_debugErrorMessage
??=
new
TextPainter
()
_debugErrorMessage
??=
new
TextPainter
()
...
@@ -215,21 +272,14 @@ class RenderChildView extends RenderBox {
...
@@ -215,21 +272,14 @@ class RenderChildView extends RenderBox {
}
}
}
}
mojom
.
ViewLayoutInfo
_layoutInfo
;
void
_handleLayoutInfoChanged
(
mojom
.
ViewLayoutInfo
layoutInfo
)
{
_layoutInfo
=
layoutInfo
;
markNeedsPaint
();
}
@override
@override
bool
hitTestSelf
(
Point
position
)
=>
true
;
bool
hitTestSelf
(
Point
position
)
=>
true
;
@override
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
assert
(
needsCompositing
);
assert
(
needsCompositing
);
if
(
_
layout
Info
!=
null
)
if
(
_
child
?.
_view
Info
!=
null
)
context
.
pushChildScene
(
offset
,
scale
,
_
layoutInfo
);
context
.
pushChildScene
(
offset
,
scale
,
_
physicalWidth
,
_physicalHeight
,
_child
.
_viewInfo
.
sceneToken
);
assert
(()
{
assert
(()
{
if
(
_view
==
null
)
{
if
(
_view
==
null
)
{
context
.
canvas
.
drawRect
(
offset
&
size
,
new
Paint
()..
color
=
const
Color
(
0xFF0000FF
));
context
.
canvas
.
drawRect
(
offset
&
size
,
new
Paint
()..
color
=
const
Color
(
0xFF0000FF
));
...
...
packages/flutter/lib/src/rendering/layer.dart
View file @
9f5febc8
...
@@ -7,7 +7,7 @@ import 'dart:ui' show Offset;
...
@@ -7,7 +7,7 @@ import 'dart:ui' show Offset;
import
'package:flutter/painting.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'package:mojo_services/mojo/
ui/layouts
.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/
gfx/composition/scene_token
.mojom.dart'
as
mojom
;
import
'debug.dart'
;
import
'debug.dart'
;
...
@@ -110,20 +110,22 @@ class PictureLayer extends Layer {
...
@@ -110,20 +110,22 @@ class PictureLayer extends Layer {
}
}
class
ChildSceneLayer
extends
Layer
{
class
ChildSceneLayer
extends
Layer
{
ChildSceneLayer
({
this
.
offset
,
this
.
devicePixelRatio
,
this
.
layoutInfo
});
ChildSceneLayer
({
this
.
offset
,
this
.
devicePixelRatio
,
this
.
physicalWidth
,
this
.
physicalHeight
,
this
.
sceneToken
});
Offset
offset
;
Offset
offset
;
double
devicePixelRatio
;
double
devicePixelRatio
;
mojom
.
ViewLayoutInfo
layoutInfo
;
int
physicalWidth
;
int
physicalHeight
;
mojom
.
SceneToken
sceneToken
;
@override
@override
void
addToScene
(
ui
.
SceneBuilder
builder
,
Offset
layerOffset
)
{
void
addToScene
(
ui
.
SceneBuilder
builder
,
Offset
layerOffset
)
{
builder
.
addChildScene
(
builder
.
addChildScene
(
offset
+
layerOffset
,
offset
+
layerOffset
,
devicePixelRatio
,
devicePixelRatio
,
layoutInfo
.
size
.
w
idth
,
physicalW
idth
,
layoutInfo
.
size
.
h
eight
,
physicalH
eight
,
layoutInfo
.
sceneToken
.
value
sceneToken
.
value
);
);
}
}
...
@@ -131,9 +133,9 @@ class ChildSceneLayer extends Layer {
...
@@ -131,9 +133,9 @@ class ChildSceneLayer extends Layer {
void
debugFillDescription
(
List
<
String
>
description
)
{
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
super
.
debugFillDescription
(
description
);
description
.
add
(
'offset:
$offset
'
);
description
.
add
(
'offset:
$offset
'
);
description
.
add
(
'physicalWidth:
$
{layoutInfo.size.width}
'
);
description
.
add
(
'physicalWidth:
$
physicalWidth
'
);
description
.
add
(
'physicalHeight:
$
{layoutInfo.size.height}
'
);
description
.
add
(
'physicalHeight:
$
physicalHeight
'
);
description
.
add
(
'sceneToken.value:
${
layoutInfo.
sceneToken.value}
'
);
description
.
add
(
'sceneToken.value:
${sceneToken.value}
'
);
}
}
}
}
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
9f5febc8
...
@@ -9,7 +9,7 @@ import 'package:flutter/gestures.dart';
...
@@ -9,7 +9,7 @@ import 'package:flutter/gestures.dart';
import
'package:flutter/painting.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:mojo_services/mojo/
ui/layouts
.mojom.dart'
as
mojom
;
import
'package:mojo_services/mojo/
gfx/composition/scene_token
.mojom.dart'
as
mojom
;
import
'package:vector_math/vector_math_64.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'debug.dart'
;
import
'debug.dart'
;
...
@@ -201,9 +201,15 @@ class PaintingContext {
...
@@ -201,9 +201,15 @@ class PaintingContext {
));
));
}
}
void
pushChildScene
(
Offset
offset
,
double
devicePixelRatio
,
mojom
.
ViewLayoutInfo
layoutInfo
)
{
void
pushChildScene
(
Offset
offset
,
double
devicePixelRatio
,
int
physicalWidth
,
int
physicalHeight
,
mojom
.
SceneToken
sceneToken
)
{
_stopRecordingIfNeeded
();
_stopRecordingIfNeeded
();
_appendLayer
(
new
ChildSceneLayer
(
offset:
offset
,
devicePixelRatio:
devicePixelRatio
,
layoutInfo:
layoutInfo
));
_appendLayer
(
new
ChildSceneLayer
(
offset:
offset
,
devicePixelRatio:
devicePixelRatio
,
physicalWidth:
physicalWidth
,
physicalHeight:
physicalHeight
,
sceneToken:
sceneToken
));
}
}
/// Push a rectangular clip rect.
/// Push a rectangular clip rect.
...
...
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