Use iOS scale when computing render buffer size (#4171) (flutter/engine#4373)

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 72c28f3a01, but
rolled back in d539abd7c5 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

Re-landed in 1a7ca91e39, and reverted in
79b9bdbbf4 after it appeared to regress
the above two benchmarks. After recent changes to microtask execution
order which fixed https://github.com/flutter/flutter/issues/9998,
re-introducing this fix results in benchmark improvements to the above
two benchmarks in local testing.
This commit is contained in:
Chris Bracken
2017-11-20 14:15:26 -08:00
committed by GitHub
parent d3a9978723
commit dc4ecd943b

View File

@@ -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_EVENT_INSTANT0("flutter", "IOSGLContext::UpdateStorageSizeIfNecessary");
FXL_DLOG(INFO) << "Updating render buffer storage size.";
if (![EAGLContext setCurrentContext:context_]) {
return false;