@@ -78,7 +78,7 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
7878}
7979
8080ISize Playground::GetWindowSize () const {
81- return { 1024 , 768 } ;
81+ return window_size_ ;
8282}
8383
8484void Playground::SetCursorPosition (Point pos) {
@@ -100,10 +100,6 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
100100 fml::ScopedCleanupClosure terminate ([]() { ::glfwTerminate (); });
101101
102102 ::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 );
107103
108104 auto window_title = GetWindowTitle (flutter::testing::GetCurrentTestName ());
109105 auto window =
@@ -114,6 +110,16 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
114110 }
115111
116112 ::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+ });
117123 ::glfwSetKeyCallback (window, &PlaygroundKeyCallback);
118124 ::glfwSetCursorPosCallback (window, [](GLFWwindow* window, double x,
119125 double y) {
@@ -138,6 +144,11 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
138144 return true ;
139145 }
140146
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+
141152 Renderer::RenderCallback wrapped_callback = [render_callback](auto & pass) {
142153 pass.SetLabel (" Playground Main Render Pass" );
143154 return render_callback (pass);
@@ -193,4 +204,8 @@ CompressedImage compressed_image(
193204 return texture;
194205}
195206
207+ void Playground::SetWindowSize (ISize size) {
208+ window_size_ = size;
209+ }
210+
196211} // namespace impeller
0 commit comments