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 
24  /// |Compositor|
25  bool CreateBackingStore(const FlutterBackingStoreConfig& config,
26  FlutterBackingStore* result) override;
27 
28  /// |Compositor|
29  bool CollectBackingStore(const FlutterBackingStore* store) override;
30 
31  /// |Compositor|
32  bool Present(FlutterWindowsView* view,
33  const FlutterLayer** layers,
34  size_t layers_count) override;
35 
36  private:
37  // The Flutter engine that manages the views to render.
38  FlutterWindowsEngine* engine_;
39 
40  private:
41  struct TextureFormat {
42  // The format passed to the engine using `FlutterOpenGLFramebuffer.target`.
43  uint32_t sized_format = 0;
44  // The format used to create textures. Passed to `glTexImage2D`.
45  uint32_t general_format = 0;
46  };
47 
48  // The compositor initializes itself lazily once |CreateBackingStore| is
49  // called. True if initialization completed successfully.
50  bool is_initialized_ = false;
51 
52  // Function used to resolve GLES functions.
53  impeller::ProcTableGLES::Resolver resolver_ = nullptr;
54 
55  // Table of resolved GLES functions. Null until the compositor is initialized.
56  std::unique_ptr<impeller::ProcTableGLES> gl_ = nullptr;
57 
58  // The OpenGL texture format for backing stores. Invalid value until
59  // the compositor is initialized.
60  TextureFormat format_;
61 
62  // Initialize the compositor. This must run on the raster thread.
63  bool Initialize();
64 
65  // Clear the view's surface and removes any previously presented layers.
66  bool Clear(FlutterWindowsView* view);
67 
68  FML_DISALLOW_COPY_AND_ASSIGN(CompositorOpenGL);
69 };
70 
71 } // namespace flutter
72 
73 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_COMPOSITOR_OPENGL_H_
flutter::FlutterWindowsView
Definition: flutter_windows_view.h:34
flutter::CompositorOpenGL::CompositorOpenGL
CompositorOpenGL(FlutterWindowsEngine *engine, impeller::ProcTableGLES::Resolver resolver)
Definition: compositor_opengl.cc:25
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:90
flutter::CompositorOpenGL::CreateBackingStore
bool CreateBackingStore(const FlutterBackingStoreConfig &config, FlutterBackingStore *result) override
|Compositor|
Definition: compositor_opengl.cc:29
flutter::CompositorOpenGL::CollectBackingStore
bool CollectBackingStore(const FlutterBackingStore *store) override
|Compositor|
Definition: compositor_opengl.cc:68
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::CompositorOpenGL::Present
bool Present(FlutterWindowsView *view, const FlutterLayer **layers, size_t layers_count) override
|Compositor|
Definition: compositor_opengl.cc:83
flutter_windows_engine.h
flutter::CompositorOpenGL
Definition: compositor_opengl.h:19
compositor.h
flutter::Compositor
Definition: compositor.h:22