Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ FlutterViewController::~FlutterViewController() {
}
}

void FlutterViewController::ForceRedraw() {
FlutterDesktopViewControllerForceRedraw(controller_);
}

std::optional<LRESULT> FlutterViewController::HandleTopLevelWindowProc(
HWND hwnd,
UINT message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class TestWindowsApi : public testing::StubFlutterWindowsApi {
// |flutter::testing::StubFlutterWindowsApi|
void ViewControllerDestroy() override { view_controller_destroyed_ = true; }

// |flutter::testing::StubFlutterWindowsApi|
void ViewControllerForceRedraw() override {
view_controller_force_redrawed_ = true;
}

// |flutter::testing::StubFlutterWindowsApi|
FlutterDesktopEngineRef EngineCreate(
const FlutterDesktopEngineProperties& engine_properties) override {
Expand All @@ -41,10 +46,14 @@ class TestWindowsApi : public testing::StubFlutterWindowsApi {

bool engine_destroyed() { return engine_destroyed_; }
bool view_controller_destroyed() { return view_controller_destroyed_; }
bool view_controller_force_redrawed() {
return view_controller_force_redrawed_;
}

private:
bool engine_destroyed_ = false;
bool view_controller_destroyed_ = false;
bool view_controller_force_redrawed_ = false;
};

} // namespace
Expand Down Expand Up @@ -79,4 +88,15 @@ TEST(FlutterViewControllerTest, GetView) {
EXPECT_NE(controller.view(), nullptr);
}

TEST(FlutterViewControllerTest, ForceRedraw) {
DartProject project(L"data");
testing::ScopedStubFlutterWindowsApi scoped_api_stub(
std::make_unique<TestWindowsApi>());
auto test_api = static_cast<TestWindowsApi*>(scoped_api_stub.stub());
FlutterViewController controller(100, 100, project);

controller.ForceRedraw();
EXPECT_TRUE(test_api->view_controller_force_redrawed());
}

} // namespace flutter
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class FlutterViewController {
// Returns the view managed by this controller.
FlutterView* view() { return view_.get(); }

// Requests new frame from the engine and repaints the view.
void ForceRedraw();

// Allows the Flutter engine and any interested plugins an opportunity to
// handle the given message.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ FlutterDesktopViewRef FlutterDesktopViewControllerGetView(
}

void FlutterDesktopViewControllerForceRedraw(
FlutterDesktopViewControllerRef controller) {}
FlutterDesktopViewControllerRef controller) {
if (s_stub_implementation) {
s_stub_implementation->ViewControllerForceRedraw();
}
}

bool FlutterDesktopViewControllerHandleTopLevelWindowProc(
FlutterDesktopViewControllerRef controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class StubFlutterWindowsApi {
// Called for FlutterDesktopViewControllerDestroy.
virtual void ViewControllerDestroy() {}

// Called for FlutterDesktopViewControllerForceRedraw.
virtual void ViewControllerForceRedraw() {}

// Called for FlutterDesktopViewControllerHandleTopLevelWindowProc.
virtual bool ViewControllerHandleTopLevelWindowProc(HWND hwnd,
UINT message,
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/public/flutter_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(
FLUTTER_EXPORT FlutterDesktopViewRef
FlutterDesktopViewControllerGetView(FlutterDesktopViewControllerRef controller);

// Requests new frame from engine and repaints the view
// Requests new frame from the engine and repaints the view.
FLUTTER_EXPORT void FlutterDesktopViewControllerForceRedraw(
FlutterDesktopViewControllerRef controller);

Expand Down