Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
android_context_gl_skia.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_ANDROID_ANDROID_CONTEXT_GL_SKIA_H_
6#define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_SKIA_H_
7
8#include "flutter/fml/macros.h"
9#include "flutter/fml/memory/ref_counted.h"
10#include "flutter/fml/memory/ref_ptr.h"
11#include "flutter/shell/common/platform_view.h"
12#include "flutter/shell/platform/android/android_environment_gl.h"
13#include "flutter/shell/platform/android/context/android_context.h"
14#include "flutter/shell/platform/android/surface/android_native_window.h"
16
17namespace flutter {
18
19class AndroidEGLSurface;
20
21//------------------------------------------------------------------------------
22/// The Android context is used by `AndroidSurfaceGL` to create and manage
23/// EGL surfaces.
24///
25/// This context binds `EGLContext` to the current rendering thread and to the
26/// draw and read `EGLSurface`s.
27///
29 public:
31 const TaskRunners& taskRunners,
32 uint8_t msaa_samples);
33
35
36 //----------------------------------------------------------------------------
37 /// @brief Allocates an new EGL window surface that is used for on-screen
38 /// pixels.
39 ///
40 /// @return The window surface.
41 ///
42 std::unique_ptr<AndroidEGLSurface> CreateOnscreenSurface(
44
45 //----------------------------------------------------------------------------
46 /// @brief Allocates an 1x1 pbuffer surface that is used for making the
47 /// offscreen current for texture uploads.
48 ///
49 /// @return The pbuffer surface.
50 ///
51 std::unique_ptr<AndroidEGLSurface> CreateOffscreenSurface() const;
52
53 //----------------------------------------------------------------------------
54 /// @brief Allocates an 1x1 pbuffer surface that is used for making the
55 /// onscreen context current for snapshotting.
56 ///
57 /// @return The pbuffer surface.
58 ///
59 std::unique_ptr<AndroidEGLSurface> CreatePbufferSurface() const;
60
61 //----------------------------------------------------------------------------
62 /// @return The Android environment that contains a reference to the
63 /// display.
64 ///
66
67 //----------------------------------------------------------------------------
68 /// @return Whether the current context is valid. That is, if the EGL
69 /// contexts were successfully created.
70 ///
71 bool IsValid() const override;
72
73 //----------------------------------------------------------------------------
74 /// @return Whether the current context was successfully clear.
75 ///
76 bool ClearCurrent() const;
77
78 //----------------------------------------------------------------------------
79 /// @brief Returns the EGLContext.
80 ///
81 /// @return EGLContext.
82 ///
83 EGLContext GetEGLContext() const;
84
85 //----------------------------------------------------------------------------
86 /// @brief Returns the EGLDisplay.
87 ///
88 /// @return EGLDisplay.
89 ///
90 EGLDisplay GetEGLDisplay() const;
91
92 //----------------------------------------------------------------------------
93 /// @brief Create a new EGLContext using the same EGLConfig.
94 ///
95 /// @return The EGLContext.
96 ///
97 EGLContext CreateNewContext() const;
98
99 //----------------------------------------------------------------------------
100 /// @brief The EGLConfig for this context.
101 ///
102 EGLConfig Config() const { return config_; }
103
104 private:
106 EGLConfig config_;
107 EGLContext context_;
108 EGLContext resource_context_;
109 bool valid_ = false;
110 TaskRunners task_runners_;
111
113};
114
115} // namespace flutter
116
117#endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_SKIA_H_
std::unique_ptr< AndroidEGLSurface > CreateOffscreenSurface() const
Allocates an 1x1 pbuffer surface that is used for making the offscreen current for texture uploads.
EGLContext CreateNewContext() const
Create a new EGLContext using the same EGLConfig.
fml::RefPtr< AndroidEnvironmentGL > Environment() const
EGLConfig Config() const
The EGLConfig for this context.
std::unique_ptr< AndroidEGLSurface > CreateOnscreenSurface(const fml::RefPtr< AndroidNativeWindow > &window) const
Allocates an new EGL window surface that is used for on-screen pixels.
EGLContext GetEGLContext() const
Returns the EGLContext.
std::unique_ptr< AndroidEGLSurface > CreatePbufferSurface() const
Allocates an 1x1 pbuffer surface that is used for making the onscreen context current for snapshottin...
EGLDisplay GetEGLDisplay() const
Returns the EGLDisplay.
Holds state that is shared across Android surfaces.
GLFWwindow * window
Definition main.cc:45
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27