Flutter Engine
The Flutter Engine
display.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_IMPELLER_TOOLKIT_EGL_DISPLAY_H_
6#define FLUTTER_IMPELLER_TOOLKIT_EGL_DISPLAY_H_
7
8#include <memory>
9
12
13namespace impeller {
14namespace egl {
15
16class Context;
17class Surface;
18
19//------------------------------------------------------------------------------
20/// @brief A connection to an EGL display. Only one connection per
21/// application instance is sufficient.
22///
23/// The display connection is used to first choose a config from
24/// among the available, create a context from that config, and then
25/// use that context with a surface on one (and only one) thread at
26/// a time.
27///
28class Display {
29 public:
30 Display();
31
32 virtual ~Display();
33
34 //----------------------------------------------------------------------------
35 /// @return True if the display connection is valid.
36 ///
37 virtual bool IsValid() const;
38
39 //----------------------------------------------------------------------------
40 /// @brief Choose a config that most closely matches a given descriptor.
41 /// If there are no matches, this method returns `nullptr`.
42 ///
43 /// @param[in] config The configuration
44 ///
45 /// @return A config that matches a descriptor if one is available.
46 /// `nullptr` otherwise.
47 ///
48 virtual std::unique_ptr<Config> ChooseConfig(ConfigDescriptor config) const;
49
50 //----------------------------------------------------------------------------
51 /// @brief Create a context with a supported config. The supported config
52 /// can be obtained via a successful call to `ChooseConfig`.
53 ///
54 /// @param[in] config The configuration.
55 /// @param[in] share_context The share context. Context within the same
56 /// share-group use the same handle table. The
57 /// contexts should still only be used exclusively
58 /// on each thread however.
59 ///
60 /// @return A context if one can be created. `nullptr` otherwise.
61 ///
62 virtual std::unique_ptr<Context> CreateContext(const Config& config,
63 const Context* share_context);
64
65 //----------------------------------------------------------------------------
66 /// @brief Create a window surface. The window is an opaque pointer whose
67 /// value value is platform specific. For instance, ANativeWindow
68 /// on Android.
69 ///
70 /// @param[in] config A valid configuration. One can be obtained via
71 /// `ChooseConfig`.
72 /// @param[in] window An opaque pointer to a platform specific window
73 /// handle.
74 ///
75 /// @return A valid window surface if one can be created. `nullptr`
76 /// otherwise.
77 ///
78 virtual std::unique_ptr<Surface> CreateWindowSurface(
79 const Config& config,
80 EGLNativeWindowType window);
81
82 //----------------------------------------------------------------------------
83 /// @brief Create an offscreen pixelbuffer surface. These are of limited
84 /// use except in the context where applications need to render to
85 /// a texture in an offscreen context. In such cases, a 1x1 pixel
86 /// buffer surface is created to obtain a surface that can be used
87 /// to make the context current on the background thread.
88 ///
89 /// @param[in] config The configuration
90 /// @param[in] width The width
91 /// @param[in] height The height
92 ///
93 /// @return A valid pixel buffer surface if one can be created. `nullptr`
94 /// otherwise.
95 ///
96 virtual std::unique_ptr<Surface>
97 CreatePixelBufferSurface(const Config& config, size_t width, size_t height);
98
99 private:
100 EGLDisplay display_ = EGL_NO_DISPLAY;
101
102 Display(const Display&) = delete;
103
104 Display& operator=(const Display&) = delete;
105};
106
107} // namespace egl
108} // namespace impeller
109
110#endif // FLUTTER_IMPELLER_TOOLKIT_EGL_DISPLAY_H_
An EGL config. These are returned by the display to indicate support for a specific config descriptor...
Definition: config.h:63
An instance of an EGL context.
Definition: context.h:30
A connection to an EGL display. Only one connection per application instance is sufficient.
Definition: display.h:28
virtual std::unique_ptr< Surface > CreatePixelBufferSurface(const Config &config, size_t width, size_t height)
Create an offscreen pixelbuffer surface. These are of limited use except in the context where applica...
Definition: display.cc:188
virtual std::unique_ptr< Context > CreateContext(const Config &config, const Context *share_context)
Create a context with a supported config. The supported config can be obtained via a successful call ...
Definition: display.cc:37
virtual bool IsValid() const
Definition: display.cc:33
virtual std::unique_ptr< Config > ChooseConfig(ConfigDescriptor config) const
Choose a config that most closely matches a given descriptor. If there are no matches,...
Definition: display.cc:72
virtual ~Display()
Definition: display.cc:25
virtual std::unique_ptr< Surface > CreateWindowSurface(const Config &config, EGLNativeWindowType window)
Create a window surface. The window is an opaque pointer whose value value is platform specific....
Definition: display.cc:172
GLFWwindow * window
Definition: main.cc:45
int32_t height
int32_t width