Flutter Impeller
playground_impl_gles.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_IMPELLER_PLAYGROUND_BACKEND_GLES_PLAYGROUND_IMPL_GLES_H_
6 #define FLUTTER_IMPELLER_PLAYGROUND_BACKEND_GLES_PLAYGROUND_IMPL_GLES_H_
7 
9 
11 
12 struct GLFWwindow;
13 
14 namespace impeller {
15 
16 class PlaygroundImplGLES final : public PlaygroundImpl {
17  public:
18  struct ShareableContext;
19 
20  explicit PlaygroundImplGLES(PlaygroundSwitches switches);
21 
23 
24  fml::Status SetCapabilities(
25  const std::shared_ptr<Capabilities>& capabilities) override;
26 
27  private:
28  class ReactorWorker;
29 
30  static void DestroyWindowHandle(WindowHandle handle);
31  using UniqueHandle =
32  std::unique_ptr<GLFWwindow, decltype(&DestroyWindowHandle)>;
33  UniqueHandle handle_;
34  const bool use_angle_;
35  void* angle_glesv2_;
36  std::shared_ptr<Context> context_;
37  std::unique_ptr<ShareableContext> unique_context_;
38 
39  // Return the best ShareableContext holder to store the context for
40  // this Playground. Note that this might be either the instance-specific
41  // |unique_context_| field or it might be one of the globally shared
42  // contexts fields used for most of the tests.
43  std::unique_ptr<PlaygroundImplGLES::ShareableContext>& GetShareableContext();
44 
45  // |PlaygroundImpl|
46  std::shared_ptr<Context> GetContext() const override;
47 
48  // |PlaygroundImpl|
49  WindowHandle GetWindowHandle() const override;
50 
51  // |PlaygroundImpl|
52  std::unique_ptr<Surface> AcquireSurfaceFrame(
53  std::shared_ptr<Context> context) override;
54 
55  // |PlaygroundImpl|
56  Playground::GLProcAddressResolver CreateGLProcAddressResolver()
57  const override;
58 
59  static Playground::GLProcAddressResolver CreateGLProcAddressResolver(
60  const PlaygroundSwitches& switches);
61 
62  static GLFWwindow* CreateGLWindow(const PlaygroundSwitches& switches,
63  GLFWwindow* share_window);
64 
65  static std::unique_ptr<ShareableContext> MakeShareableContext(
66  const PlaygroundSwitches& switches);
67 
69 
70  PlaygroundImplGLES(const PlaygroundImplGLES&) = delete;
71 
72  PlaygroundImplGLES& operator=(const PlaygroundImplGLES&) = delete;
73 };
74 
75 } // namespace impeller
76 
77 #endif // FLUTTER_IMPELLER_PLAYGROUND_BACKEND_GLES_PLAYGROUND_IMPL_GLES_H_
std::function< void *(const char *proc_name)> GLProcAddressResolver
Definition: playground.h:107
PlaygroundImplGLES(PlaygroundSwitches switches)
fml::Status SetCapabilities(const std::shared_ptr< Capabilities > &capabilities) override
static std::optional< RuntimeStageBackend > GetRuntimeStageBackend(TargetPlatform target_platform)
Definition: reflector.cc:347
std::shared_ptr< ContextGLES > context