| Flutter Impeller |

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
10 #include "impeller/toolkit/egl/config.h"
11 #include "impeller/toolkit/egl/egl.h"
12
13 namespace impeller {
14 namespace egl {
15
16 class Context;
17 class 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 ///
28 class 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 const EGLDisplay& GetHandle() const;
100
101 private:
102 EGLDisplay display_ = EGL_NO_DISPLAY;
103
104 Display(const Display&) = delete;
105
106 Display& operator=(const Display&) = delete;
107 };
108
109 } // namespace egl
110 } // namespace impeller
111
112 #endif // FLUTTER_IMPELLER_TOOLKIT_EGL_DISPLAY_H_
impeller::egl::Display::CreateWindowSurface
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
impeller::egl::Display::GetHandle
const EGLDisplay & GetHandle() const
Definition: display.cc:209
egl.h
impeller::egl::Context
An instance of an EGL context.
Definition: context.h:30
impeller::egl::Display::ChooseConfig
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:73
impeller::egl::Display
A connection to an EGL display. Only one connection per application instance is sufficient.
Definition: display.h:28
impeller::egl::Display::CreateContext
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:38
impeller::egl::Display::CreatePixelBufferSurface
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
impeller::egl::ConfigDescriptor
Definition: config.h:46
impeller::egl::Display::IsValid
virtual bool IsValid() const
Definition: display.cc:34
impeller::egl::Config
An EGL config. These are returned by the display to indicate support for a specific config descriptor...
Definition: config.h:64
impeller::egl::Display::Display
Display()
Definition: display.cc:16
impeller::egl::Display::~Display
virtual ~Display()
Definition: display.cc:26
impeller
Definition: allocation.cc:12
config.h