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
904acc83
Commit
904acc83
authored
Nov 18, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #470 from abarth/dart_timeline
Switch from ui.tracing to dart:Developer Timeline
parents
e1b721f0
c964a1f1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
42 deletions
+58
-42
spinning_square.dart
examples/raw/spinning_square.dart
+29
-28
scheduler.dart
packages/flutter/lib/src/animation/scheduler.dart
+17
-8
object.dart
packages/flutter/lib/src/rendering/object.dart
+5
-4
view.dart
packages/flutter/lib/src/rendering/view.dart
+3
-2
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+4
-0
No files found.
examples/raw/spinning_square.dart
View file @
904acc83
...
...
@@ -2,43 +2,44 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:developer'
;
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
Duration
timeBase
=
null
;
void
beginFrame
(
Duration
timeStamp
)
{
ui
.
tracing
.
begin
(
'beginFrame'
);
if
(
timeBase
==
null
)
timeBase
=
timeStamp
;
double
delta
=
(
timeStamp
-
timeBase
).
inMicroseconds
/
Duration
.
MICROSECONDS_PER_MILLISECOND
;
Timeline
.
timeSync
(
'beginFrame'
,
()
{
if
(
timeBase
==
null
)
timeBase
=
timeStamp
;
double
delta
=
(
timeStamp
-
timeBase
).
inMicroseconds
/
Duration
.
MICROSECONDS_PER_MILLISECOND
;
// paint
ui
.
Rect
paintBounds
=
ui
.
Point
.
origin
&
ui
.
window
.
size
;
ui
.
PictureRecorder
recorder
=
new
ui
.
PictureRecorder
();
ui
.
Canvas
canvas
=
new
ui
.
Canvas
(
recorder
,
paintBounds
);
canvas
.
translate
(
paintBounds
.
width
/
2.0
,
paintBounds
.
height
/
2.0
);
canvas
.
rotate
(
math
.
PI
*
delta
/
1800
);
canvas
.
drawRect
(
new
ui
.
Rect
.
fromLTRB
(-
100.0
,
-
100.0
,
100.0
,
100.0
),
new
ui
.
Paint
()..
color
=
const
ui
.
Color
.
fromARGB
(
255
,
0
,
255
,
0
));
ui
.
Picture
picture
=
recorder
.
endRecording
();
// paint
ui
.
Rect
paintBounds
=
ui
.
Point
.
origin
&
ui
.
window
.
size
;
ui
.
PictureRecorder
recorder
=
new
ui
.
PictureRecorder
();
ui
.
Canvas
canvas
=
new
ui
.
Canvas
(
recorder
,
paintBounds
);
canvas
.
translate
(
paintBounds
.
width
/
2.0
,
paintBounds
.
height
/
2.0
);
canvas
.
rotate
(
math
.
PI
*
delta
/
1800
);
canvas
.
drawRect
(
new
ui
.
Rect
.
fromLTRB
(-
100.0
,
-
100.0
,
100.0
,
100.0
),
new
ui
.
Paint
()..
color
=
const
ui
.
Color
.
fromARGB
(
255
,
0
,
255
,
0
));
ui
.
Picture
picture
=
recorder
.
endRecording
();
// composite
final
double
devicePixelRatio
=
ui
.
window
.
devicePixelRatio
;
ui
.
Rect
sceneBounds
=
new
ui
.
Rect
.
fromLTWH
(
0.0
,
0.0
,
ui
.
window
.
size
.
width
*
devicePixelRatio
,
ui
.
window
.
size
.
height
*
devicePixelRatio
);
Float64List
deviceTransform
=
new
Float64List
(
16
)
..[
0
]
=
devicePixelRatio
..[
5
]
=
devicePixelRatio
..[
10
]
=
1.0
..[
15
]
=
1.0
;
ui
.
SceneBuilder
sceneBuilder
=
new
ui
.
SceneBuilder
(
sceneBounds
)
..
pushTransform
(
deviceTransform
)
..
addPicture
(
ui
.
Offset
.
zero
,
picture
,
paintBounds
)
..
pop
();
ui
.
window
.
render
(
sceneBuilder
.
build
());
// composite
final
double
devicePixelRatio
=
ui
.
window
.
devicePixelRatio
;
ui
.
Rect
sceneBounds
=
new
ui
.
Rect
.
fromLTWH
(
0.0
,
0.0
,
ui
.
window
.
size
.
width
*
devicePixelRatio
,
ui
.
window
.
size
.
height
*
devicePixelRatio
);
Float64List
deviceTransform
=
new
Float64List
(
16
)
..[
0
]
=
devicePixelRatio
..[
5
]
=
devicePixelRatio
..[
10
]
=
1.0
..[
15
]
=
1.0
;
ui
.
SceneBuilder
sceneBuilder
=
new
ui
.
SceneBuilder
(
sceneBounds
)
..
pushTransform
(
deviceTransform
)
..
addPicture
(
ui
.
Offset
.
zero
,
picture
,
paintBounds
)
..
pop
();
ui
.
window
.
render
(
sceneBuilder
.
build
());
});
ui
.
tracing
.
end
(
'beginFrame'
);
ui
.
window
.
scheduleFrame
();
}
...
...
packages/flutter/lib/src/animation/scheduler.dart
View file @
904acc83
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:collection'
;
import
'dart:developer'
;
import
'dart:ui'
as
ui
;
/// Slows down animations by this factor to help in development.
...
...
@@ -42,6 +43,19 @@ class Scheduler {
int
get
transientCallbackCount
=>
_transientCallbacks
.
length
;
void
_invokeAnimationCallbacks
(
Duration
timeStamp
)
{
Timeline
.
startSync
(
'Animate'
);
assert
(
_inFrame
);
Map
<
int
,
SchedulerCallback
>
callbacks
=
_transientCallbacks
;
_transientCallbacks
=
new
Map
<
int
,
SchedulerCallback
>();
callbacks
.
forEach
((
int
id
,
SchedulerCallback
callback
)
{
if
(!
_removedIds
.
contains
(
id
))
invokeCallback
(
callback
,
timeStamp
);
});
_removedIds
.
clear
();
Timeline
.
finishSync
();
}
/// Called by the engine to produce a new frame.
///
/// This function first calls all the callbacks registered by
...
...
@@ -49,19 +63,13 @@ class Scheduler {
/// [addPersistentFrameCallback], which typically drive the rendering pipeline,
/// and finally calls the callbacks registered by [requestPostFrameCallback].
void
beginFrame
(
Duration
rawTimeStamp
)
{
Timeline
.
startSync
(
'Begin frame'
);
assert
(!
_inFrame
);
_inFrame
=
true
;
Duration
timeStamp
=
new
Duration
(
microseconds:
(
rawTimeStamp
.
inMicroseconds
/
timeDilation
).
round
());
_haveScheduledVisualUpdate
=
false
;
Map
<
int
,
SchedulerCallback
>
callbacks
=
_transientCallbacks
;
_transientCallbacks
=
new
Map
<
int
,
SchedulerCallback
>();
callbacks
.
forEach
((
int
id
,
SchedulerCallback
callback
)
{
if
(!
_removedIds
.
contains
(
id
))
invokeCallback
(
callback
,
timeStamp
);
});
_removedIds
.
clear
();
_invokeAnimationCallbacks
(
timeStamp
);
for
(
SchedulerCallback
callback
in
_persistentCallbacks
)
invokeCallback
(
callback
,
timeStamp
);
...
...
@@ -73,6 +81,7 @@ class Scheduler {
invokeCallback
(
callback
,
timeStamp
);
_inFrame
=
false
;
Timeline
.
finishSync
();
}
void
invokeCallback
(
SchedulerCallback
callback
,
Duration
timeStamp
)
{
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
904acc83
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:developer'
;
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
...
...
@@ -610,7 +611,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
///
/// See [FlutterBinding] for an example of how this function is used.
static
void
flushLayout
()
{
ui
.
tracing
.
begin
(
'RenderObject.flush
Layout'
);
Timeline
.
startSync
(
'
Layout'
);
_debugDoingLayout
=
true
;
try
{
// TODO(ianh): assert that we're not allowing previously dirty nodes to redirty themeselves
...
...
@@ -624,7 +625,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
}
}
finally
{
_debugDoingLayout
=
false
;
ui
.
tracing
.
end
(
'RenderObject.flushLayout'
);
Timeline
.
finishSync
(
);
}
}
void
_layoutWithoutResize
()
{
...
...
@@ -962,7 +963,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
///
/// See [FlutterBinding] for an example of how this function is used.
static
void
flushPaint
()
{
ui
.
tracing
.
begin
(
'RenderObject.flush
Paint'
);
Timeline
.
startSync
(
'
Paint'
);
_debugDoingPaint
=
true
;
try
{
List
<
RenderObject
>
dirtyNodes
=
_nodesNeedingPaint
;
...
...
@@ -976,7 +977,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
assert
(
_nodesNeedingPaint
.
length
==
0
);
}
finally
{
_debugDoingPaint
=
false
;
ui
.
tracing
.
end
(
'RenderObject.flushPaint'
);
Timeline
.
finishSync
(
);
}
}
...
...
packages/flutter/lib/src/rendering/view.dart
View file @
904acc83
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:developer'
;
import
'dart:ui'
as
ui
;
import
'package:flutter/animation.dart'
;
...
...
@@ -116,7 +117,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
///
/// Actually causes the output of the rendering pipeline to appear on screen.
void
compositeFrame
()
{
ui
.
tracing
.
begin
(
'RenderView.compositeFram
e'
);
Timeline
.
startSync
(
'Composit
e'
);
try
{
(
layer
as
TransformLayer
).
transform
=
_logicalToDeviceTransform
;
Rect
bounds
=
Point
.
origin
&
(
size
*
ui
.
window
.
devicePixelRatio
);
...
...
@@ -126,7 +127,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
ui
.
window
.
render
(
scene
);
scene
.
dispose
();
}
finally
{
ui
.
tracing
.
end
(
'RenderView.compositeFrame'
);
Timeline
.
finishSync
(
);
}
}
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
904acc83
...
...
@@ -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:developer'
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -47,6 +49,7 @@ class WidgetFlutterBinding extends FlutterBinding {
void
buildDirtyElements
()
{
if
(
_dirtyElements
.
isEmpty
)
return
;
Timeline
.
startSync
(
'Build'
);
BuildableElement
.
lockState
(()
{
_dirtyElements
.
sort
((
BuildableElement
a
,
BuildableElement
b
)
=>
a
.
depth
-
b
.
depth
);
int
dirtyCount
=
_dirtyElements
.
length
;
...
...
@@ -63,6 +66,7 @@ class WidgetFlutterBinding extends FlutterBinding {
_dirtyElements
.
clear
();
},
building:
true
);
assert
(
_dirtyElements
.
isEmpty
);
Timeline
.
finishSync
();
}
/// The [Element] that is at the root of the hierarchy (and which wraps the
...
...
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