Flutter Engine
The Flutter Engine
context.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_LIB_GPU_CONTEXT_H_
6#define FLUTTER_LIB_GPU_CONTEXT_H_
7
8#include "dart_api.h"
9#include "flutter/lib/gpu/export.h"
10#include "flutter/lib/ui/dart_wrapper.h"
12
13namespace flutter {
14namespace gpu {
15
16class Context : public RefCountedDartWrappable<Context> {
17 DEFINE_WRAPPERTYPEINFO();
18 FML_FRIEND_MAKE_REF_COUNTED(Context);
19
20 public:
21 static void SetOverrideContext(std::shared_ptr<impeller::Context> context);
22
23 static std::shared_ptr<impeller::Context> GetOverrideContext();
24
25 static std::shared_ptr<impeller::Context> GetDefaultContext(
26 std::optional<std::string>& out_error);
27
28 explicit Context(std::shared_ptr<impeller::Context> context);
29 ~Context() override;
30
31 std::shared_ptr<impeller::Context> GetContext();
32
33 private:
34 /// An Impeller context that takes precedent over the IO state context when
35 /// set. This is used to inject the context when running with the Impeller
36 /// playground, which doesn't instantiate an Engine instance.
37 static std::shared_ptr<impeller::Context> default_context_;
38
39 std::shared_ptr<impeller::Context> context_;
40
41 FML_DISALLOW_COPY_AND_ASSIGN(Context);
42};
43
44} // namespace gpu
45} // namespace flutter
46
47//----------------------------------------------------------------------------
48/// Exports
49///
50
51extern "C" {
52
55 Dart_Handle wrapper);
56
59 flutter::gpu::Context* wrapper);
60
63 flutter::gpu::Context* wrapper);
64
67 flutter::gpu::Context* wrapper);
68
71 flutter::gpu::Context* wrapper);
72
73} // extern "C"
74
75#endif // FLUTTER_LIB_GPU_CONTEXT_H_
static std::shared_ptr< impeller::Context > GetOverrideContext()
Definition: context.cc:25
Context(std::shared_ptr< impeller::Context > context)
Definition: context.cc:60
std::shared_ptr< impeller::Context > GetContext()
Definition: context.cc:65
static std::shared_ptr< impeller::Context > GetDefaultContext(std::optional< std::string > &out_error)
Definition: context.cc:29
static void SetOverrideContext(std::shared_ptr< impeller::Context > context)
Definition: context.cc:21
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
#define FLUTTER_GPU_EXPORT
Definition: export.h:13
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Context_GetDefaultDepthStencilFormat(flutter::gpu::Context *wrapper)
Definition: context.cc:101
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Context_InitializeDefault(Dart_Handle wrapper)
Definition: context.cc:76
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Context_GetBackendType(flutter::gpu::Context *wrapper)
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Context_GetDefaultStencilFormat(flutter::gpu::Context *wrapper)
Definition: context.cc:95
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Context_GetDefaultColorFormat(flutter::gpu::Context *wrapper)
Definition: context.cc:89