9 #if IMPELLER_ENABLE_METAL
14 #if IMPELLER_ENABLE_OPENGLES
19 #if IMPELLER_ENABLE_VULKAN
31 static std::once_flag sOnceFlag;
32 std::call_once(sOnceFlag, []() {
33 std::map<std::string, void*> proc_map;
34 #define IMPELLER_HPP_PROC(name) \
35 proc_map[#name] = reinterpret_cast<void*>(&name);
37 #undef IMPELLER_HPP_PROC
39 [&](
auto name) {
return proc_map.at(name); });
62 return Adopt<Context>(
68 [](
const char* proc_name,
void* user_data) ->
void* {
70 user_data))(proc_name);
74 &playground_gl_proc_address_callback));
85 const char* proc_name,
88 auto resolver =
reinterpret_cast<UserData*
>(user_data)->resolver;
90 return resolver(instance, proc_name);
95 return Adopt<Context>(
104 std::shared_ptr<impeller::Surface> shared_surface) {
106 #if IMPELLER_ENABLE_METAL
108 return Adopt<Surface>(
new SurfaceMTL(context, std::move(shared_surface)));
111 #if IMPELLER_ENABLE_OPENGLES
113 return Adopt<Surface>(
114 new SurfaceGLES(context, std::move(shared_surface)));
117 #if IMPELLER_ENABLE_VULKAN
119 return Adopt<Surface>(
new SurfaceVK(context, std::move(shared_surface)));
129 if (!interop_context) {
133 auto impeller_surface = std::make_shared<impeller::Surface>(target);
135 *interop_context.Get(),
136 std::move(impeller_surface)
139 VALIDATION_LOG <<
"Could not wrap test surface as an interop surface.";
142 return callback(interop_context, surface);
148 std::shared_ptr<impeller::Context> shared_context) {
150 #if IMPELLER_ENABLE_METAL
154 #if IMPELLER_ENABLE_OPENGLES
158 #if IMPELLER_ENABLE_VULKAN
169 if (interop_context_) {
170 return interop_context_;
177 interop_context_ = std::move(context);
178 return interop_context_;
bool OpenPlaygroundHere(const RenderCallback &render_callback)
GLProcAddressResolver CreateGLProcAddressResolver() const
const PlaygroundSwitches switches_
std::shared_ptr< Context > GetContext() const
std::function< void *(void *instance, const char *proc_name)> VKProcAddressResolver
std::function< void *(const char *proc_name)> GLProcAddressResolver
VKProcAddressResolver CreateVKProcAddressResolver() const
PlaygroundBackend GetBackend() const
static ScopedObject< Context > Create(std::function< void *(const char *gl_proc_name)> proc_address_callback)
static ScopedObject< Context > Create()
static ScopedObject< Context > Create(const Settings &settings)
ScopedObject< Context > CreateContext() const
ScopedObject< Context > GetInteropContext()
~PlaygroundTest() override
std::function< bool(const ScopedObject< Context > &context, const ScopedObject< Surface > &surface)> InteropPlaygroundCallback
bool OpenPlaygroundHere(InteropPlaygroundCallback callback)
void *IMPELLER_NULLABLE(* ImpellerProcAddressCallback)(const char *IMPELLER_NONNULL proc_name, void *IMPELLER_NULLABLE user_data)
#define IMPELLER_HPP_EACH_PROC(PROC)
ProcTable gGlobalProcTable
static ScopedObject< Context > CreateSharedContext(PlaygroundBackend backend, std::shared_ptr< impeller::Context > shared_context)
static ScopedObject< Surface > CreateSharedSurface(PlaygroundBackend backend, Context &context, std::shared_ptr< impeller::Surface > shared_surface)
static void SetupImpellerHPPProcTableOnce()
IMPELLER_EXTERN_C uint32_t ImpellerGetVersion()
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateVulkanNew(uint32_t version, const ImpellerContextVulkanSettings *settings)
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateMetalNew(uint32_t version)
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateOpenGLESNew(uint32_t version, ImpellerProcAddressCallback gl_proc_address_callback, void *gl_proc_address_callback_user_data)
bool Initialize(const std::function< void *(const char *function_name)> &resolver)
ImpellerVulkanProcAddressCallback IMPELLER_NONNULL proc_address_callback
bool enable_vulkan_validation
void *IMPELLER_NULLABLE user_data
bool enable_vulkan_validation