From 018905ddc3b19059b70241a186d3adbe9724e243 Mon Sep 17 00:00:00 2001 From: Mark Waddingham Date: Thu, 31 Aug 2017 14:03:25 +0100 Subject: [PATCH] [[ Bug 9992 ]] Improve export/import snapshot from screen on iOS7+ This patch changes the API used to render the screen when doing a screen snapshot on iOS7+. It will now use drawViewHierarchyInRect:afterScreenUpdates: which enables a greater variety of types of UIView to be captured. --- docs/notes/bugfix-9992.md | 5 +++++ engine/src/mbliphonedc.mm | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 docs/notes/bugfix-9992.md diff --git a/docs/notes/bugfix-9992.md b/docs/notes/bugfix-9992.md new file mode 100644 index 00000000000..d0e00cec917 --- /dev/null +++ b/docs/notes/bugfix-9992.md @@ -0,0 +1,5 @@ +# Improve export/import snapshot from screen on iOS + +The from screen form of export/import snapshot has been changed +to use a different API on iOS7+, which allows a greater variety +of native layers to be captured. diff --git a/engine/src/mbliphonedc.mm b/engine/src/mbliphonedc.mm index 37c9866ae80..ec4f2db6835 100644 --- a/engine/src/mbliphonedc.mm +++ b/engine/src/mbliphonedc.mm @@ -617,8 +617,19 @@ static void MCScreenDCDoSnapshot(void *p_env) -[window bounds].size.height * [[window layer] anchorPoint].y); // Render the layer hierarchy to the current context - [[window layer] renderInContext:t_img_context]; - + if ([window respondsToSelector: @selector(drawViewHierarchyInRect:afterScreenUpdates:)]) + { + // This method is supported in iOS7+ and will capture many + // native view's content. + UIGraphicsPushContext(t_img_context); + [window drawViewHierarchyInRect:[window bounds] afterScreenUpdates:YES]; + UIGraphicsPopContext(); + } + else + { + [[window layer] renderInContext:t_img_context]; + } + // Restore the context CGContextRestoreGState(t_img_context); }