Flutter Engine
embedder_test_context_gl.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_EMBEDDER_TESTS_EMBEDDER_CONTEXT_GL_H_
6 #define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_GL_H_
7 
8 #include "flutter/shell/platform/embedder/tests/embedder_test_context.h"
9 #include "flutter/testing/test_gl_surface.h"
10 
11 namespace flutter {
12 namespace testing {
13 
15  public:
16  using GLGetFBOCallback = std::function<void(FlutterFrameInfo frame_info)>;
17  using GLPresentCallback = std::function<void(uint32_t fbo_id)>;
18 
19  EmbedderTestContextGL(std::string assets_path = "");
20 
21  ~EmbedderTestContextGL() override;
22 
23  size_t GetSurfacePresentCount() const override;
24 
25  // |EmbedderTestContext|
26  EmbedderTestContextType GetContextType() const override;
27 
28  //----------------------------------------------------------------------------
29  /// @brief Sets a callback that will be invoked (on the raster task
30  /// runner) when the engine asks the embedder for a new FBO ID at
31  /// the updated size.
32  ///
33  /// @attention The callback will be invoked on the raster task runner. The
34  /// callback can be set on the tests host thread.
35  ///
36  /// @param[in] callback The callback to set. The previous callback will be
37  /// un-registered.
38  ///
40 
41  uint32_t GetWindowFBOId() const;
42 
43  //----------------------------------------------------------------------------
44  /// @brief Sets a callback that will be invoked (on the raster task
45  /// runner) when the engine presents an fbo that was given by the
46  /// embedder.
47  ///
48  /// @attention The callback will be invoked on the raster task runner. The
49  /// callback can be set on the tests host thread.
50  ///
51  /// @param[in] callback The callback to set. The previous callback will be
52  /// un-registered.
53  ///
55 
56  protected:
57  virtual void SetupCompositor() override;
58 
59  private:
60  // This allows the builder to access the hooks.
61  friend class EmbedderConfigBuilder;
62 
63  std::unique_ptr<TestGLSurface> gl_surface_;
64  size_t gl_surface_present_count_ = 0;
65  std::mutex gl_callback_mutex_;
66  GLGetFBOCallback gl_get_fbo_callback_;
67  GLPresentCallback gl_present_callback_;
68 
69  void SetupSurface(SkISize surface_size) override;
70 
71  bool GLMakeCurrent();
72 
73  bool GLClearCurrent();
74 
75  bool GLPresent(uint32_t fbo_id);
76 
77  uint32_t GLGetFramebuffer(FlutterFrameInfo frame_info);
78 
79  bool GLMakeResourceCurrent();
80 
81  void* GLGetProcAddress(const char* name);
82 
84 };
85 
86 } // namespace testing
87 } // namespace flutter
88 
89 #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_GL_H_
std::function< void(FlutterFrameInfo frame_info)> GLGetFBOCallback
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
void SetGLGetFBOCallback(GLGetFBOCallback callback)
Sets a callback that will be invoked (on the raster task runner) when the engine asks the embedder fo...
void SetGLPresentCallback(GLPresentCallback callback)
Sets a callback that will be invoked (on the raster task runner) when the engine presents an fbo that...
FlKeyEvent FlKeyResponderAsyncCallback callback
EmbedderTestContextType GetContextType() const override
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
std::function< void(uint32_t fbo_id)> GLPresentCallback