| Flutter Windows Embedder |

compositor_opengl.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_WINDOWS_COMPOSITOR_OPENGL_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_COMPOSITOR_OPENGL_H_
7
8 #include <memory>
9
10 #include "flutter/fml/macros.h"
11 #include "flutter/impeller/renderer/backend/gles/proc_table_gles.h"
12 #include "flutter/shell/platform/embedder/embedder.h"
13 #include "flutter/shell/platform/windows/compositor.h"
14 #include "flutter/shell/platform/windows/flutter_windows_engine.h"
15
16 namespace flutter {
17
18 // Enables the Flutter engine to render content on Windows using OpenGL.
19 class CompositorOpenGL : public Compositor {
20 public:
21 CompositorOpenGL(FlutterWindowsEngine* engine,
22 impeller::ProcTableGLES::Resolver resolver,
23 bool enable_impeller);
24
25 /// |Compositor|
26 bool CreateBackingStore(const FlutterBackingStoreConfig& config,
27 FlutterBackingStore* result) override;
28
29 /// |Compositor|
30 bool CollectBackingStore(const FlutterBackingStore* store) override;
31
32 /// |Compositor|
33 bool Present(FlutterWindowsView* view,
34 const FlutterLayer** layers,
35 size_t layers_count) override;
36
37 private:
38 // The Flutter engine that manages the views to render.
39 FlutterWindowsEngine* engine_;
40
41 private:
42 struct TextureFormat {
43 // The format passed to the engine using `FlutterOpenGLFramebuffer.target`.
44 uint32_t sized_format = 0;
45 // The format used to create textures. Passed to `glTexImage2D`.
46 uint32_t general_format = 0;
47 };
48
49 // The compositor initializes itself lazily once |CreateBackingStore| is
50 // called. True if initialization completed successfully.
51 bool is_initialized_ = false;
52
53 // Function used to resolve GLES functions.
54 impeller::ProcTableGLES::Resolver resolver_ = nullptr;
55
56 // Table of resolved GLES functions. Null until the compositor is initialized.
57 std::unique_ptr<impeller::ProcTableGLES> gl_ = nullptr;
58
59 // The OpenGL texture format for backing stores. Invalid value until
60 // the compositor is initialized.
61 TextureFormat format_;
62
63 // Whether the Impeller rendering backend is enabled.
64 bool enable_impeller_ = false;
65
66 // Initialize the compositor. This must run on the raster thread.
67 bool Initialize();
68
69 // Clear the view's surface and removes any previously presented layers.
70 bool Clear(FlutterWindowsView* view);
71
72 FML_DISALLOW_COPY_AND_ASSIGN(CompositorOpenGL);
73 };
74
75 } // namespace flutter
76
77 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_COMPOSITOR_OPENGL_H_
flutter::Compositor
Definition: compositor.h:22
flutter::CompositorOpenGL
Definition: compositor_opengl.h:19
flutter::CompositorOpenGL::Present
bool Present(FlutterWindowsView *view, const FlutterLayer **layers, size_t layers_count) override
|Compositor|
Definition: compositor_opengl.cc:123
flutter::CompositorOpenGL::CreateBackingStore
bool CreateBackingStore(const FlutterBackingStoreConfig &config, FlutterBackingStore *result) override
|Compositor|
Definition: compositor_opengl.cc:44
flutter::CompositorOpenGL::CollectBackingStore
bool CollectBackingStore(const FlutterBackingStore *store) override
|Compositor|
Definition: compositor_opengl.cc:108
flutter::CompositorOpenGL::CompositorOpenGL
CompositorOpenGL(FlutterWindowsEngine *engine, impeller::ProcTableGLES::Resolver resolver, bool enable_impeller)
Definition: compositor_opengl.cc:39
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:91
flutter::FlutterWindowsView
Definition: flutter_windows_view.h:34
compositor.h
flutter_windows_engine.h
flutter
Definition: accessibility_bridge_windows.cc:11