@@ -305,6 +305,9 @@ typedef enum {
305305 /// Specifies an OpenGL frame-buffer target type. Framebuffers are specified
306306 /// using the FlutterOpenGLFramebuffer struct.
307307 kFlutterOpenGLTargetTypeFramebuffer ,
308+ /// Specifies an OpenGL on-screen surface target type. Surfaces are specified
309+ /// using the FlutterOpenGLSurface struct.
310+ kFlutterOpenGLTargetTypeSurface ,
308311} FlutterOpenGLTargetType ;
309312
310313/// A pixel format to be used for software rendering.
@@ -401,9 +404,14 @@ typedef struct {
401404} FlutterOpenGLTexture ;
402405
403406typedef struct {
404- /// The target of the color attachment of the frame-buffer. For example,
405- /// GL_TEXTURE_2D or GL_RENDERBUFFER. In case of ambiguity when dealing with
406- /// Window bound frame-buffers, 0 may be used.
407+ /// The format of the color attachment of the frame-buffer. For example,
408+ /// GL_RGBA8.
409+ ///
410+ /// In case of ambiguity when dealing with Window bound frame-buffers, 0 may
411+ /// be used.
412+ ///
413+ /// @bug This field is incorrectly named as "target" when it actually
414+ /// refers to a format.
407415 uint32_t target ;
408416
409417 /// The name of the framebuffer.
@@ -417,6 +425,62 @@ typedef struct {
417425 VoidCallback destruction_callback ;
418426} FlutterOpenGLFramebuffer ;
419427
428+ typedef bool (* FlutterOpenGLSurfaceCallback )(void * /* user data */ ,
429+ bool * /* opengl state changed */ );
430+
431+ typedef struct {
432+ /// The size of this struct. Must be sizeof(FlutterOpenGLSurface).
433+ size_t struct_size ;
434+
435+ /// User data to be passed to the make_current, clear_current and
436+ /// destruction callbacks.
437+ void * user_data ;
438+
439+ /// Callback invoked (on an engine-managed thread) that asks the embedder to
440+ /// make the surface current.
441+ ///
442+ /// Should return true if the operation succeeded, false if the surface could
443+ /// not be made current and rendering should be cancelled.
444+ ///
445+ /// The second parameter 'opengl state changed' should be set to true if
446+ /// any OpenGL API state is different than before this callback was called.
447+ /// In that case, Flutter will invalidate the internal OpenGL API state cache,
448+ /// which is a somewhat expensive operation.
449+ ///
450+ /// @attention required. (non-null)
451+ FlutterOpenGLSurfaceCallback make_current_callback ;
452+
453+ /// Callback invoked (on an engine-managed thread) when the current surface
454+ /// can be cleared.
455+ ///
456+ /// Should return true if the operation succeeded, false if an error ocurred.
457+ /// That error will be logged but otherwise not handled by the engine.
458+ ///
459+ /// The second parameter 'opengl state changed' is the same as with the
460+ /// @ref make_current_callback.
461+ ///
462+ /// The embedder might clear the surface here after it was previously made
463+ /// current. That's not required however, it's also possible to clear it in
464+ /// the destruction callback. There's no way to signal OpenGL state
465+ /// changes in the destruction callback though.
466+ ///
467+ /// @attention required. (non-null)
468+ FlutterOpenGLSurfaceCallback clear_current_callback ;
469+
470+ /// Callback invoked (on an engine-managed thread) that asks the embedder to
471+ /// collect the surface.
472+ ///
473+ /// @attention required. (non-null)
474+ VoidCallback destruction_callback ;
475+
476+ /// The surface format.
477+ ///
478+ /// Allowed values:
479+ /// - GL_RGBA8
480+ /// - GL_BGRA8_EXT
481+ uint32_t format ;
482+ } FlutterOpenGLSurface ;
483+
420484typedef FlutterTransformation (* TransformationCallback )(void * /* user data */ );
421485typedef uint32_t (* UIntCallback )(void * /* user data */ );
422486typedef bool (* SoftwareSurfacePresentCallback )(void * /* user data */ ,
@@ -1546,7 +1610,7 @@ typedef void (*FlutterUpdateSemanticsCallback2)(
15461610
15471611/// An update to whether a message channel has a listener set or not.
15481612typedef struct {
1549- // The size of the struct. Must be sizeof(FlutterChannelUpdate).
1613+ /// The size of the struct. Must be sizeof(FlutterChannelUpdate).
15501614 size_t struct_size ;
15511615 /// The name of the channel.
15521616 const char * channel ;
@@ -1627,6 +1691,9 @@ typedef struct {
16271691 /// A framebuffer for Flutter to render into. The embedder must ensure that
16281692 /// the framebuffer is complete.
16291693 FlutterOpenGLFramebuffer framebuffer ;
1694+ /// A surface for Flutter to render into. Basically a wrapper around
1695+ /// a closure that'll be called when the surface should be made current.
1696+ FlutterOpenGLSurface surface ;
16301697 };
16311698} FlutterOpenGLBackingStore ;
16321699
@@ -1648,6 +1715,7 @@ typedef struct {
16481715} FlutterSoftwareBackingStore ;
16491716
16501717typedef struct {
1718+ /// The size of this struct. Must be sizeof(FlutterSoftwareBackingStore2).
16511719 size_t struct_size ;
16521720 /// A pointer to the raw bytes of the allocation described by this software
16531721 /// backing store.
@@ -1821,6 +1889,7 @@ typedef struct {
18211889/// Contains additional information about the backing store provided
18221890/// during presentation to the embedder.
18231891typedef struct {
1892+ /// The size of this struct. Must be sizeof(FlutterBackingStorePresentInfo).
18241893 size_t struct_size ;
18251894
18261895 /// The area of the backing store that contains Flutter contents. Pixels
@@ -1982,7 +2051,7 @@ typedef const FlutterLocale* (*FlutterComputePlatformResolvedLocaleCallback)(
19822051 size_t /* Number of locales*/ );
19832052
19842053typedef struct {
1985- /// This size of this struct. Must be sizeof(FlutterDisplay ).
2054+ /// The size of this struct. Must be sizeof(FlutterEngineDisplay ).
19862055 size_t struct_size ;
19872056
19882057 FlutterEngineDisplayId display_id ;
0 commit comments