Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Oct 23, 2019

issue related flutter/flutter#41620

Code
GLContextSwitch
An interface should be subclassed to switch flutter's gl context to current context on construction and switch back the previous context to current on destruction.

IOSGLContextSwitch
The iOS implementation of GLContextSwitch.

GLContextSwitchManager
Manages the GLContextSwitch, exposes 2 APIs that should be overridden by the platform: MakeCurrent, MakeResourceCurrent

IOSGLContextSwitchManager
The iOS implementation of GLContextSwitchManager. It creates a NSMutableArray as a stack to manage the EAGLContexts.
On MakeCurrent and MakeResourceCurrent, it pushes the current EAGLContext to the stack, then creates a IOSGLContextSwitch and set the current context to the respective flutter context.
When IOSGLContextSwitch goes out of the scope, the previous context is restored from the stack and set to current.

GLContextSwitchPureResult
In certain cases, when we call MakeCurrent method in ios_context_gl or ios_render_target_gl, if certain condition wasn't met, we don't set the context and returns a false directly. I added this class to accommodate this situation without further refactoring to prevent too much of refactoring during this work.

Both android and embedder use GLContextSwitchPureResult to avoid changes to the current behavior while complying to the new interface.

Test
Add a scenario app integration test that makes sure the [EAGLContext currentContext] by a Platform View is not the context used by Flutter.

Copy link
Contributor Author

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with @chinmaygarde's suggestions.

#ifndef FLUTTER_SHELL_COMMON_GL_CONTEXT_SWITCH_MANAGER_H_
#define FLUTTER_SHELL_COMMON_GL_CONTEXT_SWITCH_MANAGER_H_

#include <map>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Should be subclassed for platforms that uses GL and requires context
// switching. Always use `MakeCurrent` and `ResourceMakeCurrent` in the
// `GLContextSwitchManager` to set gl contexts.
class GLContextSwitchManager {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with the doxygen

public:
class IOSGLContextSwitch final : public GLContextSwitch {
public:
IOSGLContextSwitch(IOSGLContextSwitchManager& manager,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ghost
Copy link

ghost commented Nov 4, 2019

Excited about this update guys!

@cyanglaz cyanglaz merged commit bec5542 into flutter:master Nov 8, 2019
@cyanglaz cyanglaz deleted the gl branch November 8, 2019 18:02
@cyanglaz cyanglaz restored the gl branch November 8, 2019 18:26
cyanglaz pushed a commit that referenced this pull request Nov 8, 2019
…vent plugins from polluting Flutter's EAGLContext (#13314)"

This reverts commit bec5542.
cyanglaz pushed a commit that referenced this pull request Nov 8, 2019
…vent plugins from polluting Flutter's EAGLContext (#13314)" (#13753)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 8, 2019
…vent plugins from polluting Flutter's EAGLContext (flutter/engine#13314)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 8, 2019
…vent plugins from polluting Flutter's EAGLContext (flutter/engine#13314)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 8, 2019
…vent plugins from polluting Flutter's EAGLContext (flutter/engine#13314)
cyanglaz pushed a commit that referenced this pull request Nov 8, 2019
cyanglaz pushed a commit that referenced this pull request Nov 8, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 9, 2019
…vent plugins from polluting Flutter's EAGLContext (flutter/engine#13314)
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Nov 9, 2019
git@github.com:flutter/engine.git/compare/5f5713e33971...af04338

git log 5f5713e..af04338 --no-merges --oneline
2019-11-08 a-siva@users.noreply.github.com Manual roll of Dart e68ca9b652acdb642668a6acb5f630d5be6c03da...fa4379946109467c8a48f20f19d83d7c72968a3e (flutter/engine#13756)
2019-11-08 ychris@google.com Revert "Reland "Guarding EAGLContext used by Flutter #13314" (#13755)" (flutter/engine#13757)
2019-11-08 ferhat@gmail.com [web] Support gif/webp animations, Speed up image drawing in BitmapCanvas.  (flutter/engine#13748)
2019-11-08 ychris@google.com Reland "Guarding EAGLContext used by Flutter #13314" (flutter/engine#13755)
2019-11-08 gspencergoog@users.noreply.github.com Move TextRange from the framework to dart:ui. (flutter/engine#13747)
2019-11-08 skia-flutter-autoroll@skia.org Roll src/third_party/skia 8c1e265f6f81..c88d1774ed50 (7 commits) (flutter/engine#13754)
2019-11-08 ychris@google.com Revert "Always use `IOSGLContextSwitch` to access EAGLContexts to prevent plugins from polluting Flutter's EAGLContext (#13314)" (flutter/engine#13753)
2019-11-08 ychris@google.com Always use `IOSGLContextSwitch` to access EAGLContexts to prevent plugins from polluting Flutter's EAGLContext (flutter/engine#13314)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC garyq@google.com on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
cyanglaz pushed a commit that referenced this pull request Nov 11, 2019
cyanglaz pushed a commit that referenced this pull request Nov 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants