From 1a7ca91e3938abd5720b3553dfb2045a6b805a3b Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Tue, 3 Oct 2017 19:43:36 -0700 Subject: [PATCH] Use iOS scale when computing render buffer size (flutter/engine#4171) When checking whether render buffer size has changed, apply the device scale factor used to convert points to pixels to ensure we're not needlessly re-allocating render buffer storage. Adds trace + debug log to make this easier to detect in future. Originally introduced in 72c28f3a01bd9e6bed256edc4629705d96a7cead, but rolled back in d539abd7c5fe5291bab81b32e6e5697c1b6681b6 to test whether it was responsible for regressions to flutter_gallery_ios__transition_perf benchmarks: * average_frame_build_time_millis * missed_frame_build_budget_count --- .../flutter/shell/platform/darwin/ios/ios_gl_context.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_gl_context.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_gl_context.mm index dc018a0eb5..e9263141a0 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_gl_context.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_gl_context.mm @@ -163,14 +163,16 @@ bool IOSGLContext::PresentRenderBuffer() const { bool IOSGLContext::UpdateStorageSizeIfNecessary() { const CGSize layer_size = [layer_.get() bounds].size; - - const GLint size_width = layer_size.width; - const GLint size_height = layer_size.height; + const CGFloat contents_scale = layer_.get().contentsScale; + const GLint size_width = layer_size.width * contents_scale; + const GLint size_height = layer_size.height * contents_scale; if (size_width == storage_size_width_ && size_height == storage_size_height_) { // Nothing to since the stoage size is already consistent with the layer. return true; } + TRACE_EVENT0("flutter", "Updating render buffer storage size"); + FXL_DLOG(INFO) << "Updating render buffer storage size."; if (![EAGLContext setCurrentContext:context_]) { return false;