@@ -78,7 +78,7 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
78
78
}
79
79
80
80
ISize Playground::GetWindowSize () const {
81
- return { 1024 , 768 } ;
81
+ return window_size_ ;
82
82
}
83
83
84
84
void Playground::SetCursorPosition (Point pos) {
@@ -100,10 +100,6 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
100
100
fml::ScopedCleanupClosure terminate ([]() { ::glfwTerminate (); });
101
101
102
102
::glfwWindowHint (GLFW_CLIENT_API, GLFW_NO_API);
103
- // Recreation of the target render buffer is not setup in the playground yet.
104
- // So prevent users from resizing and getting confused that their math is
105
- // wrong.
106
- ::glfwWindowHint (GLFW_RESIZABLE, false );
107
103
108
104
auto window_title = GetWindowTitle (flutter::testing::GetCurrentTestName ());
109
105
auto window =
@@ -114,6 +110,16 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
114
110
}
115
111
116
112
::glfwSetWindowUserPointer (window, this );
113
+ ::glfwSetWindowSizeCallback (
114
+ window, [](GLFWwindow* window, int width, int height) -> void {
115
+ auto playground =
116
+ reinterpret_cast <Playground*>(::glfwGetWindowUserPointer (window));
117
+ if (!playground) {
118
+ return ;
119
+ }
120
+ playground->SetWindowSize (
121
+ ISize{std::max (width, 0 ), std::max (height, 0 )});
122
+ });
117
123
::glfwSetKeyCallback (window, &PlaygroundKeyCallback);
118
124
::glfwSetCursorPosCallback (window, [](GLFWwindow* window, double x,
119
125
double y) {
@@ -138,6 +144,11 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
138
144
return true ;
139
145
}
140
146
147
+ const auto layer_size = layer.bounds .size ;
148
+ const auto layer_scale = layer.contentsScale ;
149
+ layer.drawableSize = CGSizeMake (layer_size.width * layer_scale,
150
+ layer_size.height * layer_scale);
151
+
141
152
Renderer::RenderCallback wrapped_callback = [render_callback](auto & pass) {
142
153
pass.SetLabel (" Playground Main Render Pass" );
143
154
return render_callback (pass);
@@ -193,4 +204,8 @@ CompressedImage compressed_image(
193
204
return texture;
194
205
}
195
206
207
+ void Playground::SetWindowSize (ISize size) {
208
+ window_size_ = size;
209
+ }
210
+
196
211
} // namespace impeller
0 commit comments