-
Notifications
You must be signed in to change notification settings - Fork 6k
[macOS] Isolate openGL rendering to FlutterOpenGLRenderer #22569
[macOS] Isolate openGL rendering to FlutterOpenGLRenderer #22569
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
ac3988c to
41b490f
Compare
chinmaygarde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have reviewed some code that you only moved. But LGTM otherwise.
| const FlutterRendererConfig rendererConfig = { | ||
| .type = kOpenGL, | ||
| .open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig), | ||
| .open_gl.make_current = (BoolCallback)OnMakeCurrent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Here and elsewhere, C-style casts in ObjC++ code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
|
|
||
| - (void)textureFrameAvailable:(int64_t)textureID { | ||
| _embedderAPI.MarkExternalTextureFrameAvailable(_engine, textureID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Return codes are ignored. Maybe log it at the very least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
| FlutterExternalTextureGL* FlutterTexture = | ||
| [[FlutterExternalTextureGL alloc] initWithFlutterTexture:texture]; | ||
| int64_t textureID = [FlutterTexture textureID]; | ||
| _embedderAPI.RegisterExternalTexture(_engine, textureID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the the registered textures only if you can successfully register the texture with the engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| NSOpenGLPFAColorSize, 24, NSOpenGLPFAAlphaSize, 8, 0, | ||
| }; | ||
| NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; | ||
| _resourceContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my clarification: How is the shareContext nil here? Are we using creating this context first and then using it as the prototype for the main context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self = [super init]; | ||
| if (self) { | ||
| _engine = engine; | ||
| _textures = [[NSMutableDictionary alloc] init]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm that these TUs use ARC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in preparation for having an equivalent FlutterMetalRenderer
41b490f to
36b8aa2
Compare
| .open_gl.make_resource_current = (BoolCallback)OnMakeResourceCurrent, | ||
| .open_gl.gl_external_texture_frame_callback = (TextureFrameCallback)OnAcquireExternalTexture, | ||
| }; | ||
| [_openGLRenderer attachToFlutterView:_viewController.flutterView]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no guarantee that there will be a view here. How are you handling later changes to the view controller given that you removed setViewController:?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, will account for it.
| /** | ||
| * Called by the engine when framebuffer object ID is requested. | ||
| */ | ||
| - (uint32_t)getFBO:(const FlutterFrameInfo*)info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"get" is not idiomatic ObjC naming. This should be called identifierForFBO: or similar.
| * Coordinates a single instance of execution of a Flutter engine. | ||
| */ | ||
| FLUTTER_EXPORT | ||
| @interface FlutterEngine : NSObject <FlutterTextureRegistry, FlutterPluginRegistry> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you follow the breaking change process for this change? You've changed the public API of a public class.
…utter#22569)" This reverts commit 94e217b.
This is in preparation for having an equivalent FlutterMetalRenderer