Repository: flutter
Issue: Very slow execution of "canvas.drawPicture" with target platfrom "Windows"
Labels: engine,c: performance,platform-windows,c: rendering,a: desktop,has reproducible steps,P3,found in release: 3.10,found in release: 3.14,team-windows,triaged-windows

## Details

I'm trying to draw quite a huge amounts of objects ~40.000 into a canvas. I know about "drawRawPoints", but the "data points" being displayed will have different orientations, so just plotting a raw set of point's will not do it. However from discussions like that [ #100829](https://github.com/flutter/flutter/issues/100829) I figured that drawing/recording pictures might be the right way to go...
 
Although drawing the "point cloud" into a picture still seems to take a few hundred milliseconds to display, it runs  with acceptable speed if I compile my project with target platform "web" and run it in a Browser. (For the browser it didn't matter which one I tried Edge, Chrome and Firefox all rendered the scene with acceptable speed around a few hundred milliseconds )
If I however compile the same code (sample code blow) with target platform windows, it executes so slow that the application isn't usable any more.  Each call to "canvas.drawPicture" takes about a minutes, working with this application is not possible. 
I've tested both versions (web and windows) on the same PC both running under Windows 10. 

I've also been playing around with the "SceneBuilder" and rasterized the scene into an "Image". In this cases both versions (web and windows)  show almost the same performance, but since I'll need to zoom on the data this is no way to go for me. 

What is the reason for the huge difference in performance for the two versions just executing the same code? 
How can it be that it runs so much faster in a Browser than as a native windows application ?
Is there any way to keep the "point could" data in kind of a layer which can be quickly repainted? (Similar to [ #100829](https://github.com/flutter/flutter/issues/100829) ) Since we have changing overlayed data to display which needs to be repainted much more often that the "point cloud" itself. Ideally I'd like to keep the "point cloud" as a kind of background wallpaper and draw on top of it. When using "canvas.drawPicture" (as mentioned above) it still consumes a lot of time, is there a faster way to go?
(We've been playing around with "SceneBuilder.addRetained" but we found no way to display the scene without rasterization)

[Profiling](https://github.com/flutter/flutter/assets/19710372/c911eebb-4f55-45b4-a2aa-30a6a843d95b) shows he stack trace of the "paint" call  from the sample program. ( target platform windows ) Execution took 88s all the way down to "_drawFrame".
<img src="https://github.com/flutter/flutter/assets/19710372/c911eebb-4f55-45b4-a2aa-30a6a843d95b" >
</img>

## Code
Small sample code which reproduces the issue:
```
void main() =>runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: Scaffold(body: SafeArea(child: CustomPaint(painter: TestPainter()))));
  }
}

class TestPainter extends CustomPainter {
  final Picture _picture;

  TestPainter(): _picture =_createHugePicture();

  static Picture _createHugePicture() {
    Random rnd = Random();
    var pictureRecorder = PictureRecorder();
    var canvas = Canvas(pictureRecorder);
    Paint paint = Paint()..color = Colors.blue..style = PaintingStyle.fill;

    for(int x = 0; x < 400; x++) {
      for (int y = 0; y < 200; y++) {
        canvas.drawArc(Rect.fromCenter(center: Offset(x * 6, y * 6), width: 4, height: 4), 0,
            rnd.nextDouble() * 2 * 3.14, false, paint);
      }
    }
    return  pictureRecorder.endRecording();
  }

  @override
  void paint(Canvas canvas, Size size) =>
     canvas.drawPicture(_picture);


  @override
  bool shouldRepaint(covariant TestPainter oldDelegate) => false;

}

```
<Details>
<summary>
Flutter doctor output
</summary>

[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.19045.3324], locale de-DE)
    • Flutter version 3.10.6 on channel stable at H:\flutter                                      
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (5 weeks ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at H:\Programme\AndroidSDK
    • Platform android-33, build-tools 32.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java      
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Professional 2022 17.4.6)
    • Visual Studio at h:\Program Files\Microsoft Visual Studio\2022\Professional
    • Visual Studio Professional 2022 version 17.4.33502.350
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)     

[√] IntelliJ IDEA Community Edition (version 2020.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.4
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 202.8443

[√] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at H:\Programme\JetBrains\IntelliJ IDEA Community Edition 2021.1
    • Flutter plugin version 68.1.1
    • Dart plugin version 211.7817

[√] VS Code (version 1.62.0)
    • VS Code at C:\Users\msdn\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.3324]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 115.0.5790.171
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 115.0.1901.200

[√] Network resources
    • All expected network resources are available.

• No issues found!

</Details>