Flutter Linux Embedder
fl_compositor.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_COMPOSITOR_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_COMPOSITOR_H_
7 
8 #include <cairo.h>
9 #include <gdk/gdk.h>
10 
11 #include "flutter/shell/platform/embedder/embedder.h"
12 
13 G_BEGIN_DECLS
14 
15 // Maximum time to wait for a frame to be ready before giving up and rendering.
16 constexpr gint64 kCompositorRenderTimeoutMicroseconds = 100000; // 100ms
17 
18 G_DECLARE_DERIVABLE_TYPE(FlCompositor, fl_compositor, FL, COMPOSITOR, GObject)
19 
21  GObjectClass parent_class;
22 
23  gboolean (*present_layers)(FlCompositor* compositor,
24  const FlutterLayer** layers,
25  size_t layers_count);
26 
27  void (*get_frame_size)(FlCompositor* compositor,
28  size_t* width,
29  size_t* height);
30 
31  gboolean (*render)(FlCompositor* compositor,
32  cairo_t* cr,
33  GdkWindow* window,
34  gboolean wait_for_frame);
35 };
36 
37 /**
38  * FlCompositor:
39  *
40  * #FlCompositor is an abstract class that implements Flutter compositing.
41  */
42 
43 /**
44  * fl_compositor_present_layers:
45  * @compositor: an #FlCompositor.
46  * @layers: layers to be composited.
47  * @layers_count: number of layers.
48  *
49  * Composite layers. Called from the Flutter rendering thread.
50  *
51  * Returns %TRUE if successful.
52  */
53 gboolean fl_compositor_present_layers(FlCompositor* compositor,
54  const FlutterLayer** layers,
55  size_t layers_count);
56 
57 /**
58  * fl_compositor_get_frame_size:
59  * @compositor: an #FlCompositor.
60  * @width: location to write frame width in pixels.
61  * @height: location to write frame height in pixels.
62  *
63  * Get the size of the layer ready for rendering.
64  */
65 void fl_compositor_get_frame_size(FlCompositor* compositor,
66  size_t* width,
67  size_t* height);
68 
69 /**
70  * fl_compositor_render:
71  * @compositor: an #FlCompositor.
72  * @cr: a Cairo rendering context.
73  * @window: window being rendered into.
74  * @wait_for_frame: if the available frame is not the size of the window block
75  * until a new frame is received.
76  *
77  * Renders the current frame. Called from the GTK thread.
78  *
79  * Returns %TRUE if successful.
80  */
81 gboolean fl_compositor_render(FlCompositor* compositor,
82  cairo_t* cr,
83  GdkWindow* window,
84  gboolean wait_for_frame);
85 
86 G_END_DECLS
87 
88 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_COMPOSITOR_H_
G_BEGIN_DECLS G_DECLARE_DERIVABLE_TYPE(FlAccessibilityHandler, fl_accessibility_handler, FL, ACCESSIBILITY_HANDLER, GObject)
constexpr G_BEGIN_DECLS gint64 kCompositorRenderTimeoutMicroseconds
Definition: fl_compositor.h:16
gboolean fl_compositor_render(FlCompositor *compositor, cairo_t *cr, GdkWindow *window, gboolean wait_for_frame)
void fl_compositor_get_frame_size(FlCompositor *compositor, size_t *width, size_t *height)
gboolean fl_compositor_present_layers(FlCompositor *compositor, const FlutterLayer **layers, size_t layers_count)
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
self height
self width
GObjectClass parent_class
Definition: fl_compositor.h:21