Code cleanup on destructors (flutter/engine#16481)
This commit is contained in:
committed by
GitHub
parent
0fae445981
commit
40c7f488e9
@@ -1,5 +1,4 @@
|
||||
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
@@ -14,7 +14,7 @@ class Win32FlutterWindowTest : public Win32FlutterWindow {
|
||||
public:
|
||||
Win32FlutterWindowTest(int width, int height);
|
||||
|
||||
~Win32FlutterWindowTest();
|
||||
virtual ~Win32FlutterWindowTest();
|
||||
|
||||
// |Win32Window|
|
||||
void OnFontChange() override;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace flutter {
|
||||
|
||||
// the Windows DPI system is based on this
|
||||
// The Windows DPI system is based on this
|
||||
// constant for machines running at 100% scaling.
|
||||
constexpr int base_dpi = 96;
|
||||
|
||||
@@ -15,7 +15,6 @@ Win32FlutterWindow::Win32FlutterWindow(int width, int height) {
|
||||
|
||||
Win32FlutterWindow::~Win32FlutterWindow() {
|
||||
DestroyRenderSurface();
|
||||
Win32Window::Destroy();
|
||||
}
|
||||
|
||||
FlutterDesktopViewControllerRef Win32FlutterWindow::CreateWin32FlutterWindow(
|
||||
@@ -177,10 +176,6 @@ void Win32FlutterWindow::OnScroll(double delta_x, double delta_y) {
|
||||
}
|
||||
}
|
||||
|
||||
void Win32FlutterWindow::OnClose() {
|
||||
messageloop_running_ = false;
|
||||
}
|
||||
|
||||
void Win32FlutterWindow::OnFontChange() {
|
||||
if (engine_ == nullptr) {
|
||||
return;
|
||||
@@ -358,5 +353,4 @@ void Win32FlutterWindow::DestroyRenderSurface() {
|
||||
}
|
||||
render_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -33,7 +33,7 @@ class Win32FlutterWindow : public Win32Window {
|
||||
// Create flutter Window for use as child window
|
||||
Win32FlutterWindow(int width, int height);
|
||||
|
||||
~Win32FlutterWindow();
|
||||
virtual ~Win32FlutterWindow();
|
||||
|
||||
static FlutterDesktopViewControllerRef CreateWin32FlutterWindow(int width,
|
||||
int height);
|
||||
@@ -65,9 +65,6 @@ class Win32FlutterWindow : public Win32Window {
|
||||
// |Win32Window|
|
||||
void OnScroll(double delta_x, double delta_y) override;
|
||||
|
||||
// |Win32Window|
|
||||
void OnClose() override;
|
||||
|
||||
// |Win32Window|
|
||||
void OnFontChange() override;
|
||||
|
||||
@@ -85,9 +82,6 @@ class Win32FlutterWindow : public Win32Window {
|
||||
// Create a surface for Flutter engine to render into.
|
||||
void CreateRenderSurface();
|
||||
|
||||
// Destroy current rendering surface if one has been allocated.
|
||||
void DestroyRenderSurface();
|
||||
|
||||
// Callbacks for clearing context, settings context and swapping buffers.
|
||||
bool ClearContext();
|
||||
bool MakeCurrent();
|
||||
@@ -99,6 +93,9 @@ class Win32FlutterWindow : public Win32Window {
|
||||
void SendWindowMetrics();
|
||||
|
||||
private:
|
||||
// Destroy current rendering surface if one has been allocated.
|
||||
void DestroyRenderSurface();
|
||||
|
||||
// Reports a mouse movement to Flutter engine.
|
||||
void SendPointerMove(double x, double y);
|
||||
|
||||
@@ -174,9 +171,6 @@ class Win32FlutterWindow : public Win32Window {
|
||||
|
||||
// should we forword input messages or not
|
||||
bool process_events_ = false;
|
||||
|
||||
// flag indicating if the message loop should be running
|
||||
bool messageloop_running_ = false;
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -112,10 +112,6 @@ Win32Window::MessageHandler(HWND hwnd,
|
||||
case kWmDpiChangedBeforeParent:
|
||||
return HandleDpiChange(window_handle_, wparam, lparam, false);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
window->OnClose();
|
||||
return 0;
|
||||
break;
|
||||
case WM_SIZE:
|
||||
width = LOWORD(lparam);
|
||||
height = HIWORD(lparam);
|
||||
|
||||
@@ -37,7 +37,7 @@ struct MouseState {
|
||||
class Win32Window {
|
||||
public:
|
||||
Win32Window();
|
||||
~Win32Window();
|
||||
virtual ~Win32Window();
|
||||
|
||||
// Initializes as a child window with size using |width| and |height| and
|
||||
// |title| to identify the windowclass. Does not show window, window must be
|
||||
@@ -46,9 +46,6 @@ class Win32Window {
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
|
||||
// Release OS resources asociated with window.
|
||||
virtual void Destroy();
|
||||
|
||||
HWND GetWindowHandle();
|
||||
|
||||
protected:
|
||||
@@ -116,9 +113,6 @@ class Win32Window {
|
||||
// Called when mouse scrollwheel input occurs.
|
||||
virtual void OnScroll(double delta_x, double delta_y) = 0;
|
||||
|
||||
// Called when the user closes the Windows.
|
||||
virtual void OnClose() = 0;
|
||||
|
||||
// Called when the system font change.
|
||||
virtual void OnFontChange() = 0;
|
||||
|
||||
@@ -150,6 +144,9 @@ class Win32Window {
|
||||
void SetMouseButtons(uint64_t buttons) { mouse_state_.buttons = buttons; }
|
||||
|
||||
private:
|
||||
// Release OS resources asociated with window.
|
||||
void Destroy();
|
||||
|
||||
// Activates tracking for a "mouse leave" event.
|
||||
void TrackMouseLeaveEvent(HWND hwnd);
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ TEST(Win32FlutterWindowTest, CanFontChange) {
|
||||
LRESULT result = SendMessage(hwnd, WM_FONTCHANGE, NULL, NULL);
|
||||
ASSERT_EQ(result, 0);
|
||||
ASSERT_TRUE(window.OnFontChangeWasCalled());
|
||||
ASSERT_TRUE(TRUE);
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
|
||||
Reference in New Issue
Block a user