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"
15 
16 namespace flutter {
17 
18 // Enables the Flutter engine to render content on Windows using OpenGL.
19 class CompositorOpenGL : public Compositor {
20  public:
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  // The internal format passed to `glTexImage2D`. OpenGL ES 2.0 requires it
48  // to equal `general_format`, and only OpenGL ES 3.0 accepts `sized_format`.
49  uint32_t internal_format = 0;
50  };
51 
52  // The compositor initializes itself lazily once |CreateBackingStore| is
53  // called. True if initialization completed successfully.
54  bool is_initialized_ = false;
55 
56  // Function used to resolve GLES functions.
57  impeller::ProcTableGLES::Resolver resolver_ = nullptr;
58 
59  // Table of resolved GLES functions. Null until the compositor is initialized.
60  std::unique_ptr<impeller::ProcTableGLES> gl_ = nullptr;
61 
62  // The OpenGL texture format for backing stores. Invalid value until
63  // the compositor is initialized.
64  TextureFormat format_;
65 
66  // Whether the Impeller rendering backend is enabled.
67  bool enable_impeller_ = false;
68 
69  // Whether the OpenGL context supports implicit MSAA.
70  bool supports_implicit_msaa_ = false;
71 
72  // Whether the OpenGL context supports offscreen MSAA.
73  bool supports_offscreen_msaa_ = false;
74 
75  // Initialize the compositor. This must run on the raster thread.
76  bool Initialize();
77 
78  // Clear the view's surface and removes any previously presented layers.
79  bool Clear(FlutterWindowsView* view);
80 
81  FML_DISALLOW_COPY_AND_ASSIGN(CompositorOpenGL);
82 };
83 
84 } // namespace flutter
85 
86 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_COMPOSITOR_OPENGL_H_
bool Present(FlutterWindowsView *view, const FlutterLayer **layers, size_t layers_count) override
|Compositor|
bool CreateBackingStore(const FlutterBackingStoreConfig &config, FlutterBackingStore *result) override
|Compositor|
bool CollectBackingStore(const FlutterBackingStore *store) override
|Compositor|
CompositorOpenGL(FlutterWindowsEngine *engine, impeller::ProcTableGLES::Resolver resolver, bool enable_impeller)