Skip to content

Commit

Permalink
Revert "Reland "[Windows] Move to FlutterCompositor for rendering" (f…
Browse files Browse the repository at this point in the history
…lutter#49461)

This reverts flutter#49262 (flutter@00d7d23) as it regressed [`material_floating_search_bar`](https://pub.dev/packages/material_floating_search_bar_2)'s animation.

This revert was created manually due to merge conflicts.

Issue tracking bug: flutter/flutter#140828

Part of flutter/flutter#128904

<details>
<summary>Minimal repro of the broken animation...</summary>

Here's what the animation is supposed to look like:
![good](https://publish-01.obsidian.md/access/b48ac8ca270cd9dac18c4a64d11b1c02/assets/2023-12-28-compositor_animation_regression_good.gif)

Here's what the animation actually looks like: ![bad](https://publish-01.obsidian.md/access/b48ac8ca270cd9dac18c4a64d11b1c02/assets/2023-12-28-compositor_animation_regression_bad.gif)

Here is a minimal repro of the broken animation:

```dart
// The Windows compositor changes regresses the animation in
// the `material_floating_search_bar_2` package:
// 
// https://pub.dev/packages/material_floating_search_bar_2/versions/0.5.0
//
// Below is a minimal repro of the broken animation. This has two pieces:
//
//  1. The background fades to a grey color
//  2. A box is "revealed" using a custom clipper
//
// On framework commit b417fb8 this animation is broken on Windows.
// On framework commit 9c2a756 this animation works as expected on Windows.
//
// Good gif: https://publish-01.obsidian.md/access/b48ac8ca270cd9dac18c4a64d11b1c02/assets/2023-12-28-compositor_animation_regression_good.gif
// Bad gif: https://publish-01.obsidian.md/access/b48ac8ca270cd9dac18c4a64d11b1c02/assets/2023-12-28-compositor_animation_regression_bad.gif
import 'dart:math';
import 'dart:ui';

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @OverRide
  Widget build(BuildContext context) {
    // Not using `MaterialApp` is necessary to reproduce:
    return Container(
      color: Colors.white,
      child: const Directionality(
        textDirection: TextDirection.ltr,
        child: FloatingSearchBar(),
      ),
    );

    // Switching to `MaterialApp` fixes the issue:
    // return const MaterialApp(
    //   home: Scaffold(
    //     body: FloatingSearchBar(),
    //   ),
    // );
  }
}

class FloatingSearchBar extends StatefulWidget {
  const FloatingSearchBar({super.key});

  @OverRide
  FloatingSearchBarState createState() => FloatingSearchBarState();
}

class FloatingSearchBarState extends State<FloatingSearchBar> with SingleTickerProviderStateMixin {
  late final AnimationController _controller = AnimationController(
    vsync: this,
    duration: const Duration(seconds: 2),
  );

  @OverRide
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  void _animate() {
    if (_controller.isDismissed || _controller.status == AnimationStatus.reverse) {
      _controller.forward();
    } else {
      _controller.reverse();
    }
  }

  @OverRide
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: _controller,
      builder: (BuildContext context, _) {
        return Stack(
          children: <Widget>[
            if (!_controller.isDismissed)
              FadeTransition(
                opacity: _controller,
                child: const SizedBox.expand(
                  child: DecoratedBox(
                    decoration: BoxDecoration(color: Colors.black26),
                  ),
                ),
              ),

            _buildSearchBar(),
          ],
        );
      },
    );
  }

  Widget _buildSearchBar() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        // This is where the search text input would go...
        GestureDetector(
          onTap: () => _animate(),
          child: Text(
            switch (_controller.status) {
              AnimationStatus.forward || AnimationStatus.completed => 'Click to close',
              AnimationStatus.reverse || AnimationStatus.dismissed => 'Click to open',
            },
            style: const TextStyle(color: Colors.black),
          ),
        ),
        
        // Below are where the search results would be. Clicking on the search
        // input above reveals the results below.

        // Removing this fixes the background's fade transition.
        ClipOval(
          clipper: _CircularRevealClipper(
            fraction: _controller.value,
          ),
          child: DecoratedBox(
            decoration: BoxDecoration(
              color: Colors.white,
              // Removing this line fixes the background's fade transition.
              borderRadius: BorderRadius.circular(16.0),
            ),
            child: const Padding(
              padding: EdgeInsets.all(64.0),
              child: Text(
                'Hello world',
                style: TextStyle(color: Colors.black),
              ),
            ),
          ),
        ),
      ],
    );
  }
}

class _CircularRevealClipper extends CustomClipper<Rect> {
  const _CircularRevealClipper({required this.fraction});

  final double fraction;

  @OverRide
  Rect getClip(Size size) {
    final double halfWidth = size.width * 0.5;
    final double maxRadius = sqrt(halfWidth * halfWidth + size.height * size.height);
    final double radius = lerpDouble(0.0, maxRadius, fraction) ?? 0;

    return Rect.fromCircle(
      center: Offset(halfWidth, 0),
      radius: radius,
    );
  }

  @OverRide
  bool shouldReclip(CustomClipper<Rect> oldClipper) {
    if (oldClipper is _CircularRevealClipper) {
      return oldClipper.fraction != fraction;
    }

    return true;
  }
}

```

</details>

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
loic-sharma authored Jan 2, 2024
1 parent b5e79bd commit e95e123
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 933 deletions.
2 changes: 0 additions & 2 deletions ci/licenses_golden/excluded_files
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@
../../../flutter/shell/platform/windows/client_wrapper/flutter_view_unittests.cc
../../../flutter/shell/platform/windows/client_wrapper/plugin_registrar_windows_unittests.cc
../../../flutter/shell/platform/windows/client_wrapper/testing
../../../flutter/shell/platform/windows/compositor_opengl_unittests.cc
../../../flutter/shell/platform/windows/compositor_software_unittests.cc
../../../flutter/shell/platform/windows/cursor_handler_unittests.cc
../../../flutter/shell/platform/windows/direct_manipulation_unittests.cc
../../../flutter/shell/platform/windows/dpi_utils_unittests.cc
Expand Down
10 changes: 0 additions & 10 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -7201,11 +7201,6 @@ ORIGIN: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/f
ORIGIN: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_view.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_view_controller.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/plugin_registrar_windows.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/compositor.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/compositor_opengl.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/compositor_opengl.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/compositor_software.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/compositor_software.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/cursor_handler.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/cursor_handler.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/windows/direct_manipulation.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -10044,11 +10039,6 @@ FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/flu
FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_view.h
FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_view_controller.h
FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/plugin_registrar_windows.h
FILE: ../../../flutter/shell/platform/windows/compositor.h
FILE: ../../../flutter/shell/platform/windows/compositor_opengl.cc
FILE: ../../../flutter/shell/platform/windows/compositor_opengl.h
FILE: ../../../flutter/shell/platform/windows/compositor_software.cc
FILE: ../../../flutter/shell/platform/windows/compositor_software.h
FILE: ../../../flutter/shell/platform/windows/cursor_handler.cc
FILE: ../../../flutter/shell/platform/windows/cursor_handler.h
FILE: ../../../flutter/shell/platform/windows/direct_manipulation.cc
Expand Down
4 changes: 0 additions & 4 deletions impeller/renderer/backend/gles/description_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ std::string DescriptionGLES::GetString() const {
return stream.str();
}

Version DescriptionGLES::GetGlVersion() const {
return gl_version_;
}

bool DescriptionGLES::IsES() const {
return is_es_;
}
Expand Down
2 changes: 0 additions & 2 deletions impeller/renderer/backend/gles/description_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class DescriptionGLES {

std::string GetString() const;

Version GetGlVersion() const;

bool HasExtension(const std::string& ext) const;

/// @brief Returns whether GLES includes the debug extension.
Expand Down
3 changes: 1 addition & 2 deletions shell/platform/linux/fl_backing_store_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ uint32_t fl_backing_store_provider_get_gl_format(FlBackingStoreProvider* self) {
// In Linux kN32_SkColorType is assumed to be kBGRA_8888_SkColorType.
// So we must choose a valid gl format to be compatible with surface format
// BGRA8.
// Following logics are copied from Skia GrGLCaps.cpp:
// https://github.com/google/skia/blob/4738ed711e03212aceec3cd502a4adb545f38e63/src/gpu/ganesh/gl/GrGLCaps.cpp#L1963-L2116
// Following logics are copied from Skia GrGLCaps.cpp.

if (epoxy_is_desktop_gl()) {
// For OpenGL.
Expand Down
9 changes: 0 additions & 9 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ source_set("flutter_windows_source") {
"accessibility_bridge_windows.h",
"angle_surface_manager.cc",
"angle_surface_manager.h",
"compositor.h",
"compositor_opengl.cc",
"compositor_opengl.h",
"compositor_software.cc",
"compositor_software.h",
"cursor_handler.cc",
"cursor_handler.h",
"direct_manipulation.cc",
Expand Down Expand Up @@ -139,7 +134,6 @@ source_set("flutter_windows_source") {
deps = [
":flutter_windows_headers",
"//flutter/fml:fml",
"//flutter/impeller/renderer/backend/gles",
"//flutter/shell/platform/common:common_cpp",
"//flutter/shell/platform/common:common_cpp_input",
"//flutter/shell/platform/common:common_cpp_switches",
Expand Down Expand Up @@ -181,8 +175,6 @@ executable("flutter_windows_unittests") {
# Common Windows test sources.
sources = [
"accessibility_bridge_windows_unittests.cc",
"compositor_opengl_unittests.cc",
"compositor_software_unittests.cc",
"cursor_handler_unittests.cc",
"direct_manipulation_unittests.cc",
"dpi_utils_unittests.cc",
Expand Down Expand Up @@ -243,7 +235,6 @@ executable("flutter_windows_unittests") {
":flutter_windows_fixtures",
":flutter_windows_headers",
":flutter_windows_source",
"//flutter/impeller/renderer/backend/gles",
"//flutter/shell/platform/common:common_cpp",
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
Expand Down
39 changes: 0 additions & 39 deletions shell/platform/windows/compositor.h

This file was deleted.

188 changes: 0 additions & 188 deletions shell/platform/windows/compositor_opengl.cc

This file was deleted.

61 changes: 0 additions & 61 deletions shell/platform/windows/compositor_opengl.h

This file was deleted.

Loading

0 comments on commit e95e123

Please sign in to comment.