Flutter Impeller
playground_test.cc
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 
6 
8 
10 
12 
13 // |PlaygroundTest|
16 }
17 
18 // |PlaygroundTest|
21 }
22 
24  switch (GetBackend()) {
26  FML_CHECK(false) << "Metal not yet implemented.";
27  return nullptr;
29  Playground::GLProcAddressResolver playground_gl_proc_address_callback =
31  ImpellerProcAddressCallback gl_proc_address_callback =
32  [](const char* proc_name, void* user_data) -> void* {
33  return (*reinterpret_cast<Playground::GLProcAddressResolver*>(
34  user_data))(proc_name);
35  };
36  return Adopt<Context>(ImpellerContextCreateOpenGLESNew(
37  ImpellerGetVersion(), gl_proc_address_callback,
38  &playground_gl_proc_address_callback));
39  }
41  FML_CHECK(false) << "Vulkan not yet implemented.";
42  return nullptr;
43  }
44  FML_UNREACHABLE();
45 }
46 
48  auto context = GetInteropContext();
49  if (!context) {
50  return false;
51  }
52  return Playground::OpenPlaygroundHere([&](RenderTarget& target) -> bool {
53  auto impeller_surface = std::make_shared<impeller::Surface>(target);
54  auto surface = Create<Surface>(*context.Get(), impeller_surface);
55  if (!surface) {
56  return false;
57  }
58  return callback(context, surface);
59  });
60 }
61 
63  if (interop_context_) {
64  return interop_context_;
65  }
66  auto context = Create<Context>(GetContext(), nullptr);
67  if (!context) {
68  return nullptr;
69  }
70  interop_context_ = std::move(context);
71  return interop_context_;
72 }
73 
74 } // namespace impeller::interop::testing
impeller::interop::testing::PlaygroundTest::PlaygroundTest
PlaygroundTest()
impeller::PlaygroundBackend::kVulkan
@ kVulkan
impeller::interop::ImpellerContextCreateOpenGLESNew
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateOpenGLESNew(uint32_t version, ImpellerProcAddressCallback gl_proc_address_callback, void *gl_proc_address_callback_user_data)
Definition: impeller.cc:73
impeller::interop::ScopedObject
Definition: object.h:67
impeller::interop::testing::PlaygroundTest::GetInteropContext
ScopedObject< Context > GetInteropContext()
Definition: playground_test.cc:62
impeller::interop::testing
Definition: impeller_unittests.cc:22
impeller::PlaygroundBackend::kMetal
@ kMetal
impeller::interop::testing::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:19
impeller::interop::ImpellerGetVersion
IMPELLER_EXTERN_C uint32_t ImpellerGetVersion()
Definition: impeller.cc:68
impeller::interop::testing::PlaygroundTest::~PlaygroundTest
~PlaygroundTest() override
impeller::PlaygroundTest::SetUp
void SetUp() override
Definition: playground_test.cc:45
impeller::interop::testing::PlaygroundTest::OpenPlaygroundHere
bool OpenPlaygroundHere(InteropPlaygroundCallback callback)
Definition: playground_test.cc:47
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:197
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:76
impeller::Playground::CreateGLProcAddressResolver
GLProcAddressResolver CreateGLProcAddressResolver() const
Definition: playground.cc:516
impeller::interop::testing::PlaygroundTest::InteropPlaygroundCallback
std::function< bool(const ScopedObject< Context > &context, const ScopedObject< Surface > &surface)> InteropPlaygroundCallback
Definition: playground_test.h:39
impeller::RenderTarget
Definition: render_target.h:38
playground_test.h
impeller::interop::testing::PlaygroundTest::SetUp
void SetUp() override
Definition: playground_test.cc:14
impeller::PlaygroundBackend::kOpenGLES
@ kOpenGLES
impeller::interop::testing::PlaygroundTest::CreateContext
ScopedObject< Context > CreateContext() const
Definition: playground_test.cc:23
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:90
ImpellerProcAddressCallback
void *IMPELLER_NULLABLE(* ImpellerProcAddressCallback)(const char *IMPELLER_NONNULL proc_name, void *IMPELLER_NULLABLE user_data)
Definition: impeller.h:104
impeller::Playground::GLProcAddressResolver
std::function< void *(const char *proc_name)> GLProcAddressResolver
Definition: playground.h:117
impeller::PlaygroundTest::GetBackend
PlaygroundBackend GetBackend() const
Definition: playground_test.cc:72