diff --git a/bin/internal/engine.version b/bin/internal/engine.version index 0c7a110714..7bbfeb58d2 100644 --- a/bin/internal/engine.version +++ b/bin/internal/engine.version @@ -1 +1 @@ -16077d474b3ed44bb4aba9a90d8722c4d6591936 +84a060820a7a63d7683a4c546801ffe5c4a8f2e2 diff --git a/examples/flutter_gallery/lib/gallery/app.dart b/examples/flutter_gallery/lib/gallery/app.dart index b2b136eab9..102f060c69 100644 --- a/examples/flutter_gallery/lib/gallery/app.dart +++ b/examples/flutter_gallery/lib/gallery/app.dart @@ -29,12 +29,16 @@ class GalleryApp extends StatefulWidget { GalleryApp({ this.updateUrlFetcher, this.enablePerformanceOverlay: true, + this.checkerboardRasterCacheImages: true, Key key} ) : super(key: key); final UpdateUrlFetcher updateUrlFetcher; + final bool enablePerformanceOverlay; + final bool checkerboardRasterCacheImages; + @override GalleryAppState createState() => new GalleryAppState(); } @@ -42,6 +46,7 @@ class GalleryApp extends StatefulWidget { class GalleryAppState extends State { bool _useLightTheme = true; bool _showPerformanceOverlay = false; + bool _checkerboardRasterCacheImages = false; TargetPlatform platform = defaultTargetPlatform; @@ -60,6 +65,12 @@ class GalleryAppState extends State { _showPerformanceOverlay = value; }); } : null, + checkerboardRasterCacheImages: _checkerboardRasterCacheImages, + onCheckerboardRasterCacheImagesChanged: config.checkerboardRasterCacheImages ? (bool value) { + setState(() { + _checkerboardRasterCacheImages = value; + }); + } : null, onPlatformChanged: (TargetPlatform value) { setState(() { platform = value; @@ -85,6 +96,7 @@ class GalleryAppState extends State { color: Colors.grey[500], theme: (_useLightTheme ? _kGalleryLightTheme : _kGalleryDarkTheme).copyWith(platform: platform), showPerformanceOverlay: _showPerformanceOverlay, + checkerboardRasterCacheImages: _checkerboardRasterCacheImages, routes: _kRoutes, home: home, ); diff --git a/examples/flutter_gallery/lib/gallery/drawer.dart b/examples/flutter_gallery/lib/gallery/drawer.dart index 8249d53193..ecc5542f29 100644 --- a/examples/flutter_gallery/lib/gallery/drawer.dart +++ b/examples/flutter_gallery/lib/gallery/drawer.dart @@ -93,6 +93,8 @@ class GalleryDrawer extends StatelessWidget { this.onTimeDilationChanged, this.showPerformanceOverlay, this.onShowPerformanceOverlayChanged, + this.checkerboardRasterCacheImages, + this.onCheckerboardRasterCacheImagesChanged, this.onPlatformChanged, }) : super(key: key) { assert(onThemeChanged != null); @@ -108,6 +110,9 @@ class GalleryDrawer extends StatelessWidget { final bool showPerformanceOverlay; final ValueChanged onShowPerformanceOverlayChanged; + final bool checkerboardRasterCacheImages; + final ValueChanged onCheckerboardRasterCacheImagesChanged; + final ValueChanged onPlatformChanged; @override @@ -279,6 +284,23 @@ class GalleryDrawer extends StatelessWidget { )); } + if (onCheckerboardRasterCacheImagesChanged != null) { + allDrawerItems.insert(8, new DrawerItem( + icon: new Icon(Icons.assessment), + onPressed: () { onCheckerboardRasterCacheImagesChanged(!checkerboardRasterCacheImages); }, + selected: checkerboardRasterCacheImages, + child: new Row( + children: [ + new Flexible(child: new Text('Checkerboard Raster Cache Images')), + new Checkbox( + value: checkerboardRasterCacheImages, + onChanged: (bool value) { onCheckerboardRasterCacheImagesChanged(!checkerboardRasterCacheImages); } + ) + ] + ) + )); + } + return new Drawer(child: new Block(children: allDrawerItems)); } } diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index ea1946b889..803c260b0d 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -77,6 +77,8 @@ class GalleryHome extends StatefulWidget { this.onTimeDilationChanged, this.showPerformanceOverlay, this.onShowPerformanceOverlayChanged, + this.checkerboardRasterCacheImages, + this.onCheckerboardRasterCacheImagesChanged, this.onPlatformChanged, }) : super(key: key) { assert(onThemeChanged != null); @@ -92,6 +94,9 @@ class GalleryHome extends StatefulWidget { final bool showPerformanceOverlay; final ValueChanged onShowPerformanceOverlayChanged; + final bool checkerboardRasterCacheImages; + final ValueChanged onCheckerboardRasterCacheImagesChanged; + final ValueChanged onPlatformChanged; @override @@ -157,6 +162,8 @@ class GalleryHomeState extends State with SingleTickerProviderState onTimeDilationChanged: config.onTimeDilationChanged, showPerformanceOverlay: config.showPerformanceOverlay, onShowPerformanceOverlayChanged: config.onShowPerformanceOverlayChanged, + checkerboardRasterCacheImages: config.checkerboardRasterCacheImages, + onCheckerboardRasterCacheImagesChanged: config.onCheckerboardRasterCacheImagesChanged, onPlatformChanged: config.onPlatformChanged, ), appBar: new AppBar( diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index 6241909965..03c8bbcab9 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -57,6 +57,7 @@ class MaterialApp extends StatefulWidget { this.onLocaleChanged, this.debugShowMaterialGrid: false, this.showPerformanceOverlay: false, + this.checkerboardRasterCacheImages: false, this.showSemanticsDebugger: false, this.debugShowCheckedModeBanner: true }) : super(key: key) { @@ -128,6 +129,9 @@ class MaterialApp extends StatefulWidget { /// https://flutter.io/debugging/#performanceoverlay final bool showPerformanceOverlay; + /// Turns on checkerboarding of raster cache images. + final bool checkerboardRasterCacheImages; + /// Turns on an overlay that shows the accessibility information /// reported by the framework. final bool showSemanticsDebugger; @@ -264,6 +268,7 @@ class _MaterialAppState extends State { onGenerateRoute: _onGenerateRoute, onLocaleChanged: config.onLocaleChanged, showPerformanceOverlay: config.showPerformanceOverlay, + checkerboardRasterCacheImages: config.checkerboardRasterCacheImages, showSemanticsDebugger: config.showSemanticsDebugger, debugShowCheckedModeBanner: config.debugShowCheckedModeBanner ) diff --git a/packages/flutter/lib/src/rendering/layer.dart b/packages/flutter/lib/src/rendering/layer.dart index 8c6215ce71..e9ac48dff7 100644 --- a/packages/flutter/lib/src/rendering/layer.dart +++ b/packages/flutter/lib/src/rendering/layer.dart @@ -188,12 +188,13 @@ class ChildSceneLayer extends Layer { class PerformanceOverlayLayer extends Layer { /// Creates a layer that displays a performance overlay. PerformanceOverlayLayer({ - this.overlayRect, - this.optionsMask, - this.rasterizerThreshold + @required this.overlayRect, + @required this.optionsMask, + @required this.rasterizerThreshold, + @required this.checkerboardRasterCacheImages, }); - /// The rectangle in this layer's coodinate system that the overlay should occupy. + /// The rectangle in this layer's coordinate system that the overlay should occupy. Rect overlayRect; /// The mask is created by shifting 1 by the index of the specific @@ -205,11 +206,25 @@ class PerformanceOverlayLayer extends Layer { /// is suitable for capturing an SkPicture trace for further analysis. final int rasterizerThreshold; + /// Whether the raster cache should checkerboard cached entries. + /// + /// The compositor can sometimes decide to cache certain portions of the + /// widget hierarchy. Such portions typically don't change often from frame to + /// frame and are expensive to render. This can speed up overall rendering. However, + /// there is certain upfront cost to constructing these cache entries. And, if + /// the cache entries are not used very often, this cost may not be worth the + /// speedup in rendering of subsequent frames. If the developer wants to be certain + /// that populating the raster cache is not causing stutters, this option can be + /// set. Depending on the observations made, hints can be provided to the compositor + /// that aid it in making better decisions about caching. + final bool checkerboardRasterCacheImages; + @override void addToScene(ui.SceneBuilder builder, Offset layerOffset) { assert(optionsMask != null); builder.addPerformanceOverlay(optionsMask, overlayRect.shift(layerOffset)); builder.setRasterizerTracingThreshold(rasterizerThreshold); + builder.setCheckerboardRasterCacheImages(checkerboardRasterCacheImages); } } diff --git a/packages/flutter/lib/src/rendering/performance_overlay.dart b/packages/flutter/lib/src/rendering/performance_overlay.dart index f8bff32118..b559d35e09 100644 --- a/packages/flutter/lib/src/rendering/performance_overlay.dart +++ b/packages/flutter/lib/src/rendering/performance_overlay.dart @@ -59,12 +59,19 @@ enum PerformanceOverlayOption { class RenderPerformanceOverlay extends RenderBox { /// Creates a performance overlay render object. /// - /// The [optionsMask] and [rasterizerThreshold] arguments must not be null. + /// The [optionsMask], [rasterizerThreshold] and [checkerboardRasterCacheImages] + /// arguments must not be null. RenderPerformanceOverlay({ int optionsMask: 0, - int rasterizerThreshold: 0 + int rasterizerThreshold: 0, + bool checkerboardRasterCacheImages: false, }) : _optionsMask = optionsMask, - _rasterizerThreshold = rasterizerThreshold; + _rasterizerThreshold = rasterizerThreshold, + _checkerboardRasterCacheImages = checkerboardRasterCacheImages { + assert(optionsMask != null); + assert(rasterizerThreshold != null); + assert(checkerboardRasterCacheImages != null); + } /// The mask is created by shifting 1 by the index of the specific /// [PerformanceOverlayOption] to enable. @@ -91,6 +98,17 @@ class RenderPerformanceOverlay extends RenderBox { markNeedsPaint(); } + /// Whether the raster cache should checkerboard cached entries. + bool get checkerboardRasterCacheImages => _checkerboardRasterCacheImages; + bool _checkerboardRasterCacheImages; + set checkerboardRasterCacheImages (bool checkerboard) { + assert(checkerboard != null); + if (checkerboard == _checkerboardRasterCacheImages) + return; + _checkerboardRasterCacheImages = checkerboard; + markNeedsPaint(); + } + @override bool get sizedByParent => true; @@ -140,7 +158,8 @@ class RenderPerformanceOverlay extends RenderBox { context.addLayer(new PerformanceOverlayLayer( overlayRect: new Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height), optionsMask: optionsMask, - rasterizerThreshold: rasterizerThreshold + rasterizerThreshold: rasterizerThreshold, + checkerboardRasterCacheImages: checkerboardRasterCacheImages, )); } } diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 9ffcbc4370..49af12769a 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -48,11 +48,13 @@ class WidgetsApp extends StatefulWidget { this.initialRoute, this.onLocaleChanged, this.showPerformanceOverlay: false, + this.checkerboardRasterCacheImages: false, this.showSemanticsDebugger: false, this.debugShowCheckedModeBanner: true }) : super(key: key) { assert(onGenerateRoute != null); assert(showPerformanceOverlay != null); + assert(checkerboardRasterCacheImages != null); assert(showSemanticsDebugger != null); } @@ -86,6 +88,9 @@ class WidgetsApp extends StatefulWidget { /// https://flutter.io/debugging/#performanceoverlay final bool showPerformanceOverlay; + /// Checkerboards raster cache images. + final bool checkerboardRasterCacheImages; + /// Turns on an overlay that shows the accessibility information /// reported by the framework. final bool showSemanticsDebugger; @@ -197,11 +202,22 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv child: result ); } + + PerformanceOverlay performanceOverlay; + // We need to push a performance overlay if any of the display or checkerboarding + // options are set. if (config.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) { + performanceOverlay = new PerformanceOverlay.allEnabled( + checkerboardRasterCacheImages: config.checkerboardRasterCacheImages); + } else if (config.checkerboardRasterCacheImages) { + performanceOverlay = new PerformanceOverlay(checkerboardRasterCacheImages: true); + } + + if (performanceOverlay != null) { result = new Stack( children: [ result, - new Positioned(top: 0.0, left: 0.0, right: 0.0, child: new PerformanceOverlay.allEnabled()), + new Positioned(top: 0.0, left: 0.0, right: 0.0, child: performanceOverlay), ] ); } diff --git a/packages/flutter/lib/src/widgets/performance_overlay.dart b/packages/flutter/lib/src/widgets/performance_overlay.dart index b241c90371..25a2dcc4fd 100644 --- a/packages/flutter/lib/src/widgets/performance_overlay.dart +++ b/packages/flutter/lib/src/widgets/performance_overlay.dart @@ -29,12 +29,15 @@ class PerformanceOverlay extends LeafRenderObjectWidget { /// [StatisticOption] to enable. PerformanceOverlay({ Key key, - this.optionsMask, - this.rasterizerThreshold: 0 + this.optionsMask: 0, + this.rasterizerThreshold: 0, + this.checkerboardRasterCacheImages: false }) : super(key: key); /// Create a performance overlay that displays all available statistics - PerformanceOverlay.allEnabled({ Key key, this.rasterizerThreshold: 0 }) + PerformanceOverlay.allEnabled({ Key key, + this.rasterizerThreshold: 0, + this.checkerboardRasterCacheImages: false }) : optionsMask = ( 1 << PerformanceOverlayOption.displayRasterizerStatistics.index | 1 << PerformanceOverlayOption.visualizeRasterizerStatistics.index | @@ -75,10 +78,24 @@ class PerformanceOverlay extends LeafRenderObjectWidget { /// how many frame intervals). final int rasterizerThreshold; + /// Whether the raster cache should checkerboard cached entries. + /// + /// The compositor can sometimes decide to cache certain portions of the + /// widget hierarchy. Such portions typically don't change often from frame to + /// frame and are expensive to render. This can speed up overall rendering. However, + /// there is certain upfront cost to constructing these cache entries. And, if + /// the cache entries are not used very often, this cost may not be worth the + /// speedup in rendering of subsequent frames. If the developer wants to be certain + /// that populating the raster cache is not causing stutters, this option can be + /// set. Depending on the observations made, hints can be provided to the compositor + /// that aid it in making better decisions about caching. + final bool checkerboardRasterCacheImages; + @override RenderPerformanceOverlay createRenderObject(BuildContext context) => new RenderPerformanceOverlay( optionsMask: optionsMask, - rasterizerThreshold: rasterizerThreshold + rasterizerThreshold: rasterizerThreshold, + checkerboardRasterCacheImages: checkerboardRasterCacheImages ); @override