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
17ae19e8
Commit
17ae19e8
authored
Jan 11, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1166 from Hixie/stock-debugging
Add more debugging options to the stocks app.
parents
e0760e6a
48e1350e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
64 deletions
+129
-64
flutter.yaml
examples/stocks/flutter.yaml
+2
-0
main.dart
examples/stocks/lib/main.dart
+9
-2
stock_settings.dart
examples/stocks/lib/stock_settings.dart
+36
-6
stock_types.dart
examples/stocks/lib/stock_types.dart
+15
-5
material_app.dart
packages/flutter/lib/src/material/material_app.dart
+10
-1
statistics_box.dart
packages/flutter/lib/src/rendering/statistics_box.dart
+55
-18
statistics_overlay.dart
packages/flutter/lib/src/widgets/statistics_overlay.dart
+2
-32
No files found.
examples/stocks/flutter.yaml
View file @
17ae19e8
...
...
@@ -6,12 +6,14 @@ material-design-icons:
-
name
:
action/assessment
-
name
:
action/backup
-
name
:
action/help
-
name
:
action/picture_in_picture
-
name
:
action/search
-
name
:
action/settings
-
name
:
action/thumb_down
-
name
:
action/thumb_up
-
name
:
content/add
-
name
:
device/dvr
-
name
:
editor/border_all
-
name
:
editor/border_clear
-
name
:
navigation/arrow_back
-
name
:
navigation/menu
...
...
examples/stocks/lib/main.dart
View file @
17ae19e8
...
...
@@ -40,7 +40,9 @@ class StocksAppState extends State<StocksApp> {
StockConfiguration
_configuration
=
new
StockConfiguration
(
stockMode:
StockMode
.
optimistic
,
backupMode:
BackupMode
.
enabled
,
showGrid:
false
debugShowGrid:
false
,
debugShowSizes:
false
,
showRenderingStatistics:
false
);
void
initState
()
{
...
...
@@ -98,10 +100,15 @@ class StocksAppState extends State<StocksApp> {
}
Widget
build
(
BuildContext
context
)
{
assert
(()
{
debugPaintSizeEnabled
=
_configuration
.
debugShowSizes
;
return
true
;
});
return
new
MaterialApp
(
title:
'Stocks'
,
theme:
theme
,
debugShowMaterialGrid:
_configuration
.
showGrid
,
debugShowMaterialGrid:
_configuration
.
debugShowGrid
,
showRenderingPerformanceOverlay:
_configuration
.
showRenderingStatistics
,
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
=>
new
StockHome
(
_stocks
,
_symbols
,
_configuration
,
configurationUpdater
),
'/settings'
:
(
RouteArguments
args
)
=>
new
StockSettings
(
_configuration
,
configurationUpdater
)
...
...
examples/stocks/lib/stock_settings.dart
View file @
17ae19e8
...
...
@@ -24,7 +24,15 @@ class StockSettingsState extends State<StockSettings> {
}
void
_handleShowGridChanged
(
bool
value
)
{
sendUpdates
(
config
.
configuration
.
copyWith
(
showGrid:
value
));
sendUpdates
(
config
.
configuration
.
copyWith
(
debugShowGrid:
value
));
}
void
_handleShowSizesChanged
(
bool
value
)
{
sendUpdates
(
config
.
configuration
.
copyWith
(
debugShowSizes:
value
));
}
void
_handleShowRenderingStatisticsChanged
(
bool
value
)
{
sendUpdates
(
config
.
configuration
.
copyWith
(
showRenderingStatistics:
value
));
}
void
_confirmOptimismChange
()
{
...
...
@@ -93,22 +101,44 @@ class StockSettingsState extends State<StockSettings> {
),
])
),
new
DrawerItem
(
icon:
'action/picture_in_picture'
,
onPressed:
()
{
_handleShowRenderingStatisticsChanged
(!
config
.
configuration
.
showRenderingStatistics
);
},
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Show rendering performance overlay'
)),
new
Switch
(
value:
config
.
configuration
.
showRenderingStatistics
,
onChanged:
_handleShowRenderingStatisticsChanged
),
])
),
];
assert
(()
{
// material grid
is
only available in checked mode
rows
.
add
(
// material grid
and size construction lines are
only available in checked mode
rows
.
add
All
([
new
DrawerItem
(
icon:
'editor/border_clear'
,
onPressed:
()
{
_handleShowGridChanged
(!
config
.
configuration
.
s
howGrid
);
},
onPressed:
()
{
_handleShowGridChanged
(!
config
.
configuration
.
debugS
howGrid
);
},
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Show material grid (for debugging)'
)),
new
Switch
(
value:
config
.
configuration
.
s
howGrid
,
value:
config
.
configuration
.
debugS
howGrid
,
onChanged:
_handleShowGridChanged
),
])
),
new
DrawerItem
(
icon:
'editor/border_all'
,
onPressed:
()
{
_handleShowSizesChanged
(!
config
.
configuration
.
debugShowSizes
);
},
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Show construction lines (for debugging)'
)),
new
Switch
(
value:
config
.
configuration
.
debugShowSizes
,
onChanged:
_handleShowSizesChanged
),
])
)
);
]
);
return
true
;
});
return
new
Block
(
...
...
examples/stocks/lib/stock_types.dart
View file @
17ae19e8
...
...
@@ -11,26 +11,36 @@ class StockConfiguration {
StockConfiguration
({
this
.
stockMode
,
this
.
backupMode
,
this
.
showGrid
this
.
debugShowGrid
,
this
.
debugShowSizes
,
this
.
showRenderingStatistics
})
{
assert
(
stockMode
!=
null
);
assert
(
backupMode
!=
null
);
assert
(
showGrid
!=
null
);
assert
(
debugShowGrid
!=
null
);
assert
(
debugShowSizes
!=
null
);
assert
(
showRenderingStatistics
!=
null
);
}
final
StockMode
stockMode
;
final
BackupMode
backupMode
;
final
bool
showGrid
;
final
bool
debugShowGrid
;
final
bool
debugShowSizes
;
final
bool
showRenderingStatistics
;
StockConfiguration
copyWith
({
StockMode
stockMode
,
BackupMode
backupMode
,
bool
showGrid
bool
debugShowGrid
,
bool
debugShowSizes
,
bool
showRenderingStatistics
})
{
return
new
StockConfiguration
(
stockMode:
stockMode
??
this
.
stockMode
,
backupMode:
backupMode
??
this
.
backupMode
,
showGrid:
showGrid
??
this
.
showGrid
debugShowGrid:
debugShowGrid
??
this
.
debugShowGrid
,
debugShowSizes:
debugShowSizes
??
this
.
debugShowSizes
,
showRenderingStatistics:
showRenderingStatistics
??
this
.
showRenderingStatistics
);
}
}
\ No newline at end of file
packages/flutter/lib/src/material/material_app.dart
View file @
17ae19e8
...
...
@@ -48,11 +48,13 @@ class MaterialApp extends StatefulComponent {
this
.
routes
:
const
<
String
,
RouteBuilder
>{},
this
.
onGenerateRoute
,
this
.
onLocaleChanged
,
this
.
debugShowMaterialGrid
:
false
this
.
debugShowMaterialGrid
:
false
,
this
.
showRenderingPerformanceOverlay
:
false
})
:
super
(
key:
key
)
{
assert
(
routes
!=
null
);
assert
(
routes
.
containsKey
(
Navigator
.
defaultRouteName
)
||
onGenerateRoute
!=
null
);
assert
(
debugShowMaterialGrid
!=
null
);
assert
(
showRenderingPerformanceOverlay
!=
null
);
}
final
String
title
;
...
...
@@ -61,6 +63,7 @@ class MaterialApp extends StatefulComponent {
final
RouteFactory
onGenerateRoute
;
final
LocaleChangedCallback
onLocaleChanged
;
final
bool
debugShowMaterialGrid
;
final
bool
showRenderingPerformanceOverlay
;
_MaterialAppState
createState
()
=>
new
_MaterialAppState
();
}
...
...
@@ -171,6 +174,12 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
}
return
true
;
});
if
(
config
.
showRenderingPerformanceOverlay
)
{
result
=
new
Stack
([
result
,
new
Positioned
(
bottom:
0.0
,
left:
0.0
,
right:
0.0
,
child:
new
StatisticsOverlay
.
allEnabled
()),
]);
}
return
result
;
}
...
...
packages/flutter/lib/src/rendering/statistics_box.dart
View file @
17ae19e8
...
...
@@ -5,28 +5,57 @@
import
'box.dart'
;
import
'object.dart'
;
class
RenderStatisticsBox
extends
RenderBox
{
/// The options that control whether the statistics overlay displays certain
/// aspects of the compositor
enum
StatisticsOption
{
/// Display the frame time and FPS of the last frame rendered. This field is
/// updated every frame.
///
/// This is the time spent by the rasterizer as it tries
/// to convert the layer tree obtained from the widgets into OpenGL commands
/// and tries to flush them onto the screen. When the total time taken by this
/// step exceeds the frame slice, a frame is lost.
displayRasterizerStatistics
,
/// Display the rasterizer frame times as they change over a set period of
/// time in the form of a graph. The y axis of the graph denotes the total
/// time spent by the rasterizer as a fraction of the total frame slice. When
/// the bar turns red, a frame is lost.
visualizeRasterizerStatistics
,
/// Display the frame time and FPS at which the interface can construct a
/// layer tree for the rasterizer (whose behavior is described above) to
/// consume.
///
/// This involves all layout, animations, etc. When the total time taken by
/// this step exceeds the frame slice, a frame is lost.
displayEngineStatistics
,
/// Display the engine frame times as they change over a set period of time
/// in the form of a graph. The y axis of the graph denotes the total time
/// spent by the eninge as a fraction of the total frame slice. When the bar
/// turns red, a frame is lost.
visualizeEngineStatistics
,
}
RenderStatisticsBox
({
int
optionsMask:
0
,
int
rasterizerThreshold:
0
})
class
RenderStatisticsBox
extends
RenderBox
{
RenderStatisticsBox
({
int
optionsMask:
0
,
int
rasterizerThreshold:
0
})
:
_optionsMask
=
optionsMask
,
_rasterizerThreshold
=
rasterizerThreshold
;
int
_optionsMask
;
/// The mask is created by shifting 1 by the index of the specific
/// StatisticOption to enable.
int
get
optionsMask
=>
_optionsMask
;
void
set
optionsMask
(
int
mask
)
{
if
(
mask
==
_optionsMask
)
{
int
_optionsMask
;
void
set
optionsMask
(
int
mask
)
{
if
(
mask
==
_optionsMask
)
return
;
}
_optionsMask
=
mask
;
markNeedsPaint
();
}
int
_rasterizerThreshold
;
int
get
rasterizerThreshold
=>
_rasterizerThreshold
;
int
_rasterizerThreshold
;
void
set
rasterizerThreshold
(
int
threshold
)
{
if
(
threshold
==
_rasterizerThreshold
)
{
if
(
threshold
==
_rasterizerThreshold
)
return
;
}
_rasterizerThreshold
=
threshold
;
markNeedsPaint
();
}
...
...
@@ -34,27 +63,35 @@ class RenderStatisticsBox extends RenderBox {
bool
get
sizedByParent
=>
true
;
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
minWidth
;
return
constraints
.
constrainWidth
(
0.0
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
maxWidth
;
return
constraints
.
constrainWidth
(
0.0
);
}
double
get
intrinsicHeight
{
const
double
kGraphHeight
=
80.0
;
// must match value in statistics_layer.cc
double
result
=
0.0
;
if
((
optionsMask
|
(
1
<<
StatisticsOption
.
displayRasterizerStatistics
.
index
)
>
0
)
||
(
optionsMask
|
(
1
<<
StatisticsOption
.
visualizeRasterizerStatistics
.
index
)
>
0
))
result
+=
kGraphHeight
;
if
((
optionsMask
|
(
1
<<
StatisticsOption
.
displayEngineStatistics
.
index
)
>
0
)
||
(
optionsMask
|
(
1
<<
StatisticsOption
.
visualizeEngineStatistics
.
index
)
>
0
))
result
+=
kGraphHeight
;
return
result
;
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
minHeight
;
return
constraints
.
constrainHeight
(
intrinsicHeight
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
maxHeight
;
return
constraints
.
constrainHeight
(
intrinsicHeight
);
}
void
performResize
()
{
size
=
constraints
.
biggest
;
size
=
constraints
.
constrain
(
new
Size
(
double
.
INFINITY
,
intrinsicHeight
))
;
}
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
...
...
packages/flutter/lib/src/widgets/statistics_overlay.dart
View file @
17ae19e8
...
...
@@ -6,44 +6,14 @@ import 'package:flutter/rendering.dart';
import
'framework.dart'
;
/// The options that control whether the statistics overlay displays certain
/// aspects of the compositor
enum
StatisticsOption
{
/// Display the frame time and FPS of the last frame rendered. This field is
/// updated every frame.
///
/// This is the time spent by the rasterizer as it tries
/// to convert the layer tree obtained from the widgets into OpenGL commands
/// and tries to flush them onto the screen. When the total time taken by this
/// step exceeds the frame slice, a frame is lost.
displayRasterizerStatistics
,
/// Display the rasterizer frame times as they change over a set period of
/// time in the form of a graph. The y axis of the graph denotes the total
/// time spent by the rasterizer as a fraction of the total frame slice. When
/// the bar turns red, a frame is lost.
visualizeRasterizerStatistics
,
/// Display the frame time and FPS at which the interface can construct a
/// layer tree for the rasterizer (whose behavior is described above) to
/// consume.
///
/// This involves all layout, animations, etc. When the total time taken by
/// this step exceeds the frame slice, a frame is lost.
displayEngineStatistics
,
/// Display the engine frame times as they change over a set period of time
/// in the form of a graph. The y axis of the graph denotes the total time
/// spent by the eninge as a fraction of the total frame slice. When the bar
/// turns red, a frame is lost.
visualizeEngineStatistics
,
}
/// Displays performance statistics.
class
StatisticsOverlay
extends
LeafRenderObjectWidget
{
// TODO(abarth): We should have a page on the web site with a screenshot and
// an explanation of all the various readouts.
/// Create a statistics overlay that only displays specific statistics. The
/// mask is created by shifting 1 by the index of the specific
StatisticOption
/// to enable.
/// mask is created by shifting 1 by the index of the specific
///
[StatisticOption]
to enable.
StatisticsOverlay
({
this
.
optionsMask
,
this
.
rasterizerThreshold
:
0
,
Key
key
})
:
super
(
key:
key
);
/// Create a statistics overaly that displays all available statistics
...
...
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