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  //----------------------------------------------------------------------------
26  /// @brief Sets a callback that will be invoked (on the raster task
27  /// runner) when the engine asks the embedder for a new FBO ID at
28  /// the updated size.
29  ///
30  /// @attention The callback will be invoked on the raster task runner. The
31  /// callback can be set on the tests host thread.
32  ///
33  /// @param[in] callback The callback to set. The previous callback will be
34  /// un-registered.
35  ///
37 
38  uint32_t GetWindowFBOId() const;
39 
40  //----------------------------------------------------------------------------
41  /// @brief Sets a callback that will be invoked (on the raster task
42  /// runner) when the engine presents an fbo that was given by the
43  /// embedder.
44  ///
45  /// @attention The callback will be invoked on the raster task runner. The
46  /// callback can be set on the tests host thread.
47  ///
48  /// @param[in] callback The callback to set. The previous callback will be
49  /// un-registered.
50  ///
52 
53  protected:
54  virtual void SetupCompositor() override;
55 
56  private:
57  // This allows the builder to access the hooks.
58  friend class EmbedderConfigBuilder;
59 
60  std::unique_ptr<TestGLSurface> gl_surface_;
61  size_t gl_surface_present_count_ = 0;
62  std::mutex gl_callback_mutex_;
63  GLGetFBOCallback gl_get_fbo_callback_;
64  GLPresentCallback gl_present_callback_;
65 
66  void SetupSurface(SkISize surface_size) override;
67 
68  bool GLMakeCurrent();
69 
70  bool GLClearCurrent();
71 
72  bool GLPresent(uint32_t fbo_id);
73 
74  uint32_t GLGetFramebuffer(FlutterFrameInfo frame_info);
75 
76  bool GLMakeResourceCurrent();
77 
78  void* GLGetProcAddress(const char* name);
79 
81 };
82 
83 } // namespace testing
84 } // namespace flutter
85 
86 #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_GL_H_
std::function< void(FlutterFrameInfo frame_info)> GLGetFBOCallback
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...
const char * name
Definition: fuchsia.cc:50
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
std::function< void(uint32_t fbo_id)> GLPresentCallback